:root {
  --ink: #12061f;
  --night: #0d0221;
  --plum: #2a0b4a;
  --plum2: #3b1370;
  --cream: #fff4d6;
  --pink: #ff2e63;
  --hot: #ff2ea6;
  --yellow: #ffe066;
  --orange: #ff9f1c;
  --green: #3ee07a;
  --cyan: #34c6ff;
  --purple: #b37bff;
  --muted: #9c86c9;
  --px: 4px;
  --font-px: 'Press Start 2P', ui-monospace, monospace;
  --font-vt: 'VT323', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--cream);
  font-family: var(--font-vt);
  font-size: 22px;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: none;
  font-smooth: never;
  image-rendering: pixelated;
  user-select: none;
  -webkit-user-select: none;
}
img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

#bg { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; }
#fx { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#flash { position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: 0; }
#crt {
  position: fixed; inset: 0; z-index: 70; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.16) 2px 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 60%, rgba(0,0,0,.55) 100%);
  mix-blend-mode: multiply;
}

#app {
  position: relative; z-index: 10;
  min-height: 100vh; min-height: 100dvh;
  max-width: 1100px; margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}

/* ───── Pixel box primitive ───── */
.panel, .btn, .pill, .acronym-card, .bubble, .joker, .sysadmin, .seg button, .chips button, .toast, .emote-row button, .icon-btn, input {
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink),
    inset calc(var(--px) * -1) calc(var(--px) * -1) 0 0 rgba(0,0,0,.28),
    inset var(--px) var(--px) 0 0 rgba(255,255,255,.18);
}
.panel {
  background: rgba(42, 11, 74, .92);
  padding: 16px;
  margin: 8px 4px;
}
.label { font-family: var(--font-px); font-size: 10px; color: var(--yellow); letter-spacing: 1px; margin-bottom: 12px; }

/* ───── Top bar ───── */
#topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 8px; }
.brand { font-family: var(--font-px); font-size: 11px; color: var(--cream); text-shadow: 2px 2px 0 var(--pink); opacity: 0; transition: opacity .2s steps(3); }
.brand span { color: var(--yellow); margin-left: 6px; text-shadow: 2px 2px 0 var(--hot); }
body:not(.on-home) .brand { opacity: 1; }
.top-right { display: flex; gap: 14px; align-items: center; }
.pill { font-family: var(--font-px); font-size: 11px; padding: 6px 10px; background: var(--ink); color: var(--yellow); cursor: pointer; }
.icon-btn { width: 36px; height: 36px; background: var(--plum2); border: 0; cursor: pointer; font-size: 20px; display: grid; place-items: center; }
.icon-btn.sfx-only { color: var(--yellow); }
.icon-btn.muted { color: var(--muted); text-decoration: line-through; }

