/* Woolly Words — Party Game Aesthetic v2 */
:root {
  --bg: #0b0d17;
  --surface: #12152a;
  --surface2: #181c35;
  --surface3: #20254a;
  --accent: #8b5cf6;
  --accent2: #22d3ee;
  --accent3: #f472b6;
  --gold: #fbbf24;
  --danger: #ef4444;
  --danger2: #b91c1c;
  --good: #22c55e;
  --good2: #16a34a;
  --warn: #eab308;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --shadow: rgba(0,0,0,0.4);
  --tile-face: #2a2f5e;
  --tile-edge: #14163a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Nunito", "Baloo 2", ui-rounded, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:
    radial-gradient(1200px 800px at 15% -5%, #2a1564 0%, transparent 55%),
    radial-gradient(1000px 700px at 90% 110%, #0e3a5a 0%, transparent 55%),
    radial-gradient(700px 500px at 80% 0%, #5b1248 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
  font-weight: 600;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 22px 22px; opacity: 0.35;
}
#app { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; }
.language-switcher {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: rgba(15,18,40,0.82);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
}
.language-switcher label {
  font-size: 11px;
  font-weight: 900;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.language-switcher select {
  width: auto;
  min-width: 116px;
  margin: 0;
  padding: 6px 24px 6px 8px;
  border-radius: 10px;
  font-size: 13px;
}
.desktop-lobby-leave {
  display: none;
  width: auto;
  min-width: 96px;
  height: 34px;
  min-height: 34px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  background: linear-gradient(180deg, #f87171, #b91c1c);
  box-shadow: 0 4px 0 #7f1d1d, 0 8px 18px rgba(239,68,68,0.28), inset 0 1px 0 rgba(255,255,255,0.15);
}
.desktop-lobby-leave:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #7f1d1d, 0 5px 12px rgba(239,68,68,0.24), inset 0 1px 0 rgba(255,255,255,0.12);
}
body.lobby-active .desktop-lobby-leave {
  display: inline-flex;
}
#btn-leave {
  display: none;
}
html[dir="rtl"] .language-switcher {
  right: auto;
  left: 10px;
}
html[dir="rtl"] .sb-left,
html[dir="rtl"] .mini-row,
html[dir="rtl"] .cr-finders {
  direction: rtl;
}
.center-y { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.slogan-text {
  max-width: min(92vw, 520px);
  text-align: center;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.mb8 { margin-bottom: 8px; }
.mt8 { margin-top: 8px; }

.hero-title {
  font-size: clamp(36px, 8vw, 84px);
  font-weight: 900;
  letter-spacing: -2px;
  text-align: center;
  background: linear-gradient(90deg, #f472b6 0%, #a78bfa 30%, #22d3ee 60%, #34d399 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 18px rgba(167,139,250,0.35));
  animation: heroFloat 3.5s ease-in-out infinite;
}
@keyframes heroFloat {
  0%, 100% { transform: translateY(0) rotate(-0.5deg); }
  50% { transform: translateY(-8px) rotate(0.5deg); }
}

.card {
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 20px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 24px 70px var(--shadow), inset 0 1px 0 rgba(255,255,255,0.06);
  margin: 8px 0;
}

input, select {
  width: 100%;
  padding: 14px 14px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.3);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  margin: 6px 0;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent2); box-shadow: 0 0 0 4px rgba(34,211,238,0.18); }

.btn {
  width: 100%;
  padding: 16px 14px;
  border-radius: 16px;
  border: none;
  color: #fff;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.3px;
  cursor: pointer;
  background: linear-gradient(180deg, #a78bfa 0%, #7c3aed 60%, #5b21b6 100%);
  box-shadow:
    0 10px 0 #4c1d95,
    0 16px 30px rgba(124,58,237,0.45),
    inset 0 2px 0 rgba(255,255,255,0.25);
  transition: transform .08s ease, box-shadow .15s ease, filter .15s ease;
  margin: 6px 0;
  text-transform: uppercase;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 6px 0 #4c1d95, 0 8px 18px rgba(124,58,237,0.4), inset 0 2px 0 rgba(255,255,255,0.2); }
.btn-secondary {
  background: linear-gradient(180deg, #475569, #1e293b);
  box-shadow: 0 8px 0 #0f172a, 0 12px 22px rgba(0,0,0,0.4), inset 0 2px 0 rgba(255,255,255,0.1);
}
.btn-secondary:active { box-shadow: 0 4px 0 #0f172a, 0 6px 14px rgba(0,0,0,0.35), inset 0 2px 0 rgba(255,255,255,0.08); }
.btn.danger {
  background: linear-gradient(180deg, #f87171, #b91c1c);
  box-shadow: 0 8px 0 #7f1d1d, 0 12px 22px rgba(239,68,68,0.35), inset 0 2px 0 rgba(255,255,255,0.15);
}
.btn.danger:active { box-shadow: 0 4px 0 #7f1d1d, 0 6px 14px rgba(239,68,68,0.3), inset 0 2px 0 rgba(255,255,255,0.1); }

.btn-start-big {
  background: linear-gradient(180deg, #34d399 0%, #10b981 60%, #047857 100%);
  box-shadow: 0 10px 0 #064e3b, 0 18px 32px rgba(16,185,129,0.45), inset 0 2px 0 rgba(255,255,255,0.25);
  font-size: 20px; padding: 20px;
}
.btn-start-big:active { box-shadow: 0 5px 0 #064e3b, 0 10px 22px rgba(16,185,129,0.4), inset 0 2px 0 rgba(255,255,255,0.2); }

.avatar-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.avatar-btn {
  width: 52px; height: 52px; font-size: 30px; border-radius: 16px;
  border: 3px solid transparent; background: rgba(255,255,255,0.06);
  cursor: pointer; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.avatar-btn:hover { transform: translateY(-2px) scale(1.05); }
.avatar-btn.selected {
  border-color: var(--accent2); background: rgba(34,211,238,0.15);
  box-shadow: 0 0 0 4px rgba(34,211,238,0.18), 0 8px 22px rgba(34,211,238,0.25);
  transform: scale(1.08);
}

.home-options { margin-top: 12px; }
.home-options label { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.choice-separator {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
  text-align: center;
}

/* ===========  LOBBY  =========== */
.lobby-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; }
.lobby-body { flex: 1; overflow-y: auto; padding: 0 14px 14px; }
.lobby-footer { padding: 12px 14px; }

/* Hero banner with HUGE room code */
.lobby-hero {
  text-align: center; padding: 18px 14px 8px;
}
.lobby-hero .mini-title {
  font-size: 14px; font-weight: 900; letter-spacing: 4px;
  color: var(--muted); text-transform: uppercase; margin-bottom: 6px;
}
.room-code-big {
  display: inline-block;
  font-size: clamp(56px, 14vw, 140px);
  font-weight: 900; letter-spacing: 14px; padding: 8px 28px 10px;
  background: linear-gradient(180deg, #fef3c7 0%, #fbbf24 50%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 8px 24px rgba(251,191,36,0.4));
  animation: codeBounce 2.6s ease-in-out infinite;
  font-variant-numeric: tabular-nums;
}
@keyframes codeBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
.room-badge { font-size: 18px; font-weight: 900; letter-spacing: 3px; background: rgba(0,0,0,0.35); padding: 10px 14px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.08); }

.lobby-grid {
  display: grid; grid-template-columns: 1fr; gap: 14px; max-width: 1200px; margin: 0 auto;
}

/* Player list — animated chips */
.players-card { text-align: center; }
.players-card h3 { margin: 0 0 12px; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.player-list {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 80px;
}
.player-chip {
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  background: linear-gradient(180deg, var(--surface3), var(--surface2));
  border: 2px solid rgba(255,255,255,0.08);
  padding: 10px 12px 8px; border-radius: 18px; min-width: 84px;
  position: relative;
  box-shadow: 0 6px 14px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: chipPop .45s cubic-bezier(.34,1.56,.64,1);
}
@keyframes chipPop {
  0% { transform: scale(0.4) translateY(20px); opacity: 0; }
  60% { transform: scale(1.15) translateY(-4px); opacity: 1; }
  100% { transform: scale(1) translateY(0); }
}
.player-chip.is-host { border-color: var(--accent2); box-shadow: 0 6px 18px rgba(34,211,238,0.3), inset 0 1px 0 rgba(255,255,255,0.1); }
.player-chip.is-winner { border-color: var(--gold); box-shadow: 0 6px 24px rgba(251,191,36,0.5), inset 0 1px 0 rgba(255,255,255,0.1); }
.player-chip .chip-avatar { font-size: 36px; line-height: 1; animation: avatarIdle 3s ease-in-out infinite; }
@keyframes avatarIdle { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-3px) rotate(2deg); } }
.player-chip .chip-name { font-size: 13px; font-weight: 800; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-chip .winner-crown { position: absolute; top: -14px; right: -8px; font-size: 22px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); animation: crownBob 1.6s ease-in-out infinite; }
.player-chip .host-badge {
  position: absolute; top: -8px; right: -6px;
  background: linear-gradient(180deg,#22d3ee,#0891b2); color: #052f3a;
  font-size: 10px; font-weight: 900; letter-spacing: 1px;
  padding: 3px 7px; border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.4);
}
.player-chip .pencil-btn { position: absolute; top: -8px; left: -8px; background: var(--accent3); color: #1a0f1a; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; cursor: pointer; box-shadow: 0 3px 8px rgba(0,0,0,0.4); }

.qr-wrap { text-align: center; margin: 8px 0; }
.qr-wrap canvas { display: block; margin: 0 auto; border-radius: 16px; padding: 8px; background: #fff; }

.settings-preview { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.badge { background: rgba(255,255,255,0.08); padding: 8px 12px; border-radius: 999px; font-size: 13px; color: var(--text); font-weight: 700; border: 1px solid rgba(255,255,255,0.08); }

/* Edit profile */
#edit-profile .card { text-align: center; }
.sheep-big { font-size: 64px; animation: avatarIdle 2.5s ease-in-out infinite; }

/* ===========  GAME  =========== */
#game { flex: 1; display: flex; flex-direction: column; }
.game-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
}
.live-timer {
  font-size: clamp(32px, 6vw, 56px); font-weight: 900; letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fef3c7, #fbbf24);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 12px rgba(251,191,36,0.3));
}
.live-timer.timer-warn { background: linear-gradient(180deg,#fed7aa,#f97316); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.live-timer.timer-crit { background: linear-gradient(180deg,#fecaca,#ef4444); -webkit-background-clip: text; -webkit-text-fill-color: transparent; animation: timerPulse .6s ease-in-out infinite; }
@keyframes timerPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }

.live-words { font-size: 18px; color: var(--muted); font-weight: 800; }
.live-words::before { content: "📝 "; }

.swipe-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px; }
.grid {
  display: grid; gap: 14px; width: min(94vw, 540px); aspect-ratio: 1;
  touch-action: none; user-select: none;
  padding: 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.3), rgba(0,0,0,0.15));
  border-radius: 28px;
  border: 2px solid rgba(255,255,255,0.06);
  box-shadow: inset 0 4px 14px rgba(0,0,0,0.4), 0 16px 40px rgba(0,0,0,0.4);
}
.cell {
  background:
    linear-gradient(180deg, #3b3f7e 0%, #2a2f5e 50%, #1f2347 100%);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: clamp(22px, 6vw, 38px); color: #fff;
  text-transform: uppercase; cursor: pointer; position: relative;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.18),
    inset 0 -4px 0 rgba(0,0,0,0.35),
    0 6px 14px rgba(0,0,0,0.4);
  transition: transform .08s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
  text-shadow: 0 2px 0 rgba(0,0,0,0.35);
}
.cell::after {
  content: ""; position: absolute; inset: 6px 6px auto 6px; height: 35%;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0));
  border-radius: 10px 10px 18px 18px; pointer-events: none;
}
.cell.selected {
  background: linear-gradient(180deg, #5eead4 0%, #22d3ee 50%, #0891b2 100%);
  border-color: #ecfeff;
  color: #052f3a;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  transform: scale(1.1);
  box-shadow:
    0 0 0 4px rgba(34,211,238,0.35),
    0 0 30px rgba(34,211,238,0.55),
    inset 0 2px 0 rgba(255,255,255,0.5),
    inset 0 -4px 0 rgba(0,0,0,0.2);
  z-index: 2;
}
.cell.highlight-ok {
  background: linear-gradient(180deg, #86efac, #22c55e, #15803d);
  border-color: #f0fdf4; color: #052e16;
  box-shadow: 0 0 0 4px rgba(34,197,94,0.45), 0 0 30px rgba(34,197,94,0.55);
  animation: cellPop .5s ease;
}
.cell.highlight-bad {
  background: linear-gradient(180deg, #fca5a5, #ef4444, #991b1b);
  border-color: #fef2f2;
  box-shadow: 0 0 0 4px rgba(239,68,68,0.45);
  animation: cellShake .35s ease;
}
@keyframes cellPop { 0% { transform: scale(1); } 50% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes cellShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.word-preview {
  text-align: center; padding: 12px; min-height: 50px;
  font-size: clamp(22px, 5vw, 32px); font-weight: 900; letter-spacing: 4px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
  text-shadow: 0 2px 12px rgba(34,211,238,0.4);
}

.toast-area { position: fixed; bottom: 80px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 50; }
.toast {
  background: rgba(15,18,40,0.92); color: #fff; padding: 12px 20px; border-radius: 16px;
  font-size: 15px; font-weight: 800; backdrop-filter: blur(10px);
  border: 2px solid rgba(255,255,255,0.1);
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1), toastOut .4s ease 1.8s forwards;
  max-width: 90vw; box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}
.toast.toast-good { border-color: rgba(34,197,94,0.5); box-shadow: 0 12px 30px rgba(34,197,94,0.3); }
.toast.toast-bad { border-color: rgba(239,68,68,0.5); }
.toast.toast-warn { border-color: rgba(234,179,8,0.5); }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(0.95); } }

/* Score popup over grid */
.score-pop {
  position: fixed; pointer-events: none; z-index: 60;
  font-size: clamp(28px, 6vw, 52px); font-weight: 900;
  color: #fbbf24; text-shadow: 0 3px 0 rgba(0,0,0,0.4), 0 0 24px rgba(251,191,36,0.6);
  animation: scorePop 1.2s ease forwards;
}
@keyframes scorePop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.2) rotate(4deg); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1) rotate(-4deg); }
}

/* NEW LEADER banner */
.leader-banner {
  position: fixed; top: 24%; left: 50%; transform: translate(-50%, -50%);
  font-size: clamp(36px, 8vw, 72px); font-weight: 900; letter-spacing: 2px;
  background: linear-gradient(90deg, #fbbf24, #f472b6, #22d3ee);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: none; pointer-events: none; z-index: 70;
  animation: leaderPop 1.8s ease forwards;
  filter: drop-shadow(0 6px 24px rgba(251,191,36,0.6));
}
@keyframes leaderPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(-10deg); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

/* ===========  RESULTS  =========== */
#results { flex: 1; overflow-y: auto; padding: 16px; }
.results-wrap { max-width: 1200px; margin: 0 auto; }
.results-header { text-align: center; margin-bottom: 14px; }
.results-header h2 { font-size: clamp(24px, 4vw, 36px); margin: 6px 0; }

.results-main {
  display: grid; grid-template-columns: 1fr; gap: 14px;
}
.results-left, .results-right { background: linear-gradient(180deg, var(--surface), var(--surface2)); border: 1px solid rgba(255,255,255,0.08); border-radius: 24px; padding: 16px; box-shadow: 0 20px 50px var(--shadow); }
.reveal-speed-row { display: flex; justify-content: center; align-items: center; margin-bottom: 10px; }
.reveal-speed-toggle { min-width: 150px; min-height: 40px; }
#final-grid { display: flex; justify-content: center; }
#final-grid .grid { width: min(70vw, 340px); gap: 8px; padding: 10px; }
#final-grid .cell { font-size: clamp(16px, 4vw, 26px); }

.current-reveal {
  margin-top: 14px; text-align: center; padding: 14px;
  background: rgba(0,0,0,0.3); border-radius: 16px; border: 1px solid rgba(255,255,255,0.08);
  animation: revealIn .4s ease;
}
@keyframes revealIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.cr-tags { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.cr-tag { font-size: 12px; font-weight: 900; letter-spacing: 1px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,0.1); }
.cr-tag.cr-shared { background: rgba(34,211,238,0.2); color: #67e8f9; }
.cr-tag.cr-unique { background: linear-gradient(90deg, rgba(251,191,36,0.3), rgba(244,114,182,0.3)); color: #fde68a; }
.cr-tag.cr-unique::before { content: "⭐ "; }
.cr-word { font-size: clamp(28px, 6vw, 48px); font-weight: 900; letter-spacing: 6px; margin: 6px 0; text-shadow: 0 4px 16px rgba(34,211,238,0.4); }
.cr-finders { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0; }
.cr-finder { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 700; }
.cr-points { font-size: clamp(24px, 5vw, 36px); font-weight: 900; color: #fbbf24; text-shadow: 0 3px 12px rgba(251,191,36,0.4); }
.cr-points::before { content: ""; }

#final-grid .cell.reveal-on {
  background: linear-gradient(180deg, #fde68a, #fbbf24, #b45309);
  color: #422006; border-color: #fffbeb;
  box-shadow: 0 0 0 4px rgba(251,191,36,0.5), 0 0 24px rgba(251,191,36,0.6);
  transform: scale(1.1);
}

.scoreboard-title { margin: 0 0 12px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; font-weight: 900; }
.live-scoreboard { display: flex; flex-direction: column; gap: 8px; }
.sb-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(180deg, var(--surface3), var(--surface2));
  border: 2px solid rgba(255,255,255,0.06);
  box-sizing: border-box;
  min-height: 58px;
  transition: background .25s ease, box-shadow .25s ease, border-color .25s ease;
  position: relative;
  overflow: hidden;
}
.sb-row:first-child { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(251,191,36,0.3), 0 8px 22px rgba(251,191,36,0.2); }
.sb-row.sb-bump { background: linear-gradient(180deg, #15803d, #166534); border-color: rgba(134,239,172,0.8); box-shadow: inset 0 0 0 2px rgba(134,239,172,0.35), 0 8px 18px rgba(34,197,94,0.22); }
.sb-left { display: flex; align-items: center; gap: 10px; }
.sb-avatar { font-size: 28px; }
.sb-name { font-weight: 800; font-size: 15px; }
.sb-score {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 64px;
  width: 64px;
  min-width: 64px;
  height: 34px;
  padding: 0 4px;
  box-sizing: border-box;
  overflow: hidden;
  font-weight: 900;
  font-size: 24px;
  line-height: 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.score-delta {
  position: absolute; right: 0.4rem; top: 50%; color: #fbbf24; font-weight: 900;
  transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: flex-end;
  pointer-events: none; font-size: 18px; line-height: 1; white-space: nowrap;
  animation: scoreDeltaFade 900ms ease-out forwards;
  text-shadow: 0 2px 8px rgba(251,191,36,0.5);
}
@keyframes scoreDeltaFade { 0% { opacity: 0; transform: translateY(-50%); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(calc(-50% - 24px)); } }

/* Winner stage */
.winner-stage { margin: 20px 0; position: relative; min-height: 200px; }
.podium-wrap { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 16px; margin: 14px 0; min-height: 200px; }
.winner-announcement {
  flex: 0 0 100%;
  order: 4;
  text-align: center;
  font-size: clamp(18px, 3vw, 32px);
  font-weight: 900;
  color: var(--text);
}
.podium-item {
  text-align: center; padding: 14px 18px; border-radius: 18px 18px 6px 6px;
  background: linear-gradient(180deg, var(--surface3), var(--surface));
  border: 2px solid rgba(255,255,255,0.1); position: relative;
  animation: podiumRise .7s cubic-bezier(.34,1.56,.64,1);
}
@keyframes podiumRise { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.podium-item .avatar-large { font-size: clamp(48px, 8vw, 72px); animation: avatarIdle 2.5s ease-in-out infinite; }
.podium-item .name { font-weight: 900; font-size: 16px; margin-top: 6px; }
.podium-item .score { color: var(--gold); font-size: 18px; font-weight: 900; }
.podium-item .crown { position: absolute; top: -32px; left: 50%; transform: translateX(-50%); font-size: 36px; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5)); animation: crownBob 1.4s ease-in-out infinite; }
.podium-item.rank-1 { order: 2; min-height: 180px; border-color: var(--gold); background: linear-gradient(180deg, #fbbf24 0%, #b45309 100%); color: #1c1917; box-shadow: 0 0 40px rgba(251,191,36,0.5); }
.podium-item.rank-1 .score { color: #422006; }
.podium-item.rank-2 { order: 1; min-height: 150px; border-color: #cbd5e1; background: linear-gradient(180deg, #e2e8f0, #64748b); color: #0f172a; }
.podium-item.rank-2 .score { color: #1e293b; }
.podium-item.rank-3 { order: 3; min-height: 130px; border-color: #fdba74; background: linear-gradient(180deg, #fdba74, #c2410c); color: #1c1917; }
.podium-item.rank-3 .score { color: #431407; }
@keyframes crownBob { 0%,100% { transform: translateX(-50%) translateY(0) rotate(-4deg); } 50% { transform: translateX(-50%) translateY(-5px) rotate(4deg); } }

.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti-piece {
  position: absolute; top: -10px; width: 10px; height: 16px; border-radius: 3px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0); opacity: 1; }
  100% { transform: translateY(500px) rotate(720deg); opacity: 0; }
}

.word-stats { margin-top: 16px; padding: 18px; background: linear-gradient(180deg, var(--surface), var(--surface2)); border-radius: 18px; border: 1px solid rgba(255,255,255,0.08); }
.word-stats h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; }
.stat-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed rgba(255,255,255,0.08); font-size: 15px; font-weight: 700; }
.stat-row:last-child { border-bottom: none; }
.stat-row strong { color: var(--gold); font-size: 17px; }

#results-actions { display: flex; gap: 12px; margin-top: 20px; }
#results-actions .btn { flex: 1; }

/* Mute */
.mute-btn {
  position: fixed; bottom: 16px; right: 16px; z-index: 60;
  width: 52px; height: 52px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.12); background: rgba(15,18,40,0.7);
  color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; backdrop-filter: blur(8px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

/* Receiver */
#receiver-app { height: 100%; display: flex; flex-direction: column; }
#receiver-app .center-y { justify-content: center; text-align: center; }
#receiver-app .sheep-big { font-size: clamp(64px, 10vw, 120px); }

/* Settings stepper */
.field { margin: 14px 0; }
.field label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }
.stepper {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(0,0,0,0.35); border-radius: 16px; padding: 8px;
  border: 2px solid rgba(255,255,255,0.08);
}
.stepper-btn {
  width: 48px; height: 48px; border-radius: 12px; border: none;
  background: linear-gradient(180deg, #7c3aed, #5b21b6);
  color: #fff; font-size: 24px; font-weight: 900; cursor: pointer;
  box-shadow: 0 4px 0 #4c1d95, inset 0 2px 0 rgba(255,255,255,0.2);
  transition: transform .08s ease, box-shadow .15s ease;
}
.stepper-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #4c1d95, inset 0 2px 0 rgba(255,255,255,0.15); }
.stepper-value { font-size: 18px; font-weight: 900; color: var(--text); flex: 1; text-align: center; }

/* ===========  DESKTOP / TV LAYOUT  =========== */
@media (min-width: 900px) {
  .hero-title { font-size: clamp(56px, 6vw, 96px); }

  /* Lobby split layout */
  .lobby-grid { grid-template-columns: 1.2fr 1fr; align-items: start; }
  .lobby-hero { padding: 28px 16px 16px; }
  .room-code-big { font-size: clamp(96px, 10vw, 180px); letter-spacing: 20px; }
  .qr-wrap canvas { width: 280px; height: 280px; }
  .player-list { gap: 14px; }
  .player-chip { min-width: 110px; padding: 14px 16px 10px; }
  .player-chip .chip-avatar { font-size: 48px; }
  .player-chip .chip-name { font-size: 15px; max-width: 120px; }

  /* Game — gameshow style */
  #game { display: grid; grid-template-columns: 280px 1fr; grid-template-rows: auto 1fr auto; grid-template-areas: "top top" "left center" "preview preview"; gap: 14px; padding: 14px; }
  .game-top { grid-area: top; background: linear-gradient(180deg, var(--surface), var(--surface2)); border-radius: 20px; padding: 16px 24px; border: 1px solid rgba(255,255,255,0.08); }
  .swipe-wrap { grid-area: center; }
  .grid { width: min(60vh, 600px); gap: 18px; }
  .word-preview { grid-area: preview; font-size: 36px; }
  .tv-left { grid-area: left; }
  .tv-panel { background: linear-gradient(180deg, var(--surface), var(--surface2)); border: 1px solid rgba(255,255,255,0.08); border-radius: 20px; padding: 16px; height: 100%; overflow-y: auto; }
  .tv-panel h3 { margin: 0 0 12px; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }

  .results-main { grid-template-columns: 1.4fr 1fr; }
  #final-grid .grid { width: min(45vh, 480px); }
}

@media (min-width: 1280px) {
  #game { grid-template-columns: 340px 1fr; }
  .grid { width: min(65vh, 700px); }
  .cell { font-size: clamp(32px, 4vw, 54px); border-radius: 22px; }
}

/* Live activity feed (TV) */
.activity-feed { display: flex; flex-direction: column-reverse; gap: 8px; max-height: 100%; }
.activity-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: linear-gradient(90deg, rgba(34,211,238,0.18), rgba(124,58,237,0.18));
  border: 1px solid rgba(255,255,255,0.1); border-radius: 14px;
  animation: activityIn .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes activityIn { from { opacity: 0; transform: translateX(20px) scale(0.9); } to { opacity: 1; transform: translateX(0) scale(1); } }
.activity-item .ai-avatar { font-size: 24px; }
.activity-item .ai-name { font-weight: 800; font-size: 13px; }
.activity-item .ai-word { font-weight: 900; font-size: 14px; letter-spacing: 2px; color: var(--accent2); }
.activity-item .ai-points { margin-left: auto; font-weight: 900; color: var(--gold); }

/* Mini live scoreboard (TV left) */
.mini-scoreboard { display: flex; flex-direction: column; gap: 6px; }
.mini-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06); transition: transform .3s ease; }
.mini-row:first-child { background: linear-gradient(90deg, rgba(251,191,36,0.2), transparent); border-color: rgba(251,191,36,0.4); }
.mini-row .mr-rank { font-weight: 900; color: var(--muted); width: 18px; }
.mini-row .mr-avatar { font-size: 22px; }
.mini-row .mr-name { font-weight: 800; font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .mr-score { font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }

@media (max-width: 480px) {
  .card { padding: 16px; border-radius: 20px; }
  .grid { gap: 10px; padding: 10px; }
}

/* === Compact buttons (top of lobby) === */
.btn-mini { width: auto; padding: 8px 14px; font-size: 12px; border-radius: 12px; box-shadow: 0 4px 0 rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.15); }
.btn-mini:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.4); }
.lobby-header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; padding: 12px 14px; gap: 8px; }
.lobby-header-left { display: flex; gap: 8px; align-items: center; }
.lobby-header .hero-title { text-align: center; }

/* Room pill on edit-profile */
.room-pill { display: inline-block; margin: 6px 0 8px; padding: 6px 12px; border-radius: 999px; background: rgba(34,211,238,0.15); border: 1px solid rgba(34,211,238,0.35); font-size: 13px; letter-spacing: 2px; color: var(--accent2); }
.room-pill strong { color: #fff; letter-spacing: 3px; }

/* Longest word reveal (after winner) */
.longest-reveal {
  text-align: center; margin: 20px auto; padding: 22px;
  background: linear-gradient(180deg, rgba(244,114,182,0.15), rgba(167,139,250,0.15));
  border: 2px dashed rgba(244,114,182,0.5); border-radius: 22px;
  animation: lrIn .6s cubic-bezier(.34,1.56,.64,1);
  max-width: 560px;
}
@keyframes lrIn { 0% { opacity: 0; transform: scale(0.85); } 100% { opacity: 1; transform: scale(1); } }
.lr-label { font-size: 12px; font-weight: 900; letter-spacing: 3px; color: var(--muted); text-transform: uppercase; }
.lr-word { font-size: clamp(36px, 8vw, 64px); font-weight: 900; letter-spacing: 6px; margin: 12px 0 6px;
  background: linear-gradient(90deg, #fbbf24, #f472b6, #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 18px rgba(244,114,182,0.45));
}
.lr-note { font-size: 12px; color: var(--muted); font-style: italic; }

/* Mini scoreboard becomes "Spelers" with word counts */
.mini-row .mr-score { color: var(--accent2); }
.mini-row .mr-score::after { content: " 📝"; font-size: 12px; }

/* === Equal lobby action buttons (Verlaten + Cast) === */
.lobby-actions { display: flex; gap: 8px; align-items: stretch; }
.btn-lobby-action {
  width: auto;
  min-width: 110px;
  height: 40px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.5px;
  border-radius: 14px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.15);
  margin: 0;
}
.btn-lobby-action:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,0.4); }
.btn-leave-action { background: linear-gradient(180deg, #f87171, #b91c1c); }
.btn-cast-action  { background: linear-gradient(180deg, #475569, #1e293b); }

/* === Crown centered above avatar (no overlap with host badge) === */
.player-chip .winner-crown {
  position: absolute;
  top: -22px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  font-size: 26px;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.55));
  z-index: 3;
  pointer-events: none;
}
.player-chip.is-winner { padding-top: 14px; }

/* === Disabled primary button === */
.btn[disabled], .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
  box-shadow: 0 4px 0 rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
}
.btn[disabled]:active { transform: none; }

/* Avatar selection feedback */
.avatar-btn.selected {
  outline: 3px solid var(--accent2);
  outline-offset: 2px;
}

/* === FIX: scrollable lobby / home / edit-profile, locked during gameplay === */
html, body { height: 100%; }
body { overflow-y: auto; overflow-x: hidden; }
body.game-active { overflow: hidden; }
body.game-active #app { height: 100vh; }
#home, #edit-profile { min-height: 100vh; overflow-y: auto; }
#lobby { min-height: 100vh; overflow-y: auto; }
@media (max-height: 700px) {
  #home .card, #edit-profile .card { margin: 6px auto; }
}

/* === FIX: high-contrast pencil button === */
.player-chip .pencil-btn {
  background: #ffffff;
  color: #1a0f1a;
  width: 26px; height: 26px;
  border: 2px solid #1a0f1a;
  font-size: 13px; font-weight: 900;
  box-shadow: 0 3px 10px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.7);
  top: -10px; left: -10px;
  transition: transform .12s ease, background .12s ease;
}
.player-chip .pencil-btn:hover { background: #fde68a; transform: scale(1.12) rotate(-8deg); }

/* === FIX: hide personal live-words on large screens (mini-scoreboard shows it) === */
@media (min-width: 900px) {
  .live-words { display: none; }
}

/* === FIX: 3-2-1 countdown overlay === */
.countdown-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(16px, 5vw, 48px);
  background: radial-gradient(ellipse at center, rgba(11,13,23,0.85), rgba(11,13,23,0.96));
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.countdown-num {
  font-size: clamp(120px, 30vw, 280px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.15;
  max-width: 90vw;
  padding-block: 0.08em 0.18em;
  text-align: center;
  overflow-wrap: break-word;
  hyphens: auto;
  background: linear-gradient(180deg, #fef3c7, #fbbf24 40%, #f472b6 80%, #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 12px 40px rgba(251,191,36,0.55));
  animation: cdPop .9s cubic-bezier(.34,1.56,.64,1);
}
.countdown-num.cd-go {
  font-size: clamp(42px, 14vw, 150px);
  line-height: 1.2;
  letter-spacing: 0;
  max-width: min(90vw, 920px);
  background: linear-gradient(180deg, #86efac, #22c55e 50%, #15803d);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 12px 40px rgba(34,197,94,0.7));
}
@keyframes cdPop {
  0% { opacity: 0; transform: scale(0.3) rotate(-10deg); }
  40% { opacity: 1; transform: scale(1.15) rotate(2deg); }
  70% { transform: scale(0.98) rotate(-1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* === FIX: placeholder (joining) player chip === */
.player-chip.is-placeholder {
  opacity: 0.75;
  border-style: dashed;
  border-color: rgba(255,255,255,0.25);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
}
.player-chip.is-placeholder .chip-avatar {
  animation: placeholderPulse 1.4s ease-in-out infinite;
}
.player-chip.is-placeholder .chip-name {
  font-style: italic; color: var(--muted); font-weight: 700;
}
@keyframes placeholderPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* === FIX: host-only replay — waiting state for non-hosts === */
.waiting-host {
  text-align: center; padding: 18px;
  font-size: 16px; font-weight: 800; color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 2px dashed rgba(255,255,255,0.12);
  border-radius: 16px;
}
.waiting-host::before { content: "⌛ "; }

/* === v5: layout, mainscreen, readonly settings === */
.lobby-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 12px 14px; }
.lobby-header-left { display: flex; justify-content: flex-start; }
.lobby-header-right { display: flex; justify-content: flex-end; }
.lobby-title { font-size: clamp(20px, 2.4vw, 28px); }

/* Mobile: hide desktop leave, show full-width footer leave */
.lobby-mobile-footer { display: none; padding: 12px 14px 16px; }
@media (max-width: 720px) {
  .lobby-header-right { display: none; }
  .lobby-mobile-footer { display: block; }
  .lobby-mobile-footer .btn { width: 100%; }
}
@media (min-width: 721px) {
  .lobby-mobile-footer { display: none; }
}

/* Read-only settings for non-host */
#host-settings.readonly .stepper-btn { opacity: 0.3; pointer-events: none; }
#host-settings.readonly select { opacity: 0.6; pointer-events: none; }

/* Main screen body: hide chrome unrelated to presentation */
body.is-mainscreen .pencil-btn { display: none !important; }
body.is-mainscreen #host-settings { opacity: 0.85; }

/* Watch main screen banner */
.watch-mainscreen {
  margin: 14px auto; max-width: 540px; text-align: center;
  padding: 18px 20px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(34,211,238,0.18), rgba(124,58,237,0.18));
  border: 2px solid rgba(34,211,238,0.4);
  font-size: 16px; font-weight: 800; color: var(--text);
}
.watch-mainscreen .compact-reveal-speed {
  width: min(100%, 280px);
  margin: 14px auto 0;
}

/* Mainscreen setup screen */
#mainscreen-setup .sheep-big { text-align: center; display: block; }

/* === v6: Main-screen results — no scroll, fit viewport === */
body.is-mainscreen #results {
  height: 100vh;
  overflow: hidden;
  padding: 14px 18px;
  display: flex;
}
body.is-mainscreen #results .results-wrap {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  overflow: hidden;
}
body.is-mainscreen #results .results-header { margin: 0 0 6px; }
body.is-mainscreen #results .results-header h2 { font-size: clamp(20px, 2.2vw, 28px); margin: 2px 0; }
body.is-mainscreen #results .results-header .sheep-big { font-size: 36px; }

body.is-mainscreen #results .results-main {
  grid-template-columns: 1.1fr 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
body.is-mainscreen #results .results-left,
body.is-mainscreen #results .results-right {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px;
}
body.is-mainscreen #results .results-right .live-scoreboard {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
body.is-mainscreen #results .sb-row { padding: 8px 12px; }
body.is-mainscreen #results .sb-score { font-size: 22px; }
body.is-mainscreen #results .sb-avatar { font-size: 24px; }
body.is-mainscreen #results #final-grid .grid { width: min(34vh, 360px); }
body.is-mainscreen #results .current-reveal { margin-top: 8px; padding: 10px; }
body.is-mainscreen #results .cr-word { font-size: clamp(22px, 3vw, 36px); margin: 2px 0; }
body.is-mainscreen #results .cr-points { font-size: clamp(20px, 2.6vw, 30px); }

body.is-mainscreen #results .winner-stage {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(11,13,23,0.92), rgba(11,13,23,0.98));
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
  margin: 0;
}
body.is-mainscreen #results .winner-stage.hidden { display: none; }
body.is-mainscreen #results .longest-reveal { margin: 8px auto; padding: 12px; }
body.is-mainscreen #results .word-stats { margin-top: 8px; padding: 10px 14px; }
body.is-mainscreen #results .stat-row { padding: 4px 0; font-size: 13px; }
body.is-mainscreen #results #results-actions { display: none; }

/* Phone in watch-only mode: hide reveal panels, only show watch banner */
#results .results-main.hidden { display: none !important; }

/* === Round results: temporary winner highlight, no page scroll === */
body.results-active {
  overflow: hidden;
}

#results {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  padding: clamp(8px, 1.8vw, 16px);
}

#results .results-wrap {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#results .results-header {
  flex: 0 0 auto;
  margin-bottom: 8px;
}

#results .results-header .sheep-big {
  font-size: clamp(30px, 5vw, 52px);
}

#results .results-header h2 {
  font-size: clamp(20px, 3vw, 32px);
  margin: 2px 0;
}

#results #reveal-status {
  font-size: clamp(12px, 2vw, 15px);
}

#results .results-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr) minmax(92px, 0.7fr);
}

#results .results-left,
#results .results-right {
  min-height: 0;
  overflow: hidden;
  padding: clamp(8px, 1.6vw, 14px);
  border-radius: 18px;
}

#results .results-left {
  overflow: auto;
}

#results .results-left {
  --result-slot-height: clamp(118px, 18dvh, 164px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#results .round-results-grid-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  overflow: visible;
  width: 100%;
  min-height: 0;
}

#results .results-right {
  display: flex;
  flex-direction: column;
}

body.is-mainscreen #results .results-left {
  overflow: auto;
}

#results #final-grid {
  display: flex;
  justify-content: center;
  width: 100%;
  flex: 0 0 auto;
}

