:root[data-theme="dark"] { --soft: #1f1f21; }
/* Shared header row: tiles logo on the left, inline links and tools on the right. */
:root { --a: #b9c6ff; --b: #ffc9ad; --t2: #b9d68c; --t3: #cbb2ec; --t4: #f6d85e; --blend: multiply; }
:root[data-theme="dark"] { --a: #2a3766; --b: #5a3226; --t2: #5c7a35; --t3: #6c5596; --t4: #b8962a; --blend: screen; }
.topbar { border-bottom: 1px solid var(--line); padding: 22px 16px 14px; display: flex; justify-content: center; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 3px; position: relative; text-decoration: none; font: inherit; letter-spacing: 0; }
.brand .tl { width: 25px; height: 31px; display: grid; place-items: center; border: 1.5px solid var(--ink); border-radius: 5px; background: var(--c); color: var(--ink); font: 800 19px/1 var(--ui); }
.brand .mark { width: 45px; height: 30px; margin-left: 6px; --fw: 2px; }
.brand .mark i { width: 30px; height: 30px; border-width: 1.25px; }
.brand .mark i:last-child { left: 15px; }
.mark { position: relative; flex: none; }
.mark i { position: absolute; top: 0; border-radius: 50%; border: 1.5px solid var(--ink); mix-blend-mode: var(--blend); }
.mark i:first-child { left: 0; background: var(--a); }
.mark i:last-child { background: var(--b); }
.mark::before, .mark::after { content: ""; position: absolute; z-index: 1; pointer-events: none; }
.mark::before { inset: 0; background: radial-gradient(circle, var(--ink) 0 48%, transparent 54%) 22% 38% / 10% 15% no-repeat, radial-gradient(circle, var(--ink) 0 48%, transparent 54%) 78% 38% / 10% 15% no-repeat; }
.mark::after { left: 40%; width: 20%; top: 52%; height: 13%; border: solid var(--ink); border-width: 0 0 var(--fw, 1.5px); border-radius: 0 0 50% 50% / 0 0 100% 100%; }
a.help { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; font: 700 17px/1 var(--ui); color: var(--ink); text-decoration: none; border: 1.5px solid var(--ink); border-radius: 50%; }
a.help:hover { opacity: .88; }
a.help:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (max-width: 380px) { .brand { gap: 2px; } .brand .tl { width: 23px; height: 29px; font-size: 18px; } }

html.navigation-ready .topbar { justify-content: space-between; gap: 10px 16px; padding: 18px 24px; flex-wrap: wrap; }
html.navigation-ready .topbar .help { display: none; }
.top-nav { display: flex; align-items: center; gap: 32px; margin-left: auto; font: 500 17px/1.4 var(--ui); }
.top-nav > a { position: relative; isolation: isolate; color: var(--muted); text-decoration: none; padding: 8px 0; border-bottom: 1.5px solid transparent; transition: color 180ms ease; }
.top-nav > a[href="/"] { --nav-hover: #7f66ab; --nav-fill: #cbb2ec; }
.top-nav > a[href="/how-to-play"] { --nav-hover: #a75e42; --nav-fill: #ffc9ad; }
.top-nav > a[href="/archive"] { --nav-hover: #5d7c40; --nav-fill: #b9d68c; }
:root[data-theme="dark"] .top-nav > a[href="/"] { --nav-hover: #cbb2ec; --nav-fill: #6c5596; }
:root[data-theme="dark"] .top-nav > a[href="/how-to-play"] { --nav-hover: #ffc9ad; --nav-fill: #5a3226; }
:root[data-theme="dark"] .top-nav > a[href="/archive"] { --nav-hover: #b9d68c; --nav-fill: #5c7a35; }
.top-nav > a::before { content: ""; position: absolute; inset: 4px -9px; z-index: -1; border-radius: 7px; background: color-mix(in srgb, var(--nav-fill) 20%, var(--bg)); opacity: var(--nav-highlight, 0); transition: opacity 180ms ease; pointer-events: none; }
.top-nav > a::after { content: ""; position: absolute; bottom: -1.5px; left: 0; right: 0; height: 1.5px; background: currentColor; transform: scaleX(var(--nav-underline, 0)); transform-origin: left; transition: transform 180ms ease; pointer-events: none; }
.top-nav > a[aria-current="page"] { color: var(--ink); --nav-underline: 1; }
.top-nav > a:is(:focus-visible, :active) { color: var(--nav-hover); --nav-highlight: 1; --nav-underline: 1; }
.top-nav a:focus-visible, .tn-icon:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.top-tools { display: flex; align-items: center; gap: 2px; }
.tn-icon { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; position: static; transform: none; transition: color 180ms ease, background 180ms ease; }
.tn-icon:is(:focus-visible, :active) { color: var(--ink); background: var(--soft, #f3f3f4); }
.tn-icon svg { display: block; width: 21px; height: 21px; transition: transform 180ms ease; }
#btnInvite:is(:focus-visible, :active) svg { transform: translateY(-2px); }
.tn-icon:is(:focus-visible, :active) :is(.tn-moon, .tn-sun) { transform: rotate(-15deg); }
.brand:focus-visible .mark::before { animation: blink 260ms ease-in-out; }
@media (hover: hover) {
  .top-nav > a:hover { color: var(--nav-hover); --nav-highlight: 1; --nav-underline: 1; }
  .tn-icon:hover { color: var(--ink); background: var(--soft, #f3f3f4); }
  #btnInvite:hover svg { transform: translateY(-2px); }
  .tn-icon:hover :is(.tn-moon, .tn-sun) { transform: rotate(-15deg); }
}
@media (prefers-reduced-motion: reduce) {
  .top-nav > a, .top-nav > a::before, .top-nav > a::after, .tn-icon, .tn-icon svg { transition: none; }
  .top-nav .tn-icon svg { transform: none !important; }
  .brand .mark::before { animation: none !important; }
}
.tn-icon .tn-sun, [data-theme="dark"] .tn-icon .tn-moon { display: none; }
[data-theme="dark"] .tn-icon .tn-sun { display: block; }
@media (max-width: 560px) {
  html.navigation-ready .topbar { padding: 14px 16px 6px; }
  .top-nav { width: 100%; justify-content: space-between; gap: 8px; margin-left: 0; font-size: 15.5px; }
}

/* How to play: four numbered steps, each with a small visual. Used on /how-to-play and in the game's dialog. */
.htp { list-style: none; margin: 8px 0 22px; padding: 0; display: grid; gap: 26px; }
.htp li { margin: 0; display: grid; grid-template-columns: 44px 1fr auto; gap: 16px; align-items: center; }
.htp-n { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 600 17px/1 var(--ui); color: var(--ink); }
.htp-n.n1 { background: color-mix(in srgb, var(--a) 70%, var(--bg)); } .htp-n.n2 { background: color-mix(in srgb, var(--b) 70%, var(--bg)); }
.htp-n.n3 { background: color-mix(in srgb, var(--t4) 60%, var(--bg)); } .htp-n.n4 { background: color-mix(in srgb, var(--t2) 60%, var(--bg)); }
.htp-t b { display: block; font: 700 17px/1.3 var(--ui); }
.htp-t span { display: block; color: var(--muted); font-size: 14.5px; line-height: 1.45; margin-top: 2px; }
.htp-v { display: grid; place-items: center; min-width: 110px; }
.htp-venn { position: relative; display: block; width: 106px; height: 66px; }
.htp-venn i { position: absolute; top: 0; width: 66px; height: 66px; border-radius: 50%; mix-blend-mode: var(--blend, multiply); }
.htp-venn i.a { left: 0; background: var(--a); } .htp-venn i.b { right: 0; background: var(--b); }
.htp-venn em { position: absolute; top: 50%; transform: translateY(-50%); font: 700 9px/1 var(--ui); font-style: normal; }
.htp-venn .l1 { left: 4px; color: var(--a-ink, var(--ink)); } .htp-venn .l2 { right: 4px; color: var(--b-ink, var(--ink)); }
.htp-clock { border: 1px solid var(--line); border-radius: 10px; padding: 12px 22px; font: 500 18px/1 var(--ui); font-variant-numeric: tabular-nums; }
.htp-pts { font: 700 18px/1 var(--ui); }
.htp-100 { position: relative; display: grid; place-items: center; width: 96px; height: 96px; }
.htp-100 svg { position: absolute; inset: 0; width: 100%; height: 100%; } .htp-100 b { font: 700 24px/1 var(--ui); color: #6a5acd; }
:root[data-theme="dark"] .htp-100 b { color: #b9acff; }
.htp-note { margin: 0; }
@media (max-width: 460px) {
  .htp { gap: 20px; }
  .htp li { grid-template-columns: 36px 1fr auto; gap: 12px; }
  .htp-n { width: 36px; height: 36px; font-size: 15px; }
  .htp-t b { font-size: 16px; } .htp-t span { font-size: 13.5px; }
  .htp-v { min-width: 0; zoom: .72; }
}
