:root {
  --table: #E4DCCB; --grid: rgba(60, 40, 20, .07); --paper: #F7F2E7; --ink: #231C15; --muted: #74685A;
  --line: rgba(35, 28, 21, .16); --token: #FBF7EE; --accent: #C8402F; --accent-edge: #8E2A1E; --gold: #E2B33C; --green: #2F7D4F;
  --f-display: "Rubik", "Trebuchet MS", system-ui, sans-serif; --f-text: "Alegreya", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh; min-height: 100dvh; color: var(--ink); background-color: var(--table);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 36px 36px; font: 17px/1.5 var(--f-text); -webkit-font-smoothing: antialiased; padding-bottom: 90px;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.wrap { max-width: 1200px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

/* header */
.top { padding-top: 18px; }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; font: 800 21px var(--f-display); letter-spacing: -.02em; }
.mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #FFF7EA; display: grid; place-items: center; font: 900 21px var(--f-display); transform: rotate(-8deg); box-shadow: 0 3px 0 var(--accent-edge); }
.top-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hub-link { font: 700 14px var(--f-display); color: var(--muted); text-decoration: none; white-space: nowrap; padding: 8px 12px; border-radius: 999px; background: var(--token); box-shadow: 0 3px 0 var(--line), inset 0 0 0 1.5px var(--line); }
.hub-link:hover { color: var(--ink); }
/* The header link replaces the floating button (it would cover the game). */
#igroteka-back { display: none !important; }
@media (max-width: 560px) { .logo-name { display: none; } .hub-link { padding: 7px 10px; font-size: 13px; } .top-right { gap: 4px; } .pill { padding: 0 10px; font-size: 13px; } }
.top-right { display: flex; align-items: center; gap: 8px; }
.phase { font: 700 14px var(--f-display); color: var(--muted); font-variant-numeric: tabular-nums; }
.pill { font: 700 14px var(--f-display); min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--token); box-shadow: 0 4px 0 var(--line), inset 0 0 0 1.5px var(--line); }
.pill.ghost { background: transparent; box-shadow: none; color: var(--muted); }

