:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #f8f6f1;
  --text: #1d1b16;
  --muted: #6b665c;
  --line: #e2ddd2;
  --accent: #3355ff;
  --accent-ink: #ffffff;
  --easy: #1f9d55;
  --medium: #d98a00;
  --hard: #d6336c;
  --danger: #c92a2a;
  --gold: #f0b400;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c;
    --surface: #1d2029;
    --surface-2: #252935;
    --text: #ecebe8;
    --muted: #9a9ca5;
    --line: #2f3340;
    --accent: #6b86ff;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #14161c; --surface: #1d2029; --surface-2: #252935; --text: #ecebe8;
  --muted: #9a9ca5; --line: #2f3340; --accent: #6b86ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
h2 { font-size: 18px; margin: 0 0 4px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }

/* screens */
.screen { display: none; }
.screen.active { display: block; }
.home-wrap { max-width: 760px; margin: 0 auto; padding: 40px 16px 60px; }

.logo { font-weight: 800; font-size: 56px; letter-spacing: -.04em; line-height: 1; }
.logo span { color: var(--accent); }
.logo.small { font-size: 24px; }
.logo.tiny { font-size: 20px; }
.hero { text-align: center; margin-bottom: 28px; }
.tagline { font-size: 17px; color: var(--muted); max-width: 520px; margin: 12px auto 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cards .card { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.cards .card p { margin: 0; }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } .logo { font-size: 44px; } }

.name-field { display: flex; align-items: center; gap: 12px; margin: 0 auto 16px; max-width: 360px; }
.name-field span { font-weight: 600; white-space: nowrap; }

