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

:root {
  --bg: #0b0d14;
  --panel: #161924;
  --panel-2: #1f2330;
  --line: #2a2f40;
  --text: #ebeef5;
  --muted: #8a93a8;
  --cyan: #5ed3f3;
  --pink: #ff3d8b;
  --purple: #c98aff;
  --green: #6ee895;
  --orange: #ffaa3d;
  --red: #ff5252;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Soft animated background blobs */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(800px circle at 15% 20%, rgba(255, 61, 139, 0.15), transparent 60%),
    radial-gradient(700px circle at 85% 80%, rgba(94, 211, 243, 0.13), transparent 60%),
    radial-gradient(500px circle at 50% 50%, rgba(201, 138, 255, 0.08), transparent 60%);
  animation: bgDrift 18s ease-in-out infinite alternate;
}
@keyframes bgDrift {
  0%   { transform: translate(0, 0)   scale(1); }
  100% { transform: translate(30px, -20px) scale(1.05); }
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────────── */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: rgba(22, 25, 36, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
}
.stat-val {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-divider {
  color: var(--muted);
  margin: 0 4px;
  font-weight: 500;
}

.score-stat .stat-val {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: transform 0.15s ease;
}
.score-stat .stat-val.bounce {
  animation: scoreBounce 0.5s cubic-bezier(0.2, 1.8, 0.4, 1);
}
@keyframes scoreBounce {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.45); }
  100% { transform: scale(1); }
}

/* Timer ring */
.timer-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timer-ring {
  position: absolute;
  inset: 0;
  width: 64px;
  height: 64px;
  transform: rotate(-90deg);
}
.timer-bg {
  fill: none;
  stroke: var(--line);
  stroke-width: 5;
}
.timer-fg {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 175.93;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.95s linear, stroke 0.3s ease;
  filter: drop-shadow(0 0 6px rgba(94, 211, 243, 0.6));
}
.timer-text {
  position: relative;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--cyan);
  z-index: 1;
}

.timer-wrap.warning .timer-fg { stroke: var(--orange); filter: drop-shadow(0 0 8px rgba(255, 170, 61, 0.7)); }
.timer-wrap.warning .timer-text { color: var(--orange); }
.timer-wrap.critical .timer-fg { stroke: var(--red); filter: drop-shadow(0 0 10px rgba(255, 82, 82, 0.8)); }
.timer-wrap.critical .timer-text { color: var(--red); animation: timerPulse 0.6s ease-in-out infinite; }
@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

/* ─── Main layout ────────────────────────────────────────────────── */

main {
  display: flex;
  flex: 1;
  gap: 18px;
  padding: 18px;
  min-height: 0;
}

.stage {
  position: relative;
  flex: 2.2;
  background: #000;
  border-radius: 18px;
  overflow: hidden;
  min-width: 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--line);
}

.stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

/* Camera shutter flash on capture */
.shutter {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s ease-out;
}
.shutter.active {
  opacity: 1;
  transition: opacity 0.04s ease-in;
}

/* Word banner */
.word-banner {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  padding: 14px 36px 18px;
  border-radius: 16px;
  border: 2px solid var(--pink);
  text-align: center;
  box-shadow: 0 0 0 4px rgba(255, 61, 139, 0.18), 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: wordPulse 2.6s ease-in-out infinite;
  max-width: 92%;
}
@keyframes wordPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 61, 139, 0.18), 0 8px 30px rgba(0, 0, 0, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(255, 61, 139, 0.28), 0 8px 30px rgba(0, 0, 0, 0.5); }
}