#results .live-scoreboard {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

#results .sb-row {
  padding: 8px 10px;
  border-radius: 12px;
  min-height: 50px;
  overflow: hidden;
  box-sizing: border-box;
}

#results .sb-row.is-round-winner {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(251,191,36,0.32), 0 8px 24px rgba(251,191,36,0.18);
}

#results .sb-avatar { font-size: clamp(20px, 3vw, 26px); }
#results .sb-name { font-size: clamp(12px, 1.8vw, 15px); }
#results .sb-score {
  flex-basis: 66px;
  width: 66px;
  min-width: 66px;
  height: 32px;
  overflow: hidden;
  box-sizing: border-box;
  font-size: clamp(18px, 2.4vw, 24px);
}

#results .score-delta {
  right: 0.4rem;
}

#results #final-grid .grid {
  aspect-ratio: 1 / 1;
  width: min(70vw, 420px);
  max-width: 100%;
  flex-shrink: 0;
  gap: 6px;
  padding: 8px;
}

#results .grid-result-slot {
  min-height: 64px;
  width: 100%;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
}

#results .current-reveal {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 8px 10px;
  overflow: hidden;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(76px, 0.28fr) minmax(0, 1fr) minmax(76px, auto);
  grid-template-areas:
    "tags tags tags"
    ". word points"
    "finders finders finders";
  column-gap: clamp(10px, 2vw, 18px);
  row-gap: 4px;
  align-items: center;
}

