/* geo component styles. Only var(--token) values; tokens.css must load first. */

@font-face { font-family: Rubik; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(../fonts/rubik-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Rubik; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(../fonts/rubik-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans);
  font-size: var(--fs-base); line-height: var(--lh-base); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* icons: Lucide SVGs as masks so they take currentColor */
.icon { display: inline-block; width: 1.25em; height: 1.25em; flex: none; background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; vertical-align: -0.25em; }

/* ---------- layout ---------- */
.app-header { position: sticky; top: 0; z-index: 10; height: var(--header-h); display: flex; align-items: center;
  gap: var(--space-3); padding: 0 var(--gutter); background: var(--bg); border-bottom: 1px solid var(--border); }
.logo { font-weight: 800; font-size: var(--fs-lg); display: flex; align-items: center; gap: var(--space-2); color: var(--text); text-decoration: none; }
.logo-mark { width: 28px; height: 28px; border-radius: 50%; background: conic-gradient(var(--game-geodle) 0 25%, var(--game-rankle) 0 50%, var(--game-connections) 0 75%, var(--game-decide) 0); box-shadow: inset 0 0 0 2px var(--surface); }
.nav-pills { display: none; gap: var(--space-1); margin: 0 auto; }
.nav-pill { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 700;
  color: var(--text); text-decoration: none; transition: background var(--motion-fast); }
.nav-pill:hover { background: var(--surface-sunken); }
.nav-pill[aria-current="page"] { background: var(--g, var(--accent)); color: var(--on-game); }
@media (min-width: 960px) { .nav-pills { display: flex; } }
.page { max-width: var(--content-max); margin: 0 auto; padding: var(--space-5) var(--gutter) var(--space-8); }

/* per-game colour hook: set --g on any container */
.g-rankle { --g: var(--game-rankle); } .g-geodle { --g: var(--game-geodle); } .g-connections { --g: var(--game-connections); }
.g-decide { --g: var(--game-decide); } .g-paint { --g: var(--game-paint); }

/* ---------- game header ---------- */
.game-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.game-badge { width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--g); color: var(--on-game);
  display: grid; place-items: center; box-shadow: 0 var(--edge-card) 0 var(--edge); }
.game-header h1 { font-size: var(--fs-lg); line-height: var(--lh-lg); }
.game-header .meta { font-size: var(--fs-xs); color: var(--text-muted); }
.game-header .actions { margin-left: auto; display: flex; gap: var(--space-1); }

/* ---------- buttons ---------- */
.btn { --b: var(--accent); --fg: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-5); border: 0; border-radius: var(--radius-md); background: var(--b); color: var(--fg);
  font: 700 var(--fs-base)/1 var(--font-sans); cursor: pointer; text-decoration: none;
  box-shadow: 0 var(--edge-button) 0 color-mix(in srgb, var(--b) 60%, #000); transition: transform var(--motion-fast) var(--motion-ease), box-shadow var(--motion-fast); }
.btn:hover { --b: var(--accent-hover); }
.btn:active { transform: translateY(calc(var(--edge-button) - var(--edge-pressed))); box-shadow: 0 var(--edge-pressed) 0 color-mix(in srgb, var(--b) 60%, #000); }
.btn-game { --b: var(--g); --fg: var(--on-game); }
.btn-game:hover { --b: color-mix(in srgb, var(--g) 90%, #000); }
.btn-secondary { --b: var(--surface); --fg: var(--text); border: 1px solid var(--border-strong); box-shadow: 0 var(--edge-button) 0 var(--edge); }
.btn-secondary:hover { --b: var(--surface-sunken); }
.btn-secondary:active { box-shadow: 0 var(--edge-pressed) 0 var(--edge); }
.btn-ghost { --b: transparent; --fg: var(--text); box-shadow: none; }
.btn-ghost:hover { --b: var(--surface-sunken); }
.btn-danger-ghost { --b: var(--surface); --fg: var(--danger); border: 1px solid var(--border-strong); box-shadow: 0 var(--edge-card) 0 var(--edge); }
.btn-danger-ghost:hover { --b: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: var(--fs-sm); }
.btn-lg { min-height: 52px; width: 100%; font-size: var(--fs-lg); }
.btn:disabled, .btn[aria-disabled="true"] { --b: var(--surface-sunken); --fg: var(--text-subtle); box-shadow: none; transform: none; cursor: not-allowed; border-color: transparent; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::before { content: ""; width: 1em; height: 1em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-sunken); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: var(--space-4); }
.game-card { display: grid; grid-template-columns: 48px 1fr; gap: var(--space-1) var(--space-3); align-items: center; }
.game-card .game-badge { grid-row: span 2; width: 48px; height: 48px; }
.game-card h3 { font-size: var(--fs-lg); }
.game-card p { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.game-card .row { grid-column: 1 / -1; display: flex; gap: var(--space-2); margin-top: var(--space-3); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2); border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 700; background: var(--surface-sunken); color: var(--text-muted); }
.chip-done { background: var(--hit); color: var(--on-hit); }
.countdown { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); margin: var(--space-2) 0 var(--space-5); }
.countdown b { color: var(--text); font-size: var(--fs-lg); }

/* ---------- GeoRankle ---------- */
.cat-list { display: grid; gap: var(--space-2); }
.cat-row { display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: 0 var(--space-4); width: 100%;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: 0 var(--edge-card) 0 var(--edge); font: 700 var(--fs-sm)/1.2 var(--font-sans); cursor: pointer; text-align: left; }
.cat-row:hover { background: var(--surface-sunken); }
.cat-row .rank { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-base); font-weight: 800; }
.cat-row[aria-disabled="true"] { cursor: default; box-shadow: none; transform: translateY(1px); }
.cat-row[aria-disabled="true"]:hover { background: var(--surface); }
.cat-row.best { background: var(--hit); color: var(--on-hit); border-color: transparent; }

/* ---------- Geodle ---------- */
.combo { position: relative; }
.combo input { width: 100%; height: 52px; padding: 0 var(--space-4) 0 44px; border: 2px solid var(--border-input); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); font: 500 var(--fs-base) var(--font-sans); }
.combo input:focus { outline: 3px solid var(--focus); outline-offset: 1px; }
.combo > .icon { position: absolute; left: 14px; top: 16px; color: var(--text-muted); }
.listbox { list-style: none; margin: var(--space-1) 0 0; padding: var(--space-1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-pop); }
.listbox li { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); cursor: pointer; }
.listbox li[aria-selected="true"], .listbox li:hover { background: var(--surface-sunken); }
.listbox li[aria-disabled="true"] { color: var(--text-subtle); cursor: not-allowed; }
.listbox li[aria-disabled="true"]::after { content: attr(data-note); margin-left: auto; font-size: var(--fs-xs); }
.guess { display: grid; gap: var(--space-2); }
.guess-head { display: flex; align-items: center; gap: var(--space-3); font-weight: 700; font-size: var(--fs-lg); }
.guess-head .n { margin-left: auto; font-size: var(--fs-sm); color: var(--text-muted); }
.clues { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.clue { min-height: 56px; display: grid; place-content: center; text-align: center; gap: 2px; padding: var(--space-1); border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.clue .lbl { font-size: var(--fs-2xs); line-height: var(--lh-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; opacity: .85; }
.clue .val { font-size: var(--fs-sm); font-weight: 700; overflow-wrap: anywhere; display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.clue.hit { background: var(--hit); color: var(--on-hit); border-color: transparent; }
.clue.miss { background: var(--miss); color: var(--on-miss); border-color: transparent; }
.empty { text-align: center; color: var(--text-muted); padding: var(--space-7) 0; }
.empty svg { width: 96px; height: 96px; }

/* ---------- GeoConnections ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); }
.tile { aspect-ratio: 1; min-width: 0; display: grid; place-content: center; text-align: center; gap: 2px; padding: var(--space-1);
  background: var(--surface); color: var(--text); border: 2px solid var(--border); border-radius: var(--radius-md);
  box-shadow: 0 var(--edge-card) 0 var(--edge); font-family: var(--font-sans); cursor: pointer; }
.tile:hover { background: var(--surface-sunken); }
.tile[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); transform: translateY(1px); box-shadow: 0 1px 0 var(--edge); }
.tile .lbl { font-size: var(--fs-2xs); font-weight: 700; color: var(--text-muted); }
.tile .val { font-size: var(--fs-sm); font-weight: 700; }
.tile svg { width: 100%; height: auto; max-height: 64px; }
.tile.wrong { animation: shake 300ms; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.group-banner { grid-column: 1 / -1; padding: var(--space-4); border-radius: var(--radius-md); text-align: center; box-shadow: 0 var(--edge-card) 0 var(--edge); color: var(--text); }
.group-banner b { display: block; font-size: var(--fs-lg); text-transform: uppercase; letter-spacing: .04em; }
.group-banner i { font-size: var(--fs-sm); }
.gb-1 { background: var(--group-1); } .gb-2 { background: var(--group-2); } .gb-3 { background: var(--group-3); } .gb-4 { background: var(--group-4); }
.mistakes { display: flex; justify-content: center; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); color: var(--text-muted); margin: var(--space-5) 0 var(--space-4); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--text); }
.dot.used { background: transparent; box-shadow: inset 0 0 0 2px var(--border-strong); }
.btn-row { display: flex; gap: var(--space-2); justify-content: center; }

/* ---------- GeoDecide ---------- */
.versus { display: grid; gap: var(--space-4); }
.versus h2 { text-align: center; font-size: var(--fs-lg); }
.vs-panel { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-4); background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 var(--edge-card) 0 var(--edge); cursor: pointer; font-family: var(--font-sans); color: var(--text); }
.vs-panel:hover { border-color: var(--g); }
.vs-panel .name { font-size: var(--fs-lg); font-weight: 700; }
.vs-panel .value { font-size: var(--fs-xl); font-weight: 800; }
.vs-panel .value.hidden { color: var(--text-subtle); letter-spacing: .2em; }
.vs-panel.correct { border-color: var(--success); }
.vs-panel.wrong { border-color: var(--danger); }
.vs-divider { text-align: center; font-weight: 800; font-size: var(--fs-xl); }
@media (min-width: 640px) { .versus .pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: var(--space-4); } .versus .pair .vs-divider { align-self: center; } }

/* ---------- GeoPaint ---------- */
.paint { display: grid; gap: var(--space-5); justify-items: center; }
.paint svg.flag-big { width: 240px; height: auto; border-radius: 4px; box-shadow: 0 0 0 1px var(--border); }
.sliders { width: 100%; display: grid; gap: var(--space-4); }
.slider { display: grid; grid-template-columns: 7ch 1fr 5ch; align-items: center; gap: var(--space-3); font-size: var(--fs-sm); font-weight: 700; }
.slider input { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; border-radius: var(--radius-pill); background: var(--track); box-shadow: inset 0 0 0 1px var(--border-strong); }
.slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 3px solid var(--text); }
.slider input::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 3px solid var(--text); }
.slider output { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- result ---------- */
.result { display: grid; gap: var(--space-5); justify-items: center; text-align: center; }
.stats { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.stat { display: grid; gap: 2px; padding: 0 var(--space-3); }
.stat + .stat { border-left: 1px solid var(--border-strong); }
.stat .lbl { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 500; }
.stat .val { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: var(--fs-xs); color: var(--text-muted); }
.swatches { display: flex; gap: var(--space-3); }
.swatch { display: grid; gap: 2px; font-size: var(--fs-xs); font-weight: 700; }
.swatch span { width: 40px; height: 28px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }

/* ---------- leaderboard ---------- */
.board { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.board th { text-align: left; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500; padding: var(--space-2); }
.board td { padding: var(--space-2); border-top: 1px solid var(--border); }
.board tr.me td { background: var(--surface-sunken); font-weight: 700; }
.board .locked { filter: blur(5px); user-select: none; }

/* ---------- toast & dialog ---------- */
.toast { display: inline-flex; gap: var(--space-2); align-items: center; padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill); background: var(--text); color: var(--bg); font-weight: 700; font-size: var(--fs-sm); box-shadow: var(--shadow-pop); }
.toast.danger { background: var(--danger); color: var(--on-accent); }
dialog.modal { border: 0; padding: var(--space-5); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); max-width: min(420px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: color-mix(in srgb, var(--overlay) 50%, transparent); }
.modal h2 { font-size: var(--fs-xl); margin-bottom: var(--space-3); }

/* ---------- flags & shapes ---------- */
.flag { display: inline-block; border-radius: 2px; box-shadow: 0 0 0 1px var(--border); overflow: hidden; vertical-align: middle; }
.shape { color: color-mix(in srgb, var(--accent) 70%, var(--surface)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
  .btn:active, .tile[aria-pressed="true"] { transform: none; }
}
