:root {
  --paper: #f4efe6;
  --paper-2: #ebe4d6;
  --ink: #16161d;
  --ink-2: #4a4a57;
  --muted: #7b7a86;
  --card: #fffdf8;
  --accent: #ff5a36;
  --blue: #3d5afe;
  --lime: #c8f560;
  --yellow: #ffd23f;
  --pink: #ff3d8b;
  --green: #00b37e;
  --gold: #ffc531;
  --silver: #c9d2de;
  --bronze: #e39a5b;
  --surface: #fff;
  --on-bright: #16161d;
  --bar: #16161d;
  --dot: rgba(22, 22, 29, 0.09);
  --tint-blue: #eef0ff;
  --tint-red: #ffd9d0;
  --tint-win: #eaffd0;
  --tint-me: #fff8db;
  --tint-gold: #fff6d6;
  --border: rgba(22, 22, 29, 0.13);
  --border-strong: rgba(22, 22, 29, 0.28);
  --line: 1px solid var(--border);
  --shadow-sm: 0 1px 2px rgba(22, 22, 29, 0.06);
  --shadow: 0 1px 2px rgba(22, 22, 29, 0.05), 0 6px 18px rgba(22, 22, 29, 0.06);
  --shadow-lg: 0 2px 6px rgba(22, 22, 29, 0.06), 0 16px 40px rgba(22, 22, 29, 0.1);
  --r: 14px;
  --display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --mono: 'Space Mono', ui-monospace, monospace;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --paper: #14141b;
  --paper-2: #262630;
  --ink: #ece8df;
  --ink-2: #b9b6c2;
  --muted: #8d8a98;
  --card: #1d1d26;
  --surface: #272733;
  --bar: #0b0b10;
  --dot: rgba(236, 232, 223, 0.07);
  --tint-blue: #1f2440;
  --tint-red: #4a2018;
  --tint-win: #1d3519;
  --tint-me: #3a3215;
  --tint-gold: #3a3215;
  --border: rgba(236, 232, 223, 0.12);
  --border-strong: rgba(236, 232, 223, 0.28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.1; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; font-weight: 800; }
.muted { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; font-weight: 600; color: var(--ink-2); }

/* ---------- primitives ---------- */
.card {
  background: var(--card);
  border: var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 20px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: var(--line); border-radius: 12px; background: var(--card);
  padding: 11px 18px; font-weight: 800; font-size: 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(0.96); }
.btn:active:not(:disabled) { filter: brightness(0.9); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.danger { background: var(--tint-red); }
.btn.ghost { background: transparent; box-shadow: none; border-style: dashed; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 0.9rem; border-radius: 10px; }
.btn.xs { padding: 4px 8px; font-size: 0.85rem; border-radius: 8px; box-shadow: var(--shadow-sm); }
.btn.huge { padding: 16px 28px; font-size: 1.25rem; border-radius: 14px; box-shadow: var(--shadow); }
.icon-btn { border: none; background: none; font-size: 1.2rem; padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: rgba(0, 0, 0, 0.06); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.8rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.field input, .picker input {
  border: var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); font-size: 1.1rem; font-weight: 600; width: 100%;
  outline: none; transition: box-shadow 0.15s;
}
.field input:focus, .picker input:focus { box-shadow: 0 0 0 4px rgba(61, 90, 254, 0.25); }
.grow { flex: 1; min-width: 0; }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.av {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--c, var(--paper-2)); border: var(--line);
  font-size: 1.5rem; line-height: 1;
}
.av.sm { width: 32px; height: 32px; font-size: 1.05rem; }
.tag { display: inline-block; border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 0.85rem; font-weight: 600; background: var(--surface); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }


/* ---------- home ---------- */
.home-inner { max-width: 880px; margin: 0 auto; padding: 48px 16px 64px; display: grid; gap: 22px; }
.hero { text-align: center; display: grid; gap: 14px; justify-items: center; }
.logo { display: inline-flex; align-items: center; gap: 14px; position: relative; }
.logo-text { font-weight: 800; font-size: 3.4rem; line-height: 0.85; text-align: left; letter-spacing: -0.04em; text-transform: uppercase; }
.tagline { font-size: 1.25rem; max-width: 520px; margin: 0; color: var(--ink-2); }
.tagline em { font-style: normal; background: var(--lime); padding: 0 4px; border-radius: 4px; color: var(--on-bright); }

.profile-card { display: grid; gap: 16px; }
.profile-row { display: flex; gap: 16px; align-items: flex-end; }
.avatar-btn {
  width: 74px; height: 74px; border-radius: 50%; border: var(--line); background: var(--yellow); box-shadow: var(--shadow);
  font-size: 2.6rem; display: grid; place-items: center; transition: transform 0.15s; flex: none;
}
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.av-opt {
  aspect-ratio: 1; border: 1px solid transparent; border-radius: 12px; background: var(--paper);
  font-size: 1.5rem; display: grid; place-items: center; transition: transform 0.12s, background 0.12s;
}
.av-opt:hover { transform: scale(1.08); background: var(--surface); border-color: var(--border-strong); }
.av-opt.on { background: var(--yellow); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.join-card, .host-card { display: grid; gap: 14px; align-content: start; }
.host-card { background: var(--tint-blue); }
.host-card p { margin: 0; }
.host-card .btn { margin-top: auto; }
.code-input { font-family: var(--mono) !important; letter-spacing: 0.4em; text-transform: uppercase; font-size: 1.6rem !important; text-align: center; }

/* ---------- game bar ---------- */
.gamebar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; background: var(--paper); border-bottom: var(--line);
}
.mini-logo { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; display: inline-flex; align-items: center; gap: 8px; }
.code-chip {
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); padding: 4px 12px; font-family: var(--mono); font-size: 1rem; letter-spacing: 0.15em;
}
.code-chip small { font-family: var(--display); letter-spacing: 0; color: var(--muted); font-weight: 600; margin-right: 4px; }
.gamebar-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.conn { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--border); margin-right: 6px; }
.conn.ok { background: var(--green); }
.conn.bad { background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

/* ---------- lobby ---------- */
.lobby-grid {
  max-width: 1180px; margin: 0 auto; padding: 24px 16px 120px;
  display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start;
}
.code-card { text-align: center; display: grid; gap: 10px; background: var(--card); }
.big-code { display: flex; justify-content: center; gap: 8px; }
.big-code span {
  font-family: var(--mono); font-size: 2.7rem; width: 1.3em; height: 1.55em; display: grid; place-items: center;
  background: var(--surface); border: var(--line); border-radius: 12px; box-shadow: var(--shadow-sm);
}
.animate .big-code span { animation: drop 0.5s cubic-bezier(0.3, 1.6, 0.6, 1) both; animation-delay: calc(var(--i) * 0.07s); }
@keyframes drop { from { transform: translateY(-6px); opacity: 0; } }
.code-actions { display: flex; justify-content: center; }
.share-url { word-break: break-all; color: var(--ink-2); }

.players-card { grid-column: 1; }
.players-card h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.count { background: var(--ink); color: var(--paper); border-radius: 999px; font-size: 0.85rem; padding: 2px 9px; }
.players { display: grid; gap: 8px; }
.player { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 6px; border-radius: 12px; }
.player.enter { animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.6, 1); }
.player.is-me { background: var(--paper); }
.player.offline { opacity: 0.4; }
.player.ghost .av { background: transparent; border-style: dashed; color: var(--muted); }
.player .pname { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player em { font-style: normal; color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.pscore { font-family: var(--mono); font-size: 0.95rem; }
.pactions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.player:hover .pactions, .player:focus-within .pactions { opacity: 1; }
@media (hover: none) { .pactions { opacity: 1; } }
.xbtn { border: none; background: none; padding: 4px 6px; border-radius: 6px; font-size: 0.85rem; color: var(--ink-2); }
.xbtn:hover { background: var(--paper-2); color: var(--ink); }
.av-edit { position: relative; padding: 0; cursor: pointer; transition: transform 0.15s; }
.av-edit:hover { transform: scale(1.05); }
.av-edit i {
  position: absolute; right: -5px; bottom: -4px; font-style: normal; font-size: 0.65rem; background: var(--ink); color: var(--paper);
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--card);
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

.setup-card { grid-column: 2; grid-row: 1 / span 3; display: grid; gap: 18px; }
.settings { display: grid; gap: 16px; }
.setting { display: grid; gap: 6px; }
.setting-label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.setting-label em { font-style: normal; text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; margin-left: 6px; }
.seg { display: flex; border: var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.seg button { flex: 1; border: none; background: none; padding: 9px 6px; font-weight: 600; font-size: 0.92rem; border-left: 1px solid var(--border); transition: background 0.12s; }
.seg button:first-child { border-left: none; }
.seg button:hover { background: var(--paper); }
.seg button.on { background: var(--ink); color: var(--paper); }
.toggles { display: flex; flex-wrap: wrap; gap: 10px; }
.toggle {
  display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px 6px 6px;
  background: var(--surface); font-weight: 600; font-size: 0.92rem;
}
.toggle .knob { width: 34px; height: 20px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--border); position: relative; transition: background 0.15s; }
.toggle .knob::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); transition: transform 0.15s; }
.toggle.on .knob { background: var(--lime); }
.toggle.on .knob::after { transform: translateX(14px); background: var(--on-bright); }