#results .cr-tags {
  grid-area: tags;
  margin-bottom: 0;
}

#results .cr-word {
  grid-area: word;
  min-width: 0;
  max-width: 100%;
  font-size: clamp(20px, 3.4vw, 34px);
  letter-spacing: 2px;
  margin: 2px 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#results .cr-finders {
  grid-area: finders;
  margin: 0;
}

#results .cr-points {
  grid-area: points;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 42px;
  max-width: 100%;
  padding: 5px 18px 6px;
  border-radius: 999px;
  box-sizing: border-box;
  font-size: clamp(18px, 2.6vw, 26px);
  line-height: 1;
  white-space: nowrap;
}

#results .cr-points::before {
  content: none;
}

#results .winner-stage {
  position: absolute;
  inset: 0;
  z-index: 60;
  margin: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 28px);
  background: rgba(0,0,0,0.74);
  backdrop-filter: blur(2px);
}

#results .winner-stage.hidden {
  display: none;
}

#results .winner-stage.is-highlight .podium-wrap {
  width: min(92vw, 760px);
  min-height: 0;
  margin: 0;
  align-items: center;
}

#results .winner-stage.is-highlight .podium-item {
  opacity: 0.55;
  transform: scale(0.9);
}

#results .winner-stage.is-highlight .podium-item.rank-1 {
  opacity: 1;
  transform: scale(1);
  z-index: 2;
}