/* generic */
h1 { font: 900 clamp(40px, 7vw, 76px)/.98 var(--f-display); letter-spacing: -.045em; margin: 0; }
h1 em { font-style: normal; color: var(--accent); }
h2 { font: 800 clamp(26px, 4vw, 40px)/1.08 var(--f-display); letter-spacing: -.03em; margin: 0; text-wrap: balance; }
.lead { color: var(--muted); font-size: 20px; margin: 14px 0 0; max-width: 34ch; }
.lbl { font: 600 12px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.paper { background: var(--paper); border-radius: 16px; padding: 22px; box-shadow: 0 6px 0 var(--line), 0 30px 40px -24px rgba(0,0,0,.35); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 24px; border: 0; border-radius: 12px;
  font: 800 18px var(--f-display); background: var(--accent); color: #FFF7EA; box-shadow: 0 5px 0 var(--accent-edge); transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-edge); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.alt { background: var(--token); color: var(--ink); box-shadow: 0 5px 0 var(--line), inset 0 0 0 1.5px var(--line); }
.btn.block { width: 100%; }
.err { color: var(--accent); min-height: 1.4em; margin: 10px 0 0; font-weight: 500; }
input.field { width: 100%; height: 50px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; padding: 0 16px; outline: none; font-size: 18px; }
input.field:focus { border-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 18px; }

/* home */
.home { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; padding: clamp(28px, 6vw, 70px) 0 20px; }
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 8px; }
.avatars button { padding: 0; border: 0; border-radius: 50%; aspect-ratio: 1; overflow: hidden; opacity: .5; outline: 2.5px solid transparent; outline-offset: 2px; background: #ddd; }
.avatars button.on { opacity: 1; outline-color: var(--accent); }
.avatars img { width: 100%; height: 100%; object-fit: cover; display: block; }
.invite { background: rgba(200, 64, 47, .1); color: var(--accent-edge); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-weight: 500; }
.tg-row { margin-top: 14px; text-align: center; color: var(--muted); font-size: 15px; }
.tg-row a { color: #1C86BD; font-weight: 600; }
.steps { color: var(--muted); padding-left: 20px; margin: 18px 0 0; }

/* players */
.people { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.person { display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; border-radius: 999px; background: var(--token); box-shadow: 0 3px 0 var(--line), inset 0 0 0 1.5px var(--line); font: 600 15px var(--f-display); }
.person img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.person.off { opacity: .45; }
.person .host { color: var(--gold); }
.person .ok { color: var(--green); font-weight: 800; }
.bk-tg { vertical-align: -2px; }

/* lobby */
.lobby { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; padding-top: 34px; }
.copy { display: flex; gap: 8px; margin-top: 14px; }
.copy input { flex: 1; min-width: 0; height: 46px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; padding: 0 12px; font-size: 14px; color: var(--muted); }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); font: 600 15px var(--f-display); }
.opt:last-child { border-bottom: 0; }
.opt small { display: block; font: 400 13px var(--f-text); color: var(--muted); }
.step { display: inline-flex; align-items: center; border-radius: 10px; background: var(--token); box-shadow: inset 0 0 0 1.5px var(--line); }
.step button { width: 38px; height: 38px; border: 0; background: none; font: 800 18px var(--f-display); }
.step button:disabled { opacity: .3; }
.step span { min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; }
.switch { width: 50px; height: 30px; border-radius: 99px; border: 0; background: #D9CFBD; position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }
.switch:disabled { opacity: .6; cursor: default; }

/* question */
.stage { padding-top: 28px; }
.qcard {
  position: relative; background: var(--accent); color: #FFF7EA; border-radius: 18px; padding: clamp(26px, 5vw, 46px) clamp(22px, 5vw, 44px);
  box-shadow: 0 8px 0 var(--accent-edge), 0 30px 40px -18px rgba(0,0,0,.4); transform: rotate(-.6deg);
}
.qcard .lbl { color: rgba(255, 247, 234, .75); }
.qcard h2 { color: #FFF7EA; margin-top: 10px; font-size: clamp(28px, 5vw, 48px); }
.timer { position: absolute; right: 18px; top: 16px; font: 800 18px var(--f-display); font-variant-numeric: tabular-nums; background: rgba(0,0,0,.18); border-radius: 999px; padding: 4px 12px; }
.timer.hurry { background: #FFF7EA; color: var(--accent); }
.vote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; margin-top: 30px; }
.vote {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px 14px; border: 0; border-radius: 14px;
  background: var(--paper); box-shadow: 0 5px 0 var(--line), inset 0 0 0 1.5px var(--line); transition: transform .15s, box-shadow .15s; font: 700 15px var(--f-display);
}
.vote img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; }
.vote span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vote:hover { transform: translateY(-3px); }
.vote.on { box-shadow: 0 5px 0 var(--accent-edge), inset 0 0 0 3px var(--accent); transform: translateY(-3px); }
.vote.on::after { content: "✓"; position: absolute; top: 8px; right: 10px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 15px; }
.vote:disabled { cursor: default; opacity: .55; transform: none; }
.status { margin-top: 20px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }

/* reveal */
.bars { display: grid; gap: 12px; margin-top: 26px; }
.bar { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.bar > img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.bar .track { position: relative; height: 44px; border-radius: 10px; background: rgba(35, 28, 21, .07); overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: #D9CFBD; border-radius: 10px; animation: grow .7s cubic-bezier(.2,.8,.2,1) both; }
.bar.top .fill { background: var(--gold); }
@keyframes grow { from { width: 0 !important; } }
.bar .name { position: absolute; left: 14px; top: 0; bottom: 0; display: flex; align-items: center; gap: 8px; font: 700 16px var(--f-display); }
.bar .who { display: flex; }
.bar .who img { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--paper); margin-left: -8px; object-fit: cover; }
.bar .n { font: 800 20px var(--f-display); min-width: 28px; text-align: right; }
.crown { font-size: 18px; }
.plus { display: inline-block; font: 800 13px var(--f-display); color: var(--green); background: rgba(47, 125, 79, .12); padding: 2px 8px; border-radius: 99px; }

/* scores */
.scores { display: grid; gap: 8px; margin-top: 14px; }
.score { display: grid; grid-template-columns: 28px 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; font: 600 16px var(--f-display); }
.score img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.score .pos { color: var(--muted); text-align: center; }
.score b { font-size: 20px; }
.score.win b, .score.win .pos { color: var(--accent); }
.side-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; margin-top: 28px; align-items: start; }
.history { display: grid; gap: 10px; margin-top: 12px; }
.history div { padding: 10px 0; border-top: 1px dashed var(--line); }
.history small { color: var(--muted); display: block; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: .2s; pointer-events: none; z-index: 60;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font: 600 15px var(--f-display); max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.conn { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; padding: 6px 14px; border-radius: 99px; font: 700 13px var(--f-display); z-index: 60; }

@media (max-width: 820px) {
  .home, .lobby, .side-grid { grid-template-columns: 1fr; gap: 22px; }
  .home { padding-top: 24px; }
  .vote-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
  .vote img { width: 58px; height: 58px; }
  .vote { font-size: 13px; padding: 12px 6px; }
  .top-right .phase { display: none; }
  .logo { font-size: 17px; white-space: nowrap; }
  .pill { padding: 0 12px; }
}
@media (max-width: 420px) { .avatars { gap: 4px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ===================== «На пальцах» ===================== */
.mark.np { background: #2F7D4F; box-shadow: 0 3px 0 #1E5535; font-size: 18px; }
h1 em.np { color: #2F7D4F; }
.icon-pill { width: 40px; padding: 0; font-size: 16px; }
.top { padding-top: 22px; }
main.wrap { padding-bottom: 40px; }
.hint { color: var(--muted); font-size: 16px; margin: 14px 0 0; line-height: 1.5; }

/* ----- lobby teams ----- */
.teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-top: 20px; }
.team { border-radius: 16px; padding: 18px; background: var(--token); box-shadow: 0 4px 0 var(--line), inset 0 0 0 1.5px var(--line); transition: box-shadow .2s, transform .2s; }
.team h3 { margin: 0 0 10px; font: 800 19px var(--f-display); display: flex; align-items: center; gap: 10px; }
.team h3 i { width: 16px; height: 16px; border-radius: 50%; background: var(--tc); display: inline-block; }
.team .people { margin-top: 8px; gap: 10px; }
.team.mine { box-shadow: 0 4px 0 var(--line), inset 0 0 0 3px var(--tc); }
.join-team { margin-top: 14px; min-height: 40px; font-size: 14px; }
.lobby { gap: 28px; padding-top: 38px; }
.lobby .paper { padding: 26px 28px; }
.way-list .opt b { font: 800 16px var(--f-display); color: var(--mc); }

/* ----- track (persistent; tokens glide) ----- */
#trackbar { margin-top: 26px; }
.track { position: relative; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; padding: 16px; border-radius: 18px; background: var(--paper); box-shadow: 0 6px 0 var(--line); }
.cell { aspect-ratio: 1; border-radius: 9px; background: rgba(35,28,21,.06); display: grid; place-items: center; font: 700 12px var(--f-display); color: rgba(35,28,21,.32); }
.cell.start { background: var(--ink); color: var(--paper); font-size: 14px; }
.cell.finish { background: var(--accent); color: #fff; font-size: 16px; }
.cell.lit { background: rgba(35,28,21,.12); }
.token { position: absolute; left: 0; top: 0; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: var(--tc); z-index: 2;
  box-shadow: 0 3px 0 rgba(0,0,0,.28), inset 0 0 0 3px rgba(255,255,255,.55); transition: transform .26s cubic-bezier(.3,1.4,.5,1); }
.token.hop { animation: hop .26s ease-out; }
@keyframes hop { 50% { margin-top: -26px; } }
.score-row { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-top: 14px; font: 700 16px var(--f-display); }
.score-row span { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 4px 0; }
.score-row i { width: 14px; height: 14px; border-radius: 50%; background: var(--tc); }
.score-row .turn { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 3px; text-decoration-color: var(--tc); }
.plus { position: absolute; left: 100%; top: -6px; margin-left: 6px; font: 900 22px var(--f-display); color: var(--tc); animation: plus 1.6s ease-out forwards; pointer-events: none; }
@keyframes plus { 0% { opacity: 0; transform: translateY(10px) scale(.6); } 20% { opacity: 1; transform: translateY(0) scale(1.25); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px) scale(1); } }

/* ----- play area ----- */
.play { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 32px; margin-top: 28px; align-items: start; }
.play > div > * + * { margin-top: 22px; }
.card {
  position: relative; border-radius: 20px; padding: 28px 32px 26px; color: #FFF7EA; background: var(--mc, #2F7D4F);
  box-shadow: 0 8px 0 rgba(0,0,0,.25), 0 30px 40px -20px rgba(0,0,0,.45); transform: rotate(-.6deg);
}
.card .lbl { color: rgba(255,247,234,.85); }
.card h2 { color: #FFF7EA; margin-top: 10px; font-size: clamp(32px, 5vw, 58px); }
.card .rule { margin: 12px 0 0; font-size: 18px; color: rgba(255,247,234,.94); max-width: 46ch; line-height: 1.45; }
.card .steps { position: absolute; right: 22px; top: 20px; font: 800 16px var(--f-display); background: rgba(255,247,234,.22); color: #FFF7EA; border-radius: 999px; padding: 5px 14px; }
.card .timer { position: static; display: inline-block; margin-top: 16px; }
.card.flip-in { animation: flipIn .55s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes flipIn { from { transform: perspective(900px) rotateY(80deg) rotate(-.6deg); opacity: 0; } to { transform: perspective(900px) rotateY(0) rotate(-.6deg); opacity: 1; } }
.card.shake { animation: shake .5s ease-in-out; }
@keyframes shake { 20%, 60% { transform: translateX(-8px) rotate(-1.4deg); } 40%, 80% { transform: translateX(8px) rotate(.4deg); } }
.special { display: inline-block; margin-top: 12px; background: #FFF7EA; color: var(--accent); border-radius: 8px; padding: 5px 12px; font: 800 13px var(--f-display); letter-spacing: .06em; text-transform: uppercase; transform: rotate(-2deg); }
.who { display: flex; align-items: center; gap: 14px; }
.who img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 3px var(--tc); }
.who b { font: 800 18px var(--f-display); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn.team-btn { background: var(--tc); box-shadow: 0 5px 0 rgba(0,0,0,.3); }
.btn.big { min-height: 58px; font-size: 20px; padding: 0 30px; }

/* ----- the method roulette ----- */
.spin { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.spin div { border-radius: 16px; padding: 16px 10px 14px; text-align: center; background: var(--paper); box-shadow: 0 4px 0 var(--line), inset 0 0 0 1.5px var(--line);
  font: 800 15px var(--f-display); transition: transform .12s, background .12s, color .12s, box-shadow .12s; }
.spin div span { display: block; font-size: 30px; line-height: 1.2; margin-bottom: 4px; }
.spin div small { display: block; font: 700 13px var(--f-display); color: var(--muted); }
.spin div.on { background: var(--mc); color: #FFF7EA; transform: translateY(-6px) scale(1.04); box-shadow: 0 8px 0 rgba(0,0,0,.25); }
.spin div.on small { color: rgba(255,247,234,.85); }
.spin div.done { animation: chosen .6s ease; }
@keyframes chosen { 30% { transform: translateY(-10px) scale(1.12); } }
.spin-note { color: var(--muted); font-size: 16px; text-align: center; margin-top: 12px; }

/* ----- pick a word ----- */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.choice { position: relative; text-align: left; border: 0; border-radius: 18px; padding: 20px 22px; background: var(--paper); cursor: pointer;
  box-shadow: 0 5px 0 var(--line), inset 0 0 0 1.5px var(--line); transition: transform .15s, box-shadow .15s; animation: dealIn .45s cubic-bezier(.2,.9,.3,1.15) both; }
.choice:nth-child(2) { animation-delay: .1s; }
@keyframes dealIn { from { opacity: 0; transform: translateY(24px) rotate(3deg); } }
.choice:hover { transform: translateY(-3px); }
.choice .lbl { display: block; color: var(--muted); }
.choice b { display: block; margin-top: 8px; font: 800 26px/1.1 var(--f-display); letter-spacing: -.02em; }
.choice.on { box-shadow: 0 5px 0 var(--accent-edge), inset 0 0 0 3px var(--accent); transform: translateY(-3px); }
.choice.on::after { content: "✓"; position: absolute; right: 14px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; }

/* ----- guesses ----- */
.paper.guesses { padding: 24px 26px; }
.guess-box { display: flex; gap: 10px; margin-top: 16px; }
.guess-box input { flex: 1; min-width: 0; height: 56px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; padding: 0 16px; font-size: 19px; outline: none; }
.guess-box input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(47,125,79,.12); }
.feed { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; max-height: 340px; overflow-y: auto; }
.feed div { display: flex; gap: 10px; align-items: baseline; font-size: 17px; padding: 6px 10px; border-radius: 10px; }
.feed div.new { animation: slideIn .35s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); background: rgba(226,179,60,.25); } }
.feed b { font: 700 14px var(--f-display); color: var(--tc); flex: none; }
.feed .ok { color: var(--green); font-weight: 700; }
.feed div:has(.ok) { background: rgba(47,125,79,.1); }
.feed .no { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(200,64,47,.5); }

/* ----- canvas ----- */
.canvas-wrap { position: relative; }
.canvas-wrap canvas { display: block; width: 100%; aspect-ratio: 4 / 3; background: #FFFDF8; border-radius: 16px; box-shadow: 0 6px 0 var(--line), inset 0 0 0 1.5px var(--line); touch-action: none; }
.canvas-wrap.editable canvas { cursor: crosshair; }
.palette { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.palette button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--pc); box-shadow: inset 0 0 0 2px rgba(0,0,0,.15); }
.palette button.on { outline: 3px solid var(--ink); outline-offset: 2px; }
.palette .size { width: auto; padding: 0 14px; border-radius: 999px; background: var(--token); font: 700 14px var(--f-display); box-shadow: inset 0 0 0 1.5px var(--line); }

/* ----- reveal / end ----- */
.result { font: 800 26px var(--f-display); animation: pop .5s cubic-bezier(.2,.9,.3,1.4) both .25s; }
@keyframes pop { from { opacity: 0; transform: scale(.6); } }
.result.ok { color: var(--green); }
.result.no { color: var(--muted); }
.hist { display: grid; gap: 4px; margin-top: 14px; }
.hist div { display: grid; grid-template-columns: 16px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); font-size: 17px; }
.hist i { width: 12px; height: 12px; border-radius: 50%; background: var(--tc); }
.hist small { color: var(--muted); }
.winner h2 { font-size: clamp(34px, 5vw, 56px); animation: pop .6s cubic-bezier(.2,.9,.3,1.4) both; }

/* ----- overlays ----- */
.overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(35,28,21,.55); backdrop-filter: blur(4px); animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.ov-card { position: relative; width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--paper); border-radius: 20px; padding: 30px 28px; text-align: center; box-shadow: 0 40px 80px -20px rgba(0,0,0,.6); animation: dealIn .35s cubic-bezier(.2,.9,.3,1.15) both; }
.ov-card h2 { margin: 6px 0 8px; }
.ov-card p { color: var(--muted); margin: 0 0 20px; }
.ov-icon { font-size: 44px; }
.rules-card { width: min(640px, 100%); text-align: left; }
.rules-card .x { position: absolute; right: 16px; top: 16px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--token); font-size: 16px; box-shadow: inset 0 0 0 1.5px var(--line); }
.rules-list { padding-left: 22px; margin: 10px 0 18px; display: grid; gap: 8px; line-height: 1.45; }
.ways { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ways div { border-radius: 14px; padding: 12px 14px; background: var(--mc); color: #FFF7EA; }
.ways b { display: block; font: 800 16px var(--f-display); }
.ways span { font-size: 15px; opacity: .92; }

/* ----- confetti ----- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.fx i { position: absolute; width: 10px; height: 14px; border-radius: 2px; background: var(--c); animation: confetti var(--d) cubic-bezier(.2,.7,.4,1) forwards; }
@keyframes confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }

@media (max-width: 860px) {
  .play { grid-template-columns: 1fr; gap: 22px; }
  .track { grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 5px; padding: 12px; }
  .token { width: 16px; height: 16px; margin: -8px 0 0 -8px; }
  .card { padding: 22px 22px 20px; }
  .card h2 { font-size: clamp(28px, 8vw, 40px); }
  .spin { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .choices { grid-template-columns: 1fr; }
  .ways { grid-template-columns: 1fr; }
  .lobby { padding-top: 24px; gap: 20px; }
}
@media (prefers-reduced-motion: reduce) { .token { transition: none; } }

/* Phones: the header wraps into two rows so every button stays tappable. */
@media (max-width: 640px) {
  .top-in { flex-wrap: wrap; row-gap: 10px; }
  .top-left { flex: 1 1 100%; justify-content: space-between; }
  .logo-name { display: inline; font-size: 17px; }
  .top-right { flex: 1 1 100%; justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
  .top-right .phase { display: none; }
  .pill { min-height: 38px; }
}

/* Explainer's control bar: always on screen during their turn. */
.exp-bar {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  width: min(760px, calc(100% - 24px)); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px 14px 22px; border-radius: 18px; background: var(--ink); color: var(--paper);
  box-shadow: 0 20px 40px -12px rgba(0,0,0,.55); animation: barIn .35s cubic-bezier(.2,.9,.3,1.15) both;
}
@keyframes barIn { from { opacity: 0; transform: translate(-50%, 30px); } }
.exp-bar > span { font: 700 16px var(--f-display); }
.exp-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.exp-bar .btn.alt { background: #3A332B; color: var(--paper); box-shadow: 0 5px 0 #15110D; }
.btn.ok-btn { background: var(--green); box-shadow: 0 5px 0 #1E5535; }
body:has(.exp-bar) main.wrap { padding-bottom: 130px; }
.spin { cursor: pointer; }
@media (max-width: 640px) {
  .exp-bar { padding: 12px; gap: 10px; }
  .exp-bar > span { flex: 1 1 100%; font-size: 14px; text-align: center; }
  .exp-actions { flex: 1 1 100%; }
  .exp-actions .btn, .exp-bar > .btn { flex: 1 1 0; min-height: 52px; font-size: 17px; padding: 0 10px; }
}
