* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #f8f9fa;
  font-family: "LXGW WenKai Mono TC", monospace;
  -webkit-user-select: none;
  user-select: none;
  position: fixed;
  top: 0;
  left: 0;
}

#app {
  width: 100dvw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Main Menu */
#mainMenu {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  padding: 2rem;
}

#scoreDisplay {
  font-size: 1.4rem;
  font-weight: bold;
  color: #2c3e50;
  margin-bottom: 1.5rem;
  padding: 0.8rem 1.5rem;
  background: linear-gradient(135deg, #e8f4f8, #d0e8ee);
  border: 2px solid #b8d4da;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#langPicker {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

#langPicker label {
  font-size: 1.2rem;
  cursor: pointer;
}

button {
  font-family: "LXGW WenKai Mono TC", monospace;
  font-size: 1.5rem;
  padding: 1rem 2rem;
  border: none;
  border-radius: 12px;
  background: #ffb3ba;
  color: #2c3e50;
  cursor: pointer;
  transition: background 0.25s;
  touch-action: manipulation;
  min-height: 44px;
  min-width: 44px;
}

button:hover, button:active {
  background: #ffc9c9;
}

button.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* Fullscreen Text Views */
.fullscreenView {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #2c3e50;
  font-family: "LXGW WenKai Mono TC", monospace;
  line-height: 1.1;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
}

.fullscreenView span {
  display: block;
  font-size: 4rem;
  max-width: 100%;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Clue Input */
#clueInput {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

#clueForm {
  width: 100%;
  max-width: 500px;
}

.input-container {
  position: relative;
  width: 100%;
  border: 3px solid #ffb3ba;
  border-radius: 12px;
  overflow: hidden;
  background: white;
  height: 70px;
}

#clueField {
  font-family: "LXGW WenKai Mono TC", monospace;
  font-size: 1.5rem;
  width: 100%;
  height: 100%;
  text-align: center;
  padding: 1rem 70px 1rem 1rem;
  border: none;
  outline: none;
  background: white;
  box-sizing: border-box;
}

#submitBtn {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 1.5rem;
  padding: 0;
  border: none;
  background: #ffb3ba;
  color: #2c3e50;
  cursor: pointer;
  transition: background 0.25s;
  border-radius: 0;
  width: 60px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#submitBtn:hover, #submitBtn:active {
  background: #ffc9c9;
}

#wordInner,
#clueInner {
  font-weight: 900;
}

/* Blur effect for word text */
#wordText {
  transition: background 0.3s ease;
}

.blurred {
  filter: blur(60px);
  transition: filter 0.3s ease;
}

/* Gray background when word is blurred */
.word-blurred {
  background: #ff9aa2;
}

/* Hold progress indicator */
.hold-progress {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.hold-progress.active {
  opacity: 1;
}

.hold-progress svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.hold-progress-background {
  fill: none;
  stroke: rgba(255, 179, 186, 0.3);
  stroke-width: 8;
}

.hold-progress-ring {
  fill: none;
  stroke: #ffb3ba;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.05s linear;
}

/* Pulse animation when hold starts */
@keyframes holdPulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

.hold-progress.pulse {
  animation: holdPulse 0.3s ease-out;
}

/* Back Button */
#backBtn {
  position: fixed;
  top: 1rem;
  left: 1rem;
  font-size: 1.5rem;
  border-radius: 50%;
  background: #ff9aa2;
  z-index: 10;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#backBtn.hidden {
  display: none;
}

/* Fullscreen Button */
#fsBtn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  border-radius: 50%;
  background: #ff9aa2;
  z-index: 10;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Room Badge */
#roomBadge {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  background: #ff9aa2;
  color: #2c3e50;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 1.2rem;
  font-weight: bold;
  z-index: 10;
  cursor: pointer;
  transition: background 0.25s;
}

#roomBadge:hover {
  background: #ffc9c9;
}

