/* ══════════════════════════════════════════════════════════════════════════════
   WhoDrew.io — Premium Dark Design System (Fully Mobile & Cross-Device Responsive)
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Player palette */
  --c-neon-blue:    #00d4ff;
  --c-hot-pink:     #ff2d78;
  --c-lime-green:   #39ff14;
  --c-solar-gold:   #ffca28;
  --c-vivid-purple: #bf5fff;
  --c-coral-red:    #ff5722;
  --c-cyan-mint:    #00e5cc;
  --c-amber:        #ff9800;

  /* Surface */
  --bg-base:      #0b0c14;
  --bg-surface:   #12141f;
  --bg-card:      rgba(255,255,255,0.05);
  --bg-card-hov:  rgba(255,255,255,0.08);
  --border-glass: rgba(255,255,255,0.10);
  --border-glow:  rgba(255,255,255,0.18);

  /* Text */
  --txt-primary:   #f0f0f8;
  --txt-secondary: #8890b0;
  --txt-muted:     #4a4f6a;

  /* Brand accent */
  --accent:      #7c6ff7;
  --accent-light:#a599ff;
  --accent-glow: rgba(124,111,247,0.35);

  /* Danger & Success */
  --danger:  #ff3a5c;
  --success: #00e5a0;

  /* Spacing & Radii */
  --rad-sm: 8px;
  --rad-md: 14px;
  --rad-lg: 20px;
  --rad-xl: 28px;
  --rad-full: 9999px;

  /* Typography */
  --font-main:  'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono:  'Space Grotesk', monospace;
}

html, body {
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--txt-primary);
  font-family: var(--font-main);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Screen System ─────────────────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.screen.active {
  display: flex;
  opacity: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.fade-out { opacity: 0; pointer-events: none; }

/* Scrollable positioning on all devices to avoid cut-off headers/footers */
#screen-landing.active,
#screen-lobby.active,
#screen-drawing.active,
#screen-interrogation.active,
#screen-forger-guess.active,
#screen-results.active {
  justify-content: flex-start;
}

/* ── Glass Card ────────────────────────────────────────────────────────────── */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--rad-xl);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 28px;
  min-height: 48px; /* Touch target accessibility */
  border: none; border-radius: var(--rad-md);
  font-family: var(--font-main);
  font-size: 1rem; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
  position: relative; overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.2s;
}
.btn:hover::after { background: rgba(255,255,255,0.08); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #7c6ff7, #5a50d8);
  color: #fff;
  box-shadow: 0 0 24px rgba(124,111,247,0.4), 0 4px 20px rgba(0,0,0,0.4);
}
.btn-primary:hover {
  box-shadow: 0 0 36px rgba(124,111,247,0.6), 0 4px 24px rgba(0,0,0,0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-glass);
  color: var(--txt-primary);
}
.btn-secondary:hover { background: rgba(255,255,255,0.13); }

.btn-full { width: 100%; }

.btn-small {
  padding: 10px 18px;
  min-height: 42px;
  font-size: 0.875rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--rad-sm);
  border: none;
}

.btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; padding: 6px 8px;
  min-width: 36px; min-height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0.7; transition: opacity 0.2s;
  border-radius: var(--rad-sm);
}
.btn-icon:hover { opacity: 1; background: rgba(255,255,255,0.08); }

/* ── Form Elements ─────────────────────────────────────────────────────────── */
input[type="text"], textarea {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--rad-md);
  color: var(--txt-primary);
  font-family: var(--font-main);
  font-size: 1rem;
  padding: 13px 16px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
input[type="text"]:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--txt-muted); }

.error-msg {
  color: var(--danger);
  font-size: 0.875rem;
  padding: 10px 14px;
  background: rgba(255,58,92,0.1);
  border: 1px solid rgba(255,58,92,0.3);
  border-radius: var(--rad-sm);
  margin-top: 12px;
  text-align: center;
}
.hidden { display: none !important; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.divider {
  position: relative; text-align: center;
  color: var(--txt-muted); font-size: 0.85rem;
  padding: 8px 0;
}
.divider::before, .divider::after {
  content: '';
  position: absolute; top: 50%;
  width: 42%; height: 1px;
  background: var(--border-glass);
}
.divider::before { left: 0; }
.divider::after  { right: 0; }

/* ══════════════════════════════════════════════════════════════════════════════
   LANDING SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */
#screen-landing { position: relative; }

#screen-landing.active {
  padding-top: clamp(20px, 6vh, 60px);
  padding-bottom: clamp(20px, 6vh, 60px);
}