.waiting { text-align: center; display: grid; gap: 14px; justify-items: center; padding: 20px 0; }
.waiting h2 { font-size: 1.7rem; }
.waiting p { margin: 0; max-width: 440px; }
.spinner-globe { animation: bob 2.4s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-6px) rotate(-6deg); } }
.rules { display: grid; gap: 8px; text-align: left; background: var(--paper); border-radius: 12px; padding: 14px 18px; font-weight: 600; font-size: 0.95rem; }

.standings-card { grid-column: 1; display: grid; gap: 12px; }
.standings { display: grid; gap: 8px; }
.stand-row { display: grid; grid-template-columns: 22px 32px minmax(0, 1fr) 70px auto; align-items: center; gap: 8px; }
.animate .stand-row { animation: slidein 0.4s both; animation-delay: calc(var(--i) * 0.06s + 0.2s); }
@keyframes slidein { from { transform: translateX(-16px); opacity: 0; } }
.stand-pos { font-family: var(--mono); color: var(--muted); }
.stand-row .av { background: var(--c); }
.stand-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stand-bar { height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.stand-bar span { display: block; height: 100%; width: var(--w); background: var(--c); border-radius: 99px; }
.animate .stand-bar span { animation: grow 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--i) * 0.06s + 0.3s); }
@keyframes grow { from { width: 0; } }
.stand-score { font-family: var(--mono); text-align: right; }
@keyframes fadein { from { opacity: 0; } }

