:root {
  --bg: #f7f2ea; --bg2: #efe6d8; --card: #ffffff; --ink: #221f33; --mute: #7a7590; --line: #e7dfd0;
  --me: #ff5f6d; --opp: #14b8a6;
  --me-d: color-mix(in srgb, var(--me) 76%, #000); --opp-d: color-mix(in srgb, var(--opp) 76%, #000);
  --me-l: color-mix(in srgb, var(--me) 62%, #fff); --opp-l: color-mix(in srgb, var(--opp) 62%, #fff);
  --gold: #ffc43d; --gold-d: #e0a000; --ok: #22c55e; --bad: #ef4444;
  --shadow: 0 14px 30px -16px rgba(34, 31, 51, .35);
  --r: 22px;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14121f; --bg2: #1b1829; --card: #231f36; --ink: #f4f1ff; --mute: #a29cc0; --line: #342f4d;
    --shadow: 0 14px 30px -16px rgba(0, 0, 0, .7);
  }
  meta[name=theme-color] { content: #14121f }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); color: var(--ink); background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--me) 14%, transparent), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, color-mix(in srgb, var(--opp) 14%, transparent), transparent 60%);
  background-attachment: fixed;
  min-height: 100dvh; overflow-x: hidden;
}
#app { max-width: 560px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 16px calc(86px + env(safe-area-inset-bottom)); min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; display: flex; flex-direction: column; }
.screen { display: flex; flex-direction: column; gap: 14px; animation: screenIn .35s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h2 { font-size: 26px; font-weight: 900; }
.muted { color: var(--mute); font-weight: 700; margin: 0; }
.center { text-align: center; }
.status { min-height: 1.3em; margin: 6px 0 0; text-align: center; font-weight: 800; color: var(--mute); font-size: 14px; }
.status.err { color: var(--bad); }
.lbl { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; font-weight: 900; color: var(--mute); margin: 0 0 6px; }

/* ---------- cards & buttons ---------- */
.card { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.btn {
  font: inherit; font-weight: 900; font-size: 16px; color: var(--ink); background: var(--card);
  border: 2px solid var(--line); border-bottom-width: 5px; border-radius: 16px; padding: 12px 18px; cursor: pointer;
  transition: transform .08s, filter .15s, border-bottom-width .08s; user-select: none; position: relative; overflow: hidden;
}
.btn:hover { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(3px); border-bottom-width: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--me); border-color: var(--me-d); color: #fff; }
.btn.big { width: 100%; padding: 16px; font-size: 18px; }
.btn.small { padding: 8px 12px; font-size: 14px; border-bottom-width: 4px; }
.btnrow { display: flex; gap: 10px; }
.btnrow .btn { flex: 1; }
.iconbtn { font: inherit; font-size: 18px; background: var(--card); border: 1px solid var(--line); color: var(--ink); width: 42px; height: 42px; border-radius: 14px; cursor: pointer; box-shadow: var(--shadow); }
.iconbtn:active { transform: scale(.94); }
.field {
  width: 100%; font: inherit; font-weight: 800; font-size: 18px; color: var(--ink); background: var(--bg);
  border: 2px solid var(--line); border-radius: 14px; padding: 13px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: var(--me); box-shadow: 0 0 0 4px color-mix(in srgb, var(--me) 20%, transparent); }
.field.code { text-transform: uppercase; letter-spacing: .25em; text-align: center; }

/* ---------- home ---------- */
.logo { text-align: center; padding: 18px 0 4px; }
.logo h1 { font-size: 46px; font-weight: 900; margin-top: 8px; }
.tag { color: var(--mute); font-weight: 800; margin: 4px 0 0; }
.logo-tiles { display: inline-flex; gap: 8px; }
.logo-tiles span {
  width: 54px; height: 54px; border-radius: 15px; display: grid; place-items: center; font-weight: 900; font-size: 28px; color: #fff;
  background: linear-gradient(160deg, var(--me), var(--me-d)); box-shadow: 0 5px 0 var(--me-d);
  animation: bob 3s ease-in-out infinite;
}
.logo-tiles span:nth-child(2) { background: linear-gradient(160deg, var(--gold), var(--gold-d)); box-shadow: 0 5px 0 var(--gold-d); animation-delay: .25s; color: #3b2a00; }
.logo-tiles span:nth-child(3) { background: linear-gradient(160deg, var(--opp), var(--opp-d)); box-shadow: 0 5px 0 var(--opp-d); animation-delay: .5s; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg) } 50% { transform: translateY(-7px) rotate(3deg) } }
.invite { background: color-mix(in srgb, var(--gold) 25%, var(--card)); border: 2px dashed var(--gold-d); border-radius: 14px; padding: 10px 12px; font-weight: 800; margin-bottom: 14px; text-align: center; }
.avrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.avrow button { font-size: 24px; width: 44px; height: 44px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); cursor: pointer; transition: transform .12s; }
.avrow button:hover { transform: translateY(-2px); }
.avrow button[aria-checked=true] { border-color: var(--me); background: color-mix(in srgb, var(--me) 14%, var(--card)); transform: scale(1.08); }
.or { display: flex; align-items: center; gap: 10px; color: var(--mute); font-weight: 800; font-size: 13px; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 2px; background: var(--line); border-radius: 2px; }
.joinrow { display: flex; gap: 10px; }
.levelcard { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.lvl-badge { width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 20px; color: #3b2a00; background: radial-gradient(circle at 30% 25%, #ffe38a, var(--gold)); box-shadow: 0 3px 0 var(--gold-d); }
.lvl-body { flex: 1; min-width: 0; }
.lvl-top { display: flex; justify-content: space-between; font-weight: 900; font-size: 14px; margin-bottom: 6px; }
.lvl-top span { color: var(--mute); }
.bar { height: 10px; background: var(--bg2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #ff9f43); border-radius: 99px; transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.how { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; font-weight: 700; color: var(--mute); }
.how summary { cursor: pointer; font-weight: 900; color: var(--ink); }
.how ol { padding-left: 20px; margin: 10px 0; line-height: 1.5; }
.how p { margin: 0 0 4px; line-height: 1.5; }

/* ---------- scoreboard ---------- */
#topbar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 14px; }
.pcard { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 8px 10px; box-shadow: var(--shadow); min-width: 0; }
.pcard.opp { justify-content: flex-end; }
.pcard .av { font-size: 26px; line-height: 1; }
.pmeta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.pmeta.right { align-items: flex-end; }
.pmeta b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sc { font-weight: 900; font-size: 28px; min-width: 1ch; text-align: center; }
.pcard.me .sc { color: var(--me); } .pcard.opp .sc { color: var(--opp); }
.sc.bump { animation: bump .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump { 0% { transform: scale(1) } 40% { transform: scale(1.7) rotate(-6deg) } 100% { transform: scale(1) } }
.pips { display: flex; gap: 4px; flex-wrap: wrap; }
.pmeta.right .pips { justify-content: flex-end; }
.pips i { width: 9px; height: 9px; border-radius: 50%; background: var(--bg2); transition: background .3s, transform .3s; }
.pcard.me .pips i.on { background: var(--me); transform: scale(1.15); } .pcard.opp .pips i.on { background: var(--opp); transform: scale(1.15); }
.vs { text-align: center; line-height: 1.15; } .vs span { display: block; font-weight: 900; font-size: 13px; } .vs small { color: var(--mute); font-weight: 800; font-size: 11px; }

/* ---------- lobby ---------- */
.roomcode { font-size: 36px; font-weight: 900; letter-spacing: .14em; padding-left: .14em; color: var(--me); }
.sharebox { margin: 12px 0; } .sharebox .field { font-size: 14px; text-align: center; }
.versus { display: flex; align-items: center; justify-content: space-around; gap: 6px; }
.vplayer { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 16px; min-width: 0; }
.vplayer b { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bigav { font-size: 44px; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); border: 4px solid var(--line); }
.vplayer.me .bigav { border-color: var(--me); } .vplayer.opp .bigav { border-color: var(--opp); }
.vplayer.opp.waiting .bigav { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .6 } }
.vsdot { font-weight: 900; color: var(--mute); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.seg button { font: inherit; font-weight: 900; font-size: 18px; color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; }
.seg button.on { background: var(--me); color: #fff; border-color: var(--me-d); }

/* ---------- tiles ---------- */
.tile { --size: clamp(92px, 27vw, 128px); width: var(--size); height: var(--size); perspective: 700px; flex: none; }
.tile.big { --size: clamp(110px, 32vw, 150px); }
.tile .inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.3, 1.4, .5, 1); }
.tile.flipped .inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 26px;
  display: grid; place-items: center; font-weight: 900; font-size: calc(var(--size) * .58); line-height: 1;
}
.face.front {
  color: color-mix(in srgb, var(--ink) 35%, transparent); background:
    repeating-linear-gradient(45deg, transparent 0 10px, color-mix(in srgb, var(--ink) 5%, transparent) 10px 20px), var(--card);
  border: 3px dashed var(--line); font-size: calc(var(--size) * .45);
}
.face.back { transform: rotateY(180deg); color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, .18); }
.tile.me .face.back { background: linear-gradient(160deg, var(--me-l), var(--me) 55%, var(--me-d)); box-shadow: 0 8px 0 var(--me-d), 0 18px 28px -10px color-mix(in srgb, var(--me) 60%, transparent); }
.tile.opp .face.back { background: linear-gradient(160deg, var(--opp-l), var(--opp) 55%, var(--opp-d)); box-shadow: 0 8px 0 var(--opp-d), 0 18px 28px -10px color-mix(in srgb, var(--opp) 60%, transparent); }
.tile.pop { animation: pop .45s cubic-bezier(.2, 1.7, .4, 1); }
@keyframes pop { 0% { transform: scale(.7) } 100% { transform: scale(1) } }
.tile.locked .face.front { border-style: solid; border-color: var(--me); color: var(--me); }

/* ---------- pick ---------- */
.stagehead { text-align: center; padding-top: 6px; }
.pickrow { display: flex; flex-direction: column; align-items: center; gap: 14px; margin: 4px 0; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 7px 14px; font-weight: 800; font-size: 14px; color: var(--mute); box-shadow: var(--shadow); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mute); animation: blink 1.2s infinite; }
.chip.ok { color: var(--opp-d); } .chip.ok .dot { background: var(--ok); animation: none; }
@keyframes blink { 50% { opacity: .25 } }
.kbd { display: flex; flex-direction: column; gap: 7px; align-items: center; margin: 4px 0; }
.kbd .row { display: flex; gap: 5px; justify-content: center; width: 100%; }
.kbd button {
  flex: 1; max-width: 46px; aspect-ratio: 1 / 1.15; font: inherit; font-weight: 900; font-size: clamp(16px, 4.6vw, 21px); color: var(--ink);
  background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 11px; cursor: pointer; transition: transform .08s;
}
.kbd button:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.kbd button.sel { background: var(--me); color: #fff; border-color: var(--me-d); transform: translateY(-3px) scale(1.08); }
.kbd button:disabled { opacity: .5; }

/* ---------- round ---------- */
.timerbar { height: 8px; border-radius: 99px; background: var(--bg2); overflow: hidden; }
.timerbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--opp), var(--gold) 60%, var(--bad)); background-size: 300% 100%; background-position: 0 0; border-radius: 99px; transform-origin: left; }
.tilerow { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 4vw, 26px); margin-top: 8px; }
.tilewrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.who { font-size: 12px; font-weight: 900; color: var(--mute); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arrows { font-size: 34px; font-weight: 900; color: var(--mute); }
.rule { text-align: center; margin: 2px 0 0; font-weight: 800; color: var(--mute); min-height: 1.4em; }
.rule b { color: var(--ink); }
.diff { align-self: center; font-weight: 900; font-size: 13px; padding: 5px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); animation: pop .5s both; }
.diff.t0 { color: #16a34a } .diff.t1 { color: #0891b2 } .diff.t2 { color: #ea580c } .diff.t3 { color: #dc2626 } .diff.t4 { color: #a21caf }
.countdown { height: 96px; display: grid; place-items: center; font-size: 76px; font-weight: 900; color: var(--gold-d); }
.countdown span { display: block; animation: cd .9s ease-out both; }
.countdown span.go { color: var(--ok); font-size: 64px; }
@keyframes cd { 0% { transform: scale(2.2); opacity: 0 } 25% { opacity: 1 } 100% { transform: scale(.9); opacity: .15 } }
#guessform { display: flex; gap: 10px; }
.field.guess { font-size: 22px; text-align: center; letter-spacing: .04em; text-transform: lowercase; }
.field.guess:disabled { opacity: .5; }
#guessform.shake { animation: shake .4s; }
#guessform.shake .field { border-color: var(--bad); }
@keyframes shake { 20%, 60% { transform: translateX(-9px) } 40%, 80% { transform: translateX(9px) } }
#guessform .btn { padding-inline: 22px; }
.feedback { text-align: center; margin: 0; min-height: 1.4em; font-weight: 800; color: var(--bad); }
.feedback.ok { color: var(--ok); }
.oppchip { align-self: center; }
.hint { align-self: center; background: color-mix(in srgb, var(--gold) 25%, var(--card)); border: 2px dashed var(--gold-d); border-radius: 14px; padding: 10px 16px; font-weight: 800; text-align: center; animation: pop .5s both; }
.hint code { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .3em; font-size: 20px; margin-top: 4px; }

/* ---------- result ---------- */
.resultcard { overflow: hidden; position: relative; }
.r-emoji { font-size: 64px; animation: pop .6s cubic-bezier(.2, 1.7, .4, 1) both; }
.resultcard h2 { margin: 6px 0 2px; }
.wordtiles { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; margin: 16px 0 10px; }
.wordtiles span { min-width: 32px; height: 40px; padding: 0 3px; display: grid; place-items: center; font-weight: 900; font-size: 20px; text-transform: uppercase; border-radius: 9px; background: var(--bg); border: 2px solid var(--line); animation: letterIn .4s cubic-bezier(.2, 1.7, .4, 1) both; }
.wordtiles span.edge { background: var(--gold); border-color: var(--gold-d); color: #3b2a00; box-shadow: 0 3px 0 var(--gold-d); }
@keyframes letterIn { from { transform: translateY(-14px) scale(.5); opacity: 0 } to { transform: none; opacity: 1 } }
.r-stats { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.stat { background: var(--bg); border-radius: 14px; padding: 8px 14px; font-weight: 800; font-size: 13px; color: var(--mute); }
.stat b { display: block; font-size: 20px; color: var(--ink); }
.xp { margin-top: 14px; font-weight: 900; color: var(--gold-d); animation: pop .6s .5s cubic-bezier(.2, 1.7, .4, 1) both; }
.xp small { display: block; color: var(--mute); font-weight: 800; font-size: 12px; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips span { background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; font-weight: 800; font-size: 14px; }
.chips span.long { background: color-mix(in srgb, var(--opp) 18%, var(--card)); border-color: var(--opp); }
#btn-ready .ring { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: rgba(255, 255, 255, .55); transform-origin: left; transform: scaleX(0); }

/* ---------- final ---------- */
.trophy { font-size: 78px; animation: trophy 1.6s ease-in-out infinite; }
@keyframes trophy { 50% { transform: translateY(-8px) rotate(5deg) } }
.f-score { display: flex; justify-content: center; align-items: baseline; gap: 14px; font-size: 52px; font-weight: 900; margin: 4px 0; }
.f-score span:first-child { color: var(--me); } .f-score span:last-child { color: var(--opp); } .f-score i { color: var(--mute); font-style: normal; }
.recap { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recap li { display: flex; align-items: center; gap: 10px; font-weight: 800; padding: 8px 12px; background: var(--bg); border-radius: 12px; }
.recap li .n { color: var(--mute); width: 22px; font-size: 13px; }
.recap li .w { flex: 1; text-transform: uppercase; letter-spacing: .06em; }
.recap li .t { color: var(--mute); font-size: 13px; }

/* ---------- footer / misc ---------- */
#foot { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; pointer-events: none; }
#foot > * { pointer-events: auto; }
.ping { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: var(--mute); }
.ping i { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.ping.mid i { background: var(--gold); } .ping.bad i { background: var(--bad); }
#reactbar { position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 6px; z-index: 5; }
#reactbar button { font-size: 22px; width: 44px; height: 44px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer; transition: transform .1s; }
#reactbar button:active { transform: scale(.8); }
#floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.floater { position: absolute; bottom: 90px; font-size: 40px; animation: floatUp 2.6s ease-out forwards; text-align: center; }
.floater small { display: block; font-size: 11px; font-weight: 900; color: var(--mute); }
@keyframes floatUp { 0% { transform: translateY(0) scale(.4); opacity: 0 } 15% { opacity: 1; transform: translateY(-30px) scale(1.2) } 100% { transform: translateY(-62vh) translateX(var(--dx, 0)) scale(1); opacity: 0 } }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
#toasts { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); font-weight: 800; padding: 10px 16px; border-radius: 14px; box-shadow: var(--shadow); max-width: min(92vw, 420px); animation: toastIn .35s cubic-bezier(.2, 1.4, .4, 1), toastOut .3s 3.2s forwards; text-align: center; font-size: 14px; }
.toast.ach { display: flex; align-items: center; gap: 12px; text-align: left; background: linear-gradient(120deg, #3b2a00, #6b4a00); color: #fff3c4; border: 2px solid var(--gold); }
.toast.ach .i { font-size: 32px; } .toast.ach b { display: block; color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
@keyframes toastIn { from { transform: translateY(-30px) scale(.8); opacity: 0 } }
@keyframes toastOut { to { transform: translateY(-20px); opacity: 0 } }
.conn { position: fixed; inset: 0; z-index: 45; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(4px); display: grid; place-items: center; text-align: center; font-weight: 900; font-size: 18px; padding: 30px; }
.conn small { display: block; color: var(--mute); font-weight: 700; margin-top: 8px; font-size: 14px; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--me); margin: 0 auto 16px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* modal */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(10, 8, 20, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0 } }
.sheet { width: 100%; max-width: 560px; max-height: 88dvh; overflow: auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 18px 18px calc(24px + env(safe-area-inset-bottom)); animation: sheet .3s cubic-bezier(.2, 1, .3, 1); }
@keyframes sheet { from { transform: translateY(40px); opacity: 0 } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.statgrid .stat { text-align: center; background: var(--card); border: 1px solid var(--line); }
.achgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.ach .i { font-size: 28px; } .ach b { display: block; font-size: 14px; } .ach small { color: var(--mute); font-weight: 700; font-size: 12px; line-height: 1.2; display: block; }
.ach.locked { opacity: .45; filter: grayscale(1); }

@media (max-height: 700px) { .countdown { height: 70px; font-size: 56px; } .logo { padding-top: 4px; } }

/* ---------- mobile polish ---------- */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
.field.guess { font-size: 22px; }
body:has(#guess:focus) #reactbar, body:has(#guess:focus) #foot { display: none; }
@media (max-width: 400px) {
  #app { padding-left: 12px; padding-right: 12px; }
  .pcard { padding: 6px 8px; gap: 5px; } .pcard .av { font-size: 22px; } .sc { font-size: 24px; }
  .pips i { width: 7px; height: 7px; } .logo h1 { font-size: 38px; }
  #reactbar { gap: 4px; } #reactbar button { width: 40px; height: 40px; font-size: 20px; }
}
@media (max-height: 640px) {
  .tile { --size: clamp(70px, 22vw, 96px); } .tile.big { --size: clamp(84px, 26vw, 110px); }
  .countdown { height: 56px; font-size: 44px; } h2 { font-size: 22px; }
}


.colrow { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 18px; }
.colrow button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--line); cursor: pointer; }
.colrow button[aria-checked=true] { box-shadow: 0 0 0 3px var(--ink); }
.txtbtn { font: inherit; font-weight: 800; font-size: 13px; color: var(--mute); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px; cursor: pointer; }
.ach .i:empty, .toast.ach .i:empty { display: none; }

body:has(#reactbar:not([hidden])) #app { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }
body:has(#guess:focus) #app { padding-bottom: 12px !important; }

/* ================= v4 polish ================= */
/* ambient loops stay off; motion is for feedback only */
.logo-tiles span, .trophy, .chip .dot, .vplayer.opp.waiting .bigav, .hint { animation: none !important; }
.screen { animation-duration: .18s; }
.countdown { display: none; }
.build { font-size: 11px; opacity: .5; margin: 4px 0 0; }

/* lock the page to the visual viewport (no keyboard zoom/jump) */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; width: 100%; }
#app { position: fixed; top: var(--vvt, 0px); left: 0; right: 0; margin: 0 auto; height: var(--vvh, 100dvh); min-height: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
body.kb #foot, body.kb #rule, body.kb #diff, body.kb .stagehead { display: none !important; }
body.kb #app { padding-top: 8px; padding-bottom: 8px !important; gap: 0; }
body.kb #topbar { margin-bottom: 8px; }
body.kb .pips { display: none; }
body.kb .screen { gap: 8px; }
body.kb .tile { --size: 62px; } body.kb .tile .face.back { box-shadow: 0 4px 0 var(--me-d); border-radius: 16px; } body.kb .tile.opp .face.back { box-shadow: 0 4px 0 var(--opp-d); }
body.kb .tilerow { margin: 0; gap: 14px; } body.kb .tilewrap { gap: 4px; } body.kb .arrows { font-size: 22px; } body.kb .who { display: none; }
body.kb .timerbar { height: 5px; }
body.kb .hint { padding: 5px 10px; font-size: 13px; } body.kb .hint code { font-size: 15px; margin-top: 0; }
body.kb .chip { padding: 4px 10px; font-size: 12px; }

/* reactions: each emoji has its own personality */
#reactbar button .e, .floater .e { display: inline-block; transform-origin: 50% 70%; }
#reactbar button.hit[data-k=heart] .e, .floater .e[data-k=heart] { animation: heartPound .9s ease-out; }
#reactbar button.hit[data-k=fire] .e, .floater .e[data-k=fire] { animation: fireWiggle .9s ease-in-out; }
#reactbar button.hit[data-k=clap] .e, .floater .e[data-k=clap] { animation: clap .8s ease-in-out; }
#reactbar button.hit[data-k=laugh] .e, .floater .e[data-k=laugh] { animation: laugh .8s ease-in-out; }
#reactbar button.hit[data-k=cry] .e, .floater .e[data-k=cry] { animation: cry .9s ease-in-out; }
#reactbar button.hit[data-k=angry] .e, .floater .e[data-k=angry] { animation: angry .6s ease-in-out; }
#reactbar button.hit[data-k=melt] .e, .floater .e[data-k=melt] { animation: melt .9s ease-in-out; }
@keyframes heartPound { 0% { transform: scale(1) } 14% { transform: scale(1.65) } 28% { transform: scale(1.05) } 42% { transform: scale(1.55) } 70%, 100% { transform: scale(1) } }
@keyframes fireWiggle { 0%, 100% { transform: rotate(0) scale(1) } 18% { transform: rotate(-16deg) scale(1.15, 1.4) } 38% { transform: rotate(13deg) scale(1.05, 1.45) } 58% { transform: rotate(-11deg) scale(1.15, 1.3) } 78% { transform: rotate(8deg) scale(1.05, 1.35) } }
@keyframes clap { 0%, 100% { transform: scale(1) rotate(0) } 15% { transform: scale(1.35) rotate(-20deg) } 30% { transform: scale(.8) rotate(8deg) } 45% { transform: scale(1.35) rotate(-20deg) } 60% { transform: scale(.8) rotate(8deg) } 78% { transform: scale(1.2) rotate(-10deg) } }
@keyframes laugh { 0%, 100% { transform: translateY(0) rotate(0) } 15% { transform: translateY(-9px) rotate(-14deg) } 30% { transform: translateY(0) rotate(11deg) } 45% { transform: translateY(-9px) rotate(-14deg) } 60% { transform: translateY(0) rotate(11deg) } 78% { transform: translateY(-5px) rotate(-6deg) } }
@keyframes cry { 0%, 100% { transform: translateY(0) scale(1) } 22% { transform: translateY(5px) scale(1.18, .88) } 44% { transform: translateY(-3px) scale(.92, 1.12) } 66% { transform: translateY(5px) scale(1.18, .88) } }
@keyframes angry { 0%, 100% { transform: translateX(0) scale(1) } 15% { transform: translateX(-6px) scale(1.3) } 30% { transform: translateX(6px) scale(1.3) } 45% { transform: translateX(-5px) scale(1.25) } 60% { transform: translateX(5px) scale(1.2) } 80% { transform: translateX(-2px) scale(1.1) } }
@keyframes melt { 0%, 100% { transform: scale(1) } 30% { transform: scale(1.35, .6) translateY(6px) } 55% { transform: scale(.85, 1.3) translateY(-4px) } 75% { transform: scale(1.15, .85) } }
#reactbar button { transition: transform .1s; } #reactbar button:active { transform: scale(.85); }
.floater { font-size: 44px; } .floater.poof { font-size: 34px; font-weight: 900; color: var(--mute); bottom: 40%; animation: poof 2s ease-out forwards; }
@keyframes poof { 0% { transform: scale(.3); opacity: 0 } 20% { transform: scale(1.3); opacity: 1 } 100% { transform: translateY(-40px) scale(2); opacity: 0 } }

/* fart button (winner only) */
.fartbtn { width: 100%; background: color-mix(in srgb, var(--gold) 28%, var(--card)); border-color: var(--gold-d); }
.fartbtn.hit { animation: squish .35s ease-out; }
@keyframes squish { 0% { transform: scale(1) } 30% { transform: scale(1.06, .88) } 60% { transform: scale(.97, 1.05) } 100% { transform: scale(1) } }
body.farted #app { animation: farted .7s ease-out; }
@keyframes farted { 0%, 100% { transform: translate(0) } 10% { transform: translate(-7px, 2px) } 20% { transform: translate(7px, -2px) } 30% { transform: translate(-6px, 2px) } 45% { transform: translate(5px) } 60% { transform: translate(-3px) } 80% { transform: translate(2px) } }

/* tactile polish */
.kbd button { transition: transform .06s, background .1s; }
.btn { transition: transform .08s, border-bottom-width .08s, filter .12s; }
.tile .inner { transition: transform .45s cubic-bezier(.3, 1.4, .5, 1); }
.pips i { transition: background .2s, transform .25s cubic-bezier(.3, 1.8, .5, 1); }

/* ================= v4 flow: one persistent input ================= */
#app { display: flex; flex-direction: column; padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important; }
main { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
#reactbar { position: static !important; bottom: auto !important; padding: 4px 0; gap: 6px; flex: none; }
#reactbar button { width: 38px; height: 38px; font-size: 19px; }
#foot { position: static !important; padding: 4px 0 0; flex: none; }
#dock { flex: none; padding: 6px 0 2px; }
#dock form { display: flex; gap: 8px; }
#guess[data-mode=pick] { text-transform: uppercase; text-align: center; font-size: 28px; font-weight: 900; }
#guess[data-mode=result] { opacity: .55; }
body:has(#reactbar:not([hidden])) #app { padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important; }
body.kb .tile.big { --size: 84px; }
body.kb .pickrow { gap: 8px; margin: 0; }
body.kb .r-stats, body.kb #examples-card, body.kb .resultcard .muted { display: none; }
body.kb .resultcard { padding: 12px; } body.kb .wordtiles { margin: 8px 0 4px; } body.kb .resultcard h2 { font-size: 22px; }
body.kb .xp { margin-top: 6px; }

/* centre emoji in their boxes */
.avrow button, #reactbar button { display: grid; place-items: center; padding: 0; line-height: 1; }
.avrow button { font-size: 24px; } #reactbar button .e { display: block; line-height: 1; }

/* keep reactions visible while typing; tighter result card on phones */
body:has(#guess:focus) #reactbar { display: flex !important; }
body.kb .resultcard { padding: 8px 12px; } body.kb .xp small { display: none; } body.kb .r-sub, body.kb #r-sub { display: none; }
body.kb .wordtiles span { min-width: 26px; height: 32px; font-size: 16px; } body.kb .resultcard h2 { margin: 0; font-size: 20px; }
body.kb .fartbtn { padding: 10px; }

/* GO cue: obvious, instant, non-blocking */
#gosign { position: fixed; left: 0; right: 0; top: 32%; text-align: center; font-size: clamp(88px, 28vw, 150px); font-weight: 900; letter-spacing: .04em; color: #fff; -webkit-text-stroke: 3px var(--me-d); text-shadow: 0 8px 0 var(--me-d), 0 0 40px color-mix(in srgb, var(--me) 70%, transparent); pointer-events: none; z-index: 35; opacity: 0; }
#gosign.on { animation: goPop .7s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes goPop { 0% { transform: scale(.3) rotate(-8deg); opacity: 0 } 25% { transform: scale(1.15) rotate(3deg); opacity: 1 } 70% { transform: scale(1); opacity: 1 } 100% { transform: scale(1.4); opacity: 0 } }
#app.goflash::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 34; border: 6px solid var(--ok); border-radius: 0; animation: goBorder .6s ease-out forwards; }
@keyframes goBorder { 0% { opacity: 1; background: color-mix(in srgb, var(--ok) 22%, transparent) } 100% { opacity: 0; background: transparent } }

.small-note { font-size: 13px; margin: 8px 0 12px; line-height: 1.35; }
#home-actions .btnrow { margin-top: 4px; }
.roomcode { font-size: clamp(24px, 8vw, 36px) !important; word-break: break-all; }

#topbar { cursor: pointer; }

/* ================= v12: characters, customisation, crowns, streaks ================= */
.avsvg, .icsvg { display: block; width: 100%; height: 100%; overflow: visible; }
.av, .bigav { font-size: 0 !important; }
.pcard .av { width: 38px; height: 40px; flex: none; }
.bigav { width: 92px !important; height: 92px !important; border: none !important; background: none !important; }
.bigav .qmark, .av .qmark { font-size: 40px; font-weight: 900; color: var(--mute); display: grid; place-items: center; height: 100%; }
.vplayer.me .bigav, .vplayer.opp .bigav { border: none !important; }
.mepreview { display: flex; align-items: center; gap: 12px; margin: 12px 0 16px; }
.mepreview .av { width: 58px; height: 62px; flex: none; }
.mp-name { flex: 1; font-weight: 900; font-size: 18px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crown { display: inline-flex; vertical-align: -2px; margin-left: 4px; }
.crown.t1 { color: #cd7f32; } .crown.t2 { color: #c0c8d4; } .crown.t3 { color: #ffc43d; filter: drop-shadow(0 0 4px rgba(255, 196, 61, .6)); }
.streak { color: var(--gold-d); font-weight: 900; font-size: 11px; line-height: 1; }
.avpreview { width: 150px; height: 160px; margin: 4px auto 14px; }
.cgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.cgrid button { position: relative; aspect-ratio: 1; border-radius: 16px; border: 2px solid var(--line); background: var(--card); cursor: pointer; padding: 8px 6px 4px; overflow: visible; }
.cgrid button[aria-checked=true] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.cgrid.cols { grid-template-columns: repeat(8, 1fr); }
.cgrid.cols button { border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--line); padding: 0; }
.cgrid.cols button[aria-checked=true] { box-shadow: 0 0 0 3px var(--ink); }
.cgrid button.locked { opacity: .4; filter: grayscale(1); }
.cgrid button.locked::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 15px; height: 15px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 10V8a6 6 0 1 1 12 0v2h1a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V11a1 1 0 0 1 1-1zm2 0h8V8a4 4 0 1 0-8 0z' fill='%23888'/%3E%3C/svg%3E") center / contain no-repeat; }
.recap .t { display: flex; align-items: center; gap: 6px; }
.recap .mini { width: 24px; height: 26px; display: inline-block; }
#reactbar button .e { display: block; width: 26px; height: 26px; }
.floater .e { display: block; width: 50px; height: 50px; }
.floater .e.puffbig { width: var(--sz, 50px); height: var(--sz, 50px); }
.floater small { display: block; text-align: center; }
.tile.hot .face.back { box-shadow: 0 8px 0 var(--me-d), 0 0 0 4px rgba(255, 196, 61, .55), 0 0 30px 8px rgba(255, 196, 61, .55); }
.tile.opp.hot .face.back { box-shadow: 0 8px 0 var(--opp-d), 0 0 0 4px rgba(255, 196, 61, .55), 0 0 30px 8px rgba(255, 196, 61, .55); }
.tile.hot2 .face.back { box-shadow: 0 8px 0 var(--me-d), 0 0 0 5px #ffc43d, 0 0 46px 14px rgba(255, 196, 61, .8); }
.tile.opp.hot2 .face.back { box-shadow: 0 8px 0 var(--opp-d), 0 0 0 5px #ffc43d, 0 0 46px 14px rgba(255, 196, 61, .8); }
.small-note { font-size: 13px; margin: 8px 0 12px; line-height: 1.35; }
#btn-reconnect { margin-top: 8px; }
.roomcode { font-size: clamp(24px, 8vw, 36px) !important; word-break: break-all; }
html[data-theme=ocean] { --bg: #08161f; --bg2: #0e2230; --card: #10283a; --ink: #e8f6ff; --mute: #8fb3c7; --line: #1c3d55; }
html[data-theme=sunset] { --bg: #1d0f1c; --bg2: #2a1426; --card: #2c1829; --ink: #fff1e8; --mute: #c9a3b3; --line: #44253d; }
html[data-theme=forest] { --bg: #0d1a12; --bg2: #13271b; --card: #16301f; --ink: #eafff0; --mute: #8fb99b; --line: #244632; }
html[data-theme=candy] { --bg: #fff0f6; --bg2: #ffe0ee; --card: #ffffff; --ink: #3b1030; --mute: #a06a8c; --line: #f6cfe2; }

/* ================= v13: app shell ================= */
.hero { text-align: center; padding: 6px 0 0; }
.hero h1 { font-size: 38px; font-weight: 900; margin-top: 6px; }
.hero .logo-tiles span { width: 44px; height: 44px; font-size: 23px; border-radius: 13px; }
.profilechip { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; padding: 12px 14px; }
.profilechip:active { transform: scale(.985); }
.profilechip .av { width: 54px; height: 58px; flex: none; }
.pc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pc-name { font-weight: 900; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-sub { font-size: 12px; font-weight: 800; color: var(--mute); }
.chev { font-size: 26px; color: var(--mute); font-weight: 900; }
.goalspeek { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; padding: 14px; }
.gp-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 15px; } .gp-head span { color: var(--mute); font-weight: 900; }
.gp-rows { display: flex; flex-direction: column; gap: 6px; }
.gp-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 800; color: var(--mute); }
.gp-row.done { color: var(--ok); } .gp-p { flex: none; }
.playcard .btn.big { margin-top: 4px; }
#tabbar { display: flex; flex: none; gap: 2px; margin: 0 -16px; padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--card) 92%, transparent); border-top: 1px solid var(--line); }
#tabbar[hidden] { display: none; }
#tabbar button { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 4px; font: inherit; border: 0; background: none; color: var(--mute); cursor: pointer; border-radius: 14px; }
#tabbar button .tl { font-size: 11px; font-weight: 900; }
#tabbar button.on { color: var(--me); }
#tabbar button:active { transform: scale(.92); }
.dotbadge { position: absolute; top: 4px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--me); border: 2px solid var(--card); }
.tabhead { padding: 4px 2px 0; } .tabhead h2 { font-size: 28px; } .tabhead p { margin-top: 2px; }
.stage { text-align: center; padding: 16px 16px 14px; }
.stage-av { width: 150px; height: 158px; margin: 4px auto 8px; } .stage-name { font-weight: 900; font-size: 20px; margin-bottom: 10px; }
.stage .btnrow { justify-content: center; } .stage .btnrow .btn { flex: 0 0 auto; }
.cattabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.cattabs::-webkit-scrollbar { display: none; }
.cattabs button { flex: none; font: inherit; font-weight: 900; font-size: 14px; padding: 9px 14px; border-radius: 99px; border: 2px solid var(--line); background: var(--card); color: var(--mute); cursor: pointer; }
.cattabs button.on { background: var(--me); border-color: var(--me-d); color: #fff; }
.cgrid .item { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 8px 4px 6px; aspect-ratio: auto; gap: 4px; }
.cgrid .item .iv { display: block; width: 100%; height: 74px; } .cgrid .item .in { font-size: 11px; font-weight: 800; color: var(--mute); line-height: 1.1; text-align: center; }
.cgrid .item[aria-checked=true] .in { color: var(--ink); }
.cgrid .item:active, .themecard:active, .cgrid.cols button:active { transform: scale(.94); }
.cgrid.mini { grid-template-columns: repeat(6, 1fr); gap: 6px; } .cgrid.mini button { aspect-ratio: 1; padding: 4px 2px; border-radius: 12px; } .cgrid.mini .iv { display: block; width: 100%; height: 100%; }
.themegrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.themecard { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 8px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); cursor: pointer; font: inherit; color: var(--ink); }
.themecard[aria-checked=true] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.themecard .tp { display: block; width: 100%; height: 54px; border-radius: 10px; } .themecard .tn { font-size: 12px; font-weight: 900; }
.goal { display: flex; align-items: center; gap: 12px; padding: 14px; }
.g-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; } .g-main b { font-size: 15px; }
.g-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.xpchip { font-size: 12px; font-weight: 900; color: var(--gold-d); background: color-mix(in srgb, var(--gold) 20%, var(--card)); padding: 3px 9px; border-radius: 99px; }
.goal.ready { border-color: var(--gold-d); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 45%, transparent), var(--shadow); }
.goal.claimed { opacity: .6; } .tick { color: var(--ok); display: grid; place-items: center; height: 32px; }
.goal.bonus { border-style: dashed; }
.bar.big { height: 14px; margin: 10px 0 4px; }
.mehero { text-align: center; position: relative; padding: 20px 16px 18px; }
.gearbtn { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; }
.me-av { width: 132px; height: 140px; margin: 0 auto 6px; } .mehero h2 { font-size: 26px; }
.crownrow { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; font-size: 13px; font-weight: 800; color: var(--mute); }
.crownrow.on { color: var(--gold-d); } .crownrow .crown { margin: 0; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.statgrid .stat { text-align: center; background: var(--card); border: 1px solid var(--line); padding: 10px 6px; }
.statgrid .stat b { font-size: 20px; }
.switch { position: relative; flex: none; width: 52px; height: 30px; border-radius: 99px; border: 0; background: var(--line); cursor: pointer; padding: 0; transition: background .15s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.switch[aria-checked=true] { background: var(--ok); } .switch[aria-checked=true] i { transform: translateX(22px); }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-weight: 800; }
.nameedit { gap: 8px; } .nameedit .field { flex: 1; } .nameedit .btn { flex: 0 0 auto; }
.danger-btn { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); width: 100%; margin-top: 6px; }
.danger .btnrow .danger-btn { margin-top: 0; }
.changelog { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.changelog li { display: flex; gap: 12px; font-size: 14px; line-height: 1.35; } .changelog b { flex: none; width: 38px; color: var(--me); } .changelog span { color: var(--mute); font-weight: 700; }
.sheet { padding-bottom: calc(26px + env(safe-area-inset-bottom)); }
.sheet .lbl { margin-top: 16px; }
.overlay { position: fixed; inset: 0; z-index: 70; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.overlay[hidden] { display: none; }
.welcome-card, .cel-card { width: 100%; max-width: 420px; text-align: center; display: flex; flex-direction: column; gap: 14px; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
.wdots { display: flex; justify-content: center; gap: 6px; } .wdots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); } .wdots i.on { background: var(--me); width: 22px; border-radius: 99px; }
.w-prev { width: 150px; height: 158px; margin: 0 auto; }
.how3 { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.h3c { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; } .h3c span { color: var(--mute); font-weight: 700; font-size: 14px; }
.cel-badge { width: 120px; height: 120px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 56px; font-weight: 900; color: #3b2a00; background: radial-gradient(circle at 30% 25%, #ffe38a, var(--gold)); box-shadow: 0 8px 0 var(--gold-d), 0 0 60px rgba(255, 196, 61, .5); }
.cel-card h2 { font-size: 34px; }
.r-av { width: 96px; height: 102px; margin: 0 auto 4px; } .r-av[hidden] { display: none; }
.lvlprog { margin-top: 14px; text-align: left; } .lp-top { display: flex; justify-content: space-between; font-weight: 900; font-size: 14px; margin-bottom: 6px; } .lp-top span { color: var(--mute); }
#offline { position: fixed; top: 0; left: 0; right: 0; z-index: 80; background: var(--bad); color: #fff; text-align: center; font-weight: 800; font-size: 13px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px; }
#offline[hidden] { display: none; }
.how a, .build a { color: var(--me); font-weight: 800; }
.build { font-size: 12px; opacity: .7; }
a.skip { position: absolute; left: -999px; }
html.calm *, html.calm *::before, html.calm *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
@media (max-width: 400px) { .cgrid { gap: 8px; } .cgrid .item .iv { height: 64px; } .stage-av { width: 126px; height: 134px; } }
@media (max-height: 640px) { .stage-av { width: 100px; height: 106px; } }
body.kb #tabbar { display: none; }

.recap li.empty { justify-content: center; color: var(--mute); font-weight: 700; background: none; }
.playcard .status:empty { display: none; }
.cattabs { mask-image: linear-gradient(90deg, #000 88%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); }

/* ================= v14: modes, twists, power-ups ================= */
.evrow { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.evrow[hidden] { display: none; }
.evchip { font-size: 13px; font-weight: 900; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); }
.evchip.twist { color: #a78bfa; border-color: color-mix(in srgb, #8b5cf6 55%, var(--line)); }
.evchip.golden { color: var(--gold-d); border-color: var(--gold-d); background: color-mix(in srgb, var(--gold) 16%, var(--card)); }
.evchip.lightning { color: #38bdf8; border-color: color-mix(in srgb, #38bdf8 55%, var(--line)); }
#gosign.gold { color: #ffd23f; -webkit-text-stroke-color: #b8891a; text-shadow: 0 8px 0 #b8891a, 0 0 40px rgba(255, 196, 61, .8); }
.pubar { display: flex; justify-content: center; gap: 10px; }
.pubar .btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; }
.pubar .btn .n { font-size: 12px; background: var(--bg2); border-radius: 99px; padding: 1px 8px; min-width: 22px; text-align: center; }
.hint.clue { border-color: var(--me); background: color-mix(in srgb, var(--me) 14%, var(--card)); }
.hint.clue code { color: var(--ink); }
#dock.frozen .field.guess { border-color: #38bdf8; background: color-mix(in srgb, #38bdf8 14%, var(--bg)); box-shadow: 0 0 0 4px rgba(56, 189, 248, .25); }
#dock.frozen .field.guess::placeholder { color: #38bdf8; opacity: 1; }
.rules-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.rule .lbl { margin-top: 10px; }
.seg { grid-template-columns: repeat(var(--n, 4), 1fr); margin-bottom: 8px; }
.seg button:disabled { opacity: .75; cursor: default; }
.seg button.on:disabled { opacity: 1; }
.switch:disabled { opacity: .75; cursor: default; }
.awards { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.award { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.award .mini { width: 26px; height: 28px; flex: none; } .award .al { color: var(--mute); font-weight: 800; flex: 1; text-align: left; } .award b { font-size: 14px; }

/* keep the round's twist/event visible while the keyboard is up */
body.kb #diff.evrow:not([hidden]) { display: flex !important; }
body.kb .evchip { padding: 3px 10px; font-size: 12px; }
.vplayer { gap: 12px; }

/* ================= v15: stats ================= */
.formcard { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; padding: 14px; }
.fdots { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 14px; }
.fd { width: 14px; height: 14px; border-radius: 50%; display: inline-block; background: var(--line); }
.fd.w { background: var(--ok); } .fd.l { background: var(--bad); opacity: .85; } .fd.t { background: var(--mute); opacity: .6; }
.scard { display: flex; flex-direction: column; gap: 10px; } .scard .lbl { margin: 0; }
.scard .statgrid { margin: 0; } .statgrid.two { grid-template-columns: repeat(2, 1fr); }
.stylecard { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: linear-gradient(135deg, color-mix(in srgb, var(--me) 18%, var(--card)), var(--card)); }
.stylecard b { font-size: 26px; letter-spacing: -.02em; }
.bignum { display: flex; align-items: baseline; gap: 10px; } .bignum b { font-size: 38px; letter-spacing: -.02em; }
.spark { position: relative; height: 54px; background: var(--bg); border-radius: 12px; padding: 4px 8px; }
.spark svg { width: 100%; height: 100%; display: block; }
.spark i { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; }
.spark .sp-best { border: 2px solid var(--ok); background: var(--card); } .spark .sp-last { background: var(--me); }
.trend { margin: 0; font-weight: 800; font-size: 13px; } .trend.up { color: var(--ok); } .trend.down { color: var(--gold-d); }
.sbar { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.sbar .sl { flex: none; width: 74px; font-weight: 900; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sbar .sb { flex: 1; height: 10px; border-radius: 99px; background: var(--bg2); overflow: hidden; } .sbar .sb i { display: block; height: 100%; background: linear-gradient(90deg, var(--me), color-mix(in srgb, var(--me) 55%, var(--gold))); border-radius: 99px; }
.sbar .sv { flex: none; font-size: 12px; color: var(--mute); min-width: 52px; text-align: right; font-weight: 800; }
.rival { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); } .rival:first-of-type { border-top: 0; padding-top: 0; }
.rv-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; } .rv-top span { color: var(--mute); font-weight: 800; font-size: 12px; }
.mestats { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; font-weight: 800; color: var(--mute); } .mestats b { color: var(--ink); font-size: 15px; }
.goalspeek, .goal { display: none; }

.sbar .sl { width: 96px; }

/* ================= v16: persistence / transfer ================= */
.modal { z-index: 95; }
.linkbtn { background: none; border: 0; color: var(--me); font: inherit; font-weight: 800; font-size: 14px; cursor: pointer; padding: 6px; }
.xcode { font-size: clamp(26px, 8vw, 34px); font-weight: 900; letter-spacing: .12em; text-align: center; padding: 18px 8px; margin: 12px 0 6px; background: var(--bg); border: 2px dashed var(--line); border-radius: 16px; color: var(--me); user-select: all; -webkit-user-select: all; }

/* ================= v17: stats visualisations ================= */
.filterbar { position: sticky; top: 0; z-index: 4; margin: 0 -2px; padding: 6px 2px 8px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.filterbar .cattabs { padding-bottom: 0; }
.vsep { flex: none; width: 1px; background: var(--line); margin: 4px 4px; }
.cattabs.inline { padding: 0 0 4px; }
.sh { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sh b { font-size: 18px; letter-spacing: -.01em; } .sh small { font-size: 12px; font-weight: 700; text-align: right; }
.chart { width: 100%; } .chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart.donut { width: 116px; flex: none; }
.ov { display: flex; align-items: center; gap: 14px; } .ov-k { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ov-k .stat { padding: 8px 4px; } .ov-k .stat b { font-size: 19px; }
.chart-empty { padding: 18px 12px; text-align: center; color: var(--mute); font-weight: 700; font-size: 13px; border: 1.5px dashed var(--line); border-radius: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; font-weight: 800; color: var(--mute); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.fdots.long { gap: 4px; } .fdots.long .fd { width: 9px; height: 9px; }
.statgrid.four { grid-template-columns: repeat(4, 1fr); gap: 6px; } .statgrid.four .stat { padding: 8px 2px; font-size: 10.5px; } .statgrid.four .stat b { font-size: 16px; }
.alpha { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.at { aspect-ratio: 1; border-radius: 10px; border: 2px solid transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; font: inherit; color: var(--ink); cursor: pointer; padding: 0; line-height: 1.15; }
.at b { font-size: 15px; } .at small { font-size: 9px; font-weight: 800; opacity: .9; }
.at.none { background: var(--bg2); color: var(--mute); } .at.sel { border-color: var(--ink); } .at:active { transform: scale(.92); }
.detail { display: flex; flex-direction: column; gap: 6px; background: var(--bg); border-radius: 14px; padding: 12px; font-size: 13px; font-weight: 700; } .detail b { font-size: 14px; } .detail .ex { color: var(--ink); }
.cloud { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; line-height: 1.1; font-weight: 900; }
.rec { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--line); } .rec:first-of-type { border-top: 0; }
.rec .ra { color: var(--mute); font-weight: 800; font-size: 13px; } .rec small { grid-column: 1 / -1; }
.chart.wmap { max-width: 440px; margin: 0 auto; cursor: pointer; }
.chart.mini { margin-top: -2px; }

.choice { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

/* ================= v19 ================= */
.rlinks { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 14px; margin-top: 2px; }
.chipbtn { font: inherit; font-weight: 800; font-size: 14px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; cursor: pointer; }
.chipbtn:active { transform: scale(.95); }
.wl .chips { margin-bottom: 4px; }

/* ================= v19: account ================= */
.gbtn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; font: inherit; font-weight: 800; font-size: 16px; color: #1f1f1f; background: #fff; border: 1px solid #dadce0; border-radius: 14px; padding: 13px 16px; cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.gbtn .gl { display: grid; place-items: center; width: 20px; height: 20px; } .gbtn:active { transform: scale(.98); }
.acct { display: flex; flex-direction: column; gap: 10px; }
.acct-top { display: flex; gap: 12px; align-items: center; }
.acct-pic { width: 52px; height: 52px; border-radius: 50%; flex: none; object-fit: cover; border: 2px solid var(--line); }
.acct-pic.ph { display: grid; place-items: center; background: var(--me); color: #fff; font-weight: 900; font-size: 22px; }
.acct-b { display: flex; flex-direction: column; gap: 2px; min-width: 0; } .acct-b b, .acct-b span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.syncpill { align-self: flex-start; font-size: 11px; font-weight: 900; padding: 3px 9px; border-radius: 99px; background: var(--bg2); color: var(--mute); }
.syncpill.ok { color: var(--ok); } .syncpill.error, .syncpill.needs-auth { color: var(--bad); } .syncpill.behind { color: var(--gold-d); }
.syncprompt { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 14px; } .syncprompt .sp-t { display: flex; flex-direction: column; gap: 2px; padding-right: 30px; }
.syncprompt.warn { border-color: var(--gold-d); } .xbtn { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; font-size: 14px; box-shadow: none; }
.linkbtn.danger { color: var(--bad); align-self: center; } .err { color: var(--bad); }
.welcome-card .or { margin: 4px 0; }

.about { padding: 4px 4px 0; } .about h2 { font-size: 16px; margin-bottom: 6px; } .about p { color: var(--mute); font-weight: 700; font-size: 14px; line-height: 1.55; margin: 0 0 8px; }

.how3 .h3c { padding: 14px; }
.build a { text-decoration: none; }