.landing-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: orb-drift 8s ease-in-out infinite alternate;
}
.orb-1 { width: clamp(260px, 45vw, 400px); height: clamp(260px, 45vw, 400px); background: rgba(124,111,247,0.18); top: -100px; left: -100px; animation-delay: 0s; }
.orb-2 { width: clamp(220px, 40vw, 350px); height: clamp(220px, 40vw, 350px); background: rgba(0,212,255,0.12); bottom: -80px; right: -80px; animation-delay: -3s; }
.orb-3 { width: clamp(180px, 30vw, 250px); height: clamp(180px, 30vw, 250px); background: rgba(255,45,120,0.10); top: 40%; right: 10%; animation-delay: -5s; }

@keyframes orb-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(25px, 35px) scale(1.08); }
}

.landing-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: clamp(20px, 4vh, 32px);
  padding: 20px 16px;
  max-width: 440px; width: 100%;
}

.logo-block { text-align: center; }
.logo-icon { font-size: clamp(2.5rem, 8vw, 3.5rem); margin-bottom: 6px; filter: drop-shadow(0 0 20px rgba(124,111,247,0.6)); }
.logo-text {
  font-size: clamp(2rem, 7.5vw, 2.8rem); font-weight: 900;
  background: linear-gradient(120deg, var(--accent-light), var(--c-neon-blue), var(--c-hot-pink));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.05;
}
.logo-dot { -webkit-text-fill-color: var(--txt-muted); font-size: 0.75em; }
.logo-tagline {
  color: var(--txt-secondary);
  font-size: clamp(0.8rem, 2.5vw, 1rem); font-weight: 400; letter-spacing: 0.18em; text-transform: uppercase;
  margin-top: 8px;
}

.landing-card {
  padding: clamp(20px, 5vw, 32px); width: 100%;
}
.name-field { margin-bottom: 20px; }
.name-field label {
  display: block; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--txt-secondary); margin-bottom: 8px;
}

.landing-actions { display: flex; flex-direction: column; gap: 14px; }

.join-row { display: flex; gap: 8px; }
.code-input { flex: 1; text-transform: uppercase; letter-spacing: 0.2em; font-weight: 700; text-align: center; }

.landing-rules {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.landing-rules span {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--rad-full);
  padding: 6px 12px; font-size: 0.78rem;
  color: var(--txt-secondary);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════════
   LOBBY SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */
#screen-lobby.active {
  padding: clamp(14px, 3vh, 28px) clamp(12px, 3vw, 24px);
  gap: clamp(12px, 2.5vh, 20px);
  align-items: stretch;
  justify-content: flex-start;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

.lobby-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border-glass);
  flex-wrap: wrap;
}
.room-badge { display: flex; align-items: center; gap: 8px; }
.room-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--txt-muted); }
.room-code {
  font-family: var(--font-mono); font-size: clamp(1.4rem, 5vw, 1.8rem); font-weight: 700;
  letter-spacing: 0.2em; color: var(--accent-light);
  text-shadow: 0 0 12px var(--accent-glow);
}
.lobby-title { font-size: clamp(0.9rem, 3vw, 1.1rem); color: var(--txt-secondary); }

.lobby-body {
  display: grid; grid-template-columns: 1fr 340px; gap: 20px;
  flex: 1;
}

@media (max-width: 820px) {
  .lobby-body { grid-template-columns: 1fr; gap: 16px; }
  .lobby-header { gap: 10px; }
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  align-content: start;
}

.player-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--rad-lg);
  padding: 14px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}
.player-card.is-you { border-color: rgba(255,255,255,0.25); }