.word-banner-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--pink);
  font-weight: 700;
  margin-bottom: 4px;
}
.word-banner-text {
  display: block;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: capitalize;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.word-banner.entering { animation: wordEnter 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes wordEnter {
  0%   { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.85); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* Skip button */
.skip-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.2s ease, background 0.15s ease, transform 0.1s ease;
}
.skip-btn.visible { opacity: 1; }
.skip-btn:hover { background: rgba(255, 61, 139, 0.3); border-color: var(--pink); }
.skip-btn:active { transform: scale(0.96); }

/* Thinking indicator */
.thinking {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 12px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.15s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.thinking.visible { opacity: 1; }
.thinking-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  animation: thinkingDot 1s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes thinkingDot {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.4; }
  40%           { transform: scale(1); opacity: 1; }
}

/* ─── Side panel ─────────────────────────────────────────────────── */

.side-panel {
  flex: 1;
  min-width: 300px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

/* Latest guess — big chat-bubble vibe */
.latest-guess {
  background: linear-gradient(135deg, rgba(94, 211, 243, 0.12), rgba(201, 138, 255, 0.12));
  border: 1px solid rgba(94, 211, 243, 0.35);
  border-radius: 16px;
  padding: 16px 18px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  transition: all 0.2s ease;
}
.latest-guess-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cyan);
  font-weight: 700;
  margin-bottom: 6px;
}
.latest-guess-text {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: capitalize;
  word-break: break-word;
}
.latest-guess.speaking {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(94, 211, 243, 0.15), 0 0 30px rgba(94, 211, 243, 0.25);
}
.latest-guess.speaking .latest-guess-text {
  animation: bubblePop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes bubblePop {
  0%   { transform: scale(0.92); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Guess feed */
.guess-feed {
  flex: 1;
  background: rgba(22, 25, 36, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.guess-feed h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 700;
}

#guesses {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}
#guesses::-webkit-scrollbar { width: 6px; }
#guesses::-webkit-scrollbar-track { background: transparent; }
#guesses::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

#guesses li {
  padding: 9px 14px;
  background: var(--panel-2);
  border-radius: 10px;
  font-size: 15px;
  animation: slideIn 0.22s cubic-bezier(0.2, 1.4, 0.4, 1);
  text-transform: capitalize;
}
#guesses li.hit {
  background: linear-gradient(135deg, rgba(110, 232, 149, 0.2), rgba(110, 232, 149, 0.08));
  color: var(--green);
  font-weight: 700;
  border: 1px solid rgba(110, 232, 149, 0.4);
}
#guesses li.miss {
  background: rgba(255, 82, 82, 0.12);
  color: var(--red);
  font-weight: 600;
  border: 1px solid rgba(255, 82, 82, 0.25);
}
#guesses li.error {
  color: var(--orange);
  font-style: italic;
  font-size: 12px;
  background: transparent;
  padding: 4px 14px;
  text-transform: none;
}

@keyframes slideIn {
  0%   { opacity: 0; transform: translateX(-12px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* ─── Overlay ────────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 13, 20, 0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  gap: 24px;
  text-align: center;
  padding: 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.overlay.hidden { display: none; }

.overlay h1 {
  font-size: 84px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
}
.overlay h1 .vs {
  color: var(--muted);
  font-weight: 400;
  font-style: italic;
}
.overlay h1 .ai {
  background: linear-gradient(135deg, var(--cyan), var(--purple), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.overlay p {
  font-size: 18px;
  color: var(--muted);
  max-width: 540px;
  line-height: 1.55;
}
.overlay p strong { color: var(--text); }

.big-btn {
  padding: 18px 48px;
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 30px rgba(255, 61, 139, 0.4);
  margin-top: 8px;
  letter-spacing: 0.02em;
}
.big-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(255, 61, 139, 0.55); }
.big-btn:active { transform: translateY(0) scale(0.98); }

/* ─── Flash overlay (correct/time-up) ────────────────────────────── */

.flash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  font-size: 140px;
  font-weight: 900;
  letter-spacing: -0.04em;
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.6);
}
.flash.show { animation: flashIn 1.0s ease-out forwards; }
.flash.hit { color: var(--green); }
.flash.miss { color: var(--orange); }
@keyframes flashIn {
  0%   { opacity: 0; transform: scale(0.6); }
  20%  { opacity: 1; transform: scale(1.1); }
  60%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

/* ─── Confetti ───────────────────────────────────────────────────── */

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: confettiFall 1.6s var(--delay, 0s) cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}
@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 700px)) rotate(var(--rot));
  }
}
