* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  background: #0a0e14;
  color: #f4f7fa;
  font-family: "Segoe UI", system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Screen page */
body.screen {
  overflow: hidden;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  background: #0a0e14 center / cover no-repeat url("/img/backdrop.png");
  overflow: hidden;
}

.view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4vh 4vw;
}

.loading-text {
  font-size: clamp(18px, 2.2vw, 28px);
  color: rgba(244, 247, 250, 0.85);
}

.lobby-view {
  gap: 2vh;
  perspective: 1200px;
}

.logo {
  max-width: min(600px, 50vw);
  max-height: 37.5vh;
  object-fit: contain;
  animation: logo-hover 20s ease-in-out infinite;
  transform-style: preserve-3d;
  will-change: transform;
}

@keyframes logo-hover {
  0% {
    transform: translateY(0) translateX(0) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }
  12% {
    transform: translateY(-5px) translateX(2px) rotateX(2deg) rotateY(-3deg) rotateZ(0.4deg);
  }
  25% {
    transform: translateY(-11px) translateX(-1px) rotateX(4deg) rotateY(-6deg) rotateZ(-0.5deg);
  }
  38% {
    transform: translateY(-6px) translateX(-3px) rotateX(2deg) rotateY(-2deg) rotateZ(0.6deg);
  }
  50% {
    transform: translateY(2px) translateX(0) rotateX(-3deg) rotateY(4deg) rotateZ(0deg);
  }
  62% {
    transform: translateY(6px) translateX(3px) rotateX(-4deg) rotateY(6deg) rotateZ(-0.6deg);
  }
  75% {
    transform: translateY(-1px) translateX(2px) rotateX(-2deg) rotateY(3deg) rotateZ(0.5deg);
  }
  88% {
    transform: translateY(-8px) translateX(-2px) rotateX(3deg) rotateY(-4deg) rotateZ(-0.3deg);
  }
  100% {
    transform: translateY(0) translateX(0) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }
}

.lobby-message {
  font-size: clamp(20px, 2.2vw, 28px);
  color: rgba(255, 255, 255, 0.9);
}

.lobby-hint {
  font-size: clamp(15px, 1.5vw, 20px);
  font-weight: 300;
  color: rgba(255, 255, 255, 0.6);
}

.round-label {
  font-size: clamp(24px, 3vw, 40px);
  font-weight: 700;
  margin-bottom: 2vh;
}

.countdown-value {
  font-size: clamp(80px, 14vw, 180px);
  font-weight: 700;
  line-height: 1;
}

.playing-view {
  flex-direction: row;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}

.play-game-area {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
}

.play-card {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.play-image.slide-in {
  animation: play-image-slide-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.play-image.slide-out {
  animation: play-image-slide-out 0.5s cubic-bezier(0.7, 0, 0.84, 0) both;
}

@keyframes play-image-slide-in {
  from {
    transform: translateX(60vw);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes play-image-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-60vw);
    opacity: 0;
  }
}

.result-banner {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 20px;
  font-size: clamp(18px, 2.2vw, 30px);
  font-weight: 700;
  color: #0a0e14;
  text-align: center;
}

.result-banner.correct {
  background: rgba(76, 217, 100, 0.92);
}

.result-banner.reveal {
  background: rgba(255, 95, 86, 0.92);
}

.result-banner.pending {
  background: rgba(255, 159, 10, 0.92);
}

.leaderboard-panel {
  width: 20%;
  flex: none;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  padding: 4vh 1.5vw;
  text-align: left;
  overflow: hidden;
}

.play-timer {
  display: block;
  font-size: clamp(32px, 3.5vw, 56px);
  font-weight: 700;
  text-align: center;
  color: #f4f7fa;
  margin-bottom: 3vh;
}

.play-timer.warning {
  color: #ff5f56;
}

.leaderboard-panel h3 {
  font-size: clamp(12px, 1.2vw, 16px);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 10px;
}

.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: clamp(14px, 1.4vw, 18px);
  color: #f4f7fa;
}

.leaderboard-list .lb-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.leaderboard-list .lb-score {
  flex: none;
}

.gameover-title {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 700;
  margin-bottom: 1vh;
}

.gameover-winner {
  font-size: clamp(20px, 3vw, 36px);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 2vh;
}

.leaderboard-list-large {
  width: min(420px, 60vw);
  gap: 10px;
  margin: 1vh 0;
}