/* Connection Error Notification */
.connection-error {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: linear-gradient(135deg, #ff6b6b, #ff4444);
  color: white;
  padding: 1rem 1.4rem;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(255, 68, 68, 0.3);
  z-index: 1000;
  max-width: 320px;
  animation: slideIn 0.3s ease-out;
  pointer-events: auto;
}

.connection-error.hidden {
  display: none !important;
  pointer-events: none;
}

.error-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.error-title {
  font-weight: bold;
}

.error-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  margin: -0.5rem -0.5rem 0 0.5rem;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.error-close:hover {
  opacity: 1;
}

.error-message {
  font-size: 0.9rem;
  opacity: 0.95;
  line-height: 1.4;
}

#roomBadge.hidden {
  display: none;
}

/* End Round Button */
#endRoundBtn {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: #ff9aa2;
  color: #2c3e50;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 1.2rem;
  font-weight: bold;
  z-index: 10;
  cursor: pointer;
  transition: background 0.25s;
}

#endRoundBtn:hover {
  background: #ffc9c9;
}

#endRoundBtn.hidden {
  display: none;
}

/* Room Modal */
#roomModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 2rem;
}

#roomModal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  position: relative;
}

.modal-content h2 {
  margin-bottom: 1.5rem;
  color: #2c3e50;
}

.modal-content input {
  font-family: "LXGW WenKai Mono TC", monospace;
  font-size: 1.5rem;
  text-align: center;
  padding: 0.5rem;
  border: 2px solid #ffb3ba;
  border-radius: 8px;
  width: 100%;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.modal-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.modal-buttons button {
  font-size: 1.2rem;
  padding: 0.5rem 1.5rem;
}

/* Player List Display */
.player-list-container {
  margin: 1rem 0;
}

.player-count {
  font-size: 1.1rem;
  color: #2c3e50;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.player-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 350px;
  margin: 0 auto;
}

.player-list li {
  padding: 0.6rem 1rem;
  margin-bottom: 0.4rem;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
  transition: background 0.3s ease;
  color: #495057;
  border: 1px solid #e9ecef;
}

.player-list li.current-player {
  background: #e8f4f8;
  font-weight: bold;
  color: #2c3e50;
  border-color: #c3e6f0;
  position: relative;
}

.player-list li.current-player::before {
  content: "👤";
  position: absolute;
  left: 0.8rem;
}

/* Submitted Words Display */
#submittedWords {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 2rem;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  max-height: 70%;
  overflow-y: auto;
  z-index: 5;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#submittedWords.hidden {
  display: none;
}

#submittedWords h3 {
  margin-bottom: 1rem;
  color: #2c3e50;
  text-align: center;
}

.word-list {
  list-style: none;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 12px;
  border: 2px solid #e9ecef;
  position: relative;
}

.word-list::before {
  content: "PLAYER CLUES";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: #6c757d;
  color: white;
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.word-list li {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: white;
  border-radius: 8px;
  font-size: 1.2rem;
  text-align: center;
  transition: background 0.3s ease;
  border: 1px solid #e9ecef;
}

.word-list li:last-child {
  margin-bottom: 0;
}

.word-list li.own-word {
  background: #d0e8ee;
  font-weight: bold;
  position: relative;
}

.word-list li.own-word::after {
  content: "YOUR CLUE";
  position: absolute;
  top: -8px;
  right: -8px;
  background: #bddbe3;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

/* Distance-based coloring - Ultra pastel traffic light system */
.word-list li.distance-0 {
  background: #fce4e4;
  color: #8b1a1a;
  font-weight: bold;
  position: relative;
}

.word-list li.distance-1 {
  background: #ffe8cc;
  color: #963707;
  font-weight: bold;
}

.word-list li.distance-2 {
  background: #fff4cc;
  color: #765d10;
  font-weight: bold;
}

#currentWordDisplay {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 3px solid #5a67d8;
  border-radius: 12px;
  font-size: 1.4rem;
  font-weight: bold;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
}

#currentWordDisplay::before {
  content: attr(data-label);
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: #4c51bf;
  color: white;
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

#currentWordDisplay.hidden {
  display: none;
}