/* ---------- results ---------- */
.results-inner { max-width: 1100px; margin: 0 auto; padding: 28px 16px 130px; display: grid; gap: 26px; }
.res-head { text-align: center; display: grid; gap: 8px; }
.res-head h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 800; letter-spacing: -0.03em; }
.matchline { margin: 0; font-size: 1.1rem; font-weight: 600; }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; min-height: 360px; padding-top: 20px; border-bottom: var(--line); }
.final .podium { min-height: 400px; }
.step { width: 190px; display: flex; flex-direction: column; align-items: center; }
.pod-player { display: grid; justify-items: center; gap: 4px; padding-bottom: 12px; text-align: center; position: relative; }
.pod-av {
  width: 84px; height: 84px; border-radius: 50%; border: 1px solid var(--border); background: var(--c, var(--paper-2)); font-size: 2.8rem;
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.p1 .pod-av { width: 108px; height: 108px; font-size: 3.6rem; }
.pod-name { font-weight: 800; font-size: 1.2rem; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-meta { font-size: 0.85rem; color: var(--ink-2); font-family: var(--mono); }
.crown { position: absolute; top: -40px; animation: crown 1.6s ease-in-out infinite alternate; }
@keyframes crown { from { transform: translateY(0); } to { transform: translateY(-4px); } }
.pod-block {
  width: 100%; border: var(--line); border-bottom: none; border-radius: 14px 14px 0 0; display: grid; place-items: center; align-content: start;
  padding-top: 14px; gap: 2px; box-shadow: var(--shadow); position: relative;
}
.pod-block span { font-family: var(--mono); font-size: 3rem; line-height: 1; }
.pod-block em { font-style: normal; font-weight: 800; font-family: var(--mono); font-size: 0.95rem; }
.p1 .pod-block { height: 190px; background: var(--gold); }
.p2 .pod-block { height: 140px; background: var(--silver); }
.p3 .pod-block { height: 100px; background: var(--bronze); }
.step.empty { opacity: 0.4; }
.step.empty .pod-av { background: transparent; border-style: dashed; box-shadow: none; }

.animate .step { animation: rise 0.7s cubic-bezier(0.3, 1.4, 0.6, 1) both; transform-origin: bottom; }
.animate .step.p3 { animation-delay: 0.2s; }
.animate .step.p2 { animation-delay: 0.7s; }
.animate .step.p1 { animation-delay: 1.3s; }
.animate .pod-player { animation: fadein 0.4s both; }
.animate .p3 .pod-player { animation-delay: 0.6s; }
.animate .p2 .pod-player { animation-delay: 1.1s; }
.animate .p1 .pod-player { animation-delay: 1.8s; }
@keyframes rise { from { transform: scaleY(0); opacity: 0; } }

.awards { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.award {
  display: flex; gap: 12px; align-items: center; background: var(--card); border: var(--line); border-radius: 14px; padding: 10px 16px 10px 10px;
  box-shadow: var(--shadow-sm); animation: pop 0.4s both; animation-delay: calc(2s + var(--i) * 0.12s);
}
.results-inner:not(.animate) .award { animation: none; }
.award-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--c); border: 1px solid var(--border); display: grid; place-items: center; color: #fff !important; }
.award > span:last-child { display: grid; }
.award small { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.7rem; font-weight: 600; color: var(--ink-2); }
.award em { font-style: normal; font-size: 0.82rem; color: var(--muted); }

.res-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; }
.res-actions.sticky {
  position: sticky; bottom: 12px; z-index: 30; align-items: center; background: var(--card); border: var(--line); border-radius: 18px;
  box-shadow: var(--shadow-lg); padding: 12px; margin: 0 auto; width: fit-content; max-width: 100%;
}
.res-actions.sticky .btn.huge { padding: 12px 22px; font-size: 1.1rem; }
.waiting-line { margin: 0; padding: 4px 10px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.final-table { overflow-x: auto; }
.final-table h2 { margin-bottom: 12px; }
.final-table table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.final-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); padding: 6px 8px; border-bottom: var(--line); }
.final-table td { padding: 8px; border-bottom: 1px solid var(--paper-2); white-space: nowrap; }
.final-table td:nth-child(2) { display: flex; align-items: center; gap: 8px; }
.final-table td .av { background: var(--c); }
.final-table .num { font-family: var(--mono); }
.final-table tr:first-child td { background: var(--tint-gold); }
.final-table .pos { font-family: var(--mono); color: var(--muted); }