.player-avatar {
  width: clamp(42px, 10vw, 52px); height: clamp(42px, 10vw, 52px);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(1.1rem, 3vw, 1.4rem); font-weight: 700;
}
.player-name-label {
  font-size: 0.85rem; font-weight: 600; text-align: center;
  color: var(--txt-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 110px;
}
.player-color-name {
  font-size: 0.7rem; color: var(--txt-muted); letter-spacing: 0.04em;
}
.host-badge {
  position: absolute; top: -6px; right: 8px;
  background: var(--accent); color: #fff;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em;
  padding: 2px 7px; border-radius: var(--rad-full);
  text-transform: uppercase;
}

/* Settings panel */
.lobby-settings-panel { padding: clamp(16px, 4vw, 24px); display: flex; flex-direction: column; gap: 14px; }
.settings-title { font-size: 1rem; font-weight: 700; color: var(--txt-primary); }

.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.setting-info { flex: 1; }
.setting-name { font-size: 0.88rem; font-weight: 600; }
.setting-desc { font-size: 0.74rem; color: var(--txt-muted); margin-top: 2px; }

/* Round stepper */
.round-stepper { display: flex; align-items: center; gap: 10px; }
.stepper-btn {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.08); border: 1px solid var(--border-glass);
  border-radius: 8px; color: #fff; font-size: 1.1rem; font-weight: 700;
  cursor: pointer; transition: background 0.2s;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
}
.stepper-btn:hover { background: rgba(255,255,255,0.15); }
.stepper-val { font-size: 1.15rem; font-weight: 700; min-width: 20px; text-align: center; }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 13px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute; left: 3px; bottom: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--txt-secondary);
  transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .toggle-slider { background: rgba(124,111,247,0.4); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
  background: var(--accent-light);
}

.custom-words-input { resize: vertical; font-size: 0.85rem; line-height: 1.5; }

.waiting-msg {
  text-align: center; color: var(--txt-secondary);
  font-size: 0.92rem; padding: 14px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--rad-md);
}

/* ══════════════════════════════════════════════════════════════════════════════
   ROLE REVEAL SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */
#screen-role {
  background: radial-gradient(ellipse at center, rgba(124,111,247,0.08) 0%, transparent 70%);
}

#screen-role.active {
  justify-content: center;
}

.role-reveal-container {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: clamp(20px, 5vh, 40px) clamp(16px, 4vw, 20px);
}

.role-card {
  max-width: 440px; width: 100%;
  padding: clamp(24px, 6vw, 48px) clamp(18px, 6vw, 40px); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  animation: card-pop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes card-pop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.role-icon { font-size: clamp(3rem, 10vw, 4rem); }
.role-title { font-size: clamp(1.5rem, 6vw, 2.2rem); font-weight: 900; }
.role-subtitle { color: var(--txt-secondary); font-size: clamp(0.88rem, 3vw, 1rem); }
.role-word-box {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border-glow);
  border-radius: var(--rad-lg);
  padding: 16px clamp(16px, 4vw, 36px);
  font-size: clamp(1.3rem, 6vw, 2rem); font-weight: 900; letter-spacing: 0.04em;
  width: 100%;
  word-break: break-word;
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50%       { box-shadow: 0 0 20px 4px rgba(124,111,247,0.25); }
}
.role-tip { font-size: clamp(0.78rem, 2.5vw, 0.85rem); color: var(--txt-muted); max-width: 340px; line-height: 1.5; }

.role-countdown { width: 100%; height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.role-countdown-bar {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--c-neon-blue));
  transform-origin: left;
  animation: countdown-shrink 5s linear forwards;
}
@keyframes countdown-shrink {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ══════════════════════════════════════════════════════════════════════════════
   DRAWING SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */
#screen-drawing.active {
  padding: clamp(8px, 2vh, 16px) clamp(10px, 3vw, 16px);
  gap: clamp(8px, 1.5vh, 12px);
  justify-content: flex-start;
  align-items: center;
}

.drawing-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 960px;
  padding: 2px 0;
  gap: 8px;
}
.drawing-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.round-label {
  font-size: clamp(0.75rem, 2.5vw, 0.85rem); font-weight: 600; letter-spacing: 0.05em;
  color: var(--txt-secondary); text-transform: uppercase;
  white-space: nowrap;
}
.word-hint, .forger-hint {
  font-size: clamp(0.78rem, 2.5vw, 0.9rem); color: var(--txt-secondary);
  background: rgba(255,255,255,0.05); border-radius: var(--rad-full);
  padding: 4px 12px; border: 1px solid var(--border-glass);
  white-space: nowrap;
}
.word-hint strong { color: var(--c-lime-green); }
.forger-hint strong { color: var(--c-hot-pink); }