#showClueBtn {
  width: 100%;
  margin-top: 1rem;
  font-size: 1.2rem;
  padding: 0.8rem;
  position: sticky;
  bottom: 0;
}

/* Scoring Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  padding: 2rem;
}

.modal.hidden {
  display: none !important;
}

.scoring-word {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  font-size: 1.3rem;
  font-weight: bold;
}

.scoring-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  justify-content: center;
}

.scoring-btn {
  font-family: "LXGW WenKai Mono TC", monospace;
  font-size: 1.2rem;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s;
  text-align: center;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.scoring-btn.correct {
  background: #d4edda;
  color: #155724;
  border: 2px solid #c3e6cb;
}

.scoring-btn.correct:hover {
  background: #c3e6cb;
  transform: translateY(-2px);
}

.scoring-btn.neutral {
  background: #fff3cd;
  color: #856404;
  border: 2px solid #ffeaa7;
}

.scoring-btn.neutral:hover {
  background: #ffeaa7;
  transform: translateY(-2px);
}

.scoring-btn.fail {
  background: #f8d7da;
  color: #721c24;
  border: 2px solid #f5c6cb;
}

.scoring-btn.fail:hover {
  background: #f5c6cb;
  transform: translateY(-2px);
}

.score-value {
  font-size: 0.9rem;
  opacity: 0.8;
}

.skip-btn {
  margin-top: 1rem;
  background: #e8e8e8;
  color: #555;
  border: 2px solid #ccc;
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  border-radius: 6px;
  width: 100%;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.skip-btn:hover {
  background: #d8d8d8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.skip-btn .score-value {
  font-size: 0.9rem;
  opacity: 0.7;
  font-weight: normal;
}

.cancel-btn {
  background: #6c757d;
  color: white;
  margin-top: 1rem;
  padding: 0.6rem 2rem;
  font-size: 1rem;
}

.cancel-btn:hover {
  background: #5a6268;
}

/* Score Notification */
.score-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 1rem 2rem;
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: bold;
  z-index: 150;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  animation: scoreSlideIn 0.3s ease-out;
  pointer-events: none;
  text-align: center;
  min-width: 250px;
}

.score-notification.hidden {
  display: none !important;
}

.score-notification.success {
  background: linear-gradient(135deg, #d4edda, #c3e6cb);
  color: #155724;
  border: 2px solid #b8d4da;
}

.score-notification.neutral {
  background: linear-gradient(135deg, #fff3cd, #ffeaa7);
  color: #856404;
  border: 2px solid #e6cc00;
}

.score-notification.fail {
  background: linear-gradient(135deg, #f8d7da, #f5c6cb);
  color: #721c24;
  border: 2px solid #e6a8ad;
}

@keyframes scoreSlideIn {
  from {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* Rules Button and Modal */
.rules-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: #ffb3ba;
  color: #2c3e50;
  font-size: 1.3rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.rules-button:hover {
  background: #ffc9c9;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.rules-button:active {
  transform: scale(0.95);
}

#rulesModal .modal-content {
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgba(0, 0, 0, 0.1);
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  color: #495057;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.2);
  color: #212529;
}

.rules-content {
  text-align: left;
  margin-top: 1rem;
}

.rules-content h3 {
  color: #667eea;
  margin-top: 1.5rem;
  margin-bottom: 0.8rem;
  font-size: 1.3rem;
}

.rules-content h3:first-child {
  margin-top: 0.5rem;
}

.rules-content p {
  margin-bottom: 1rem;
  line-height: 1.6;
  color: #495057;
}

.rules-content ol,
.rules-content ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.rules-content li {
  margin-bottom: 0.8rem;
  line-height: 1.5;
  color: #495057;
}

.rules-content strong {
  color: #2c3e50;
  font-weight: 600;
}
