:root {
  --pink: #ed1b76;
  --teal: #067a6a;
  --teal-light: #0fb39a;
  --green: #22c55e;
  --red: #ef233c;
  --bg: #121016;
  --panel: #1d1a23;
  --panel-2: #26222e;
  --text: #f4f1f6;
  --muted: #a39cae;
  --sand: #d8b98a;
  --sand-dark: #c49f6b;
  --radius: 14px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --display: 'Bebas Neue', Impact, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  transition: background-color .3s;
}
body.light-green { background: #0f1a14; }
body.light-red { background: #1f0d10; }

[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--panel-2);
}
.logo { margin: 0; font-family: var(--display); font-size: 30px; letter-spacing: 1.5px; font-weight: 400; }
.shapes { color: var(--pink); margin-right: 6px; }

/* Bottom padding leaves room for the fixed reaction bar. */
main { max-width: 980px; margin: 0 auto; padding: 24px 16px 88px; }

.card { background: var(--panel); border-radius: var(--radius); padding: 24px; border: 1px solid var(--panel-2); }
.screen.card { max-width: 560px; margin: 24px auto; }

h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: 1px; margin: 0 0 12px; }
h2 { font-size: 34px; }
h3 { font-size: 24px; margin-top: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.g { color: var(--green); }
.r { color: var(--red); }

label { display: block; font-size: 13px; color: var(--muted); margin: 16px 0 6px; }
input, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid #3a3544;
  border-radius: 10px;
  padding: 10px 12px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--pink); outline-offset: 1px; }

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid #3a3544;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--pink); }
.btn.primary { background: var(--pink); border-color: var(--pink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: none; border: none; color: var(--muted); padding-left: 0; margin-top: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: none; font-size: 22px; cursor: pointer; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.lang-btn { padding: 6px 10px; font: 700 13px var(--mono); letter-spacing: 1px; }

.join-screen { max-width: 760px; margin: 24px auto; }
.join-card { max-width: 560px; margin: 0 auto; }

.guide { margin-top: 32px; }
.guide h2 { text-align: center; }
.guide h3 { margin-top: 28px; }
.rules { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.rules li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: 10px;
  padding: 12px 14px;
  line-height: 1.5;
}
.rule-icon { font-size: 20px; line-height: 1.3; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.mode-card {
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-top: 3px solid var(--pink);
  border-radius: 10px;
  padding: 14px 16px;
}
.mode-card h4 { margin: 0 0 6px; font-size: 16px; }
.mode-card p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 14px; }
.mode-card p b { color: var(--text); }
.guide-note { margin-top: 10px; }
.difficulty-list { margin: 0; padding-left: 20px; line-height: 1.8; }

.join-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.join-actions #room-code { width: 110px; text-transform: uppercase; font-family: var(--mono); letter-spacing: 2px; }
.or { color: var(--muted); font-size: 13px; }

.lobby-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.room-code { font-family: var(--mono); font-size: 40px; font-weight: 700; letter-spacing: 6px; color: var(--pink); }
.player-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  max-height: 320px;
  overflow-y: auto;
}
.player-list li { background: var(--panel-2); border-radius: 8px; padding: 8px 12px; display: flex; gap: 8px; align-items: center; min-width: 0; }
.player-list li > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list .num { font-family: var(--mono); color: var(--teal-light); }
.player-list .tag { margin-left: auto; font-size: 13px; flex-shrink: 0; }
.player-list li.me { box-shadow: inset 0 0 0 2px var(--pink); }
.lobby-controls { margin-top: 12px; }
#mode-help { margin: 6px 0 0; min-height: 2.6em; }
.lobby-controls .btn { margin-top: 14px; width: 100%; }

/* Race */
.hud { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.light-banner {
  font-family: var(--display);
  font-size: clamp(32px, 7vw, 56px);
  letter-spacing: 2px;
  color: var(--muted);
  transition: color .15s, text-shadow .15s;
}
.light-green .light-banner { color: var(--green); text-shadow: 0 0 24px rgba(34, 197, 94, .5); }
.light-red .light-banner { color: var(--red); text-shadow: 0 0 24px rgba(239, 35, 60, .6); }
.timer { font-family: var(--mono); font-size: 32px; font-weight: 700; }
.hud-right { display: flex; align-items: center; gap: 12px; }
.round-badge {
  font: 700 13px var(--mono);
  letter-spacing: .5px;
  color: var(--pink);
  border: 1px solid var(--pink);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.end-match { display: block; margin: 12px 0 0 auto; }
.spectate-note { margin: 0 0 10px; color: var(--pink); font-weight: 600; }
.timer.low { color: var(--red); }

.chant { margin: -4px 0 12px; }
.chant-words {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-height: 1.6em;
  font-family: var(--display);
  font-size: clamp(20px, 4vw, 28px);
  letter-spacing: 1px;
}
.chant-words span { color: var(--panel-2); transition: color .12s, transform .12s; }
.chant-words span.on { color: var(--green); transform: translateY(-1px); }
.chant-words span.on:last-child { color: #f59e0b; }
.chant.red .chant-words span { color: var(--red); }
.chant-bar { height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.chant-bar span { display: block; height: 100%; width: 0; background: var(--green); }
.chant.red .chant-bar span { background: var(--red); }
.doll.twitch { animation: twitch .45s ease-in-out; }
@keyframes twitch {
  0%, 100% { transform: none; }
  35% { transform: rotate(-8deg) scaleX(.82); }
  60% { transform: rotate(5deg); }
}

.field {
  position: relative;
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(0, 0, 0, .05) 79px 80px),
    linear-gradient(180deg, var(--sand) 0%, var(--sand-dark) 100%);
  padding: 16px 150px 16px 16px;
  min-height: 220px;
  overflow: hidden;
}
.finish-line {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 140px;
  width: 6px;
  background: var(--red);
  box-shadow: 0 0 8px rgba(239, 35, 60, .6);
}
.doll-wrap { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); display: flex; align-items: end; }
.tree { width: 40px; height: 120px; margin-right: -8px; }
.doll { width: 84px; height: 150px; transition: transform .25s ease-in-out; }
.doll .doll-front { display: none; }
.light-red .doll .doll-front { display: inline; }
.light-red .doll .doll-back { display: none; }
.light-red .doll { animation: turn .25s ease-in-out; }
.light-red .doll .eye { fill: var(--red); filter: drop-shadow(0 0 3px var(--red)); }
@keyframes turn { from { transform: scaleX(0.1); } to { transform: scaleX(1); } }

.lanes { display: grid; gap: 6px; }
.lane { position: relative; height: 34px; border-bottom: 1px dashed rgba(0, 0, 0, .15); }
.runner {
  --p: 0;
  position: absolute;
  top: 2px;
  left: calc(var(--p) * (100% - 30px));
  display: flex;
  align-items: center;
  gap: 6px;
  transition: left .12s linear;
  white-space: nowrap;
}
.runner .body {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid #043d35;
  color: #fff;
  font: 700 10px var(--mono);
  display: grid;
  place-items: center;
}
.runner .label { font-size: 12px; font-weight: 600; color: #3b2b17; }
.runner.me .body { background: var(--pink); border-color: #7a0b3c; box-shadow: 0 0 0 3px rgba(237, 27, 118, .35); }
.runner.dead .body { background: #555; border-color: #333; transform: rotate(90deg); }
.runner.dead .body::after { content: '✕'; position: absolute; color: var(--red); font-size: 22px; }
.runner.dead .label { text-decoration: line-through; opacity: .6; }
.runner.won .body { border-color: gold; box-shadow: 0 0 10px gold; }

/* Compact track for big rooms: shared lanes, small dots, only you labelled. */
.field.compact .lanes { gap: 2px; }
.field.compact .lane { height: 22px; }
.field.compact .runner { top: 3px; left: calc(var(--p) * (100% - 16px)); }
.field.compact .runner .body { width: 16px; height: 16px; border-width: 1.5px; }
.field.compact .runner.dead .body::after { font-size: 13px; }
.field.compact .runner.me { top: -1px; left: calc(var(--p) * (100% - 24px)); z-index: 2; }
.field.compact .runner.me .body { width: 24px; height: 24px; font-size: 8px; }
.field.compact .runner:not(.me) { opacity: .9; }
.field.compact .runner.dead:not(.me) { opacity: .45; }

.flash { position: absolute; inset: 0; background: var(--red); opacity: 0; pointer-events: none; }
.flash.go { animation: flash .5s ease-out; }
@keyframes flash { 0% { opacity: .55; } 100% { opacity: 0; } }

/* ---- other games ---- */
.stage { margin-bottom: 4px; }
.light-banner[data-tone='honeycomb'] { color: #f5c26b; }
.light-banner[data-tone='tug'] { color: #f28c28; }
.light-banner[data-tone='bridge'] { color: #7dd3fc; }
.games .game-card { border-top-color: var(--teal-light); }

/* Honeycomb */
.hc { display: grid; gap: 10px; justify-items: center; }
.hc-mine { width: min(340px, 100%); }
.cookie { width: 100%; height: auto; display: block; }
.cookie-disc { fill: #d9a55b; stroke: #b9853b; stroke-width: 4; }
.cookie-outline { fill: none; stroke: #b37a30; stroke-width: 2; stroke-dasharray: 4 5; }
.cookie-letters { font: 700 13px var(--mono); fill: #5b3a1e; dominant-baseline: middle; }
.cookie-letters .carved { fill: #fff3d6; }
.cookie-letters .next { fill: var(--pink); font-size: 17px; }
.cookie-needle { fill: #cfd6dd; stroke: #6b7682; stroke-width: 2; }
.cookie-cracks polyline { fill: none; stroke: #5b3a1e; stroke-width: 3; stroke-linejoin: bevel; }
.cookie.broken .cookie-disc { fill: #8a6a45; }
.cookie.broken { animation: shake .4s; opacity: .7; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.hc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; width: 100%; }
.hc-tile { display: flex; gap: 6px; align-items: center; justify-content: center; background: var(--panel); border: 1px solid var(--panel-2); border-radius: 8px; padding: 4px 6px; font: 600 12px var(--mono); }
.hc-tile.me { border-color: var(--pink); }
.hc-tile.won { border-color: var(--green); }
.hc-tile.dead { opacity: .45; }
.hc-icon { color: #f5c26b; font-size: 15px; }

/* Tug of war */
.tug { display: grid; gap: 12px; }
.tug-heave { justify-self: center; font: 400 34px var(--display); letter-spacing: 3px; color: var(--panel-2); transition: color .1s, transform .1s; }
.tug-heave.on { color: #f28c28; transform: scale(1.15); }
.tug-track { position: relative; height: 54px; border-radius: var(--radius); background: linear-gradient(180deg, var(--sand) 0%, var(--sand-dark) 100%); overflow: hidden; }
.tug-track::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 6px; margin-top: -3px; background: repeating-linear-gradient(90deg, #7a5230 0 10px, #9b6b3f 10px 20px); }
.tug-line { position: absolute; top: 0; bottom: 0; width: 4px; background: var(--red); }
.tug-line-left { left: 5%; }
.tug-line-right { right: 5%; }
.tug-center { position: absolute; top: 8px; bottom: 8px; left: 50%; width: 2px; background: rgba(0, 0, 0, .25); }
.tug-knot { position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: var(--pink); border: 3px solid #7a0b3c; transition: left .15s linear; }
.tug-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tug-team { background: var(--panel); border: 1px solid var(--panel-2); border-radius: 10px; padding: 8px 10px; }
.tug-team.mine { border-color: var(--pink); }
.tug-team h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.tug-right { text-align: right; }
.tug-players { display: flex; flex-wrap: wrap; gap: 4px; }
.tug-right .tug-players { justify-content: flex-end; }
.tug-chip { font: 600 11px var(--mono); background: var(--teal); border-radius: 999px; padding: 2px 7px; }
.tug-chip.me { background: var(--pink); }
.tug-hint { margin: 0; text-align: center; }

/* Glass bridge */
.bridge { display: grid; gap: 10px; }
.bridge-prompt { margin: 0; text-align: center; font-weight: 600; }
.bridge-prompt.mine { color: var(--pink); font-size: 18px; }
.bridge-timer { height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bridge-timer span { display: block; height: 100%; background: #7dd3fc; }
.bridge-panes { display: flex; gap: 4px; overflow-x: auto; padding: 10px; border-radius: var(--radius); background: linear-gradient(180deg, #0b1320, #152238); scrollbar-width: thin; }
.bridge-platform { flex: 0 0 26px; border-radius: 6px; background: #3b4252; }
.bridge-platform.end { background: var(--teal); }
.bridge-step { flex: 0 0 auto; display: grid; grid-template-rows: 1fr 1fr; gap: 6px; }
.pane { width: 58px; height: 46px; border-radius: 6px; border: 1px solid rgba(125, 211, 252, .45); background: rgba(125, 211, 252, .12); display: grid; place-items: center; font: 700 14px var(--mono); color: #cfefff; }
.bridge-step.active .pane { width: 72px; border-color: #7dd3fc; background: rgba(125, 211, 252, .25); box-shadow: 0 0 12px rgba(125, 211, 252, .35); }
.pane b { color: var(--pink); }
.pane.safe { background: rgba(15, 179, 154, .45); border-color: var(--teal-light); }
.pane.unsafe { opacity: .35; }
.pane.broken { background: repeating-linear-gradient(45deg, rgba(239, 35, 60, .35) 0 6px, transparent 6px 12px); border-color: var(--red); }
.bridge-queue { display: flex; flex-wrap: wrap; gap: 4px; }
.bridge-chip { font: 600 11px var(--mono); background: var(--panel-2); border-radius: 999px; padding: 2px 8px; }
.bridge-chip.active { background: #7dd3fc; color: #0b1320; }
.bridge-chip.me { outline: 2px solid var(--pink); }
.bridge-chip.fell { opacity: .45; text-decoration: line-through; }
.bridge-chip.crossed { background: var(--teal); }

.letters-panel {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: text;
}
.letters-panel:focus { outline: none; border-color: var(--pink); }
.letters { font-family: var(--mono); font-size: clamp(20px, 3.2vw, 28px); line-height: 1.7; word-break: break-all; }
.letters span { color: var(--muted); padding: 0 1px; border-radius: 4px; }
.letters span:nth-child(5n) { margin-right: .6em; }
/* Words mode: real spaces, wrap between words. */
.letters.words { word-break: normal; white-space: pre-wrap; }
.letters.words span:nth-child(5n) { margin-right: 0; }
.site-footer { text-align: center; padding: 8px 16px 72px; }

/* Quick play and public rooms */
.quick-play { width: 100%; margin-top: 12px; }
.public-rooms { max-width: 560px; margin: 16px auto 0; }
.public-rooms h3 { margin-top: 0; }
.public-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.public-room { display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: 'game code join' 'meta meta join'; gap: 2px 10px; align-items: center; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.public-room-game { grid-area: game; font-weight: 600; }
.public-room code { grid-area: code; font: 700 13px var(--mono); color: var(--pink); letter-spacing: 2px; }
.public-room-meta { grid-area: meta; }
.public-room .btn { grid-area: join; padding: 6px 12px; }
.check-row { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: var(--text); font-size: 14px; }
.check-row input { width: auto; }

/* Emoji reactions */
.reaction-bar { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 4px; padding: 5px 8px; background: var(--panel); border: 1px solid var(--panel-2); border-radius: 999px; z-index: 15; box-shadow: 0 4px 18px rgba(0, 0, 0, .35); }
.reaction-btn { background: none; border: none; font-size: 22px; line-height: 1; padding: 4px 5px; cursor: pointer; border-radius: 50%; transition: transform .1s; }
.reaction-btn:hover { transform: scale(1.2); }
.reaction-btn:active { transform: scale(.9); }
.reaction-layer { position: fixed; inset: 0; pointer-events: none; z-index: 14; overflow: hidden; }
.reaction-float { position: absolute; bottom: 60px; display: grid; justify-items: center; animation: float-up 2.6s ease-out forwards; }
.reaction-float span { font-size: 34px; }
.reaction-float small { font: 700 10px var(--mono); color: var(--muted); }
@keyframes float-up {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  12% { transform: translateY(-20px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-60vh) scale(1); opacity: 0; }
}
.site-footer a { color: var(--muted); }
.letters span.done { color: var(--green); opacity: .55; }
.letters span.current { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -3px 0 var(--pink); }
.letters span.wrong { background: rgba(239, 35, 60, .35); }
.light-red .letters span.current { box-shadow: inset 0 -3px 0 var(--red); }

.type-sink { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; left: -100px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 12, .8);
  display: grid;
  place-items: center;
  z-index: 10;
  padding: 16px;
}
.countdown-box { text-align: center; }
.countdown-label { font-family: var(--display); font-size: 36px; letter-spacing: 2px; color: var(--text); min-height: 1em; }
.countdown-num { font-family: var(--display); font-size: 160px; color: var(--pink); animation: pop 1s ease-out infinite; }
@keyframes pop { 0% { transform: scale(1.4); opacity: 0; } 30% { transform: scale(1); opacity: 1; } }

.results-card { width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.results-scroll { overflow-y: auto; min-height: 0; margin: 8px 0 18px; }
.results-scroll .results-table { margin: 0; }
.results-table thead th { position: sticky; top: 0; background: var(--panel); }
.results-table { width: 100%; border-collapse: collapse; margin: 8px 0 18px; font-size: 14px; }
.results-table th, .results-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--panel-2); }
.results-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.results-table tr.me td { color: var(--pink); font-weight: 700; }
.status-won { color: var(--green); }
.status-dead { color: var(--red); }
.status-cut { color: #f59e0b; }
.results-fate { font-family: var(--display); font-size: 30px; letter-spacing: 1px; margin: 0 0 4px; }
.results-fate.good { color: var(--green); }
.results-fate.bad { color: var(--red); }
.results-fate.cut { color: #f59e0b; }
.results-next { margin: -8px 0 12px; text-align: center; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--pink);
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 20;
  max-width: calc(100% - 32px);
}

@media (max-width: 600px) {
  .field { padding-right: 96px; }
  .finish-line { right: 90px; }
  .doll { width: 56px; height: 100px; }
  .tree { display: none; }
  .runner .label { display: none; }
}


/* =====================================================================
   Theme: invitation card, ○△□ motifs, guard pink, tracksuit teal
   ===================================================================== */
:root {
  --ink: #1b1410;
  --card: #d9b98c;
  --card-dark: #c49c68;
  --gold: #f5c542;
}

/* Giant faint shapes behind everything. */
.backdrop { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.backdrop i { position: absolute; border: 3px solid rgba(237, 27, 118, .07); }
.bd-circle { width: 460px; height: 460px; border-radius: 50%; left: -160px; top: 90px; }
.bd-square { width: 360px; height: 360px; right: -120px; bottom: -80px; transform: rotate(12deg); }
.bd-triangle { width: 420px; height: 380px; right: 8%; top: -140px; border: none !important; background: rgba(15, 179, 154, .05); clip-path: polygon(50% 0, 100% 100%, 0 100%); }

.logo .shapes b { font-weight: 400; margin-right: 1px; }
.logo .shapes b:nth-child(2) { color: var(--teal-light); }
.logo .shapes b:nth-child(3) { color: var(--gold); }

/* Start page */
.join-screen { max-width: 820px; }
.invite { perspective: 1200px; display: grid; justify-items: center; padding: 8px 0 12px; }
.invite-card {
  position: relative;
  width: min(560px, 100%);
  color: var(--ink);
  border-radius: 12px;
  padding: 26px 28px 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, .18), transparent 40%),
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .025) 0 2px, transparent 2px 5px),
    linear-gradient(160deg, var(--card) 0%, var(--card-dark) 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(255, 255, 255, .25);
  transform: rotateX(4deg) rotate(-1deg);
  animation: invite-in .7s cubic-bezier(.2, .8, .2, 1);
}
@keyframes invite-in { from { opacity: 0; transform: translateY(30px) rotateX(25deg) rotate(-4deg); } }
.invite-shapes { display: flex; gap: 14px; justify-content: center; margin-bottom: 10px; }
.invite-shapes i { width: 34px; height: 34px; border: 3px solid var(--ink); display: block; }
.ic-circle { border-radius: 50%; }
.ic-triangle { border: none !important; background: var(--ink); clip-path: polygon(50% 0, 100% 100%, 0 100%, 0 100%, 12% 86%, 88% 86%, 50% 16%, 12% 86%, 0 100%); }
.invite-title { font-family: var(--display); font-size: clamp(34px, 7vw, 48px); text-align: center; margin: 0 0 6px; letter-spacing: 2px; color: var(--ink); }
.invite-intro { text-align: center; margin: 0 auto 16px; max-width: 420px; line-height: 1.5; font-size: 14px; color: #3d2f22; }
.invite-intro .g { color: #0b7a3c; }
.invite-intro .r { color: #b3122e; }
.invite-label { color: #5a4632; margin: 0 0 4px; font-weight: 600; }
.invite-input {
  background: rgba(255, 255, 255, .28);
  border: none;
  border-bottom: 2px solid var(--ink);
  border-radius: 6px 6px 0 0;
  color: var(--ink);
  font-weight: 600;
}
.invite-input::placeholder { color: rgba(27, 20, 16, .45); }
.invite-input:focus { outline: none; background: rgba(255, 255, 255, .45); }
.btn.big { font-size: 18px; padding: 14px 18px; letter-spacing: .5px; }
.invite .quick-play { width: 100%; margin-top: 14px; box-shadow: 0 6px 18px rgba(237, 27, 118, .45); }
.btn.ink { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
.btn.ink:hover { background: var(--ink); color: var(--card); border-color: var(--ink); }
.invite-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; }
.invite-actions .or { color: #5a4632; font-size: 13px; }
.code-join { display: flex; gap: 6px; }
.code-input { width: 104px; text-transform: uppercase; font-family: var(--mono); letter-spacing: 3px; text-align: center; }

.section-title { display: flex; align-items: center; gap: 10px; font-family: var(--display); letter-spacing: 1.5px; }
.section-title .st-shape { color: var(--pink); font-size: .9em; }
.small-title { font-size: 22px; }

.public-rooms { max-width: 560px; margin: 22px auto 0; }
.public-room { border: 1px solid #3a3544; background: linear-gradient(90deg, rgba(6, 122, 106, .18), transparent 60%), var(--panel); }
.public-room code { background: rgba(237, 27, 118, .12); padding: 2px 6px; border-radius: 6px; }

.guide { margin-top: 40px; }
.guide h2.section-title { justify-content: center; font-size: 34px; }
.rules { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.mode-card { position: relative; overflow: hidden; }
.mode-card::after { content: ''; position: absolute; right: -14px; bottom: -14px; width: 54px; height: 54px; border: 2px solid rgba(237, 27, 118, .12); border-radius: 50%; }

@media (max-width: 600px) {
  .invite-card { padding: 22px 18px 20px; transform: none; }
  .code-join { width: 100%; }
  .code-input { flex: 1; }
  .invite-actions .btn.ink[data-action="create"] { width: 100%; }
  .invite-actions .or { width: 100%; text-align: center; }
}

/* ---- Lobby: tracksuit badges and setting tiles ---- */
.lobby { max-width: 1040px; margin: 16px auto; }
.lobby-top {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-radius: 12px; color: var(--ink);
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .025) 0 2px, transparent 2px 5px),
    linear-gradient(160deg, var(--card) 0%, var(--card-dark) 100%);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
}
.lobby-code-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #5a4632; }
.lobby-top .room-code { color: var(--ink); font-size: clamp(34px, 7vw, 48px); letter-spacing: 8px; line-height: 1; }
.lobby-top-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.lobby-top .btn { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
.lobby-top .btn:hover { background: var(--ink); color: var(--card); }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 40px; height: 22px; border-radius: 999px; background: rgba(27, 20, 16, .35); position: relative; flex-shrink: 0; transition: background .2s; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--pink); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--ink); outline-offset: 2px; }
.switch input:disabled ~ * { opacity: .6; cursor: default; }

.lobby-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 1.5fr); gap: 16px; margin-top: 16px; align-items: start; }
.lobby-panel { background: var(--panel); border: 1px solid var(--panel-2); border-radius: var(--radius); padding: 18px; }
.lobby-panel .section-title { margin-top: 0; }

.lobby .player-list { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px 10px; max-height: 460px; padding: 10px 8px 4px; overflow-x: hidden; }
.player-list li.badge {
  position: relative; display: grid; justify-items: center; gap: 4px; padding: 10px 6px 8px;
  border-radius: 10px; background: linear-gradient(180deg, #0b8f7c 0%, var(--teal) 100%);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2); min-width: 0;
}
.badge-num { font: 700 20px var(--mono); color: #fff; letter-spacing: 1px; background: rgba(255, 255, 255, .92); color: var(--teal); border-radius: 4px; padding: 0 6px; }
.badge-name { font-size: 12px; font-weight: 600; color: #e7fff9; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list li.badge.me { box-shadow: 0 0 0 3px var(--pink), inset 0 -3px 0 rgba(0, 0, 0, .2); }
.badge-host { position: absolute; top: -9px; right: -6px; font-size: 16px; }
.waiting { margin: 14px 0 0; color: var(--muted); font-style: italic; }

.lobby-settings { display: grid; gap: 6px; }
.lobby-settings fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
.lobby-settings legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 10px 0 6px; padding: 0; }
.tiles { display: grid; gap: 8px; }
.tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tile { position: relative; display: grid; justify-items: center; gap: 4px; margin: 0; padding: 12px 6px 10px; border-radius: 10px; border: 2px solid var(--panel-2); background: var(--panel-2); color: var(--text); text-align: center; cursor: pointer; transition: border-color .15s, transform .1s, background .15s; }
.tile:hover { border-color: rgba(237, 27, 118, .5); }
.tile:active { transform: scale(.97); }
.tile input, .segmented input { position: absolute; opacity: 0; pointer-events: none; }
.tile-icon { font-size: 26px; line-height: 1; }
.tile-icon.shape { font-size: 30px; color: var(--pink); }
.tile-name { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.tile.is-checked { border-color: var(--pink); background: rgba(237, 27, 118, .14); box-shadow: 0 0 0 1px var(--pink), 0 6px 18px rgba(237, 27, 118, .18); }
.tile:has(input:focus-visible), .segmented label:has(input:focus-visible) { outline: 2px solid var(--pink); outline-offset: 2px; }
.tile-help { margin: 4px 2px 0; font-size: 13px; color: var(--muted); line-height: 1.45; min-height: 1.4em; }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented label { position: relative; margin: 0; cursor: pointer; }
.segmented label span { display: grid; gap: 1px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--panel-2); background: var(--panel-2); font-size: 13.5px; font-weight: 600; color: var(--text); text-align: center; transition: border-color .15s, background .15s; }
.segmented label span small { font-size: 11px; font-weight: 500; color: var(--muted); }
.segmented label.is-checked span { border-color: var(--pink); background: rgba(237, 27, 118, .14); }
.text-settings { display: flex; flex-wrap: wrap; gap: 0 18px; }

/* Guests see the choices, not the controls. */
.lobby-settings.readonly .tile, .lobby-settings.readonly .segmented label { cursor: default; }
.lobby-settings.readonly .tile:not(.is-checked), .lobby-settings.readonly .segmented label:not(.is-checked) { opacity: .38; }
.lobby-settings.readonly .tile:hover { border-color: var(--panel-2); }

.start-btn { width: 100%; margin-top: 16px; font-family: var(--display); font-size: 24px; letter-spacing: 3px; box-shadow: 0 8px 22px rgba(237, 27, 118, .4); }

@media (max-width: 760px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .tiles-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lobby-top { padding: 14px 16px; }
}

/* ---- Race screen ---- */
.hud {
  margin-bottom: 8px; padding: 10px 16px; border-radius: 12px;
  background: linear-gradient(180deg, #1f1b26, #17141c); border: 1px solid var(--panel-2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
}
.hud-light { display: flex; align-items: center; gap: 14px; min-width: 0; }
.lamp {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5a5363, #2a2530 70%);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, .5), 0 0 0 3px #2a2530;
  transition: background .15s, box-shadow .15s;
}
.lamp[data-tone='green'] { background: radial-gradient(circle at 35% 30%, #b7ffcf, #22c55e 55%, #117a38); box-shadow: 0 0 22px rgba(34, 197, 94, .8), 0 0 0 3px #0d3a1f; }
.lamp[data-tone='red'] { background: radial-gradient(circle at 35% 30%, #ffc2cb, #ef233c 55%, #8e0f22); box-shadow: 0 0 26px rgba(239, 35, 60, .9), 0 0 0 3px #3d0a12; }
.lamp[data-tone='honeycomb'] { background: radial-gradient(circle at 35% 30%, #ffe8b8, #f5c26b 55%, #a8741f); box-shadow: 0 0 18px rgba(245, 194, 107, .6), 0 0 0 3px #3b2a10; }
.lamp[data-tone='tug'] { background: radial-gradient(circle at 35% 30%, #ffd2ad, #f28c28 55%, #9a4f0d); box-shadow: 0 0 18px rgba(242, 140, 40, .6), 0 0 0 3px #3b220b; }
.lamp[data-tone='bridge'] { background: radial-gradient(circle at 35% 30%, #e3f7ff, #7dd3fc 55%, #2d7fa6); box-shadow: 0 0 18px rgba(125, 211, 252, .6), 0 0 0 3px #10303f; }
.round-badge { background: rgba(237, 27, 118, .1); }
.timer { font-family: var(--mono); background: #0b0a0e; border: 1px solid #332e3b; border-radius: 8px; padding: 2px 12px; min-width: 96px; text-align: right; color: #f4f1f6; box-shadow: inset 0 0 12px rgba(0, 0, 0, .6); }
.timer.low { color: var(--red); text-shadow: 0 0 12px rgba(239, 35, 60, .7); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.time-bar { height: 4px; border-radius: 2px; background: var(--panel-2); overflow: hidden; margin: 0 4px 12px; }
.time-bar span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--teal-light), var(--pink)); transition: width .25s linear; }
.time-bar.low span { background: var(--red); }

/* The playground wall with its painted sky, behind the doll. */
.field { box-shadow: 0 14px 34px rgba(0, 0, 0, .4); }
.field::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 60px;
  background:
    radial-gradient(ellipse 60px 18px at 18% 45%, rgba(255, 255, 255, .9), transparent 70%),
    radial-gradient(ellipse 80px 22px at 55% 30%, rgba(255, 255, 255, .85), transparent 70%),
    radial-gradient(ellipse 50px 15px at 82% 60%, rgba(255, 255, 255, .8), transparent 70%),
    linear-gradient(180deg, #7ec8f2 0%, #a9dcf7 100%);
  border-bottom: 4px solid #e8d7b6;
  pointer-events: none;
}
.field { padding-top: 72px; }
.field .finish-line { top: 60px; }
/* Lanes and runners sit on the sand, in front of the wall. */
.field .lanes { position: relative; }

/* Letters panel */
.letters-panel { background: linear-gradient(180deg, #1f1b26, #19161f); box-shadow: inset 0 2px 10px rgba(0, 0, 0, .35); }
.letters { font-size: clamp(22px, 3.4vw, 30px); letter-spacing: .5px; }
.letters span.current { background: var(--pink); color: #fff; box-shadow: 0 0 0 2px rgba(237, 27, 118, .35), 0 4px 12px rgba(237, 27, 118, .35); border-radius: 6px; }
.light-red .letters span.current { background: var(--red); box-shadow: 0 0 0 2px rgba(239, 35, 60, .4); }
.letters span.done { color: var(--teal-light); opacity: .6; }
.spectate-note { font-family: var(--display); font-size: 20px; letter-spacing: 1px; }

/* Countdown inside the guards' mask shapes */
.countdown-shape { position: relative; width: 200px; height: 200px; display: grid; place-items: center; margin: 8px auto 0; }
.countdown-shape::before { content: ''; position: absolute; inset: 0; border: 8px solid var(--pink); filter: drop-shadow(0 0 18px rgba(237, 27, 118, .6)); }
.countdown-shape[data-shape='circle']::before { border-radius: 50%; }
.countdown-shape[data-shape='square']::before { border-radius: 8px; }
.countdown-shape[data-shape='triangle']::before { border: none; background: var(--pink); clip-path: polygon(50% 2%, 98% 96%, 2% 96%, 2% 96%, 13% 88%, 87% 88%, 50% 17%, 13% 88%, 2% 96%); }
.countdown-shape[data-shape='triangle'] .countdown-num { margin-top: 36px; font-size: 110px; }
.countdown-num { font-size: 130px; line-height: 1; }

/* ELIMINATED / SURVIVED stamp */
.stamp {
  position: fixed; left: 50%; top: 42%; z-index: 30; pointer-events: none;
  font-family: var(--display); font-size: clamp(54px, 12vw, 120px); letter-spacing: 6px; line-height: 1;
  padding: 10px 28px; border: 8px solid currentColor; border-radius: 14px;
  transform: translate(-50%, -50%) rotate(-12deg); opacity: 0;
  background: rgba(255, 250, 245, .82);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
.stamp.eliminated { color: #d10f2f; }
.stamp.survived { color: #0e9a4a; }
.stamp.show { animation: stamp-in 2.2s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes stamp-in {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(2.4); }
  12% { opacity: 1; transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
}

/* Game stages: a bit more depth */
.cookie { filter: drop-shadow(0 16px 24px rgba(0, 0, 0, .5)); }
.tug-track { box-shadow: 0 10px 26px rgba(0, 0, 0, .4); height: 64px; }
.tug-track::before { height: 10px; margin-top: -5px; border-radius: 5px; }
.tug-knot { width: 28px; height: 28px; margin: -14px 0 0 -14px; box-shadow: 0 0 14px rgba(237, 27, 118, .7); }
.bridge-panes { box-shadow: inset 0 0 40px rgba(0, 0, 0, .6), 0 12px 30px rgba(0, 0, 0, .4); }

@media (max-width: 600px) {
  .hud { padding: 8px 10px; gap: 8px; }
  .hud-light { gap: 8px; }
  .light-banner { font-size: 26px; white-space: nowrap; }
  .round-badge { font-size: 10.5px; padding: 3px 7px; }
  .hud-right { gap: 6px; }
  .lamp { width: 26px; height: 26px; }
  .timer { min-width: 76px; font-size: 24px; }
  .countdown-shape { width: 160px; height: 160px; }
  .countdown-num { font-size: 100px; }
}

/* Toasts sit above the reaction bar. */
.toast { bottom: 72px; }

/* ---- Results ---- */
.overlay { backdrop-filter: blur(3px); }
.results-card {
  position: relative; width: min(620px, 100%); overflow-y: auto;
  border-top: 4px solid var(--pink);
  background: linear-gradient(180deg, #221d29 0%, var(--panel) 40%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  animation: card-in .35s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes card-in { from { opacity: 0; transform: translateY(24px) scale(.96); } }
.results-shapes { display: flex; justify-content: center; gap: 10px; font-size: 18px; margin-bottom: 2px; }
.results-shapes b { font-weight: 400; color: var(--pink); }
.results-shapes b:nth-child(2) { color: var(--teal-light); }
.results-shapes b:nth-child(3) { color: var(--gold); }
#results-title { text-align: center; font-size: clamp(30px, 6vw, 42px); }
.results-fate { text-align: center; font-size: clamp(24px, 5vw, 32px); }

.num-chip { display: inline-block; font: 700 11px var(--mono); color: var(--teal); background: #eafbf7; border-radius: 4px; padding: 1px 5px; margin-right: 8px; box-shadow: inset 0 -2px 0 rgba(6, 122, 106, .25); }
.player-cell { white-space: nowrap; }
.results-table tr.out td { opacity: .5; }
.results-table tr.out td:first-child::before { content: '✕ '; color: var(--red); opacity: 1; }
.results-table tr.me td { background: rgba(237, 27, 118, .1); }
.results-table tr.me td:first-child { box-shadow: inset 3px 0 0 var(--pink); }

/* Podium: 2nd, 1st, 3rd */
.podium { list-style: none; margin: 10px 0 14px; padding: 0; display: flex; justify-content: center; align-items: flex-end; gap: 8px; }
.podium-step { position: relative; flex: 1; max-width: 170px; display: grid; justify-items: center; gap: 4px; padding: 10px 8px 34px; border-radius: 10px 10px 0 0; text-align: center; min-width: 0; }
.podium-step .num-chip { margin: 0; font-size: 13px; }
.podium-name { font-weight: 700; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-stat { font-size: 11.5px; color: rgba(255, 255, 255, .75); }
.podium-place { position: absolute; bottom: 4px; font-family: var(--display); font-size: 28px; line-height: 1; color: rgba(0, 0, 0, .35); }
.place-1 { min-height: 150px; background: linear-gradient(180deg, #f5c542, #b8860b); color: #2a1c05; }
.place-1 .podium-stat { color: rgba(42, 28, 5, .75); }
.place-2 { min-height: 118px; background: linear-gradient(180deg, #d9dde3, #8d949e); color: #1d2026; }
.place-2 .podium-stat { color: rgba(29, 32, 38, .7); }
.place-3 { min-height: 96px; background: linear-gradient(180deg, #e0a36b, #9a5b25); color: #2a1506; }
.place-3 .podium-stat { color: rgba(42, 21, 6, .7); }
.podium-step.me { box-shadow: 0 0 0 3px var(--pink); }
.podium-step { animation: rise .5s cubic-bezier(.2, .9, .3, 1.2) backwards; }
.place-2 { animation-delay: .1s; }
.place-1 { animation-delay: .25s; }
.place-3 { animation-delay: .05s; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }

/* The winner and the golden piggy bank */
.winner { position: relative; display: grid; justify-items: center; gap: 6px; margin: 6px 0 12px; overflow: hidden; padding-top: 4px; }
.piggy { width: min(240px, 70%); height: auto; filter: drop-shadow(0 0 30px rgba(245, 197, 66, .35)); animation: sway 3.2s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
.piggy-money { animation: fill-up 2.2s ease-out forwards; transform: translateY(40px); }
@keyframes fill-up { to { transform: translateY(0); } }
.coins { position: absolute; inset: 0; pointer-events: none; }
.coins i { position: absolute; top: -20px; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b0, #f5c542 60%, #b8860b); box-shadow: 0 0 6px rgba(245, 197, 66, .7); animation: coin-fall 2.4s linear infinite; }
.coins i:nth-child(1) { left: 12%; animation-delay: 0s; }
.coins i:nth-child(2) { left: 24%; animation-delay: .7s; }
.coins i:nth-child(3) { left: 38%; animation-delay: 1.3s; }
.coins i:nth-child(4) { left: 52%; animation-delay: .3s; }
.coins i:nth-child(5) { left: 64%; animation-delay: 1.8s; }
.coins i:nth-child(6) { left: 76%; animation-delay: 1s; }
.coins i:nth-child(7) { left: 88%; animation-delay: .5s; }
.coins i:nth-child(8) { left: 45%; animation-delay: 2s; }
@keyframes coin-fall { 0% { transform: translateY(0) rotateY(0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translateY(260px) rotateY(720deg); opacity: 0; } }
.winner-badge { display: flex; align-items: center; gap: 10px; }
.winner-num { font: 700 26px var(--mono); color: var(--teal); background: #eafbf7; border-radius: 6px; padding: 2px 10px; }
.winner-name { font-family: var(--display); font-size: 34px; letter-spacing: 1px; color: var(--gold); text-shadow: 0 0 18px rgba(245, 197, 66, .4); }
.winner-prize { margin: 0; font: 700 14px var(--mono); color: var(--gold); letter-spacing: 1px; }

@media (max-width: 600px) {
  .podium-step { padding: 8px 4px 30px; }
  .place-1 { min-height: 128px; }
  .place-2 { min-height: 104px; }
  .place-3 { min-height: 86px; }
  .podium-stat { font-size: 10.5px; }
  .winner-name { font-size: 28px; }
}

/* ---- Title bar: guard style ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: 10px 20px; gap: 12px;
  background: rgba(18, 16, 22, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(237, 27, 118, .35);
  box-shadow: 0 1px 0 rgba(237, 27, 118, .15), 0 8px 24px rgba(0, 0, 0, .35), 0 1px 18px rgba(237, 27, 118, .18);
}
.brand { display: flex; align-items: center; gap: 12px; margin: 0; min-width: 0; }
.masks { display: flex; gap: 5px; flex-shrink: 0; }
/* Black guard masks with the pink shape on the face. */
.mask { position: relative; width: 24px; height: 28px; border-radius: 50% 50% 46% 46%; background: #0b0a0d; box-shadow: inset 0 0 0 1px #2e2a35, 0 2px 6px rgba(0, 0, 0, .5); display: block; }
.mask::before { content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.m-circle::before { width: 11px; height: 11px; border: 2px solid var(--pink); border-radius: 50%; }
.m-square::before { width: 10px; height: 10px; border: 2px solid var(--pink); }
.m-triangle::before { width: 14px; height: 12px; background: var(--pink); clip-path: polygon(50% 0, 100% 100%, 0 100%, 0 100%, 16% 84%, 84% 84%, 50% 18%, 16% 84%, 0 100%); transform: translate(-50%, -58%); }
.brand-name { font-family: var(--display); font-size: 28px; letter-spacing: 2.5px; line-height: 1; white-space: nowrap; background: linear-gradient(180deg, #fff 30%, #ffd1e4); -webkit-background-clip: text; background-clip: text; color: transparent; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.room-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px 12px; border-radius: 999px; font: inherit; color: var(--text);
  background: rgba(237, 27, 118, .12); border: 1px solid rgba(237, 27, 118, .5);
}
.room-chip:hover { background: rgba(237, 27, 118, .22); }
.room-chip-code { font: 700 14px var(--mono); letter-spacing: 2px; color: var(--pink); }
.room-chip-count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.round-btn {
  width: 36px; height: 36px; display: grid; place-items: center; flex-shrink: 0;
  border-radius: 50%; border: 1px solid #3a3544; background: var(--panel-2);
  color: var(--text); font: 700 16px Inter, system-ui, sans-serif; cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.round-btn:hover { border-color: var(--pink); }
.round-btn:active { transform: scale(.94); }
.round-btn[aria-pressed='true'] { opacity: .7; }
.lang-switch { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--panel-2); border: 1px solid #3a3544; }
.lang-switch button { border: none; background: none; color: var(--muted); font: 700 12px var(--mono); letter-spacing: 1px; padding: 5px 9px; border-radius: 999px; cursor: pointer; }
.lang-switch button.active { background: var(--pink); color: #fff; }

/* How to play, as a dialog from any screen */
.help-dialog {
  width: min(760px, calc(100% - 24px)); max-height: min(86vh, 900px); padding: 0;
  border: 1px solid var(--panel-2); border-top: 4px solid var(--pink); border-radius: 14px;
  background: var(--bg); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.help-dialog::backdrop { background: rgba(10, 8, 12, .7); backdrop-filter: blur(3px); }
.help-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; background: var(--bg); border-bottom: 1px solid var(--panel-2); }
.help-head h2 { margin: 0; font-size: 28px; }
.help-body { padding: 4px 18px 20px; }
.help-body .guide { margin-top: 12px; }

@media (max-width: 600px) {
  .topbar { padding: 8px 12px; }
  .brand { gap: 8px; }
  .mask { width: 20px; height: 24px; }
  .brand-name { font-size: 22px; letter-spacing: 1.5px; }
  .topbar-actions { gap: 6px; }
  .round-btn { width: 32px; height: 32px; font-size: 14px; }
  .lang-switch button { padding: 4px 7px; }
  /* In a room the chip needs the space: keep the masks, drop the name. */
  .topbar.in-room .brand-name { display: none; }
  .room-chip { padding: 4px 9px; }
}
.mode-card p b.g { color: var(--green); }
.mode-card p b.r { color: var(--red); }

/* Rotating teaser on the invitation card */
.invite-teaser { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 2.6em; margin: -6px auto 14px; max-width: 440px; text-align: center; font-weight: 600; font-size: 14.5px; color: var(--ink); }
.teaser-icon { font-size: 20px; line-height: 1; }
.invite-teaser.fade { animation: teaser-in .6s ease-out; }
@keyframes teaser-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  .invite-teaser.fade { animation: none; }
}

/* Offline page (served by the service worker) */
.offline { max-width: 420px; margin: 18vh auto 0; padding: 0 16px; text-align: center; }
.offline img { border-radius: 24px; }
.offline h1 { font-family: var(--display); font-size: 2.6rem; letter-spacing: 0.04em; color: var(--pink); margin: 16px 0 8px; }
.offline p { color: var(--muted); }

/* Bots: computer players the host adds from the lobby */
.player-list li.badge.bot { background: linear-gradient(180deg, #4a4358 0%, #332d3f 100%); }
.player-list li.badge.bot .badge-num { color: #332d3f; }
.badge-bot { position: absolute; top: 4px; left: 6px; font-size: 13px; opacity: .85; }
.badge-remove {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--panel-2); background: var(--bg); color: var(--muted); font-size: 11px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; padding: 0;
}
.badge-remove:hover, .badge-remove:focus-visible { color: #fff; border-color: var(--pink); background: var(--pink); }
.bot-bar { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--panel-2); }
.bot-hint { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.bot-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bot-label { font-size: 13px; font-weight: 600; margin-right: 4px; }
.bot-add { padding: 6px 12px; font-size: 13px; }
.bot-add:disabled { opacity: .45; cursor: not-allowed; }

/* Invite as a QR code */
.qr-dialog { width: min(400px, calc(100% - 24px)); }
.qr-body { display: grid; justify-items: center; gap: 10px; padding: 20px 18px 22px; text-align: center; }
.qr-canvas { width: min(296px, 100%); height: auto; aspect-ratio: 1; border-radius: 12px; image-rendering: pixelated; }
.qr-code-line { margin: 4px 0 0; color: var(--muted); }
.qr-room-code { font: 700 22px var(--mono); letter-spacing: 4px; color: var(--text); margin-left: 6px; }
.qr-link { margin: 0; font: 13px var(--mono); color: var(--muted); word-break: break-all; }

/* Start page records: today's leaderboard and your own stats */
.records { max-width: 560px; margin: 22px auto 0; }
.records h3 { margin: 0 0 4px; }
.board-note { margin: 0 0 10px; }
.board-tabs { display: inline-flex; gap: 4px; padding: 3px; margin-bottom: 8px; border-radius: 999px; background: var(--panel-2); }
.board-tab { border: 0; border-radius: 999px; padding: 5px 14px; background: none; color: var(--muted); font: 600 13px inherit; cursor: pointer; }
.board-tab[aria-pressed="true"] { background: var(--pink); color: #fff; }
.board-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.board-row {
  display: grid; grid-template-columns: 22px auto 1fr auto; grid-template-areas: 'rank num name wpm' 'rank num detail wpm';
  align-items: center; gap: 0 10px; padding: 6px 10px; border-radius: 8px; background: var(--panel-2);
}
.board-row.me { box-shadow: inset 0 0 0 2px var(--pink); }
.board-rank { grid-area: rank; font: 700 16px var(--mono); color: var(--muted); text-align: center; }
.board-row:nth-child(1) .board-rank { color: #f5c542; }
.board-row:nth-child(2) .board-rank { color: #cfd6de; }
.board-row:nth-child(3) .board-rank { color: #d99155; }
.board-row .num-chip { grid-area: num; }
.board-name { grid-area: name; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.board-detail { grid-area: detail; }
.board-wpm { grid-area: wpm; font: 700 15px var(--mono); color: var(--teal-light); }
.my-stats { margin-top: 16px; padding: 12px 14px; border-radius: 10px; border: 1px dashed var(--panel-2); }
.my-stats h4 { margin: 0 0 8px; font-family: var(--display); font-size: 20px; letter-spacing: .04em; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin: 0; }
.stats-grid div { display: grid; gap: 2px; }
.stats-grid dt { font-size: 12px; color: var(--muted); }
.stats-grid dd { margin: 0; font: 700 18px var(--mono); }
.my-stats .muted { margin: 8px 0 0; }

/* Spectator link */
.spectator-count { font: 600 13px var(--mono); color: var(--teal-light); margin-left: 4px; }
body.watching .bot-bar, body.watching #start { display: none; }

/* Marbles: one card per pair, the duel code in the middle */
.marbles { display: grid; gap: 10px; }
.marbles-note { margin: 0; text-align: center; font-weight: 600; color: var(--muted); }
.marbles-note.overtime { color: #f28c28; }
.marbles-pairs { display: grid; gap: 8px; }
.marbles-pair {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--panel-2);
}
.marbles-pair.mine { border-color: var(--pink); box-shadow: 0 0 0 1px var(--pink); }
.marbles-pair.over { opacity: .75; }
.marbles-side { display: grid; gap: 4px; min-width: 0; }
.marbles-side:last-child { justify-items: end; text-align: right; }
.marbles-player { display: flex; align-items: center; gap: 6px; min-width: 0; }
.marbles-side:last-child .marbles-player { flex-direction: row-reverse; }
.marbles-side:last-child .num-chip { margin: 0 0 0 8px; }
.marbles-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marbles-count { font: 700 22px var(--mono); color: var(--teal-light); }
.marbles-side.winner .marbles-count { color: #f5c542; }
.marbles-side.loser .marbles-count { color: var(--red); }
.marble-row { display: flex; flex-wrap: wrap; gap: 3px; max-width: 150px; }
.marbles-side:last-child .marble-row { justify-content: flex-end; }
.marble { width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff 0, #7dd3fc 35%, #1d4ed8 100%); }
.marble.empty { background: var(--panel-2); }
.marbles-typed { font: 12px var(--mono); color: var(--muted); letter-spacing: 2px; }
.marbles-code {
  min-width: 96px; padding: 10px 14px; border-radius: 8px; text-align: center;
  font: 700 22px var(--mono); letter-spacing: 3px; color: var(--muted); background: var(--panel-2);
}
.marbles-code.mine { color: #cfefff; background: rgba(125, 211, 252, .18); border: 1px solid rgba(125, 211, 252, .5); font-size: 28px; }
.marbles-code b { color: var(--pink); }
.marbles-code.mine b { color: var(--teal-light); }
.marbles-result { font: 600 13px inherit; letter-spacing: 0; }
.marbles-wait { color: var(--muted); }
@media (max-width: 600px) {
  .marbles-pair { grid-template-columns: 1fr; text-align: center; }
  .marbles-side, .marbles-side:last-child { justify-items: center; text-align: center; }
  .marbles-side:last-child .marbles-player { flex-direction: row; }
  .marble-row, .marbles-side:last-child .marble-row { justify-content: center; }
}

/* Per-game pages (server-rendered, for search engines and sharing) */
.brand-link { text-decoration: none; color: inherit; }
.lang-links { display: inline-flex; gap: 2px; }
.lang-links a { padding: 4px 9px; border-radius: 999px; font: 700 12px var(--mono); color: var(--muted); text-decoration: none; }
.lang-links a.active { background: var(--pink); color: #fff; }
.page { max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; }
.page-card { background: var(--panel); border: 1px solid var(--panel-2); border-top: 4px solid var(--pink); border-radius: var(--radius); padding: 24px 22px 28px; }
.page-kicker { margin: 0 0 6px; font: 600 12px var(--mono); letter-spacing: 2px; text-transform: uppercase; }
.page-kicker a { color: var(--muted); text-decoration: none; }
.page-title { margin: 0; font-family: var(--display); font-size: clamp(38px, 7vw, 56px); letter-spacing: 2px; line-height: 1; }
.page-teaser { margin: 8px 0 0; font-size: 18px; color: var(--sand); font-weight: 600; }
.page-intro { color: var(--muted); }
.page .btn.big { display: inline-block; margin: 6px 0 22px; text-decoration: none; }
.page .section-title { margin: 22px 0 8px; }
.page-rules { line-height: 1.6; }
.page-rules b { color: var(--text); }
.page-rules b.g { color: var(--green); }
.page-rules b.r { color: var(--red); }
.page-others { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.page-others a { display: block; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); color: var(--text); text-decoration: none; font-weight: 600; }
.page-others a:hover { outline: 2px solid var(--pink); }

/* About and FAQ on the start page (also what search engines read) */
.about { max-width: 720px; margin: 36px auto 0; }
.about h2 { text-align: center; }
.about > p { color: var(--muted); line-height: 1.6; }
.faq { margin: 18px 0 0; display: grid; gap: 14px; }
.faq dt { font-weight: 700; }
.faq dd { margin: 4px 0 0; color: var(--muted); line-height: 1.6; }
.about-disclaimer { margin-top: 18px; text-align: center; }
.page-about { margin-top: 24px; line-height: 1.6; }