/* Timer ring */
.timer-block { position: relative; width: clamp(40px, 10vw, 48px); height: clamp(40px, 10vw, 48px); flex-shrink: 0; }
.timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-bg { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 3; }
.timer-fg {
  fill: none; stroke: var(--accent-light); stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.9s linear, stroke 0.3s;
}
.timer-fg.urgent { stroke: var(--danger); }
.timer-number {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(0.88rem, 3vw, 1rem); font-weight: 700;
}

/* Canvas Wrapper */
.canvas-wrapper {
  position: relative; flex-shrink: 0;
  border-radius: clamp(10px, 2.5vw, 20px); overflow: hidden;
  border: 2px solid var(--border-glass);
  box-shadow: 0 0 0 2px transparent;
  transition: border-color 0.3s, box-shadow 0.3s;
  background: #1a1c2e;
  width: 100%; max-width: 960px;
  aspect-ratio: 16 / 9;
  touch-action: none;
}
.canvas-wrapper.my-turn {
  border-color: var(--current-player-color, var(--accent));
  box-shadow: 0 0 24px 4px var(--current-player-color, var(--accent-glow));
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  cursor: crosshair;
  touch-action: none;
}
#game-canvas.not-my-turn { cursor: not-allowed; }

.canvas-overlay {
  position: absolute; inset: 0;
  background: #1a1c2e;
  display: none;
  pointer-events: none;
}
.canvas-overlay.active { display: block; }

.turn-banner {
  position: absolute; top: clamp(6px, 1.5vw, 12px); left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(8px);
  border-radius: var(--rad-full); padding: 4px 14px;
  font-size: clamp(0.72rem, 2.5vw, 0.85rem); font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.3s;
  pointer-events: none;
}

.your-turn-flash {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(1.4rem, 6vw, 2.5rem); font-weight: 900; letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 30px rgba(255,255,255,0.5);
  animation: flash-in 0.4s ease forwards;
  pointer-events: none;
  opacity: 0;
}
.your-turn-flash.active { animation: flash-sequence 1s ease forwards; }
@keyframes flash-sequence {
  0%   { opacity: 0; transform: scale(0.7); }
  30%  { opacity: 1; transform: scale(1.05); }
  70%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.1); }
}

/* Player turn strip */
.drawing-footer {
  width: 100%; max-width: 960px; padding-bottom: 8px;
}
.player-turn-strip {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
}
.turn-pip {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border-radius: var(--rad-full);
  border: 2px solid transparent;
  background: rgba(255,255,255,0.04);
  font-size: clamp(0.7rem, 2.3vw, 0.8rem); font-weight: 600;
  transition: all 0.3s;
  opacity: 0.45;
  white-space: nowrap;
}
.turn-pip.active-turn {
  opacity: 1;
  border-color: var(--pip-color, var(--accent));
  box-shadow: 0 0 10px var(--pip-color, var(--accent-glow));
  background: rgba(255,255,255,0.08);
}
.turn-pip.done-turn { opacity: 0.6; }
.pip-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════════════════════
   INTERROGATION SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */
#screen-interrogation.active {
  padding: clamp(10px, 2.5vh, 20px) clamp(10px, 3vw, 16px);
  justify-content: flex-start;
  align-items: center;
}

.interrogation-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  width: 100%; max-width: 1140px;
  align-items: start;
}

@media (max-width: 850px) {
  .interrogation-layout { grid-template-columns: 1fr; gap: 14px; }
}

.int-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.int-title { font-size: clamp(1.1rem, 4vw, 1.3rem); font-weight: 800; }

/* Interrogation timer */
.int-timer-block { display: flex; align-items: center; gap: 8px; }
.int-timer-bar {
  width: clamp(80px, 25vw, 160px); height: 6px;
  background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden;
}
.int-timer-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--c-lime-green), var(--c-solar-gold), var(--danger));
  transform-origin: left;
  transition: transform 1s linear;
}
.int-timer-num { font-size: 1rem; font-weight: 700; min-width: 24px; }