#results .winner-stage.is-highlight .podium-item .avatar-large {
  font-size: clamp(42px, 9vw, 84px);
}

#results .podium-wrap {
  gap: clamp(8px, 2vw, 16px);
}

#results .podium-item {
  padding: clamp(10px, 2vw, 16px);
  min-width: 0;
  max-width: 220px;
}

#results .podium-item .name {
  overflow-wrap: anywhere;
}

#results .podium-item.rank-1,
#results .podium-item.rank-2,
#results .podium-item.rank-3 {
  min-height: auto;
}

#results .longest-reveal {
  flex: 0 0 auto;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 8px 12px;
  border-radius: 16px;
  overflow: visible;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#results .lr-word {
  font-size: clamp(22px, 4.4vw, 42px);
  letter-spacing: 2px;
  margin: 2px 0;
  overflow-wrap: anywhere;
}

#results .lr-label,
#results .lr-note {
  line-height: 1.15;
  max-width: 100%;
  overflow-wrap: anywhere;
}

#results .word-stats {
  flex: 0 0 auto;
  margin-top: 6px;
  padding: 8px 12px;
}

#results .word-stats h3 {
  margin-bottom: 4px;
}

#results .stat-row {
  padding: 3px 0;
  font-size: 13px;
}

#results #results-actions {
  flex: 0 0 auto;
  margin-top: 8px;
}

