/* ==========================================================================
   LinkMe — "game-show risograph" art style
   Chunky ink outlines, hard offset shadows, candy colours, grain + blobs.
   ========================================================================== */

:root {
  --ink: #160d2e;
  --ink-2: #221543;
  --ink-3: #2f1f5c;
  --paper: #fff7e8;
  --paper-2: #ffecc9;
  --muted: #b9acd9;

  --pink: #ff4f8b;
  --pink-d: #b8195a;
  --sun: #ffc93c;
  --sun-d: #c48a00;
  --teal: #19d3c5;
  --teal-d: #0a8f85;
  --violet: #8f6bff;
  --lime: #b5f23d;
  --orange: #ff8a3d;
  --sky: #4cc3ff;
  --red: #ff4d4d;
  --green: #2ee27a;

  --line: 3px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --r: 18px;
  --r-sm: 12px;

  --font: 'Bricolage Grotesque', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;

  --cat: var(--pink);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font);
  font-optical-sizing: auto;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--sun); }
[hidden] { display: none !important; }
::selection { background: var(--pink); color: var(--paper); }

/* ---------- Background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; animation: drift 22s ease-in-out infinite alternate; }
.b1 { width: 48vmax; height: 48vmax; background: var(--pink); top: -18vmax; left: -12vmax; }
.b2 { width: 40vmax; height: 40vmax; background: var(--violet); bottom: -16vmax; right: -10vmax; animation-delay: -6s; }
.b3 { width: 28vmax; height: 28vmax; background: var(--teal); top: 40%; left: 55%; opacity: .32; animation-delay: -12s; }
.b4 { width: 22vmax; height: 22vmax; background: var(--sun); top: 62%; left: 4%; opacity: .25; animation-delay: -3s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(6vmax, 4vmax) scale(1.08); }
  100% { transform: translate(-4vmax, 7vmax) scale(.95); }
}
.grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
}
.grain {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  opacity: .13; mix-blend-mode: overlay;
}
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Primitives ---------- */
.btn {
  --bg: var(--paper); --fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .7em 1.2em; min-height: 48px;
  background: var(--bg); color: var(--fg);
  border: var(--line); border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-weight: 800; letter-spacing: .01em; line-height: 1.1;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
  user-select: none; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.05); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }
.btn:focus-visible, .chip:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
.btn-pink { --bg: var(--pink); --fg: #fff; }
.btn-sun { --bg: var(--sun); }
.btn-teal { --bg: var(--teal); }
.btn-violet { --bg: var(--violet); --fg: #fff; }
.btn-lime { --bg: var(--lime); }
.btn-ink { --bg: var(--ink-3); --fg: var(--paper); border-color: var(--ink); }
.btn-ghost { --bg: transparent; --fg: var(--paper); border-color: rgba(255,255,255,.35); box-shadow: none; }
.btn-ghost:hover { box-shadow: none; background: rgba(255,255,255,.08); }
.btn-big { font-size: 1.25rem; padding: .85em 1.6em; min-height: 60px; box-shadow: var(--shadow); }
.btn-sm { font-size: .85rem; padding: .45em .9em; min-height: 36px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.18);
  font-size: 1.15rem; transition: background .15s, transform .08s;
}
.icon-btn:hover { background: rgba(255,255,255,.16); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { background: var(--sun); color: var(--ink); border-color: var(--ink); }

.panel {
  background: var(--paper); color: var(--ink);
  border: var(--line); border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 1.1rem;
}
.panel-dark {
  background: rgba(34, 21, 67, .82); color: var(--paper);
  border: 2px solid rgba(255,255,255,.14); border-radius: var(--r);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 1.1rem;
}
.panel h2, .panel-dark h2 { margin: 0 0 .7rem; font-size: 1.15rem; letter-spacing: -.01em; }
.label { display: block; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; opacity: .7; margin: 0 0 .35rem; }

.input {
  width: 100%; min-height: 50px; padding: .65em .9em;
  background: #fff; color: var(--ink);
  border: var(--line); border-radius: var(--r-sm);
  box-shadow: inset 0 3px 0 rgba(22,13,46,.08);
  font-weight: 600; font-size: 1.05rem;
}
.input:focus { outline: 3px solid var(--sun); outline-offset: 2px; }
.input::placeholder { color: #8f86a8; font-weight: 500; }
textarea.input { min-height: 90px; resize: vertical; font-size: .95rem; line-height: 1.4; }
.input.mono { font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; }

.chip {
  display: inline-flex; align-items: center; gap: .4em;
  padding: .45em .85em; min-height: 40px;
  border-radius: 999px; border: 2px solid var(--ink);
  background: #fff; color: var(--ink); font-weight: 700; font-size: .9rem;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform .08s, background .15s;
}
.chip:active { transform: translate(2px, 2px); box-shadow: none; }
.chip.on { background: var(--c, var(--sun)); color: var(--ink); }
.chip.off { opacity: .55; background: #eee4d2; text-decoration: line-through; text-decoration-thickness: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }

.seg { display: inline-flex; border: var(--line); border-radius: 999px; overflow: hidden; background: #fff; box-shadow: 2px 2px 0 var(--ink); }
.seg button { border: 0; background: transparent; padding: .5em .9em; min-height: 40px; font-weight: 700; font-size: .88rem; color: var(--ink); }
.seg button + button { border-left: 2px solid var(--ink); }
.seg button.on { background: var(--ink); color: var(--sun); }

.switch { display: flex; align-items: center; gap: .7rem; cursor: pointer; font-weight: 700; user-select: none; }
.switch input { appearance: none; width: 52px; height: 30px; border-radius: 999px; background: #d9cfe9; border: var(--line); position: relative; flex: none; transition: background .2s; cursor: pointer; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: transform .2s; }
.switch input:checked { background: var(--teal); }
.switch input:checked::after { transform: translateX(22px); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: .9rem; }
.spacer { flex: 1; }

/* ---------- Logo ---------- */
.logo { display: flex; justify-content: center; align-items: center; gap: .18em; margin: 0; font-size: clamp(2.4rem, 11vw, 5.2rem); line-height: 1; user-select: none; }
.logo .t {
  display: inline-grid; place-items: center;
  width: 1.12em; height: 1.2em; border: .06em solid var(--ink); border-radius: .2em;
  background: var(--c); color: var(--ink); font-weight: 800; box-shadow: .07em .07em 0 var(--ink);
  transform: rotate(var(--rot, 0deg));
  animation: tile-in .6s cubic-bezier(.2, 1.6, .4, 1) both;
  animation-delay: calc(var(--i) * 70ms);
}
.logo .chain { font-size: .72em; margin: 0 .05em; animation: swing 2.6s ease-in-out infinite; display: inline-block; filter: drop-shadow(.05em .05em 0 var(--ink)); }
.logo.sm { font-size: 1.35rem; gap: .12em; }
.logo.sm .t { animation: none; }
.logo.sm .chain { animation: none; }
@keyframes tile-in { from { transform: translateY(-60%) rotate(-25deg) scale(.4); opacity: 0; } to { transform: rotate(var(--rot, 0deg)); opacity: 1; } }
@keyframes swing { 0%,100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }

/* ---------- Screens ---------- */
.screen { width: min(1100px, 100%); margin: 0 auto; padding: 18px 16px calc(28px + var(--safe-b)); animation: screen-in .35s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.screen-head { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.screen-head h1 { margin: 0; font-size: clamp(1.5rem, 5vw, 2.2rem); letter-spacing: -.02em; }

/* Home */
.home { display: grid; gap: 1.4rem; max-width: 560px; padding-top: clamp(24px, 7vh, 72px); }
.hero { text-align: center; }
.tagline { margin: .9rem 0 0; font-size: clamp(1.05rem, 3.6vw, 1.35rem); font-weight: 600; color: var(--paper-2); }
.tagline b { color: var(--sun); }
.avatar-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: .4rem; margin-top: .7rem; }
.avatar-pick button { aspect-ratio: 1; border-radius: 12px; border: 2px solid transparent; background: rgba(22,13,46,.06); font-size: 1.5rem; display: grid; place-items: center; transition: transform .1s; }
.avatar-pick button:hover { transform: scale(1.1); }
.avatar-pick button.on { border-color: var(--ink); background: var(--sun); box-shadow: 2px 2px 0 var(--ink); }
.home-actions { display: grid; gap: .9rem; }
.join-row { display: flex; gap: .6rem; }
.join-row .input { flex: 1; min-width: 0; }
.home-links { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.foot { text-align: center; font-size: .8rem; color: var(--muted); }
.foot a { color: var(--muted); }

/* ---------- Room layout ---------- */
.room { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: .55rem;
  padding: 10px 16px; position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, rgba(22,13,46,.95), rgba(22,13,46,.7));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 2px solid rgba(255,255,255,.08);
}
.code-chip {
  display: inline-flex; align-items: center; gap: .45em;
  font-family: var(--mono); font-weight: 700; font-size: .95rem; letter-spacing: .05em;
  background: var(--sun); color: var(--ink); border: 2px solid var(--ink); border-radius: 10px;
  padding: .35em .7em; box-shadow: 2px 2px 0 var(--ink);
}
.card-count { font-weight: 800; font-size: .9rem; color: var(--paper-2); white-space: nowrap; }
.net-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(46,226,122,.25); flex: none; }
.net-dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(255,77,77,.25); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.room-body { flex: 1; display: grid; grid-template-columns: 1fr; gap: 14px; padding: 14px 16px; width: min(1280px, 100%); margin: 0 auto; align-content: start; }
@media (min-width: 900px) {
  .room-body { grid-template-columns: minmax(0, 1fr) 290px; align-items: start; }
  .room-body .board { position: sticky; top: 76px; }
  .room-body.solo { grid-template-columns: minmax(0, 1fr); width: min(1100px, 100%); }
}

/* ---------- Scoreboard ---------- */
.board { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
@media (min-width: 900px) { .board { flex-direction: column; overflow: visible; padding: 0; } }
@media (max-width: 899px) { .room-body .board { order: -1; } }
.pl {
  --pc: var(--pink);
  display: flex; align-items: center; gap: .55rem;
  padding: .45rem .7rem .45rem .45rem; min-width: max-content;
  background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.12); border-radius: 14px;
  position: relative; transition: transform .25s, background .25s, border-color .25s;
}
.pl .av { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 1.35rem; background: var(--pc); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); flex: none; }
.pl .nm { font-weight: 800; font-size: .92rem; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .meta { display: grid; gap: 3px; min-width: 0; }
.pl .sc { margin-left: auto; font-family: var(--mono); font-weight: 700; font-size: 1.05rem; color: var(--sun); padding-left: .4rem; }
.pl.me { border-color: var(--sun); background: rgba(255,201,60,.12); }
.pl.off { opacity: .45; }
.pl.locked .av { filter: grayscale(1); }
.pl.locked::after { content: '🔒'; position: absolute; left: 30px; top: -6px; font-size: .9rem; }
.pl.buzzing { background: var(--pink); border-color: var(--ink); transform: scale(1.04); box-shadow: var(--shadow-sm); }
.pl.buzzing .sc { color: #fff; }
.pl.leader .av::after { content: '👑'; position: absolute; top: -12px; left: 12px; font-size: .95rem; transform: rotate(-15deg); }
.pl .av { position: relative; }
.pl .tag { font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.letters { display: inline-flex; gap: 2px; }
.letters i {
  font-style: normal; display: inline-grid; place-items: center;
  width: 15px; height: 17px; border-radius: 4px; font-size: .62rem; font-weight: 800;
  border: 1.5px solid rgba(255,255,255,.28); color: rgba(255,255,255,.35);
}
.letters i.got { background: var(--sun); color: var(--ink); border-color: var(--ink); }
.letters i.got.pop { animation: letter-pop .6s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes letter-pop { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: none; } }

/* ---------- Stage ---------- */
.stage { min-width: 0; display: grid; gap: 14px; align-content: start; }
.cat-badge {
  display: inline-flex; align-items: center; gap: .45em;
  background: var(--cat); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 999px; box-shadow: 2px 2px 0 var(--ink);
  padding: .3em .8em; font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em;
}
.stage-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

.timer { height: 14px; border-radius: 999px; background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.14); overflow: hidden; position: relative; }
.timer .fill { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, var(--teal), var(--sun) 70%, var(--pink)); border-radius: 999px; }
.timer.paused .fill { background: repeating-linear-gradient(45deg, var(--muted) 0 10px, #9285b8 10px 20px); }
.timer-label { font-family: var(--mono); font-weight: 700; font-size: .85rem; color: var(--paper-2); min-width: 3ch; text-align: right; }

.clues { display: grid; gap: 12px; grid-template-columns: 1fr; counter-reset: clue; }
@media (min-width: 700px) { .clues { grid-template-columns: 1fr 1fr; } }
.clue {
  position: relative; min-height: 118px;
  background: var(--paper); color: var(--ink);
  border: var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 14px 14px 12px 54px;
  display: grid; align-content: space-between; gap: 10px;
  transition: opacity .3s, transform .3s;
}
.clue .num {
  position: absolute; left: 12px; top: 12px;
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; font-weight: 800; font-size: 1.05rem;
  background: var(--cat); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
}
.clue .q { font-size: clamp(1rem, 2.6vw, 1.15rem); font-weight: 600; line-height: 1.3; }
.clue .a {
  justify-self: start; display: inline-flex; align-items: center; gap: .4em;
  background: var(--ink); color: var(--sun);
  border-radius: 10px; padding: .35em .75em; font-weight: 800; font-size: 1.1rem;
  transform-origin: top center;
}
.clue .a.pending { background: repeating-linear-gradient(135deg, #eadfca 0 8px, #f3ead9 8px 16px); color: transparent; min-width: 120px; border: 2px dashed #c9bb9f; }
.clue.hidden { background: rgba(255,247,232,.08); border-color: rgba(255,255,255,.2); box-shadow: none; color: var(--paper); }
.clue.hidden .num { background: transparent; border-color: rgba(255,255,255,.3); box-shadow: none; color: rgba(255,255,255,.5); }
.clue.hidden .q { color: rgba(255,255,255,.35); font-style: italic; }
.clue.current { outline: 4px solid var(--sun); outline-offset: 3px; }
.clue.fresh-q { animation: clue-in .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.clue .a.fresh { animation: flip-in .6s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes clue-in { from { transform: translateY(18px) rotate(-2deg) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes flip-in { 0% { transform: rotateX(90deg); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* Intro splash */
.intro { display: grid; place-items: center; text-align: center; min-height: 46vh; gap: 1rem; }
.intro .big-num { font-size: clamp(4rem, 20vw, 9rem); font-weight: 800; line-height: .9; color: var(--cat); -webkit-text-stroke: 3px var(--ink); text-shadow: 6px 6px 0 var(--ink); animation: slam .55s cubic-bezier(.2, 1.6, .4, 1) both; }
.intro .intro-cat { animation: screen-in .5s .2s both; }
.intro .cat-badge { font-size: clamp(1rem, 3.5vw, 1.4rem); }
@keyframes slam { from { transform: scale(2.4) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* Buzz banner / verdict */
.banner {
  display: flex; align-items: center; gap: .8rem;
  padding: .8rem 1rem; border-radius: var(--r);
  border: var(--line); box-shadow: var(--shadow);
  background: var(--pink); color: #fff; font-weight: 800; font-size: 1.15rem;
  animation: banner-in .4s cubic-bezier(.2, 1.6, .4, 1) both;
}
.banner .av { font-size: 1.8rem; }
.banner.wrong { background: var(--red); }
.banner.right { background: var(--green); color: var(--ink); }
.banner .guess { font-family: var(--mono); background: rgba(0,0,0,.2); padding: .15em .5em; border-radius: 8px; }
.banner.wrong { animation: shake .5s both; }
@keyframes banner-in { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }

/* Reveal */
.reveal { display: grid; gap: 14px; text-align: center; }
.link-card {
  position: relative; overflow: hidden;
  background: var(--cat); color: var(--ink);
  border: var(--line); border-radius: 24px; box-shadow: 8px 8px 0 var(--ink);
  padding: 1.3rem 1rem 1.5rem;
  animation: slam .6s cubic-bezier(.2, 1.5, .4, 1) both;
}
.link-card::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-conic-gradient(from 0deg at 50% 120%, rgba(255,255,255,.22) 0 8deg, transparent 8deg 16deg);
  animation: rays 18s linear infinite; pointer-events: none;
}
@keyframes rays { to { transform: rotate(360deg); } }
.link-card .kicker { position: relative; font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.link-card .the-link { position: relative; font-size: clamp(1.8rem, 7vw, 3.4rem); font-weight: 800; line-height: 1.05; letter-spacing: -.02em; margin: .3rem 0 0; }
.link-card .the-link span { display: inline-block; animation: tile-in .5s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: calc(var(--i) * 35ms + .25s); white-space: pre; }
.answers-row { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.answers-row .a { background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: 10px; padding: .35em .8em; font-weight: 800; box-shadow: 2px 2px 0 var(--ink); animation: screen-in .4s both; animation-delay: calc(var(--i) * 90ms + .5s); }
.answers-row .plus { align-self: center; font-weight: 800; color: var(--sun); }
.winner { display: flex; align-items: center; justify-content: center; gap: .7rem; font-size: 1.2rem; font-weight: 800; animation: screen-in .5s .6s both; flex-wrap: wrap; }
.winner .av { font-size: 2.2rem; animation: bounce 1s infinite; }
.winner .pts { background: var(--sun); color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; padding: .2em .7em; font-size: 1rem; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* Podium */
.over { display: grid; gap: 1.2rem; text-align: center; }
.over h2 { margin: 0; font-size: clamp(2rem, 8vw, 3.6rem); letter-spacing: -.02em; }
.podium { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end; gap: 10px; max-width: 560px; margin: 0 auto; width: 100%; }
.podium .step { display: grid; gap: .4rem; justify-items: center; }
.podium .block { width: 100%; border: var(--line); border-radius: 14px 14px 0 0; box-shadow: var(--shadow); display: grid; place-items: center; font-size: 2rem; font-weight: 800; color: var(--ink); animation: rise .8s cubic-bezier(.2, 1.3, .4, 1) both; transform-origin: bottom; }
.podium .p1 .block { height: 150px; background: var(--sun); animation-delay: .6s; }
.podium .p2 .block { height: 110px; background: #d8dcef; animation-delay: .3s; }
.podium .p3 .block { height: 80px; background: var(--orange); }
.podium .av { font-size: 2.4rem; }
.podium .nm { font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .sc { font-family: var(--mono); color: var(--sun); font-weight: 700; }
@keyframes rise { from { transform: scaleY(0); } to { transform: none; } }
.standings { display: grid; gap: 6px; max-width: 520px; margin: 0 auto; width: 100%; text-align: left; }

/* ---------- Action (player controls) ---------- */
.dock { position: sticky; bottom: 0; z-index: 15; }
.action {
  padding: 12px 16px calc(14px + var(--safe-b));
  background: linear-gradient(0deg, rgba(22,13,46,.98) 60%, rgba(22,13,46,0));
}
.action:empty { display: none; }
.action-inner { width: min(760px, 100%); margin: 0 auto; display: grid; gap: 10px; justify-items: center; }

.buzzer {
  --b: var(--pink); --bd: var(--pink-d);
  width: min(92vw, 420px); height: clamp(84px, 14vh, 120px);
  border-radius: 999px; border: 4px solid var(--ink);
  background: radial-gradient(ellipse at 50% 25%, rgba(255,255,255,.45), transparent 55%), var(--b);
  color: #fff; font-size: clamp(1.8rem, 7vw, 2.6rem); font-weight: 800; letter-spacing: .06em;
  text-shadow: 3px 3px 0 var(--ink);
  box-shadow: 0 10px 0 var(--bd), 0 14px 0 var(--ink), 0 20px 30px rgba(0,0,0,.4);
  transform: translateY(0); transition: transform .06s, box-shadow .06s;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.buzzer:active:not(:disabled), .buzzer.pressed { transform: translateY(10px); box-shadow: 0 0 0 var(--bd), 0 4px 0 var(--ink), 0 6px 10px rgba(0,0,0,.4); }
.buzzer:disabled { --b: #5a4f7a; --bd: #3a3157; color: rgba(255,255,255,.6); cursor: not-allowed; }
.buzzer.ready { animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 10px 0 var(--bd), 0 14px 0 var(--ink), 0 0 40px rgba(255,79,139,.8); } }
.action-note { font-weight: 700; color: var(--paper-2); font-size: .95rem; text-align: center; }

.answer-form { width: 100%; display: grid; gap: 8px; animation: banner-in .3s both; }
.answer-form .row { flex-wrap: nowrap; }
.answer-form .input { font-size: 1.2rem; min-height: 58px; }
.answer-form .btn { min-height: 58px; }
.answer-form .prompt { font-weight: 800; font-size: 1.1rem; color: var(--sun); text-align: center; }

.react-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.react-row button { width: 44px; height: 40px; border-radius: 12px; border: 2px solid rgba(255,255,255,.15); background: rgba(255,255,255,.07); font-size: 1.25rem; transition: transform .08s; }
.react-row button:active { transform: scale(.85); }

.vote-row { display: flex; gap: .7rem; align-items: center; justify-content: center; flex-wrap: wrap; }
.vote-row .vbtn { width: 64px; height: 52px; border-radius: 16px; border: var(--line); background: var(--paper); font-size: 1.6rem; box-shadow: var(--shadow-sm); transition: transform .1s; }
.vote-row .vbtn:active { transform: translate(3px, 3px); box-shadow: none; }
.vote-row .vbtn.on.up { background: var(--green); transform: scale(1.08) rotate(-4deg); }
.vote-row .vbtn.on.down { background: var(--red); transform: scale(1.08) rotate(4deg); }

/* ---------- Host bar ---------- */
.hostbar {
  display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: rgba(15, 8, 34, .96); border-top: 2px dashed rgba(255,201,60,.4);
}
.hostbar:empty { display: none; }
.action:not(:empty) { padding-bottom: 12px; }
.hostbar .hb-label { font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--sun); margin-right: .3rem; }
.peek { font-family: var(--mono); font-weight: 700; background: var(--ink-3); border: 2px dashed var(--sun); border-radius: 10px; padding: .45em .8em; color: var(--sun); user-select: none; -webkit-user-select: none; touch-action: none; }
.peek .ans { filter: blur(7px); transition: filter .1s; }
.peek:active .ans, .peek.show .ans { filter: none; }

/* ---------- Lobby ---------- */
.lobby { display: grid; gap: 14px; }
.lobby-hero { display: grid; gap: 1rem; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 700px) { .lobby-hero { grid-template-columns: 1fr auto; } }
.room-code-big { font-family: var(--mono); font-weight: 700; font-size: clamp(2.2rem, 10vw, 4rem); letter-spacing: .06em; color: var(--sun); text-shadow: 4px 4px 0 var(--ink); line-height: 1; }
.share-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.qr-box { background: #fff; border: var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 10px; width: 180px; justify-self: center; }
.qr-box svg { display: block; width: 100%; height: auto; }
.players-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.slot {
  --pc: var(--pink);
  display: grid; justify-items: center; gap: .35rem; padding: .8rem .4rem;
  border-radius: 16px; border: 2px dashed rgba(255,255,255,.18); min-height: 104px; align-content: center;
  position: relative; text-align: center;
}
.slot.filled { border: var(--line); background: var(--paper); color: var(--ink); box-shadow: var(--shadow-sm); animation: tile-in .45s cubic-bezier(.2, 1.6, .4, 1) both; }
.slot .av { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.7rem; background: var(--pc); border: 2px solid var(--ink); }
.slot .nm { font-weight: 800; font-size: .9rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .empty { color: rgba(255,255,255,.25); font-weight: 800; font-size: 1.4rem; }
.slot .kick { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--ink); background: #fff; font-size: .75rem; display: grid; place-items: center; opacity: .6; }
.slot .kick:hover { opacity: 1; background: var(--red); }
.slot .host-tag { font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; background: var(--ink); color: var(--sun); padding: .15em .5em; border-radius: 6px; }
.slot.off { opacity: .5; }
.settings { display: grid; gap: 1.1rem; }
.settings .set { display: grid; gap: .45rem; }
.settings .hint { font-size: .8rem; opacity: .7; font-weight: 600; }
.cat-chip .count { font-family: var(--mono); font-size: .72rem; opacity: .7; }
.waiting { text-align: center; padding: 1.4rem 1rem; }
.waiting .dots span { display: inline-block; animation: bounce 1.2s infinite; }
.waiting .dots span:nth-child(2) { animation-delay: .15s; }
.waiting .dots span:nth-child(3) { animation-delay: .3s; }
.settings-summary { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.settings-summary span { font-size: .8rem; font-weight: 700; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); padding: .3em .7em; border-radius: 999px; }

/* ---------- TV mode ---------- */
body.tv .room-body { width: 100%; padding: 2vh 3vw; gap: 2vw; }
@media (min-width: 900px) {
  body.tv .room-body { grid-template-columns: minmax(0, 1fr) clamp(260px, 22vw, 420px); }
  body.tv .room-body.solo { grid-template-columns: minmax(0, 1fr); }
}
body.tv .stage { gap: 2vh; }
body.tv .clue { min-height: 20vh; padding: 2.2vh 2vw 2vh 5.4vw; }
body.tv .clue .num { width: 3.2vw; height: 3.2vw; min-width: 36px; min-height: 36px; font-size: 1.6vw; left: 1.2vw; top: 1.8vh; border-radius: .7vw; }
body.tv .clue .q { font-size: clamp(1.1rem, 1.9vw, 2.4rem); }
body.tv .clue .a { font-size: clamp(1.2rem, 2.1vw, 2.6rem); }
body.tv .pl { padding: .7vh .8vw .7vh .6vw; }
body.tv .pl .av { width: clamp(38px, 3vw, 60px); height: clamp(38px, 3vw, 60px); font-size: clamp(1.3rem, 1.9vw, 2.3rem); }
body.tv .pl .nm { font-size: clamp(.9rem, 1.2vw, 1.5rem); max-width: 14vw; }
body.tv .pl .sc { font-size: clamp(1rem, 1.5vw, 1.9rem); }
body.tv .letters i { width: clamp(15px, 1.2vw, 24px); height: clamp(17px, 1.4vw, 27px); font-size: clamp(.62rem, .8vw, 1rem); }
body.tv .banner { font-size: clamp(1.2rem, 2.2vw, 2.6rem); }
body.tv .cat-badge { font-size: clamp(.85rem, 1.2vw, 1.4rem); }
body.tv .timer { height: 1.6vh; min-height: 14px; }
body.tv .link-card .the-link { font-size: clamp(2rem, 5.5vw, 6rem); }
body.tv .answers-row .a { font-size: clamp(1rem, 1.6vw, 2rem); }
body.tv .qr-box { width: clamp(180px, 22vw, 340px); }
body.tv .room-code-big { font-size: clamp(2.6rem, 7vw, 7rem); }
body.tv .players-grid { grid-template-columns: repeat(auto-fill, minmax(clamp(120px, 11vw, 190px), 1fr)); }
body.tv .hostbar { opacity: .35; transition: opacity .2s; }
body.tv .hostbar:hover, body.tv .hostbar:focus-within { opacity: 1; }
.tv-join-hint { display: none; }
body.tv .tv-join-hint { display: flex; align-items: center; gap: .8rem; justify-content: center; font-weight: 700; color: var(--paper-2); font-size: clamp(.9rem, 1.2vw, 1.3rem); }
body.tv .tv-join-hint b { font-family: var(--mono); color: var(--sun); }

/* Phone view when a TV is being used */
.look-tv { display: flex; gap: .5rem; align-items: center; justify-content: center; font-weight: 700; color: var(--paper-2); font-size: .85rem; }
.compact-clues .clue { min-height: 0; padding: 10px 10px 10px 46px; box-shadow: var(--shadow-sm); }
.compact-clues .clue .num { width: 26px; height: 26px; font-size: .9rem; left: 10px; top: 10px; }
.compact-clues .clue .q { font-size: .95rem; }
.compact-clues .clue .a { font-size: .95rem; }

/* ---------- Floating reactions ---------- */
#reactions { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.float-emoji { position: absolute; bottom: -60px; font-size: 2.6rem; animation: float-up 2.6s ease-out forwards; }
.float-emoji small { display: block; font-size: .8rem; font-weight: 800; text-align: center; color: var(--paper); text-shadow: 1px 1px 0 var(--ink); }
@keyframes float-up { 0% { transform: translateY(0) scale(.6); opacity: 0; } 10% { opacity: 1; transform: translateY(-10vh) scale(1.1); } 100% { transform: translateY(-85vh) translateX(var(--dx)) scale(1); opacity: 0; } }
body.tv .float-emoji { font-size: 4.5rem; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--paper); color: var(--ink); border: var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); padding: .7rem 1rem; font-weight: 700; animation: toast-in .3s cubic-bezier(.2, 1.5, .4, 1) both; pointer-events: auto; }
.toast.err { background: #ffd9d9; }
.toast.ok { background: #d4ffe5; }
.toast.out { animation: toast-out .25s ease forwards; }
@keyframes toast-in { from { transform: translateY(-20px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(-14px); opacity: 0; } }

/* ---------- Modals ---------- */
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(10, 5, 25, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fade .2s both; }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; animation: banner-in .3s cubic-bezier(.2, 1.5, .4, 1) both; position: relative; }
.modal .close { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border-radius: 10px; border: 2px solid var(--ink); background: #fff; font-weight: 800; font-size: 1rem; }
.modal h2 { padding-right: 44px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.qr-modal { text-align: center; display: grid; gap: .9rem; justify-items: center; }
.qr-modal .qr-box { width: min(300px, 80vw); box-shadow: none; }
.qr-modal .room-code-big { text-shadow: 3px 3px 0 var(--sun); color: var(--ink); }
.url-box { font-family: var(--mono); font-size: .85rem; background: #f1e7d4; border: 2px solid var(--ink); border-radius: 10px; padding: .5em .8em; word-break: break-all; }
.how ol { padding-left: 1.2rem; margin: .4rem 0; display: grid; gap: .5rem; }
.how li { line-height: 1.4; }
.how .example { background: #f5ecd9; border: 2px solid var(--ink); border-radius: 12px; padding: .7rem .9rem; margin-top: .7rem; font-size: .92rem; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

/* ---------- Pack creator ---------- */
.packs-layout { display: grid; gap: 14px; }
@media (min-width: 900px) { .packs-layout { grid-template-columns: 300px minmax(0, 1fr); align-items: start; } }
.pack-list { display: grid; gap: 8px; }
.pack-item { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border-radius: 14px; border: 2px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); text-align: left; width: 100%; color: var(--paper); }
.pack-item.on { border-color: var(--sun); background: rgba(255,201,60,.14); }
.pack-item .em { font-size: 1.5rem; }
.pack-item .pn { font-weight: 800; }
.pack-item .pc { font-size: .78rem; color: var(--muted); font-weight: 700; }
.card-edit { display: grid; gap: .7rem; border: var(--line); border-radius: var(--r); padding: .9rem; background: #fffdf8; box-shadow: var(--shadow-sm); }
.card-edit .ce-head { display: flex; align-items: center; gap: .5rem; }
.card-edit .ce-head b { font-size: 1.05rem; }
.clue-edit { display: grid; grid-template-columns: 30px 1fr; gap: .5rem; align-items: start; }
.clue-edit .n { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--sun); border: 2px solid var(--ink); font-weight: 800; margin-top: 10px; }
.clue-edit .fields { display: grid; grid-template-columns: 1fr; gap: .4rem; }
@media (min-width: 640px) { .clue-edit .fields { grid-template-columns: 2fr 1fr; } }
.card-mini { display: flex; gap: .6rem; align-items: center; padding: .6rem .8rem; border: 2px solid var(--ink); border-radius: 12px; background: #fff; }
.card-mini .link { font-weight: 800; }
.card-mini .ans { font-size: .8rem; color: #6d6385; }
.card-mini .meta { min-width: 0; flex: 1; }
.card-mini .meta div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-list { color: #b3123e; font-weight: 700; font-size: .88rem; margin: 0; padding-left: 1.1rem; }

/* ---------- Rankings ---------- */
.rank-controls { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.rank-controls .input { max-width: 280px; min-height: 44px; }
.rank-table { display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .8rem; align-items: center; padding: .7rem .9rem; border-radius: 14px; background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.1); cursor: pointer; text-align: left; width: 100%; color: var(--paper); }
.rank-row:hover { background: rgba(255,255,255,.1); }
.rank-row .rk { font-family: var(--mono); font-weight: 700; color: var(--muted); min-width: 3ch; }
.rank-row .lk { font-weight: 800; }
.rank-row .cc { font-size: .78rem; color: var(--muted); font-weight: 700; }
.rank-row .votes { display: flex; gap: .7rem; font-family: var(--mono); font-weight: 700; font-size: .9rem; align-items: center; }
.rank-row .votes .net { min-width: 4ch; text-align: right; padding: .15em .5em; border-radius: 8px; }
.net.pos { background: rgba(46,226,122,.2); color: var(--green); }
.net.neg { background: rgba(255,77,77,.2); color: #ff8c8c; }
.net.zero { background: rgba(255,255,255,.08); color: var(--muted); }
.rank-row .detail { grid-column: 1 / -1; display: grid; gap: .3rem; font-size: .9rem; padding-top: .4rem; border-top: 1px dashed rgba(255,255,255,.15); }
.rank-row .detail b { color: var(--sun); }
.bar-mini { height: 6px; border-radius: 99px; background: rgba(255,77,77,.6); overflow: hidden; width: 70px; }
.bar-mini span { display: block; height: 100%; background: var(--green); }
.stat-row { display: flex; gap: .7rem; flex-wrap: wrap; }
.stat { background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.12); border-radius: 14px; padding: .6rem .9rem; }
.stat b { display: block; font-size: 1.5rem; font-family: var(--mono); color: var(--sun); }
.stat span { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* Connecting overlay */
.overlay-msg { position: fixed; inset: 0; z-index: 75; display: grid; place-items: center; background: rgba(10,5,25,.8); backdrop-filter: blur(4px); padding: 16px; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 6px solid rgba(255,255,255,.15); border-top-color: var(--sun); animation: spin .8s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Phone tweaks ---------- */
@media (max-width: 600px) {
  .topbar { gap: .35rem; padding: 8px 10px; }
  .topbar .logo.sm { display: none; }
  .topbar .icon-btn { width: 36px; height: 36px; font-size: 1rem; border-radius: 10px; }
  .code-chip { font-size: .82rem; padding: .3em .55em; white-space: nowrap; }
  .card-count { font-size: .8rem; }
  .room-body { padding: 10px 12px; gap: 10px; }
  .clue { min-height: 0; }
  .clue.hidden { min-height: 0; padding-top: 10px; padding-bottom: 10px; }
  .clue.hidden .num { top: 6px; }
  .stage-head .cat-badge { font-size: .75rem; }
  .pl { padding: .35rem .55rem .35rem .35rem; }
  .pl .av { width: 32px; height: 32px; font-size: 1.1rem; }
  .buzzer { height: 88px; }
}