#frozen-canvas, #guess-canvas {
  display: block;
  border-radius: clamp(10px, 2.5vw, 20px);
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 1px solid var(--border-glass);
  background: #1a1c2e;
}

/* Vote area */
.vote-area { margin-top: 14px; }
.vote-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 10px; }
.vote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
  gap: 8px;
}
.vote-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 8px;
  background: var(--bg-card); border: 2px solid transparent;
  border-radius: var(--rad-md); cursor: pointer;
  transition: all 0.2s;
  min-width: 0; width: 100%;
  user-select: none;
}
.vote-card:hover { background: var(--bg-card-hov); transform: translateY(-2px); }
.vote-card.voted-this {
  border-color: var(--danger);
  box-shadow: 0 0 12px rgba(255,58,92,0.3);
}
.vote-card.has-votes { background: rgba(255,58,92,0.08); }
.vote-card.disabled { pointer-events: none; opacity: 0.5; }
.vote-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700;
}
.vote-name {
  font-size: 0.78rem; font-weight: 600; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.vote-count {
  font-size: 0.68rem; color: var(--txt-muted);
  background: rgba(255,255,255,0.06); border-radius: var(--rad-full);
  padding: 2px 7px;
}

.vote-status {
  margin-top: 10px; font-size: 0.82rem; color: var(--txt-secondary);
}

/* Chat */
.interrogation-right {
  padding: clamp(14px, 3vw, 20px);
  display: flex; flex-direction: column; gap: 10px;
  height: 100%; min-height: 280px;
}
@media (max-width: 850px) {
  .interrogation-right { min-height: 240px; max-height: 380px; }
}
.chat-title { font-size: 0.95rem; font-weight: 700; }
.chat-messages {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  min-height: 140px; max-height: 320px; padding-right: 4px;
  scrollbar-width: thin; scrollbar-color: var(--border-glass) transparent;
}
.chat-msg {
  font-size: 0.82rem; line-height: 1.45;
  background: rgba(255,255,255,0.04);
  border-radius: var(--rad-sm); padding: 7px 10px;
  word-break: break-word;
}
.chat-msg.system { color: var(--txt-muted); font-style: italic; background: transparent; padding: 4px 0; }
.chat-msg-name { font-weight: 700; margin-right: 4px; }
.chat-input-row { display: flex; gap: 6px; }
.chat-input-row input { flex: 1; }

/* ══════════════════════════════════════════════════════════════════════════════
   FORGER GUESS SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */
#screen-forger-guess {
  background: radial-gradient(ellipse at center, rgba(255,58,92,0.06) 0%, transparent 70%);
}

#screen-forger-guess.active {
  justify-content: center;
}

.forger-guess-container {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: clamp(20px, 5vh, 40px) clamp(14px, 4vw, 20px);
}
.orb-red { width: 300px; height: 300px; background: rgba(255,58,92,0.15); top: 30%; left: 20%; filter: blur(80px); }