input {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
  min-width: 0;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 10px 14px; transition: transform .06s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.diff { flex: 1; color: #fff; border: none; }
.btn.diff.easy { background: var(--easy); }
.btn.diff.medium { background: var(--medium); }
.btn.diff.hard { background: var(--hard); }
.btn.diff:hover { filter: brightness(1.08); }
.diff-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.diff-buttons.secondary .btn { flex: 1; }
#room-diff .btn { opacity: .55; }
#room-diff .btn.selected { opacity: 1; outline: 2px solid var(--text); outline-offset: 2px; }

.custom-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
#room-custom { margin: 12px 0 0; }
#start-race { margin-top: 16px; }
.join-form { display: flex; gap: 8px; }
#join-code { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }

.rules summary { cursor: pointer; font-weight: 600; }
.rules ul { margin: 12px 0 0; padding-left: 20px; }
.foot { text-align: center; font-size: 13px; }

.challenge { border-color: var(--accent); }
.challenge .route-big { font-size: 20px; font-weight: 700; margin: 6px 0 12px; }

/* lobby */
.lobby-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.room-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.room-code { font-size: 40px; font-weight: 800; letter-spacing: .15em; font-variant-numeric: tabular-nums; }
.invite { flex: 1; display: flex; gap: 8px; min-width: 260px; }
@media (max-width: 640px) { .invite { flex-direction: column; min-width: 0; width: 100%; } }

.player-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.player-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface-2); border-radius: 10px;
}
.player-list .pname { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list .pmeta { color: var(--muted); font-size: 13px; text-align: right; }
.player-list .me .pname::after { content: " (you)"; color: var(--muted); font-weight: 400; }
.player-list .off { opacity: .5; }
.player-list.compact li { padding: 8px 10px; flex-wrap: wrap; gap: 4px 8px; }
.player-list.compact .pmeta { width: 100%; text-align: left; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--text); }
.badge.host { background: var(--accent); color: #fff; }
.badge.done { background: var(--easy); color: #fff; }
.badge.out { background: var(--danger); color: #fff; }
.wins { font-weight: 700; color: var(--gold); font-size: 13px; }

/* game */
.hud {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.hud-left { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.route { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.route span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.route strong { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); }
.hud-stats { display: flex; gap: 18px; }
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.stat span { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.hud-actions { display: flex; gap: 6px; }
#btn-panel { display: none; }
@media (max-width: 760px) {
  .hud { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .hud-left { flex-basis: 100%; }
  .hud-left .logo { display: none; }
  .hud-stats { gap: 14px; }
  .hud-actions { margin-left: auto; }
  #btn-panel { display: inline-block; }
}

.racers-strip {
  display: flex; gap: 6px; overflow-x: auto; flex-basis: 100%; font-size: 13px; padding-bottom: 2px;
}
.racers-strip .chip { white-space: nowrap; padding: 2px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
@media (min-width: 761px) { .racers-strip { display: none !important; } }

.game-body { display: flex; gap: 20px; max-width: 1280px; margin: 0 auto; padding: 20px 16px 80px; align-items: flex-start; }
.article-wrap {
  flex: 1; min-width: 0; position: relative;
  background: #fff; color: #202122; border-radius: var(--radius); border: 1px solid var(--line);
  padding: 24px 32px 40px; box-shadow: var(--shadow);
}
@media (max-width: 760px) { .article-wrap { padding: 16px; } .game-body { padding: 12px 12px 60px; } }
.panel { width: 300px; flex-shrink: 0; position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.panel-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
@media (max-width: 760px) {
  .panel { display: none; position: fixed; inset: auto 0 0 0; top: auto; width: 100%; max-height: 70vh; z-index: 30;
    background: var(--bg); padding: 12px; border-top: 1px solid var(--line); box-shadow: 0 -8px 30px rgba(0,0,0,.2); }
  .panel.open { display: flex; }
}

.target-card img { width: 100%; max-height: 180px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; background: var(--surface-2); }
.target-card .tname { font-size: 18px; font-weight: 700; }
.target-card .tdesc { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.target-card .textract { font-size: 13px; margin: 0; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }

.path { margin: 0; padding-left: 22px; font-size: 14px; }
.path li { padding: 2px 0; }
.path li:last-child { font-weight: 700; }
.path li.back { color: var(--muted); }

.loading { position: absolute; inset: 0; background: rgba(255,255,255,.6); display: flex; justify-content: center; padding-top: 80px; z-index: 5; border-radius: var(--radius); }
.spinner { width: 36px; height: 36px; border: 4px solid #ddd; border-top-color: #3355ff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Wikipedia article content (always on a light "paper" surface) */
.article-title { font-family: "Source Serif 4", Georgia, serif; font-weight: 400; font-size: 32px; margin: 0 0 12px; padding-bottom: 6px; border-bottom: 1px solid #a2a9b1; color: #202122; }
.article [id] { scroll-margin-top: 90px; }
.article { font-size: 15px; line-height: 1.6; overflow-wrap: break-word; }
.article a { color: #3366cc; text-decoration: none; }
.article a:hover { text-decoration: underline; }
.article a.wr-dead { color: #54595d; cursor: not-allowed; }
.article a.wr-dead:hover { text-decoration: none; }
.article a.wr-target { background: #fff3a8; border-radius: 3px; }
.article h2 { font-family: "Source Serif 4", Georgia, serif; font-weight: 400; font-size: 24px; border-bottom: 1px solid #a2a9b1; margin: 24px 0 8px; color: #202122; }
.article h3 { font-size: 17px; font-weight: 700; text-transform: none; letter-spacing: 0; color: #202122; margin: 18px 0 6px; }
.article h4 { font-size: 15px; margin: 14px 0 4px; }
.article img { max-width: 100%; height: auto; }
.article .mw-heading { all: unset; display: block; }
.article .infobox, .article .infobox_v2, .article .sidebar {
  float: right; clear: right; width: 290px; margin: 0 0 12px 16px; font-size: 13px; line-height: 1.4;
  border: 1px solid #a2a9b1; background: #f8f9fa; padding: 4px; border-spacing: 3px;
}
.article .infobox th, .article .infobox td { vertical-align: top; padding: 2px 4px; text-align: left; }
.article .infobox-above, .article .infobox-title { font-size: 120%; font-weight: 700; text-align: center !important; }
.article .infobox-image, .article .infobox-caption { text-align: center !important; }
.article figure, .article .thumb { margin: 4px 0 12px 16px; float: right; clear: right; max-width: 260px; font-size: 13px; }
.article figure.mw-halign-left { float: left; margin: 4px 16px 12px 0; }
.article figure.mw-halign-center, .article figure.mw-halign-none { float: none; margin: 8px 0; }
.article figcaption { color: #54595d; padding-top: 4px; }
.article table.wikitable { border-collapse: collapse; background: #f8f9fa; font-size: 14px; margin: 12px 0; display: block; overflow-x: auto; }
.article table.wikitable th, .article table.wikitable td { border: 1px solid #a2a9b1; padding: 4px 8px; }
.article table.wikitable th { background: #eaecf0; }
.article .hatnote { font-style: italic; color: #54595d; padding-left: 1.6em; margin-bottom: 8px; }
.article blockquote { border-left: 3px solid #c8ccd1; margin: 12px 0; padding: 4px 16px; }
.article .navbox { border: 1px solid #a2a9b1; font-size: 12px; margin-top: 12px; width: 100%; }
.article .navbox th { background: #ccf; padding: 2px 6px; }
.article .navbox td { padding: 2px 6px; }
.article .reflist, .article .refbegin { font-size: 13px; }
.article .mw-collapsible-toggle, .article .navbar { display: none; }
.article .gallery { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.article ul, .article ol { padding-left: 1.6em; }
.article .clear-both, .article .reflist { clear: both; }
@media (max-width: 760px) {
  .article .infobox, .article .infobox_v2, .article .sidebar, .article figure, .article .thumb { float: none; width: 100% !important; max-width: 100%; margin: 8px 0; }
  .article table { display: block; overflow-x: auto; }
}

/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(10,12,20,.55); backdrop-filter: blur(4px); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.countdown-box { text-align: center; color: #fff; }
.cd-route { font-size: 22px; font-weight: 600; margin-bottom: 12px; }
.cd-route b { color: #9fb2ff; }
.cd-num { font-size: 120px; font-weight: 800; line-height: 1; animation: pop .9s ease-out infinite; }
@keyframes pop { 0% { transform: scale(1.4); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { opacity: .9; } }

.modal { background: var(--surface); border-radius: 18px; max-width: 560px; width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { font-size: 26px; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.big-stats { display: flex; gap: 12px; margin: 14px 0; }
.big-stats > div { flex: 1; background: var(--surface-2); border-radius: 12px; padding: 12px; text-align: center; }
.big-stats b { display: block; font-size: 28px; }
.big-stats small { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
.path-inline { font-size: 14px; line-height: 1.8; }
.path-inline .arrow { color: var(--muted); margin: 0 4px; }
.rank { width: 26px; font-weight: 800; text-align: center; }
.rank.gold { color: var(--gold); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px);
  background: #1d1b16; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 500;
  transition: transform .25s; z-index: 100; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

/* ===== v2 additions ===== */
.btn small { display: block; font-size: 11px; font-weight: 500; opacity: .85; }
.btn.big { padding: 14px; font-size: 17px; }
.btn.tiny { padding: 3px 8px; font-size: 12px; border-radius: 8px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.small-print { font-size: 12px; }
.full { flex-basis: 100%; margin: 0; }
.flappy-btn { margin-top: 4px; }
.wait-text { margin: 0; font-size: 15px; }
.room-code.pub { font-size: 26px; letter-spacing: 0; }

/* HUD timer + penalties */
.pen { color: var(--danger); font-size: 12px; font-weight: 800; margin-left: 2px; }
#stat-time.urgent span { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.cd-diff { color: #ffd43b; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 13px; margin-bottom: 6px; }

/* avatars + chips */
.avatar {
  --c: #3355ff; flex-shrink: 0;
  width: 28px; height: 28px; border-radius: 50%; background: var(--c); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--c) 40%, transparent);
}
.player-list li .avatar { width: 26px; height: 26px; font-size: 12px; }
.racers-strip .chip { border-left: 4px solid var(--c, var(--line)); }
.chip-s { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.chip-s.ok { background: color-mix(in srgb, var(--easy) 18%, transparent); color: var(--easy); }
.chip-s.bad { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.chip-s.pending { background: color-mix(in srgb, var(--medium) 18%, transparent); color: var(--medium); }
.chip-s.live { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.pen-chip { color: var(--danger); font-weight: 700; }

/* results / comparison */
.modal { position: relative; }
.modal.wide { max-width: 820px; }
.res-head { text-align: center; }
.res-head h2 { font-size: 30px; margin: 4px 0; }
.res-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
h3.sec { margin: 20px 0 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.legend { text-transform: none; letter-spacing: 0; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 10px; margin: 18px auto 4px; max-width: 460px; }
.step { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; animation: rise .6s cubic-bezier(.2,1.4,.4,1) both; }
.step.p1 { animation-delay: .35s; } .step.p2 { animation-delay: .15s; } .step.p3 { animation-delay: .5s; }
.step .avatar { width: 46px; height: 46px; font-size: 20px; }
.step.p1 .avatar { width: 58px; height: 58px; font-size: 24px; }
.crown { font-size: 26px; margin-bottom: -8px; animation: bob 1.6s ease-in-out infinite; }
.pod-name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-score { font-weight: 800; font-size: 18px; }
.pod-score small { font-weight: 500; color: var(--muted); font-size: 11px; }
.pod-block { width: 100%; border-radius: 10px 10px 0 0; color: #fff; font-weight: 800; font-size: 28px; display: flex; align-items: flex-start; justify-content: center; padding-top: 6px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 85%, #fff), var(--c)); }
.step.p1 .pod-block { height: 110px; } .step.p2 .pod-block { height: 80px; } .step.p3 .pod-block { height: 56px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-6deg); } }

.lanes { display: flex; flex-direction: column; gap: 10px; }
.lane { --c: #3355ff; border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 12px; padding: 10px 12px; background: var(--surface-2); }
.lane-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lane-rank { width: 24px; text-align: center; font-weight: 800; }
.lane-name { font-weight: 700; }
.lane-stats { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.flag-reason { font-size: 12px; color: var(--danger); margin-top: 6px; }
.route-line, .spec-path { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0; margin-top: 10px; }
.node {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--c, var(--accent)) 55%, var(--line));
}
.node.start { background: var(--line); border-color: transparent; }
.node.end { background: linear-gradient(135deg, #ffd43b, #f59f00); color: #3b2a00; border-color: transparent; box-shadow: 0 2px 10px rgba(245,159,0,.35); }
.node.end::before { content: "🏁 "; }
.node.back { opacity: .55; font-style: italic; }
.node.shared { border-style: dashed; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.node.shared::after { content: " ⇄"; color: var(--accent); }
.node.mini { padding: 1px 8px; font-size: 11px; }
.edge { width: 18px; height: 2px; background: color-mix(in srgb, var(--c, var(--accent)) 60%, var(--line)); position: relative; margin: 0 2px; }
.edge::after { content: ""; position: absolute; right: -1px; top: -3px; border: 4px solid transparent; border-left: 5px solid color-mix(in srgb, var(--c, var(--accent)) 60%, var(--line)); border-right: 0; }
.lane.animate .node, .lane.animate .edge { animation: pop-in .35s cubic-bezier(.2,1.5,.5,1) both; animation-delay: var(--d, 0ms); }
.lane.animate .edge { animation-name: grow; }
@keyframes pop-in { from { transform: scale(.4); opacity: 0; } }
@keyframes grow { from { transform: scaleX(0); transform-origin: left; } }
.next-in { font-weight: 700; color: var(--accent); margin: 14px 0 0; }

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 18px; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105%; transform: rotate(720deg) translateX(40px); opacity: .9; } }

/* spectate */
.overlay.spectate { z-index: 60; align-items: stretch; }
.spec-box { background: var(--surface); border-radius: 18px; width: 100%; max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.spec-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.spec-who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-size: 14px; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #e03131; animation: pulse 1.2s infinite; flex-shrink: 0; }
.spec-path { margin: 0; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); max-height: 92px; overflow-y: auto; }
.spec-body { flex: 1; overflow-y: auto; background: #fff; color: #202122; padding: 20px 28px; }
.article.readonly a { pointer-events: none; }

/* flappy */
.overlay.flappy { z-index: 70; }
.flappy-box { background: var(--surface); border-radius: 18px; padding: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.35); width: min(384px, 100%); }
.flappy-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.flappy-head b { flex: 1; }
#flappy-canvas { width: 100%; aspect-ratio: 360 / 520; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 12px; display: block; touch-action: manipulation; cursor: pointer; }

@media (max-width: 640px) {
  .lane-stats { margin-left: 32px; width: 100%; }
  .spec-body { padding: 14px; }
  .modal { padding: 18px; }
  .res-head h2 { font-size: 24px; }
}

/* ===== v3: word-search-proof links, spectate tracking, how to play ===== */
.article a[data-label]::before { content: attr(data-label); }
.article a.wr-i { font-style: italic; }
.article a.wr-b { font-weight: 700; }
.article a.their-hover { background: #ffe066; outline: 3px solid #ffe066; border-radius: 3px; transition: background .15s; }
.watch { font-size: 12px; font-weight: 700; color: #e03131; background: color-mix(in srgb, #e03131 12%, transparent); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.spec-box { position: relative; }
.spec-hover { font-size: 13px; color: var(--muted); max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spec-rail { position: absolute; right: 6px; top: 140px; bottom: 16px; width: 6px; border-radius: 3px; background: rgba(0,0,0,.12); z-index: 2; }
.spec-rail span { position: absolute; left: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #e03131; box-shadow: 0 0 0 3px rgba(224,49,49,.25); transition: top .25s ease-out; top: 0; }

.howto summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 10px; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary h2 { margin: 0; }
.howto[open] .toggle-hint::after { content: ""; }
.howto:not([open]) .toggle-hint { font-size: 0; }
.howto:not([open]) .toggle-hint::after { content: "tap to show"; font-size: 13px; }
.toggle-hint { font-size: 13px; margin-left: auto; }
.steps { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); border-radius: 12px; padding: 12px; }
.steps p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.step-n { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rule { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.rule-h { font-weight: 700; margin-bottom: 6px; }
.rule p { margin: 0; font-size: 14px; }
.rule ul { margin: 0; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 3px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { color: #fff; font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.pill.easy { background: var(--easy); } .pill.medium { background: var(--medium); } .pill.hard { background: var(--hard); }
@media (max-width: 640px) {
  .steps, .rule-grid { grid-template-columns: 1fr; }
  .spec-hover { display: none; }
}

/* ===== daily challenge ===== */
.daily { border: 1.5px solid color-mix(in srgb, var(--hard) 45%, var(--line)); background:
  linear-gradient(135deg, color-mix(in srgb, var(--hard) 9%, var(--surface)), var(--surface) 60%); }
.daily-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.daily-badge { font-weight: 800; font-size: 15px; }
.daily-players { margin-left: auto; font-size: 13px; }
.streak { font-weight: 700; font-size: 13px; color: var(--medium); }
.daily-route { font-size: 22px; font-weight: 800; margin: 10px 0 4px; letter-spacing: -.01em; }
.daily-route .arrow { color: var(--muted); font-weight: 500; }
.daily-route .tgt { color: var(--hard); }
.daily-sub { margin: 0 0 12px; font-size: 14px; }
.daily-done { margin: 6px 0 12px; }
.daily-done .top { color: var(--easy); }
.daily-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.daily-actions b { font-variant-numeric: tabular-nums; }
.rank-tile b { color: var(--easy); }
.verdict { text-align: center; margin: 4px 0 0; }
.histo { display: flex; align-items: flex-end; gap: 5px; height: 170px; padding-top: 22px; }
.hbar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.hfill { width: 100%; height: var(--h); background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); border-radius: 6px 6px 2px 2px; position: relative;
  animation: barup .6s cubic-bezier(.2,1.2,.4,1) both; animation-delay: var(--d); transform-origin: bottom; }
.hbar.dnf .hfill { background: color-mix(in srgb, var(--danger) 30%, var(--surface-2)); }
.hbar.mine .hfill { background: var(--accent); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.hbar.mine.dnf .hfill { background: var(--danger); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--danger); }
.hpct { font-size: 11px; color: var(--muted); margin-bottom: 3px; white-space: nowrap; }
.hbar.mine .hpct { color: var(--text); font-weight: 800; }
.hlabel { font-size: 12px; font-weight: 700; margin-top: 4px; white-space: nowrap; }
.you { position: absolute; top: -40px; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 800; color: #fff; background: var(--text); color: var(--surface); padding: 1px 6px; border-radius: 6px; }
.histo-axis { text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }
@keyframes barup { from { transform: scaleY(0); } }
.daily-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 13px; margin-top: 14px; background: var(--surface-2); border-radius: 12px; padding: 10px 14px; }
.next-daily { margin: 14px 0 0; font-size: 13px; }
@media (max-width: 640px) { .daily-facts { grid-template-columns: 1fr; } .daily-route { font-size: 18px; } .histo { gap: 3px; } .hpct { font-size: 9px; } }
.daily-route.mystery .q { letter-spacing: .15em; filter: blur(.4px); opacity: .75; }
.cards { margin-bottom: 16px; }

/* ===================== v6: scoreboard look ===================== */
:root {
  --bg: #f4f2ed; --surface: #ffffff; --surface-2: #ebe8e1; --text: #111111; --muted: #55524b; --line: #d8d3c8; --ink-line: #111111;
  --accent: #cc2a1b; --accent-ink: #ffffff; --signal: #cc2a1b; --signal-ink: #ffffff;
  --easy: #1a7a43; --medium: #9a620b; --hard: #cc2a1b; --danger: #cc2a1b;
  /* Fills that carry white text: the same in both themes so they always pass WCAG AA (4.5:1). */
  --accent-fill: #cc2a1b; --easy-fill: #1a7a43; --medium-fill: #9a620b;
  --radius: 0px; --shadow: none;
  --display: "Archivo", system-ui, sans-serif; --sans: "Archivo", system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --surface: #1a1a1a; --surface-2: #232323; --text: #f4f2ed; --muted: #a29e95; --line: #333333; --ink-line: #f4f2ed;
    --accent: #ff5545; --signal: #ff5545; --easy: #4cc27e; --medium: #e0a33a; --hard: #ff5545; --danger: #ff5545;
  }
}
:root[data-theme="dark"] { --bg: #111111; --surface: #1a1a1a; --surface-2: #232323; --text: #f4f2ed; --muted: #a29e95; --line: #333333; --ink-line: #f4f2ed; --accent: #ff5545; --signal: #ff5545; --easy: #4cc27e; --medium: #e0a33a; --hard: #ff5545; --danger: #ff5545; }
body { font-family: var(--sans); font-size: 15px; }
.card { border-radius: 0; box-shadow: none; }
.btn { border-radius: 0; font-family: var(--sans); font-weight: 700; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn small { font-family: var(--mono); font-weight: 500; }
input { border-radius: 0; font-family: var(--sans); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- home ---------- */
#home { overflow-x: clip; }
#home .home-wrap {
  max-width: 1220px; margin: 0 auto; padding: 18px 28px 14px; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
}
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav .sp { flex: 1; }
#home .logo { font-family: var(--display); font-weight: 900; font-stretch: 75%; font-size: 30px; text-transform: uppercase; letter-spacing: .01em; line-height: 1; }
#home .logo span { color: var(--accent); }
.navlink { background: none; border: 0; padding: 0; font: 800 16px var(--display); font-stretch: 80%; text-transform: uppercase; color: var(--text); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.topnav .name-field { margin: 0; }
.topnav .name-field input { border: 2px solid var(--ink-line); background: var(--surface); padding: 8px 12px; font: 700 15px var(--sans); width: 200px; text-transform: none; }

.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: stretch; }
.headline { font-family: var(--display); font-weight: 900; font-stretch: 66%; font-size: clamp(64px, 8.6vw, 112px); line-height: .86; text-transform: uppercase; margin: 0; letter-spacing: -.005em; }
.headline span { color: var(--accent); }
.hero-sub { font-size: 18px; font-weight: 500; margin: 16px 0 0; max-width: 480px; color: var(--text); }

.board { background: #111; color: #f4f2ed; padding: 18px 22px; display: flex; flex-direction: column; min-height: 300px; }
.board-head { display: flex; justify-content: space-between; font: 600 12px var(--mono); color: #8a8a8a; letter-spacing: .1em; text-transform: uppercase; border-bottom: 1px solid #333; padding-bottom: 10px; margin-bottom: 4px; }
.route-demo { display: flex; flex-direction: column; flex: 1; }
.rd-row { display: flex; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px dashed #2b2b2b; transform: rotateX(90deg); transform-origin: top; opacity: 0; animation: flip-in .5s cubic-bezier(.3,1.4,.5,1) forwards; animation-delay: var(--d); }
.rd-row i { font: 600 14px var(--mono); color: var(--accent); font-style: normal; width: 28px; }
.rd-row b { font-family: var(--display); font-weight: 800; font-stretch: 80%; font-size: clamp(22px, 2.6vw, 32px); text-transform: uppercase; line-height: 1.1; }
.rd-row.end b { background: var(--accent); color: #fff; padding: 0 8px; }
.rd-count { margin-top: auto; padding-top: 12px; font: 600 14px var(--mono); color: var(--accent); opacity: 0; animation: fade-in .3s forwards; animation-delay: var(--d); }
.route-demo.out > * { animation: fade-out .3s forwards !important; }
@keyframes flip-in { to { transform: none; opacity: 1; } }
@keyframes fade-in { to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; transform: none; } to { opacity: 0; } }

.actions { display: grid; grid-template-columns: 1.15fr 1.25fr 1fr 1fr; gap: 12px; }
.blk { border: 2px solid var(--ink-line); background: var(--surface); color: var(--text); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; text-align: left; font: inherit; margin: 0; }
.blk-title { margin: 0; font-family: var(--display); font-weight: 900; font-stretch: 75%; font-size: 30px; text-transform: uppercase; line-height: 1; letter-spacing: 0; color: inherit; }
.blk-sub { margin: 0; font-size: 14px; font-weight: 500; color: var(--muted); }
.blk-sub b { color: var(--text); }
.blk-sub .hl { color: var(--accent); }
.blk-meta { font: 500 11.5px var(--mono); color: var(--muted); letter-spacing: .04em; margin-top: auto; }
.blk.red { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.blk.red .blk-sub { color: #ffeae7; }
.blk.red .blk-go { margin-top: auto; font: 600 14px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.blk.red:hover { transform: translate(-3px, -3px); box-shadow: 6px 6px 0 var(--ink-line); }
.blk.red:active { transform: translate(0, 0); box-shadow: none; }
.blk.red:hover .blk-go { text-decoration: underline; text-underline-offset: 4px; }
.sq { border: 2px solid var(--ink-line); background: var(--ink-line); color: var(--bg); padding: 9px 12px; font: 800 15px var(--display); font-stretch: 85%; text-transform: uppercase; cursor: pointer; transition: transform .1s; }
.sq:hover { transform: translateY(-1px); }
.sq.red { background: var(--accent); border-color: var(--accent); color: #fff; }
.sq.light { background: var(--surface); color: var(--text); }
.sq.light:hover { background: var(--ink-line); color: var(--bg); }
.frow { display: flex; gap: 6px; margin-top: auto; }
.frow .join-form { display: flex; gap: 6px; flex: 1; min-width: 0; }
.frow #join-code { flex: 1; min-width: 0; border: 2px solid var(--ink-line); background: var(--surface); color: var(--text); padding: 8px; font: 600 14px var(--mono); letter-spacing: .3em; text-align: center; }
.diffs { display: flex; gap: 6px; margin-top: auto; }
.diffs .sq { flex: 1; padding: 8px 4px; font-size: 15px; }
.solo-more { display: flex; gap: 14px; }
.textlink { background: none; border: 0; padding: 0; font: 600 12.5px var(--sans); color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.textlink:hover { color: var(--text); }
#solo-stats { font: 500 11px var(--mono); }
.blk .custom-form { margin: 0; gap: 6px; }
.blk .custom-form input { border: 2px solid var(--ink-line); padding: 7px 9px; background: var(--surface); color: var(--text); }

.howstrip { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px 28px; border-top: 2px solid var(--ink-line); padding-top: 12px; font-weight: 600; font-size: 15px; }
.howstrip .t { font-family: var(--display); font-weight: 900; font-stretch: 75%; text-transform: uppercase; font-size: 22px; }
.howstrip b { font-family: var(--display); font-weight: 900; font-stretch: 75%; color: var(--accent); font-size: 22px; margin-right: 8px; }
.howstrip .sp-left { margin-left: auto; font-size: 14px; }
.credit { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.site-foot { display: grid; gap: 6px; padding: 4px 0 8px; }
.site-foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; font-size: 13px; }
.site-foot nav a { color: var(--text); text-decoration: none; padding: 4px 0; }
.site-foot nav a:hover { text-decoration: underline; }
.site-foot .credit { max-width: 70ch; margin: 0 auto; line-height: 1.5; }
.article-credit { margin: 32px 0 8px; padding-top: 12px; border-top: 1px solid #c8ccd1; font-size: 12px; color: #54595d; line-height: 1.5; }
.article-credit a { color: #54595d; }
.credit a { color: var(--muted); }

/* entrance */
.rise { opacity: 0; animation: rise .45s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen.active { animation: screen-in .25s ease; }
@keyframes screen-in { from { opacity: 0; } }

/* how-to modal, results, game: match the new type */
.modal { border-radius: 0; border: 2px solid var(--ink-line); }
.modal.howto { max-width: 760px; }
.howto-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.howto-head h2, .res-head h2, .modal h2 { font-family: var(--display); font-weight: 900; font-stretch: 75%; text-transform: uppercase; letter-spacing: 0; }
.step-n { background: var(--accent); color: #fff; border-radius: 0; font-family: var(--mono); }
.rule, .pill, .steps li { border-radius: 0; }
.lobby-head .logo, .hud .logo { font-family: var(--display); font-weight: 900; font-stretch: 75%; text-transform: uppercase; }
.room-code, .stat span, .big-stats b { font-family: var(--mono); font-weight: 600; }
.cd-num { font-family: var(--display); font-weight: 900; font-stretch: 75%; }
.big-stats > div, .lane, .player-list li, .panel-section, .article-wrap, .daily-facts, .node { border-radius: 0; }
.node.end { background: var(--accent); color: #fff; box-shadow: none; }

@media (max-width: 980px) {
  .actions { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  #home .home-wrap { min-height: 0; justify-content: flex-start; }
  .hero { grid-template-columns: 1fr; }
  .board { min-height: 0; }
  .topnav .name-field input { width: 140px; }
  .howstrip .sp-left { margin-left: 0; }
}
@media (max-width: 520px) {
  .actions { grid-template-columns: 1fr; }
  .topnav { flex-wrap: wrap; }
  .topnav .name-field { width: 100%; order: 3; }
  .topnav .name-field input { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .rise, .rd-row, .rd-count { opacity: 1; transform: none; }
}
.hero, .hero-text { text-align: left; }
.board { border: 2px solid #111; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .board { background: #000; border-color: var(--ink-line); } }
:root[data-theme="dark"] .board { background: #000; border-color: var(--ink-line); }

/* ---------- home demo: a mini article with a cursor clicking through ---------- */
.board { position: relative; overflow: hidden; }
.board-head .rec { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 1px; animation: blink 1.4s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.demo-page { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 6px 0 4px; }
.demo-page.flip { animation: page-in .28s cubic-bezier(.2,.8,.2,1); }
@keyframes page-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
.demo-url { font: 500 12px var(--mono); color: #8f8f8f; margin-bottom: 6px; }
.demo-title {
  margin: 0 0 10px; font-family: var(--display); font-weight: 900; font-stretch: 72%; text-transform: uppercase;
  font-size: clamp(34px, 4.2vw, 54px); line-height: .95; color: #f4f2ed; letter-spacing: 0;
}
.board.done .demo-title { color: #fff; background: var(--accent); align-self: flex-start; padding: 2px 10px 0; }
.board.done .demo-title::after { content: " ✓"; }
.demo-text { margin: 0; font-size: 17px; line-height: 1.55; color: #bdb9b0; max-width: 46ch; }
.dl { color: #f4f2ed; text-decoration: underline; text-decoration-color: #6f6f6f; text-underline-offset: 3px; transition: background .15s, color .15s; }
.dl.next { text-decoration-color: #f4f2ed; }
.dl.hit { background: var(--accent); color: #fff; text-decoration: none; padding: 0 3px; }
.demo-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-top: 1px solid #333; padding-top: 10px; font: 600 12px var(--mono); color: #8a8a8a; text-transform: uppercase; letter-spacing: .06em; }
.demo-trail { display: flex; flex-wrap: wrap; gap: 4px 6px; min-width: 0; }
.demo-trail i { font-style: normal; color: #555; }
.demo-trail .cur { color: #f4f2ed; }
.demo-clicks b { color: var(--accent); font-size: 15px; }
.demo-cursor {
  position: absolute; left: 0; top: 0; width: 22px; height: 22px; pointer-events: none; z-index: 3;
  transition: transform .45s cubic-bezier(.45,.05,.25,1); filter: drop-shadow(0 2px 3px rgba(0,0,0,.5));
}
.demo-cursor.press { scale: .82; }
@media (max-width: 760px) { .demo-text { font-size: 15px; } .demo-title { font-size: 34px; } }

/* ---------- brand: the logo is the hero ---------- */
:root { --brand: "Bungee", "Archivo", system-ui, sans-serif; }
.headline.brand { font-family: var(--brand); font-stretch: 100%; font-weight: 400; font-size: clamp(64px, 8.6vw, 124px); line-height: .92; letter-spacing: -.01em; }
.headline.brand span { color: var(--accent); }
.hero-sub.big { font-size: clamp(19px, 1.8vw, 24px); font-weight: 700; max-width: 520px; margin-top: 18px; color: var(--text); }
.hero-sub.big em { font-style: normal; color: var(--accent); }
.hero-sub.small { margin-top: 6px; color: var(--muted); font-size: 16px; }
.lobby-head .logo, .hud .logo { font-family: var(--brand); font-weight: 400; font-stretch: 100%; text-transform: uppercase; letter-spacing: 0; }
.lobby-head .logo span, .hud .logo span { color: var(--accent); }
@media (max-width: 760px) { .headline.brand { font-size: 64px; } }

/* ---------- hero v2: controls under the brand, chain-y trail, lifted layout ---------- */
#home .home-wrap { justify-content: center; padding-top: 3vh; padding-bottom: 9vh; gap: 22px; }
.hero { align-items: center; }
.hero-controls { display: flex; gap: 10px; margin-top: 22px; max-width: 520px; }
.hero-controls .name-field { margin: 0; flex: 1; }
.hero-controls input { width: 100%; border: 2px solid var(--ink-line); background: var(--surface); color: var(--text); padding: 9px 12px; font: 700 15px var(--sans); }
.hero-controls .sq { white-space: nowrap; padding: 9px 16px; }
.demo-foot { font-size: 13px; padding-top: 12px; }
.demo-trail { gap: 6px 8px; align-items: center; }
.demo-trail span { background: #222; color: #cfcac0; padding: 3px 9px; border: 1px solid #3a3a3a; }
.demo-trail span.cur { background: #f4f2ed; color: #111; border-color: #f4f2ed; }
.demo-trail i { color: var(--accent); font-size: 20px; font-weight: 800; line-height: 1; }
.demo-trail .pop { animation: chain-pop .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes chain-pop { from { transform: scale(.4) translateY(-14px); opacity: 0; background: var(--accent); color: #fff; } 60% { background: var(--accent); color: #fff; } }
.demo-clicks b { display: inline-block; font-size: 18px; }
.demo-clicks b.bump { animation: bump .4s ease; }
@keyframes bump { 40% { transform: scale(1.6); } }
.demo-cursor { transition: transform .62s cubic-bezier(.45,.05,.25,1); }
.dl.hit { box-shadow: 0 0 0 3px rgba(255,68,51,.35); }
/* difficulty buttons take their colour on hover */
.diffs .sq[data-solo="easy"]:hover { background: var(--easy); border-color: var(--easy); color: #fff; }
.diffs .sq[data-solo="medium"]:hover { background: var(--medium); border-color: var(--medium); color: #fff; }
.diffs .sq[data-solo="hard"]:hover { background: var(--hard); border-color: var(--hard); color: #fff; }
@media (max-width: 760px) { #home .home-wrap { padding-bottom: 24px; } .hero-controls { max-width: none; } }
#home .home-wrap { padding-top: 4vh; padding-bottom: 7vh; gap: 34px; }
.board { min-height: 330px; }
.actions .blk { min-height: 178px; }

/* target badge in the demo board */
.board-head { align-items: center; }
#board-target { display: inline-flex; align-items: stretch; font: 700 13px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
#board-target .tl { background: #f4f2ed; color: #111; padding: 5px 8px; }
#board-target .tl::after { content: " →"; }
#board-target .tv { background: var(--accent); color: #fff; padding: 5px 10px; font-family: var(--display); font-weight: 900; font-stretch: 80%; font-size: 17px; letter-spacing: .02em; line-height: 1.1; }
.board.done #board-target .tv::after { content: " ✓"; }
.dl.tgt { color: #fff; background: rgba(255,68,51,.22); text-decoration: underline 2px var(--accent); padding: 0 3px; }
.dl.tgt::before { content: "🏁 "; font-size: .8em; }
.lobby-flappy { display: flex; justify-content: center; margin-top: 12px; }
.lobby-flappy .flappy-box { box-shadow: none; border: 2px solid var(--ink-line); }
.lobby-flappy #flappy-canvas { max-height: 60vh; }

/* ===================== scoreboard style for lobby, race, results ===================== */
/* shared */
.btn { border: 2px solid var(--ink-line); background: var(--surface); color: var(--text); text-transform: uppercase; font-family: var(--display); font-weight: 800; font-stretch: 85%; letter-spacing: .01em; }
.btn:hover:not(:disabled) { background: var(--ink-line); color: var(--bg); transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--accent); border-color: var(--accent); }
.btn.tiny { border-width: 1.5px; font-size: 12px; padding: 3px 8px; }
.card { border: 2px solid var(--ink-line); background: var(--surface); }
.card h2, .modal h3.sec, h3.sec { font-family: var(--display); font-weight: 900; font-stretch: 75%; text-transform: uppercase; letter-spacing: 0; }
.card h2 { font-size: 26px; margin-bottom: 10px; }
h3.sec { font-size: 18px; color: var(--text); }
.avatar { border-radius: 0; box-shadow: none; width: 26px; height: 26px; }
.badge { border-radius: 0; font-family: var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.badge.host { background: var(--text); color: var(--bg); }
.badge.ready { background: var(--easy); color: #fff; }
.toast { border-radius: 0; background: var(--text); color: var(--bg); font-weight: 700; }
.chip-s { border-radius: 0; font-family: var(--mono); text-transform: uppercase; }
.overlay { background: rgba(10,10,10,.72); backdrop-filter: blur(3px); }

/* lobby */
#lobby .home-wrap { max-width: 860px; padding: 26px 24px 40px; min-height: 0; display: block; }
#lobby .card { margin-bottom: 14px; padding: 18px 20px; }
.lobby-head { margin-bottom: 18px; }
.lobby-head .logo.small { font-size: 26px; }
.room-row { gap: 24px; }
.room-row .label, #room-label { font-family: var(--mono); font-size: 11.5px; letter-spacing: .1em; color: var(--muted); }
.room-code { font-family: var(--brand); font-weight: 400; font-size: 46px; letter-spacing: .08em; line-height: 1.05; }
.room-code.pub { font-family: var(--display); font-weight: 900; font-stretch: 75%; text-transform: uppercase; font-size: 34px; letter-spacing: 0; }
#invite-link { border: 2px solid var(--ink-line); background: var(--bg); font-family: var(--mono); font-size: 13px; }
#lobby-status { font-size: 14px; margin: 10px 0 0; }
#player-count { font-family: var(--mono); font-size: 14px; font-weight: 500; }
#lobby .player-list li { border: 1.5px solid var(--line); background: var(--bg); border-radius: 0; padding: 9px 12px; }
#lobby .player-list li.me { border-color: var(--ink-line); }
#lobby .player-list .pname { font-weight: 700; }
#lobby .player-list .pmeta { font-family: var(--mono); font-size: 12px; }
.wins { color: var(--medium); font-family: var(--mono); }
#room-diff .btn { opacity: 1; border-color: var(--ink-line); background: var(--surface); color: var(--text); }
#room-diff .btn.diff.easy:hover, #room-diff .btn.diff.easy.selected { background: var(--easy); border-color: var(--easy); color: #fff; }
#room-diff .btn.diff.medium:hover, #room-diff .btn.diff.medium.selected { background: var(--medium); border-color: var(--medium); color: #fff; }
#room-diff .btn.diff.hard:hover, #room-diff .btn.diff.hard.selected { background: var(--hard); border-color: var(--hard); color: #fff; }
#room-diff .btn.selected { outline: none; }
#room-diff .btn.ghost.selected { background: var(--text); color: var(--bg); }
#room-diff .btn small { color: inherit; opacity: .8; }
#room-custom input { border: 2px solid var(--ink-line); background: var(--bg); }
#start-race { padding: 14px; font-size: 18px; }
.wait-text { font-family: var(--sans); font-size: 15px; }
.wait-text b { font-family: var(--mono); color: var(--accent); font-size: 18px; }
#lobby .flappy-btn { border: 2px dashed var(--line); font-size: 14px; }
/* public lobby: vote + ready */
.pc-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: end; }
.vote-row { display: flex; gap: 8px; }
.vote-row .sq { flex: 1; display: flex; justify-content: center; align-items: baseline; gap: 6px; }
.vote-row .vc { font-family: var(--mono); font-size: 13px; }
.vote-row .vc:not(:empty)::before { content: "· "; opacity: .6; }
.vote-row .vote.easy:hover, .vote-row .vote.easy.selected { background: var(--easy); border-color: var(--easy); color: #fff; }
.vote-row .vote.medium:hover, .vote-row .vote.medium.selected { background: var(--medium); border-color: var(--medium); color: #fff; }
.vote-row .vote.hard:hover, .vote-row .vote.hard.selected { background: var(--hard); border-color: var(--hard); color: #fff; }
.ready-btn { width: 100%; padding: 14px; font-size: 20px; }
.ready-btn.on { background: var(--easy); border-color: var(--easy); }
.ready-text { margin: 8px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.ready-text b { font-family: var(--mono); color: var(--text); }
@media (max-width: 640px) { .pc-row { grid-template-columns: 1fr; } }

/* race HUD + side panel */
.hud { border-bottom: 2px solid var(--ink-line); }
.hud .logo.tiny { font-size: 20px; }
.route span { font-family: var(--mono); letter-spacing: .1em; }
.route strong { font-family: var(--display); font-weight: 900; font-stretch: 78%; text-transform: uppercase; font-size: 22px; color: var(--accent); }
.stat span { font-family: var(--mono); }
.stat small { font-family: var(--mono); }
.panel-section { border: 2px solid var(--ink-line); }
.panel-section h3, .target-card h3 { font-family: var(--mono); letter-spacing: .1em; }
.target-card .tname { font-family: var(--display); font-weight: 900; font-stretch: 78%; text-transform: uppercase; font-size: 24px; }
.target-card img { border-radius: 0; }
.article-wrap { border: 2px solid var(--ink-line); }
.racers-strip .chip { border-radius: 0; }

/* countdown */
.cd-diff { font-family: var(--mono); color: var(--accent); }
.cd-route { font-family: var(--display); font-weight: 900; font-stretch: 78%; text-transform: uppercase; font-size: 30px; }
.cd-route b { color: var(--accent); }
.cd-num { font-family: var(--brand); font-weight: 400; font-size: 140px; }

/* results */
.modal { background: var(--surface); }
.res-kicker { font-family: var(--mono); letter-spacing: .1em; }
.res-head h2 { font-size: 40px; line-height: 1; }
.big-stats > div { border: 2px solid var(--ink-line); background: var(--bg); }
.big-stats b { font-size: 30px; }
.big-stats small { font-family: var(--mono); }
.podium .avatar { border-radius: 0; }
.pod-name { font-family: var(--display); font-weight: 900; font-stretch: 80%; text-transform: uppercase; }
.pod-score { font-family: var(--mono); }
.pod-block { border-radius: 0; background: var(--c); font-family: var(--brand); font-weight: 400; }
.lane { border: 2px solid var(--line); border-left: 6px solid var(--c); background: var(--bg); }
.lane-name { font-family: var(--display); font-weight: 900; font-stretch: 80%; text-transform: uppercase; font-size: 17px; }
.lane-stats { font-family: var(--mono); font-size: 12px; }
.node { border-radius: 0; font-family: var(--sans); border-width: 1.5px; }
.node.start { background: var(--text); color: var(--bg); }
.edge { background: var(--accent); }
.edge::after { border-left-color: var(--accent); }
.modal-actions .btn { padding: 12px; font-size: 16px; }
.next-in { font-family: var(--mono); color: var(--accent); }
.daily-facts, .histo .hfill { border-radius: 0; }
.hbar.mine .hfill { background: var(--accent); box-shadow: none; }
.you { border-radius: 0; background: var(--accent); color: #fff; }
.flappy-box, .spec-box { border-radius: 0; border: 2px solid var(--ink-line); }
#flappy-canvas { border-radius: 0; }
.mg-title { font-family: var(--brand); font-weight: 400; font-size: 20px; letter-spacing: .02em; }
.flappy-box { background: var(--surface); }
.flappy-btn:disabled { opacity: .55; cursor: not-allowed; }
.hud-diff { font: 800 13px var(--display); font-stretch: 85%; text-transform: uppercase; letter-spacing: .04em; padding: 5px 9px; color: var(--bg); background: var(--text); white-space: nowrap; align-self: center; }
.hud-diff.easy { background: var(--easy); } .hud-diff.medium { background: var(--medium); } .hud-diff.hard, .hud-diff.daily { background: var(--hard); }
.hud-diff:empty { display: none; }
/* race controls: bottom-right, out of the way of the article */
.race-controls { position: fixed; right: 16px; bottom: 16px; z-index: 25; display: flex; gap: 8px; }
.race-controls .btn { padding: 10px 16px; font-size: 15px; background: var(--surface); box-shadow: 4px 4px 0 var(--ink-line); }
.race-controls .btn:hover:not(:disabled) { background: var(--ink-line); color: var(--bg); }
.race-controls .btn.danger { color: var(--accent); border-color: var(--accent); box-shadow: 4px 4px 0 var(--accent); }
.race-controls .btn.danger:hover:not(:disabled) { background: var(--accent); color: #fff; }
.race-controls .btn:disabled { opacity: .45; box-shadow: none; }
@media (max-width: 760px) { .race-controls { right: 10px; bottom: 10px; } .race-controls .btn { padding: 8px 12px; font-size: 14px; } }
/* Lane Rush is landscape */
.flappy-box { width: min(672px, 100%); }
#flappy-canvas { aspect-ratio: 640 / 300; max-height: none; height: auto; }
.lobby-flappy #flappy-canvas { max-height: none; }
#room-diff .btn { border: 2px solid var(--ink-line); }

/* themed confirm dialog */
#confirm { z-index: 90; }
.confirm-box { background: var(--surface); border: 2px solid var(--ink-line); box-shadow: 8px 8px 0 var(--accent); padding: 24px; width: min(440px, 100%); animation: pop-confirm .18s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop-confirm { from { transform: scale(.94); opacity: 0; } }
.confirm-box h2 { margin: 0 0 8px; font-family: var(--display); font-weight: 900; font-stretch: 75%; text-transform: uppercase; font-size: 32px; line-height: 1; }
.confirm-box p { margin: 0 0 20px; color: var(--muted); font-size: 15px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; padding: 12px; font-size: 16px; }
.btn.danger-fill { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ready button pulses until you press it */
.ready-btn:not(.on) { animation: ready-pulse 1.6s ease-in-out infinite; }
@keyframes ready-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,68,51,.55); transform: scale(1); }
  50% { box-shadow: 0 0 0 10px rgba(255,68,51,0); transform: scale(1.03); }
}
.ready-btn.on { animation: none; }
/* spectate: live route along the top */
.spec-path { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; padding: 10px 16px; gap: 0; scrollbar-width: thin; }
.spec-path .node { white-space: nowrap; flex-shrink: 0; }
.spec-path .node.cur { background: var(--accent); color: #fff; border-color: var(--accent); }
.spec-path .edge { flex-shrink: 0; }
.spec-path-label { font: 600 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-right: 10px; flex-shrink: 0; }
#flappy-canvas { aspect-ratio: 640 / 252; }
.flappy-box { padding: 10px; }
.flappy-head { margin-bottom: 8px; }
/* demo: highlight without changing layout, keep the trail on one line so nothing jumps */
.dl.hit { padding: 0; background: var(--accent); color: #fff; box-shadow: 0 0 0 3px var(--accent); text-decoration: none; }
.dl.tgt { padding: 0; box-shadow: 0 0 0 2px rgba(255,68,51,.25); }
.demo-foot { flex-wrap: nowrap; }
.demo-trail { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; min-width: 0; flex: 1; -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px); mask-image: linear-gradient(90deg, transparent 0, #000 18px); justify-content: flex-start; }
.demo-trail span, .demo-trail i { flex-shrink: 0; }
.demo-clicks { flex-shrink: 0; }
.demo-cursor.press { scale: .85; transition: transform .62s cubic-bezier(.45,.05,.25,1), scale .1s; }
/* live route of someone still racing (shown once you're done) */
.node.live-cur { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 2px rgba(255,68,51,.25); }
.node.live-tail { border-style: dashed; color: var(--muted); font-style: italic; animation: live-blink 1.4s ease-in-out infinite; }
.edge.dashed { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px); }
.edge.dashed::after { border-left-color: var(--muted); }
@keyframes live-blink { 50% { opacity: .45; } }
/* demo: smoother click: cursor press eases both ways, page swaps with a soft fade (no slide) */
.demo-cursor { transition: transform .62s cubic-bezier(.45,.05,.25,1), scale .14s ease; }
.demo-cursor.press { scale: .86; transition: transform .62s cubic-bezier(.45,.05,.25,1), scale .14s ease; }
.demo-page.flip { animation: page-fade .26s ease-out; }
@keyframes page-fade { from { opacity: .15; } to { opacity: 1; } }
.demo-trail { scroll-behavior: smooth; }

/* ---------- contrast (WCAG AA) ----------
   Filled surfaces with white text use the fixed *-fill colours; the theme colours above are tuned
   for coloured text on the page background, which needs a brighter red/green/amber in dark mode. */
.btn.primary, .blk.red, .sq.red, #board-target .tv, .badge.host, .badge.out, .step-n, .node.end, .dl.hit, .you,
.rd-row.end b, .board.done .demo-title, .btn.diff.hard, .pill.hard, .hud-diff.hard, .hud-diff.daily,
.diffs .sq[data-solo="hard"]:hover, #room-diff .btn.diff.hard:hover, #room-diff .btn.diff.hard.selected,
.vote-row .vote.hard:hover, .vote-row .vote.hard.selected { background-color: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.btn.diff.easy, .badge.done, .badge.ready, .pill.easy, .hud-diff.easy, .ready-btn.on, .diffs .sq[data-solo="easy"]:hover,
#room-diff .btn.diff.easy:hover, #room-diff .btn.diff.easy.selected, .vote-row .vote.easy:hover, .vote-row .vote.easy.selected { background-color: var(--easy-fill); border-color: var(--easy-fill); color: #fff; }
.btn.diff.medium, .pill.medium, .hud-diff.medium, .diffs .sq[data-solo="medium"]:hover,
#room-diff .btn.diff.medium:hover, #room-diff .btn.diff.medium.selected, .vote-row .vote.medium:hover, .vote-row .vote.medium.selected { background-color: var(--medium-fill); border-color: var(--medium-fill); color: #fff; }