.leaderboard-list-large li {
  font-size: clamp(18px, 2vw, 26px);
  color: rgba(255, 255, 255, 0.85);
}

.leaderboard-list-large li:first-child {
  color: #4cd964;
  font-weight: 700;
}

.gameover-hint {
  font-size: clamp(15px, 1.6vw, 22px);
  font-weight: 300;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 3vh;
}

/* Controller page */
body.controller {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 16px;
  touch-action: none;
}

.status {
  text-align: center;
  font-size: 18px;
  line-height: 1.4;
  padding: 16px 8px;
}

.mute-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(244, 247, 250, 0.75);
  background: #1b212c;
  border: 1px solid #2a3242;
  border-radius: 20px;
  -webkit-tap-highlight-color: transparent;
}

.mute-btn.active {
  color: #0a0e14;
  background: #ff9f0a;
  border-color: #ff9f0a;
}

.nickname-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  margin: 8px auto 0;
}

.nickname-label {
  text-align: center;
  font-size: 14px;
  color: rgba(244, 247, 250, 0.6);
}

.nickname-input {
  padding: 14px;
  font-size: 20px;
  text-align: center;
  color: #f4f7fa;
  background: #1b212c;
  border: 2px solid #2a3242;
  border-radius: 12px;
}

.nickname-input:focus {
  outline: none;
  border-color: #4cd964;
}

.ready-btn {
  margin: 16px auto;
  padding: 18px 48px;
  font-size: 22px;
  font-weight: 700;
  color: #0a0e14;
  background: #4cd964;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

.ready-btn:disabled {
  background: #3a4250;
  color: #aab2bf;
}

.mode-select {
  max-width: 360px;
  margin: 16px auto 0;
  text-align: center;
}

.mode-select-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(244, 247, 250, 0.5);
  margin-bottom: 8px;
}

.mode-buttons {
  display: flex;
  gap: 8px;
}

.mode-btn {
  flex: 1;
  padding: 12px 6px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(244, 247, 250, 0.75);
  background: #1b212c;
  border: 2px solid #2a3242;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}

.mode-btn.active {
  color: #0a0e14;
  background: #4cd964;
  border-color: #4cd964;
}

.mode-btn:disabled {
  opacity: 0.7;
}

.mode-description {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.4;
  color: rgba(244, 247, 250, 0.55);
}

.host-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.host-answer-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(244, 247, 250, 0.5);
}

.host-answer {
  padding: 18px 20px;
  font-size: 26px;
  font-weight: 700;
  color: #4cd964;
  background: #1b212c;
  border: 2px solid #2a3242;
  border-radius: 12px;
  text-align: center;
}

.judge-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}

.judge-btn {
  flex: 1;
  min-height: 100px;
  font-size: 22px;
  font-weight: 700;
  color: #0a0e14;
  border: none;
  border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
}

.judge-btn.judge-correct {
  background: #4cd964;
}

.judge-btn.judge-wrong {
  background: #ff5f56;
}

.controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.zone {
  flex: 1;
  font-size: 48px;
  color: #f4f7fa;
  background: #1b212c;
  border: none;
  border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
}

.zone:active {
  background: #2a3242;
}

.hidden {
  display: none !important;
}

.score {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #4cd964;
  padding-bottom: 8px;
}

.result {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 8px;
  border-radius: 12px;
  margin: 0 0 16px;
}

.result.correct {
  background: rgba(76, 217, 100, 0.18);
  color: #4cd964;
}

.result.reveal {
  background: rgba(255, 95, 86, 0.18);
  color: #ff5f56;
}

.answer-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  margin-top: 8px;
}

.answer-input {
  padding: 16px;
  font-size: 20px;
  color: #f4f7fa;
  background: #1b212c;
  border: 2px solid #2a3242;
  border-radius: 12px;
}

.answer-input:focus {
  outline: none;
  border-color: #4cd964;
}

.buzz-btn {
  flex: 1;
  min-height: 140px;
  font-size: 32px;
  font-weight: 700;
  color: #0a0e14;
  background: #ff9f0a;
  border: none;
  border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
}

.buzz-btn:active {
  background: #e08c00;
}

.buzz-btn:disabled {
  background: #3a4250;
  color: #aab2bf;
}

.leaderboard {
  padding: 8px 4px;
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  padding: 6px 8px;
  color: rgba(244, 247, 250, 0.85);
}

.leaderboard-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}