.forger-guess-card {
  max-width: 520px; width: 100%; padding: clamp(24px, 5vw, 44px) clamp(16px, 5vw, 36px);
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px;
  animation: card-pop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
.forger-guess-icon { font-size: clamp(2.8rem, 8vw, 3.5rem); }
.forger-guess-title { font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 900; }
.forger-guess-subtitle { color: var(--txt-secondary); font-size: clamp(0.85rem, 3vw, 1rem); }

.forger-guess-countdown {
  font-size: clamp(2.5rem, 8vw, 3.5rem); font-weight: 900;
  color: var(--danger);
  text-shadow: 0 0 20px rgba(255,58,92,0.5);
  line-height: 1;
  transition: color 0.3s;
}
.forger-guess-countdown.safe { color: var(--c-solar-gold); }

.forger-input-area { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.forger-input-area input { font-size: 1rem; text-align: center; font-weight: 600; }

.forger-waiting { color: var(--txt-secondary); font-size: 1rem; line-height: 1.8; }
.forger-waiting-dots span {
  animation: dot-bounce 1.2s ease infinite;
  font-size: 1.4rem;
  display: inline-block;
}
.forger-waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.forger-waiting-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

.forger-canvas-preview { width: 100%; max-width: 440px; }
.forger-canvas-preview canvas {
  max-width: 100%; border-radius: var(--rad-md);
  border: 1px solid var(--border-glass); background: #1a1c2e;
}

/* ══════════════════════════════════════════════════════════════════════════════
   RESULTS SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */
#screen-results.active {
  padding: clamp(20px, 4vh, 32px) clamp(12px, 4vw, 20px);
  justify-content: flex-start;
  align-items: center;
}

.results-container {
  display: flex; flex-direction: column; align-items: center; gap: clamp(16px, 3vh, 24px);
  max-width: 660px; width: 100%;
}
.results-header { text-align: center; display: flex; flex-direction: column; gap: 8px; }
.results-outcome-icon { font-size: clamp(3rem, 10vw, 4rem); animation: icon-bounce 0.6s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes icon-bounce {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}
.results-outcome-title { font-size: clamp(1.5rem, 6vw, 2.2rem); font-weight: 900; }
.results-word-reveal { color: var(--txt-secondary); font-size: clamp(0.9rem, 3vw, 1rem); }
.results-word-reveal strong { color: var(--c-lime-green); font-size: 1.15em; }
.results-forger-reveal { color: var(--txt-secondary); font-size: clamp(0.85rem, 2.8vw, 0.95rem); }
.results-forger-reveal strong { color: var(--c-hot-pink); }

/* Score deltas */
.score-deltas {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%;
}
.score-delta-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--rad-lg);
  padding: 12px 14px; min-width: 100px; flex: 1 1 100px; max-width: 150px; text-align: center;
  animation: delta-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes delta-pop {
  from { transform: scale(0.7) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.delta-name { font-size: 0.78rem; color: var(--txt-secondary); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delta-points {
  font-size: clamp(1.2rem, 4vw, 1.5rem); font-weight: 900;
}
.delta-points.positive { color: var(--success); }
.delta-points.negative { color: var(--danger); }
.delta-points.zero { color: var(--txt-muted); }

/* Leaderboard */
.leaderboard { padding: clamp(16px, 4vw, 24px); width: 100%; }
.leaderboard-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 12px; }
.leaderboard-rows { display: flex; flex-direction: column; gap: 6px; }
.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03); border-radius: var(--rad-md);
  transition: background 0.2s;
}
.lb-rank {
  font-size: 0.82rem; font-weight: 700; color: var(--txt-muted);
  min-width: 20px; text-align: center;
}
.lb-rank.top1 { color: var(--c-solar-gold); }
.lb-rank.top2 { color: var(--txt-secondary); }
.lb-rank.top3 { color: var(--c-coral-red); }
.lb-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 700; flex-shrink: 0; }
.lb-name { flex: 1; font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-size: 1rem; font-weight: 900; font-family: var(--font-mono); }

.results-footer { text-align: center; }
.returning-countdown { color: var(--txt-muted); font-size: 0.88rem; }
.returning-countdown span { color: var(--txt-secondary); font-weight: 700; }

/* ══════════════════════════════════════════════════════════════════════════════
   NOTIFICATION TOAST
   ══════════════════════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: clamp(14px, 4vh, 24px); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 9999; pointer-events: none;
  width: 90%; max-width: 400px;
}
.toast {
  background: rgba(20,22,35,0.95);
  border: 1px solid var(--border-glow);
  backdrop-filter: blur(16px);
  border-radius: var(--rad-full);
  padding: 8px 18px;
  font-size: 0.85rem; font-weight: 600;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
  white-space: nowrap; text-align: center;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ── Vote Result Overlay ───────────────────────────────────────────────────── */
#vote-result-overlay {
  position: fixed; inset: 0; z-index: 8000;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(10px);
  pointer-events: none;
  padding: 16px;
}
#vote-result-overlay.active {
  display: flex;
  pointer-events: all;
  animation: overlay-in 0.3s ease forwards;
}
@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.vote-result-card {
  background: var(--bg-surface); border: 1px solid var(--border-glow);
  border-radius: var(--rad-xl); padding: clamp(24px, 6vw, 48px) clamp(16px, 5vw, 36px);
  text-align: center; display: flex; flex-direction: column; gap: 14px;
  animation: card-pop 0.5s ease;
  max-width: 400px; width: 100%;
}
.vrc-icon { font-size: clamp(2.5rem, 8vw, 3rem); }
.vrc-title { font-size: clamp(1.4rem, 5vw, 1.8rem); font-weight: 900; }
.vrc-subtitle { color: var(--txt-secondary); font-size: 0.9rem; }