/* ---------- reactions + floaters + toasts ---------- */
.reactions {
  position: fixed; left: 16px; bottom: 16px; z-index: 40; display: flex; gap: 2px; background: var(--card); border: var(--line);
  border-radius: 999px; padding: 4px 6px; box-shadow: var(--shadow);
}
.reactions button, .react-row button { border: none; background: none; font-size: 1.35rem; width: 38px; height: 38px; border-radius: 50%; transition: transform 0.12s; }
.reactions button:hover, .react-row button:hover { transform: scale(1.2) translateY(-2px); background: var(--paper); }
.reactions button:active, .react-row button:active { transform: scale(0.9); }
.floaters { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.floater { position: absolute; bottom: -60px; display: grid; justify-items: center; gap: 2px; animation: floatup 3.2s ease-out forwards; }
.floater .fe { font-size: 3rem; }
.floater small { font-size: 0.75rem; font-weight: 700; color: #fff; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); white-space: nowrap; }
@keyframes floatup {
  0% { transform: translate(0, 0) scale(0.5); opacity: 0; }
  10% { opacity: 1; transform: translate(0, -60px) scale(1.1); }
  100% { transform: translate(var(--drift), -75vh) scale(0.9); opacity: 0; }
}
.toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow);
  animation: toastin 0.35s cubic-bezier(0.3, 1.5, 0.6, 1); transition: opacity 0.4s, transform 0.4s;
}
.toast.bad { background: var(--accent); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toastin { from { transform: translateY(-20px) scale(0.9); opacity: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 150; }

/* ---------- dialogs ---------- */
.picker { border: var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
.picker::backdrop { background: rgba(22, 22, 29, 0.5); }
.picker-inner { padding: 18px; display: grid; gap: 12px; }
.picker-head { display: flex; justify-content: space-between; align-items: center; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .setup-card, .players-card, .standings-card { grid-column: 1; grid-row: auto; }
  .setup-card { order: 3; }
  .standings-card { order: 4; }
  .res-actions.sticky { width: 100%; }
  .res-actions.sticky .btn.huge { flex: 1; font-size: 0.95rem; padding: 10px 12px; }
}
@media (max-width: 640px) {
  .home-inner { padding-top: 56px; }
  .logo-text { font-size: 2.5rem; }
  .tagline { font-size: 1.05rem; }
  .home-actions { grid-template-columns: 1fr; }
  .podium { gap: 6px; min-height: 300px; }
  .final .podium { min-height: 320px; }
  .step { width: 31%; }
  .pod-av { width: 58px; height: 58px; font-size: 2rem; }
  .p1 .pod-av { width: 74px; height: 74px; font-size: 2.6rem; }
  .pod-name { font-size: 0.95rem; max-width: 100%; }
  .pod-meta { font-size: 0.7rem; }
  .p1 .pod-block { height: 150px; } .p2 .pod-block { height: 110px; } .p3 .pod-block { height: 80px; }
  .pod-block span { font-size: 2.2rem; }
  .seg { flex-wrap: wrap; }
  .seg button { font-size: 0.82rem; padding: 8px 4px; }
  .gamebar { padding: 8px 12px; gap: 8px; }
  .mini-logo { font-size: 0; gap: 0; }
  .reactions button { width: 32px; height: 32px; font-size: 1.1rem; }
}

/* ---------- theme + ads (shared across bondia.sh games) ---------- */
/* Bright fills keep dark text in both themes. */
:is(.pod-block, .avatar-btn, .av-opt.on, .theme-opt.on .theme-ic) { color: var(--on-bright); }
.floating-theme { position: fixed; top: 12px; right: 12px; z-index: 50; }
body:not([data-screen='home']) .floating-theme { display: none; }
.ad-slot { max-width: 970px; margin: 0 auto 120px; padding: 0 16px; text-align: center; }
.ad-slot small { display: block; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

/* ---------- icons ---------- */
.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.btn .i, .icon-btn .i { vertical-align: middle; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); background: var(--paper-2); }
.tag .i, .pill .i, .toggle .i, .seg .i, .setting-label .i { width: 1em; height: 1em; }
.spinner-globe .i { width: 56px; height: 56px; color: var(--ink-2); stroke-width: 1.5; }
.host-mark { color: var(--gold); }
.host-mark .i { width: 0.95em; height: 0.95em; }
.crown .i { width: 40px; height: 40px; color: var(--gold); }
.award-icon .i { width: 22px; height: 22px; }
.rules div { display: flex; align-items: center; gap: 8px; }
.tag { display: inline-flex; align-items: center; gap: 6px; }
.btn { gap: 6px; }

/* ---------- hub link, close room, privacy footer ---------- */
.hub-link {
  position: fixed; top: 12px; left: 12px; z-index: 50; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: 999px; background: var(--card); border: var(--line); box-shadow: var(--shadow-sm);
  text-decoration: none; font-weight: 700; font-size: 0.9rem; color: var(--ink-2);
}
.hub-link:hover { color: var(--ink); }
body:not([data-screen='home']) .hub-link { display: none; }
.gamebar > a.icon-btn { text-decoration: none; margin-right: -6px; }
.danger-ic:hover { color: var(--accent); }
.site-foot { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); padding: 8px 0 24px; }
.site-foot a, .site-foot button { color: var(--muted); background: none; border: none; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.site-foot a:hover, .site-foot button:hover { color: var(--ink); }

/* ---------- sketch ---------- */
:root { --brand: #7a5cff; --tint-brand: #efebff; --tint-good: #e3f7ec; --tint-close: #fff4d6; }
:root[data-theme='dark'] { --tint-brand: #29234a; --tint-good: #183424; --tint-close: #3a3215; }
.av.big { width: 72px; height: 72px; font-size: 2.4rem; }
.logo-mark {
  width: 96px; height: 96px; border-radius: 26px; background: var(--brand); color: #fff; display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
}
.logo-mark .i { width: 54px; height: 54px; stroke-width: 1.75; }
.mini-logo > span { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff; display: inline-grid; place-items: center; }
.mini-logo > span .i { width: 17px; height: 17px; }
textarea.input {
  font: inherit; border: var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface); color: var(--ink); width: 100%;
  min-height: 110px; font-size: 0.95rem; line-height: 1.5; resize: vertical; outline: none;
}
textarea.input:focus { box-shadow: 0 0 0 4px rgba(122, 92, 255, 0.22); }
.custom-status { font-size: 0.85rem; font-weight: 600; }
.custom-status.bad { color: var(--accent); }
.custom-status.ok { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 0.8rem; font-weight: 700; background: var(--surface); }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.theme-opt {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left;
  border: var(--line); border-radius: 12px; background: var(--surface); padding: 10px; transition: border-color 0.12s, background 0.12s;
}
.theme-opt:hover { border-color: var(--border-strong); }
.theme-opt.on { border-color: var(--brand); background: var(--tint-brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.theme-ic { grid-row: span 2; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--paper); color: var(--ink-2); }
.theme-opt.on .theme-ic { background: var(--brand); color: #fff !important; }
.theme-opt b { font-size: 0.92rem; line-height: 1.2; }
.theme-opt small { font-size: 0.75rem; color: var(--muted); }

/* play screen: turn bar on top, canvas + tools on the left, chat and scores on the right */
#play { min-height: calc(100dvh - 58px); }
.play-wrap { max-width: 1240px; margin: 0 auto; padding: 14px 16px 40px; display: grid; gap: 14px; }
.turn-bar {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  background: var(--card); border: var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 10px 14px 14px; overflow: hidden;
}
.round-pill { font-size: 0.85rem; color: var(--ink-2); border: var(--line); border-radius: 999px; padding: 4px 10px; background: var(--surface); white-space: nowrap; }
.round-pill b { color: var(--ink); }
.word-box { display: grid; justify-items: center; gap: 2px; min-width: 0; text-align: center; }
.word-note { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.word-note .i { width: 1em; height: 1em; }
.word-text { font-size: clamp(1.3rem, 3vw, 1.8rem); font-weight: 800; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.blanks { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 6px 16px; }
.blank-word { display: inline-flex; gap: 5px; }
.slot {
  width: 0.95em; height: 1.35em; border-bottom: 2.5px solid var(--ink); display: grid; place-items: end center;
  font-size: clamp(1.15rem, 2.6vw, 1.55rem); font-weight: 800; font-family: var(--mono); line-height: 1.2;
}
.slot.shown { color: var(--brand); animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.6, 1); }
.blanks sup { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); align-self: flex-start; }
.clock { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 1.5rem; color: var(--ink); min-width: 3.6ch; justify-content: flex-end; }
.clock .i { color: var(--muted); width: 0.85em; height: 0.85em; }
.clock.low { color: var(--accent); }
.tb-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--paper-2); }
.tb-progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width 0.2s linear, background 0.3s; }
.tb-progress span.low { background: var(--accent); }

.play-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
/* Canvas and tools share one width: as big as fits under the turn bar with room for the tools, 4:3. */
.stage { --stage-w: max(min(100%, 420px), min(100%, calc((100dvh - 290px) * 4 / 3))); display: grid; gap: 12px; justify-items: center; min-width: 0; }
.canvas-box {
  position: relative; width: var(--stage-w); aspect-ratio: 4 / 3;
  border-radius: var(--r); border: var(--line); box-shadow: var(--shadow); overflow: hidden; background: #fff;
}
#board { display: block; width: 100%; height: 100%; touch-action: none; }
#board.can-draw { cursor: crosshair; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(22, 22, 29, 0.28); animation: fadein 0.25s; }
.overlay.reveal { background: rgba(22, 22, 29, 0.08); }
.clock.hide { visibility: hidden; }
.ov-card {
  background: var(--card); color: var(--ink); border: var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 20px 22px;
  display: grid; gap: 10px; justify-items: center; text-align: center; width: min(440px, 100%); max-height: 100%; overflow-y: auto;
  animation: pop 0.3s cubic-bezier(0.3, 1.5, 0.6, 1);
}
.ov-card h2 { font-size: 1.35rem; }
.ov-timer { margin: 0; font-size: 0.9rem; }
.choices { display: grid; gap: 8px; width: 100%; }
.btn.choice { font-size: 1.15rem; padding: 12px 16px; }
.btn.choice:hover { border-color: var(--brand); background: var(--tint-brand); }
.reveal-word { color: var(--brand); }
.gains { display: grid; gap: 4px; width: 100%; }
.gain-row { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; text-align: left; padding: 4px 6px; border-radius: 10px; }
.gain-row .av { background: var(--c); }
.gain-row span { font-weight: 700; display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.gain-row small { color: var(--muted); font-family: var(--mono); font-weight: 400; }
.gain-row b { font-family: var(--mono); color: var(--green); }
.gains p { margin: 4px 0 0; }

.tools {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; width: var(--stage-w);
  background: var(--card); border: var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 8px 10px;
}
.swatches { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; background: var(--sw); border: 1px solid var(--border-strong); padding: 0;
  transition: transform 0.1s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.on { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }
.tool-group { display: flex; gap: 2px; padding-left: 10px; border-left: var(--line); }
.tool { width: 38px; height: 38px; border: none; border-radius: 10px; background: none; display: grid; place-items: center; color: var(--ink-2); }
.tool:hover { background: var(--paper); color: var(--ink); }
.tool.on { background: var(--ink); color: var(--paper); }
.tool .dot { width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; }
.host-dock:empty { display: none; }
.host-bar {
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  background: var(--card); border: var(--line); border-radius: 16px; box-shadow: var(--shadow-sm); padding: 8px;
}

.side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.chat-card { padding: 0; display: grid; overflow: hidden; }
.chat-log { height: 300px; overflow-y: auto; padding: 12px 14px; display: grid; align-content: start; gap: 6px; font-size: 0.93rem; }
.msg { line-height: 1.35; overflow-wrap: anywhere; }
.msg .i { width: 1em; height: 1em; }
.msg.good { color: var(--green); font-weight: 700; background: var(--tint-good); border-radius: 8px; padding: 4px 8px; display: flex; align-items: center; gap: 6px; }
.msg.good .gain { font-family: var(--mono); }
.msg.close { background: var(--tint-close); border-radius: 8px; padding: 4px 8px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.msg.sys { color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 6px; }
.msg.sys b { color: var(--ink-2); }
.msg.inner { color: var(--ink-2); font-style: italic; }
.msg.inner > span .i { color: var(--muted); }
.guess-form { display: flex; gap: 6px; padding: 8px; border-top: var(--line); }
.guess-form input {
  flex: 1; min-width: 0; border: var(--line); border-radius: 10px; padding: 9px 12px; background: var(--surface); color: var(--ink);
  font-size: 1rem; font-weight: 600; outline: none;
}
.guess-form input:focus { box-shadow: 0 0 0 3px rgba(122, 92, 255, 0.25); }
.react-row { display: flex; justify-content: space-between; padding: 2px 8px 6px; }
.react-row button { width: 34px; height: 34px; font-size: 1.15rem; }

.roster-card { padding: 8px; }
.roster { display: grid; gap: 2px; }
.r-row { display: grid; grid-template-columns: 20px 32px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 10px; }
.r-row .av { background: var(--c); }
.r-row.is-me { background: var(--paper); }
.r-row.got { background: var(--tint-good); }
.r-row.offline { opacity: 0.45; }
.r-pos { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); text-align: center; }
.r-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-score { font-family: var(--mono); text-align: right; display: grid; line-height: 1.1; }
.r-score small { color: var(--green); font-size: 0.72rem; }
.st { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
.st .i { width: 15px; height: 15px; }
.st.drawing { background: var(--tint-brand); color: var(--brand); }
.st.good { background: var(--green); color: #fff; }

.gallery-card h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; border: var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; background: #fff; }
.gallery figcaption { display: grid; padding: 6px 10px 8px; }
.gallery figcaption small { color: var(--muted); }

@media (max-width: 900px) {
  .play-grid { grid-template-columns: 1fr; }
  .stage { --stage-w: 100%; }
  .side { grid-template-columns: 1fr; }
  .chat-log { height: 200px; }
}
@media (max-width: 640px) {
  .logo-mark { width: 72px; height: 72px; border-radius: 20px; }
  .logo-mark .i { width: 40px; height: 40px; }
  .play-wrap { padding: 8px 10px 30px; gap: 10px; }
  .turn-bar { grid-template-columns: 1fr auto; padding: 8px 10px 12px; gap: 6px 10px; }
  .round-pill { grid-row: 1; justify-self: start; font-size: 0.78rem; }
  .clock { grid-row: 1; grid-column: 2; font-size: 1.25rem; }
  .word-box { grid-row: 2; grid-column: 1 / -1; }
  .tools { gap: 6px; padding: 6px; }
  .swatch { width: 26px; height: 26px; }
  .tool-group { padding-left: 6px; }
  .tool { width: 34px; height: 34px; }
  .ov-card { padding: 14px; gap: 8px; }
  .ov-card h2 { font-size: 1.1rem; }
  .btn.choice { padding: 9px 12px; font-size: 1rem; }
  .av.big { width: 52px; height: 52px; font-size: 1.7rem; }
  .theme-grid { grid-template-columns: 1fr 1fr; }
}