@media (max-width: 720px) {
  #results .results-main {
    gap: 8px;
  }

  #results .results-left,
  #results .results-right {
    padding: 8px;
  }

  #results #final-grid .grid {
    width: min(74vw, 320px);
  }

  #results .results-left {
    --result-slot-height: clamp(104px, 20dvh, 132px);
    gap: 6px;
  }

  #results .longest-reveal {
    padding: 7px 10px;
  }

  #results .lr-word {
    font-size: clamp(20px, 8vw, 30px);
  }

  #results .cr-points {
    min-width: 68px;
    min-height: 38px;
    padding: 5px 16px;
    font-size: clamp(17px, 5vw, 22px);
  }

  #results .current-reveal {
    grid-template-columns: minmax(58px, 0.2fr) minmax(0, 1fr) minmax(68px, auto);
    column-gap: 8px;
  }

  #results .scoreboard-title {
    margin-bottom: 6px;
    font-size: 12px;
  }

  #results .live-scoreboard {
    gap: 5px;
  }

  #results .winner-stage {
    padding: 10px;
  }

  #results .winner-stage.is-highlight .podium-wrap {
    gap: 6px;
    flex-wrap: wrap;
  }

  #results .winner-stage.is-highlight .podium-item {
    flex: 1 1 92px;
    max-width: 160px;
  }
}