/* ───── Buttons ───── */
.btn {
  font-family: var(--font-px); font-size: 12px; letter-spacing: 1px;
  background: var(--plum2); border: 0; padding: 12px 16px; cursor: pointer;
  color: var(--cream); transition: transform .05s steps(1); position: relative;
}
.btn:hover { background: #4c1c8c; }
.btn:active, .btn.pressed { transform: translate(2px, 2px); }
.btn.primary { background: var(--pink); text-shadow: 2px 2px 0 #8a0f33; }
.btn.primary:hover { background: #ff4f7d; }
.btn.big { font-size: 14px; padding: 16px 20px; }
.btn.small { font-size: 9px; padding: 8px 10px; }
.btn.ghost { background: rgba(18, 6, 31, .6); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary.pulse { animation: pulse 1s steps(2) infinite; }
@keyframes pulse { 50% { background: #ff6f94; } }

input {
  background: var(--ink); border: 0; padding: 12px; width: 100%;
  font-family: var(--font-px); font-size: 14px; color: var(--yellow); outline: none;
  user-select: text; -webkit-user-select: text;
}
input::placeholder { color: #5b4a7a; }
input:focus { background: #1d0a33; }

/* ───── Screens ───── */
.screen { display: none; flex: 1; flex-direction: column; animation: screenIn .35s steps(5); }
.screen.active { display: flex; }
@keyframes screenIn {
  0% { opacity: 0; clip-path: inset(50% 0 50% 0); }
  60% { opacity: 1; clip-path: inset(8% 0 8% 0); }
  100% { clip-path: inset(0 0 0 0); }
}

/* ───── Home ───── */
#screen-home { align-items: center; }
.logo { text-align: center; margin: 12px 0 18px; }
.logo-top { font-family: var(--font-px); font-size: 10px; color: var(--cyan); letter-spacing: 2px; margin-bottom: 10px; text-shadow: 2px 2px 0 var(--ink); }
.logo-main { margin: 0; font-family: var(--font-px); font-weight: normal; line-height: 1.15; display: flex; flex-direction: column; align-items: center; }
.logo-main span:first-child {
  font-size: clamp(28px, 8vw, 60px); color: var(--yellow);
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--ink);
  animation: wobble 2.4s steps(4) infinite;
}
.logo-main span:last-child {
  font-size: clamp(22px, 6vw, 44px); color: var(--cream);
  text-shadow: 4px 4px 0 var(--hot), 8px 8px 0 var(--ink);
  animation: wobble 2.4s steps(4) infinite reverse;
}
@keyframes wobble { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg) scale(1.03); } }
.logo-sub { margin-top: 14px; font-family: var(--font-px); font-size: 9px; color: var(--ink); background: var(--yellow); display: inline-block; padding: 6px 8px; transform: rotate(-3deg); }

.home-panel { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; }
.avatar-edit { display: flex; align-items: center; justify-content: center; gap: 18px; }
.avatar { width: 48px; height: 48px; display: block; }
.avatar.xl { width: 96px; height: 96px; animation: bob 1s steps(2) infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.field { display: flex; flex-direction: column; gap: 8px; }
.field span { font-family: var(--font-px); font-size: 9px; color: var(--muted); }
.or { display: flex; align-items: center; gap: 10px; font-family: var(--font-px); font-size: 9px; color: var(--muted); }
.or::before, .or::after { content: ''; flex: 1; height: 4px; background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 8px); }
.join-row { display: flex; gap: 12px; }
#code-input { text-transform: uppercase; text-align: center; letter-spacing: 6px; font-size: 18px; }
.join-row .btn { flex: none; }

.howto { width: min(560px, 100%); font-size: 20px; line-height: 1.15; }
.howto summary { font-family: var(--font-px); font-size: 10px; color: var(--yellow); cursor: pointer; list-style: none; }
.howto summary::before { content: '▶ '; }
.howto[open] summary::before { content: '▼ '; }
.howto ul { margin: 12px 0 0; padding-left: 20px; }
.howto li { margin-bottom: 6px; }
.howto b { color: var(--yellow); font-weight: normal; }
kbd { background: var(--ink); padding: 0 6px; color: var(--cyan); }
.footer-note { font-size: 18px; color: var(--muted); margin-top: auto; padding-top: 12px; text-align: center; }

/* ───── Lobby ───── */
.lobby-grid { display: grid; grid-template-columns: 260px 1fr; grid-template-areas: 'invite players' 'settings settings'; gap: 8px; }
.invite { grid-area: invite; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.players-panel { grid-area: players; }
.settings { grid-area: settings; }
.big-code { font-family: var(--font-px); font-size: 40px; color: var(--yellow); text-shadow: 4px 4px 0 var(--pink); letter-spacing: 6px; cursor: pointer; }
#qr { width: 150px; height: 150px; background: var(--cream); padding: 4px; }
.hint { font-size: 18px; color: var(--muted); word-break: break-all; }
.lobby-players { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.lp { display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; animation: popIn .3s steps(4); }
.lp .avatar { width: 64px; height: 64px; animation: bob 1s steps(2) infinite; }
.lp:nth-child(2n) .avatar { animation-delay: .5s; }
.lp .nm { font-size: 22px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp.me .nm { color: var(--yellow); }
.lp .tag { font-family: var(--font-px); font-size: 7px; background: var(--yellow); color: var(--ink); padding: 3px 4px; position: absolute; top: -6px; right: 4px; }
.lp.offline .avatar { filter: grayscale(1) brightness(.6); animation: none; }
.lp.empty .avatar { opacity: .15; filter: grayscale(1); animation: none; }
@keyframes popIn { 0% { transform: scale(0); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }

.setting { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.setting > span { font-family: var(--font-px); font-size: 9px; width: 64px; color: var(--muted); }
.seg { display: flex; gap: 10px; flex-wrap: wrap; }
.seg button, .chips button {
  font-family: var(--font-px); font-size: 9px; background: var(--ink); border: 0; padding: 9px 10px; cursor: pointer; color: var(--muted);
}
.seg button.on { background: var(--cyan); color: var(--ink); }
.chips { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.chips button.on { background: var(--green); color: var(--ink); }
.settings.locked button { cursor: default; }
.lobby-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.waiting { font-family: var(--font-px); font-size: 10px; color: var(--muted); }
.dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ───── Emotes ───── */
.emote-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar .emote-row { flex-wrap: nowrap; overflow-x: auto; flex: 1; min-width: 0; padding: 4px; scrollbar-width: none; }
.toolbar .emote-row::-webkit-scrollbar { display: none; }
.toolbar .emote-row button { flex: none; }
.emote-row button { font-family: var(--font-px); font-size: 8px; background: var(--ink); border: 0; padding: 7px 6px; cursor: pointer; color: var(--cyan); }
.emote-row button:active { transform: translate(1px, 1px); background: var(--plum2); }
.lobby-emotes { margin-top: 16px; justify-content: flex-start; }
.emote-bubble {
  position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%);
  font-family: var(--font-px); font-size: 9px; color: var(--ink); background: var(--cream);
  padding: 5px 6px; white-space: nowrap; pointer-events: none; z-index: 5;
  box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink);
  animation: emoteUp 1.6s steps(8) forwards;
}
@keyframes emoteUp { 0% { transform: translate(-50%, 8px) scale(.4); opacity: 0; } 15% { transform: translate(-50%, 0) scale(1.15); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%, -26px); opacity: 0; } }

/* ───── Game ───── */
#screen-game { gap: 8px; }
.hud { display: flex; align-items: center; gap: 10px; }
.round-badge { font-family: var(--font-px); font-size: 12px; background: var(--yellow); color: var(--ink); padding: 6px 8px; }
.cat-chip { font-family: var(--font-px); font-size: 9px; background: var(--ink); color: var(--cyan); padding: 7px 8px; }
.diff { color: var(--orange); font-size: 22px; letter-spacing: 2px; }
.timer-num { margin-left: auto; font-family: var(--font-px); font-size: 26px; color: var(--cream); text-shadow: 3px 3px 0 var(--ink); min-width: 2.5ch; text-align: right; }
.timer-num.urgent { color: var(--pink); animation: throb .25s steps(2) infinite; }
@keyframes throb { 50% { transform: scale(1.25); } }

.host-row { display: flex; align-items: flex-end; gap: 12px; min-height: 64px; }
.host { width: 48px; height: 60px; flex: none; }
.host.talk { animation: hostBounce .3s steps(2) infinite; }
@keyframes hostBounce { 50% { transform: translateY(-2px); } }
.bubble { position: relative; background: var(--cream); color: var(--ink); padding: 8px 10px; font-size: 21px; line-height: 1; flex: 1; min-height: 38px; margin-bottom: 10px; }
.bubble::before { content: ''; position: absolute; left: -12px; bottom: 6px; width: 8px; height: 8px; background: var(--cream); box-shadow: -4px 4px 0 var(--cream), 0 -4px 0 var(--ink), -4px 0 0 var(--ink), -8px 4px 0 var(--ink), -4px 8px 0 var(--ink), 0 4px 0 var(--cream); }
.bubble b { font-family: var(--font-px); font-size: 8px; color: var(--pink); font-weight: normal; }

.acronym-card { background: linear-gradient(180deg, #1b0638, #3b1370); padding: 14px 10px 10px; text-align: center; margin: 4px; position: relative; overflow: hidden; }
.acronym-card::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 22px, rgba(255,255,255,.03) 22px 24px); pointer-events: none; }
.acronym { font-family: var(--font-px); font-size: clamp(34px, 11vw, 76px); color: var(--yellow); text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--ink); min-height: 1.1em; line-height: 1.1; white-space: nowrap; }
.acronym .ch { display: inline-block; animation: dropIn .4s steps(5) backwards; }
@keyframes dropIn { 0% { transform: translateY(-120%) rotate(-20deg); opacity: 0; } 70% { transform: translateY(8%) rotate(4deg); opacity: 1; } 100% { transform: none; } }
.acronym.long { font-size: clamp(24px, 8vw, 56px); }
.prompt { font-family: var(--font-px); font-size: 9px; color: var(--muted); margin-top: 8px; letter-spacing: 2px; }

.timer-bar { height: 16px; background: var(--ink); margin: 4px; position: relative; box-shadow: 0 0 0 4px var(--ink); }
#timer-fill { height: 100%; width: 100%; background: var(--green); transform-origin: left; box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), inset 0 4px 0 rgba(255,255,255,.25); }
#timer-fill.mid { background: var(--yellow); }
#timer-fill.low { background: var(--pink); animation: blink .2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .5; } }

/* Millionaire-style lozenges */
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; margin: 8px 0 4px; position: relative; }
.answers::before, .answers::after { content: ''; position: absolute; left: -16px; right: -16px; height: 4px; background: var(--ink); z-index: 0; }
.answers::before { top: calc(25% - 5px); }
.answers::after { top: calc(75% - 1px); }
.answer {
  --fill: #1e0b3d; --edge: var(--purple);
  position: relative; z-index: 1; border: 0; padding: 0; background: var(--edge); cursor: pointer;
  min-height: 58px; display: flex; align-items: center; text-align: left;
  clip-path: polygon(16px 0, calc(100% - 16px) 0, calc(100% - 16px) 4px, calc(100% - 12px) 4px, calc(100% - 12px) 8px, calc(100% - 8px) 8px, calc(100% - 8px) 12px, calc(100% - 4px) 12px, calc(100% - 4px) 16px, 100% 16px, 100% calc(100% - 16px), calc(100% - 4px) calc(100% - 16px), calc(100% - 4px) calc(100% - 12px), calc(100% - 8px) calc(100% - 12px), calc(100% - 8px) calc(100% - 8px), calc(100% - 12px) calc(100% - 8px), calc(100% - 12px) calc(100% - 4px), calc(100% - 16px) calc(100% - 4px), calc(100% - 16px) 100%, 16px 100%, 16px calc(100% - 4px), 12px calc(100% - 4px), 12px calc(100% - 8px), 8px calc(100% - 8px), 8px calc(100% - 12px), 4px calc(100% - 12px), 4px calc(100% - 16px), 0 calc(100% - 16px), 0 16px, 4px 16px, 4px 12px, 8px 12px, 8px 8px, 12px 8px, 12px 4px, 16px 4px);
  transition: transform .06s steps(1);
}
.answer::before {
  content: ''; position: absolute; inset: 4px; background: var(--fill); clip-path: inherit; z-index: -1;
}
.answer .letter { font-family: var(--font-px); font-size: 13px; color: var(--orange); padding: 0 10px 0 22px; flex: none; }
.answer .text { flex: 1; font-size: 25px; line-height: .95; padding: 8px 18px 8px 0; color: var(--cream); }
.answer .pins { position: absolute; right: 22px; top: -2px; display: flex; flex-direction: row-reverse; }
.answer .pins img { width: 28px; height: 28px; margin-left: -8px; animation: popIn .25s steps(3) backwards; }
.answer:not(:disabled):hover { --edge: var(--cyan); }
.answer:not(:disabled):active { transform: translate(2px, 2px); }
.answer:disabled { cursor: default; }
.answer.dim { opacity: .45; }
.answer.locked { --fill: var(--orange); --edge: var(--yellow); opacity: 1; animation: lockBlink .5s steps(2) 3; }
.answer.locked .text, .answer.locked .letter { color: var(--ink); }
@keyframes lockBlink { 50% { --fill: #ffc56b; filter: brightness(1.2); } }
.answer.nuked { visibility: hidden; animation: none; }
.answer.dissolve { animation: dissolve .5s steps(5) forwards; }
@keyframes dissolve { 0% { filter: none; } 40% { filter: hue-rotate(90deg) contrast(3); transform: skewX(20deg); } 100% { opacity: 0; transform: scaleY(0); } }
.answer.correct { --fill: var(--green); --edge: #b6ffcf; opacity: 1; animation: correctBlink .25s steps(2) 5; }
.answer.correct .text, .answer.correct .letter { color: var(--ink); }
@keyframes correctBlink { 50% { --fill: #9dffbf; } }
.answer.wrong { --fill: var(--pink); --edge: #ffb3c6; opacity: 1; }
.answer.wrong .text, .answer.wrong .letter { color: var(--cream); }
.answer.hinted { --edge: var(--yellow); }
.answer.hinted .letter::after { content: '*'; margin-left: 6px; color: var(--yellow); }
.answer.hinted.locked .letter::after { color: var(--ink); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 4px 0; }
.jokers { flex: none; }
.jokers { display: flex; gap: 12px; }
.joker { font-family: var(--font-px); font-size: 9px; background: var(--cyan); color: var(--ink); border: 0; padding: 9px 10px; cursor: pointer; }
.joker:disabled { background: #3b2a4f; color: #6c5a86; cursor: not-allowed; text-decoration: line-through; }
.joker:not(:disabled):hover { background: #7fdcff; }

.sysadmin { display: flex; gap: 10px; align-items: center; background: #0b2a1c; color: var(--green); padding: 8px 10px; margin: 4px 4px 10px; font-size: 21px; line-height: 1; animation: popIn .3s steps(4); min-height: 56px; }
#screen-game.hinting .host-row { display: none; }
.sysadmin img { width: 44px; height: 44px; flex: none; }
.sysadmin b { font-family: var(--font-px); font-size: 8px; font-weight: normal; color: var(--yellow); }

.status-line { text-align: center; font-family: var(--font-px); font-size: 9px; color: var(--muted); min-height: 14px; margin-top: 2px; }

/* Roster */
.roster { display: flex; flex-wrap: wrap; gap: 10px 6px; justify-content: center; margin-top: auto; padding-top: 22px; }
.rp { position: relative; display: flex; flex-direction: column; align-items: center; width: 76px; }
.rp .avatar { width: 44px; height: 44px; }
.rp .nm { font-size: 18px; max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1; }
.rp.me .nm { color: var(--yellow); }
.rp .hearts { display: flex; gap: 2px; height: 12px; }
.heart { width: 14px; height: 12px; display: block; }
.heart.breaking { animation: heartBreak .6s steps(4) forwards; }
@keyframes heartBreak { 0% { transform: scale(1.6); } 40% { transform: scale(1.6) rotate(20deg); filter: brightness(3); } 100% { transform: scale(1); } }
.rp .lock { position: absolute; top: -10px; right: 10px; font-family: var(--font-px); font-size: 7px; background: var(--orange); color: var(--ink); padding: 2px 3px; animation: popIn .2s steps(3); }
.rp .pts { position: absolute; top: -18px; font-family: var(--font-px); font-size: 9px; color: var(--green); text-shadow: 2px 2px 0 var(--ink); animation: emoteUp 1.8s steps(8) forwards; left: 50%; }
.rp.dead { opacity: .55; }
.rp.dead .avatar { animation: ghostFloat 2s steps(4) infinite; }
@keyframes ghostFloat { 50% { transform: translateY(-5px); } }
.rp.offline .avatar { filter: grayscale(1) brightness(.6); }
.rp.hit .avatar { animation: hit .5s steps(4); }
@keyframes hit { 0%, 100% { transform: none; filter: none; } 25% { transform: translateX(-6px); filter: brightness(3) saturate(0); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); filter: brightness(2) sepia(1) hue-rotate(-50deg) saturate(6); } }
.rp.win .avatar { animation: bob .4s steps(2) 4; }
.rp .streak { position: absolute; top: 20px; left: 2px; font-family: var(--font-px); font-size: 7px; color: var(--orange); text-shadow: 1px 1px 0 var(--ink); }

/* ───── Banner & toast ───── */
.banner {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 40; pointer-events: none;
  font-family: var(--font-px); font-size: clamp(28px, 9vw, 72px); color: var(--yellow); text-align: center; white-space: nowrap;
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--ink); opacity: 0;
}
.banner small { display: block; font-size: .28em; color: var(--cream); text-shadow: 2px 2px 0 var(--ink); margin-top: 14px; white-space: normal; }
.banner.show { animation: bannerPop 1.1s steps(8) forwards; }
.banner.show.long { animation-duration: 2s; }
.banner.good { color: var(--green); text-shadow: 4px 4px 0 #0b5a2c, 8px 8px 0 var(--ink); }
.banner.bad { color: var(--pink); text-shadow: 4px 4px 0 #5a0b1c, 8px 8px 0 var(--ink); }
.banner.info { color: var(--cyan); text-shadow: 4px 4px 0 #0b3a5a, 8px 8px 0 var(--ink); }
@keyframes bannerPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(3) rotate(-8deg); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(.9) rotate(2deg); }
  25% { transform: translate(-50%, -50%) scale(1.05) rotate(-1deg); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 200%); z-index: 80; background: var(--cream); color: var(--ink); padding: 10px 14px; font-size: 22px; transition: transform .25s steps(4); max-width: calc(100vw - 32px); }
.toast.show { transform: translate(-50%, 0); }

/* ───── Game over ───── */
#screen-over { align-items: center; }
.over-title { font-family: var(--font-px); font-size: clamp(20px, 6vw, 44px); color: var(--yellow); text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--ink); text-align: center; margin-top: 10px; line-height: 1.3; }
.over-sub { font-size: 24px; color: var(--cyan); margin: 8px 0 12px; text-align: center; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 14px 0 6px; min-height: 180px; }
.pod { display: flex; flex-direction: column; align-items: center; width: 100px; }
.pod .avatar { width: 72px; height: 72px; animation: bob .8s steps(2) infinite; }
.pod .nm { font-size: 22px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .block { width: 100%; background: var(--plum2); display: grid; place-items: center; font-family: var(--font-px); font-size: 22px; color: var(--ink); animation: rise .6s steps(6) backwards; transform-origin: bottom; box-shadow: inset -4px -4px 0 rgba(0,0,0,.3), inset 4px 4px 0 rgba(255,255,255,.2), 0 0 0 4px var(--ink); }
.pod.p1 .block { height: 110px; background: var(--yellow); animation-delay: .6s; }
.pod.p2 .block { height: 76px; background: #c9c9ff; animation-delay: .3s; }
.pod.p3 .block { height: 52px; background: var(--orange); }
@keyframes rise { 0% { transform: scaleY(0); } 100% { transform: scaleY(1); } }
.standings { width: min(560px, 100%); }
.st { display: flex; align-items: center; gap: 12px; padding: 4px 0; font-size: 22px; }
.st .pl { font-family: var(--font-px); font-size: 11px; width: 34px; color: var(--yellow); }
.st .avatar { width: 32px; height: 32px; }
.st .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st .sc { color: var(--cyan); }
.st .rd { color: var(--muted); font-size: 18px; width: 90px; text-align: right; }
.st.me .nm { color: var(--yellow); }
.awards { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; width: min(760px, 100%); }
.award { background: var(--ink); padding: 10px 12px; display: flex; gap: 10px; align-items: center; min-width: 200px; animation: popIn .4s steps(4) backwards; box-shadow: 0 0 0 4px var(--purple); margin: 4px; }
.award .avatar { width: 36px; height: 36px; }
.award b { font-family: var(--font-px); font-size: 9px; color: var(--yellow); font-weight: normal; display: block; margin-bottom: 4px; }
.award span { font-size: 20px; }

/* ───── Glitch ───── */
.glitching #app, #app.glitching { animation: glitch .5s steps(10); }
@keyframes glitch {
  0% { clip-path: inset(10% 0 60% 0); transform: translate(-8px, 0); filter: hue-rotate(90deg); }
  20% { clip-path: inset(40% 0 20% 0); transform: translate(8px, 0); }
  40% { clip-path: inset(70% 0 5% 0); transform: translate(-4px, 0); filter: invert(1); }
  60% { clip-path: inset(0 0 80% 0); transform: translate(6px, 0); filter: none; }
  80% { clip-path: inset(30% 0 30% 0); transform: translate(-2px, 0); filter: hue-rotate(-90deg); }
  100% { clip-path: inset(0); transform: none; filter: none; }
}
body.danger #crt { background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.16) 2px 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 50%, rgba(160,0,30,.55) 100%); }

/* ───── Responsive ───── */
@media (max-width: 720px) {
  body { font-size: 20px; }
  #app { padding-left: 16px; padding-right: 16px; }
  .lobby-grid { grid-template-columns: 1fr; grid-template-areas: 'invite' 'players' 'settings'; }
  #qr { width: 120px; height: 120px; }
  .answers { grid-template-columns: 1fr; gap: 8px; }
  .answers::before, .answers::after { display: none; }
  .answer { min-height: 48px; }
  .answer .text { font-size: 23px; padding: 6px 16px 6px 0; }
  .answer .letter { padding-left: 18px; font-size: 11px; }
  .answer .pins img { width: 24px; height: 24px; }
  .host { width: 40px; height: 50px; }
  .host-row { min-height: 52px; }
  .bubble { font-size: 19px; }
  .timer-num { font-size: 20px; }
  .acronym-card { padding: 10px 6px 8px; }
  .rp { width: 62px; }
  .rp .avatar { width: 36px; height: 36px; }
  .rp .nm { font-size: 16px; max-width: 62px; }
  .emote-row button { padding: 6px 5px; font-size: 7px; }
  .lobby-actions .btn.big { flex: 1; }
  .st .rd { display: none; }
}
@media (max-height: 700px) and (max-width: 720px) {
  .host-row { display: none; }
  .roster { padding-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