/* ── Leave Room Button & Disconnection Indicators ───────────────────────── */
.btn-leave {
  background: rgba(255, 45, 120, 0.12);
  border: 1px solid rgba(255, 45, 120, 0.35);
  color: var(--c-hot-pink);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  min-height: 36px;
  border-radius: var(--rad-full);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.btn-leave:hover {
  background: rgba(255, 45, 120, 0.25);
  border-color: var(--c-hot-pink);
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(255, 45, 120, 0.3);
}

.player-card.disconnected {
  opacity: 0.55;
  filter: grayscale(0.5);
  border-style: dashed;
}

.turn-pip.offline {
  opacity: 0.45;
  filter: grayscale(0.6);
}

.vote-card.disconnected {
  opacity: 0.5;
  filter: grayscale(0.7);
}

/* ══════════════════════════════════════════════════════════════════════════════
   SPECIAL BREAKPOINTS FOR TABLETS & LANDSCAPE PHONES
   ══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .join-row { flex-direction: column; }
  .join-row .btn { width: 100%; }
  .lobby-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .lobby-header .btn-leave { align-self: flex-end; margin-top: -36px; }
  .drawing-header { flex-direction: row; align-items: center; }
}

@media (max-height: 520px) and (orientation: landscape) {
  #screen-landing.active,
  #screen-lobby.active,
  #screen-drawing.active,
  #screen-interrogation.active,
  #screen-forger-guess.active,
  #screen-results.active {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .canvas-wrapper {
    max-height: 60vh;
    width: auto;
    aspect-ratio: 16 / 9;
  }

  #frozen-canvas, #guess-canvas {
    max-height: 55vh;
    width: auto;
  }

  .role-card, .forger-guess-card, .landing-card {
    padding: 16px 20px;
    gap: 8px;
  }
  .role-icon, .forger-guess-icon { font-size: 2rem; }
  .role-title, .forger-guess-title { font-size: 1.2rem; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   STATIC PAGES (About, Privacy, Terms, Contact) & FOOTER
   ══════════════════════════════════════════════════════════════════════════════ */
.static-page-wrapper {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  padding: 24px 16px 40px;
  overflow-y: auto;
}

.static-nav {
  width: 100%;
  max-width: 800px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 24px;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 24px;
}
.static-nav-logo {
  font-size: 1.5rem;
  font-weight: 900;
  text-decoration: none;
  background: linear-gradient(120deg, var(--accent-light), var(--c-neon-blue));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}
.static-nav-links {
  display: flex;
  gap: 16px;
  align-items: center;
}
.static-nav-links a {
  color: var(--txt-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: color 0.2s;
}
.static-nav-links a:hover,
.static-nav-links a.active {
  color: var(--accent-light);
}

.static-card {
  max-width: 800px;
  width: 100%;
  padding: clamp(24px, 5vw, 40px);
  margin-bottom: 32px;
}
.static-title {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 900;
  margin-bottom: 8px;
  background: linear-gradient(120deg, var(--txt-primary), var(--accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.static-subtitle {
  color: var(--txt-muted);
  font-size: 0.88rem;
  margin-bottom: 24px;
}
.static-body {
  line-height: 1.7;
  color: var(--txt-secondary);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.static-body h2 {
  color: var(--txt-primary);
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 12px;
}
.static-body p {
  font-size: 0.95rem;
}
.static-body ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.static-body li {
  font-size: 0.92rem;
}

/* Contact Form */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--txt-secondary);
}

/* Site Footer */
.site-footer {
  width: 100%;
  margin-top: auto;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border-glass);
}
.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-links a {
  color: var(--txt-secondary);
  font-size: 0.82rem;
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links a:hover {
  color: var(--accent-light);
}
.footer-copy {
  color: var(--txt-muted);
  font-size: 0.75rem;
}