@media (min-width: 900px) {
  #results .results-main {
    grid-template-columns: 1.4fr 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  body.is-mainscreen #results .results-left,
  #results .results-left {
    display: flex;
    flex-direction: column;
    align-content: normal;
  }

  body.is-mainscreen #results .grid-result-slot .longest-reveal {
    margin: 0 auto;
    padding: 8px 12px;
  }
}

@media (max-width: 600px) {
  html,
  body {
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  #app {
    min-height: 100dvh;
    height: auto;
  }

  body.game-active {
    overflow: hidden;
  }

  .language-switcher {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    z-index: 120;
    border-radius: 14px;
  }

  .language-switcher::before {
    content: "🌐";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    pointer-events: none;
  }

  .language-switcher label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .language-switcher select {
    position: absolute;
    inset: 0;
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    opacity: 0.01;
  }

  body.lobby-active .desktop-lobby-leave,
  .desktop-lobby-leave {
    display: none;
  }

  .center-y {
    min-height: 100dvh;
    justify-content: flex-start;
    padding: 64px 14px 18px;
  }

  #home,
  #edit-profile,
  #mainscreen-setup,
  #lobby {
    min-height: 100dvh;
    overflow-y: visible;
  }

  .hero-title {
    font-size: clamp(34px, 13vw, 54px);
    letter-spacing: 0;
  }

  .lobby-header {
    grid-template-columns: 1fr;
    padding: 12px 64px 8px 14px;
    min-width: 0;
    overflow: visible;
  }

  .lobby-header-left,
  .lobby-header-right {
    display: none;
  }

  .lobby-title {
    justify-self: center;
    max-width: calc(100vw - 92px);
    transform: translateX(-18px);
    white-space: nowrap;
    overflow: visible;
    font-size: clamp(22px, 7.5vw, 30px);
  }

  .lobby-hero {
    padding-top: 8px;
  }

  .room-code-big {
    max-width: 100%;
    letter-spacing: clamp(5px, 2.5vw, 10px);
    font-size: clamp(44px, 17vw, 72px);
    padding-inline: 8px;
  }

  #home > .muted {
    font-size: 14px;
    text-align: center;
    margin: 4px 0 8px;
  }

  .card {
    max-width: 100%;
    margin: 6px 0;
  }

  .btn,
  button,
  input,
  select,
  .avatar-btn,
  .stepper-btn {
    min-height: 44px;
  }

  .avatar-row {
    gap: 8px;
  }

  .avatar-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .lobby-mobile-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 14px 18px;
  }

  .lobby-mobile-footer .btn,
  .lobby-mobile-footer .btn-lobby-action {
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 44px;
    padding: 16px 14px;
    margin: 0;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 900;
    line-height: 1.2;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
  }

  .lobby-mobile-footer #btn-cast-lobby.hidden {
    display: none !important;
  }

  #results {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
    padding: 10px;
  }

  #results .results-wrap {
    height: auto;
    min-height: 100%;
    overflow: visible;
  }

  #results .results-main {
    overflow: visible;
    grid-template-rows: none;
  }

  #results .results-left,
  #results .results-right,
  #results .live-scoreboard,
  body.is-mainscreen #results .results-left,
  body.is-mainscreen #results .results-right,
  body.is-mainscreen #results .results-right .live-scoreboard {
    overflow: visible;
  }

  #results .round-results-grid-area,
  #results #final-grid,
  #results .grid-result-slot,
  #results .current-reveal,
  #results .longest-reveal,
  #results .word-stats {
    max-width: 100%;
  }

  #results #final-grid .grid {
    width: min(88vw, 320px);
    max-width: 100%;
  }

  #results .current-reveal {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: visible;
  }

  #results .cr-word {
    white-space: normal;
    text-overflow: clip;
    overflow: visible;
    overflow-wrap: anywhere;
  }

  #results #results-actions {
    flex-direction: column;
  }

  .watch-mainscreen {
    margin: 10px auto;
    padding: 16px 14px;
    max-width: 520px;
    width: 100%;
    box-sizing: border-box;
  }

  .watch-mainscreen .compact-reveal-speed {
    width: 100%;
    min-height: 44px;
  }

  #results #results-actions {
    width: 100%;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
  }
}
