/* geoguess.es — starter component library (design.md §7). Every interactive element has hover,
   active, focus-visible and disabled states; focus is always the 2 px --focus ring. One gilt (.btn-gilt)
   per view. Feature packages add their own CSS files next to their pages (css/<area>.css, loaded by the
   page module via ui/dom.js loadCss) and never edit this file without the lead (it is shared). */

/* ------------------------------------------------------------------ buttons (§7.1) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 40px; padding: 0 var(--sp-4);
  border: 1px solid transparent; border-radius: var(--r-2);
  font-family: var(--font-ui); font-weight: 600; font-size: var(--fs-15); line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-sm { height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-14); }
.btn-lg { height: 48px; padding: 0 22px; font-size: var(--fs-16); }
.btn-xl { height: 56px; padding: 0 28px; font-size: var(--fs-18); }
.btn-block { width: 100%; }
.btn-gilt { background: var(--cta); border-color: var(--cta-edge); color: var(--cta-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn-gilt:hover:not(:disabled) { background: var(--cta-hover); color: var(--cta-ink); }
.btn-indigo { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-indigo:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-outline { background: transparent; border-color: var(--field); color: var(--ink); }
.btn-outline:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.btn-danger { background: transparent; border-color: var(--loss); color: var(--loss); }
.btn-danger:hover:not(:disabled) { background: var(--loss-soft); }
.btn-danger-solid { background: var(--loss); border-color: var(--loss); color: var(--card); }
.btn-cream { background: var(--chrome-ink); border-color: var(--chrome-ink); color: var(--chrome); }
.btn-cream:hover { filter: brightness(1.06); color: var(--chrome); }
.btn-ghost-chrome { background: transparent; border-color: var(--chrome-3); color: var(--chrome-ink); }
.btn-ghost-chrome:hover { background: var(--chrome-2); color: var(--chrome-ink); }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--r-2); background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
kbd { font-family: var(--font-mono); font-weight: 500; font-size: var(--fs-11); padding: 1px 5px; border: 1px solid currentColor; border-radius: var(--r-1); opacity: .8; line-height: 1.3; }

/* ------------------------------------------------------------------ inputs (§7.2) */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--fs-13); font-weight: 500; color: var(--ink-2); }
.field-hint { font-size: var(--fs-12); color: var(--ink-3); }
.field-error { font-size: var(--fs-12); color: var(--loss); }
.input, .select, .textarea {
  height: 40px; width: 100%; padding: 0 var(--sp-3);
  background: var(--raised); color: var(--ink);
  border: 1px solid var(--field); border-radius: var(--r-2);
  font-size: var(--fs-15);
}
.textarea { height: auto; min-height: 96px; padding: var(--sp-2) var(--sp-3); line-height: var(--lh-body); resize: vertical; }
.input::placeholder { color: var(--ink-3); }
.input[aria-invalid="true"] { border-color: var(--loss); }
:root[data-theme="dark"] .input, :root[data-theme="dark"] .select, :root[data-theme="dark"] .textarea { background: var(--sunken); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .input, :root:not([data-theme="light"]) .select, :root:not([data-theme="light"]) .textarea { background: var(--sunken); } }
.code-input { display: flex; gap: var(--sp-2); }
.code-input input { width: 44px; height: 52px; text-align: center; font-family: var(--font-mono); font-weight: 600; font-size: 22px; border: 1px solid var(--field); border-radius: var(--r-2); background: var(--raised); }
.segmented { display: inline-flex; border: 1px solid var(--field); border-radius: var(--r-2); overflow: hidden; height: 32px; }
.segmented label { display: inline-flex; align-items: center; padding: 0 var(--sp-3); font-size: var(--fs-13); font-weight: 500; color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--field); }
.segmented label:last-child { border-right: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:checked + span { color: var(--accent-ink); }
.segmented label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
.toggle { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-14); }
.toggle input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--sunken); border: 1px solid var(--field); position: relative; margin: 0; transition: background var(--t-fast) var(--ease); }
.toggle input::after { content: ""; position: absolute; top: 1px; left: 1px; width: 16px; height: 16px; border-radius: 50%; background: var(--raised); box-shadow: var(--shadow-1); transition: transform var(--t-fast) var(--ease); }
.toggle input:checked { background: var(--accent); border-color: var(--accent); }
.toggle input:checked::after { transform: translateX(16px); }

/* ------------------------------------------------------------------ cards and tiles (§7.3) */
.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-3); box-shadow: var(--shadow-1); padding: var(--sp-4); }
.card-lg { padding: var(--sp-6); }
.card-head { display: flex; align-items: baseline; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.card-head .flavour { margin: 2px 0 0; }
.card-head > div { flex: 1; min-width: 0; }
.card-head a { font-size: var(--fs-13); font-weight: 600; }
.card-reading .card-head { border-bottom: 3px double var(--rule-2); padding-bottom: var(--sp-2); }
:root[data-theme="dark"] .card { box-shadow: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card { box-shadow: none; } }

.tc-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-3); }
@media (max-width: 767.98px) { .tc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tc-tile {
  --tc: var(--tc-blitz);
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: var(--sp-3); min-height: 132px;
  background: var(--raised); color: var(--ink);
  border: 1px solid var(--rule-2); border-top: 3px solid var(--tc); border-radius: var(--r-2);
  cursor: pointer; transition: box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.tc-tile:hover { box-shadow: var(--shadow-2); }
.tc-tile[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.tc-tile .icon { width: 28px; height: 28px; margin-bottom: var(--sp-2); color: var(--ink); }
.tc-tile .tc-name { font-weight: 600; font-size: var(--fs-16); }
.tc-tile .tc-time { font-weight: 600; font-size: var(--fs-13); color: var(--tc); }
.tc-tile .tc-flavour { font-family: var(--font-serif); font-style: italic; font-size: var(--fs-12); color: var(--ink-3); }
.tc-tile .tc-live { margin-top: auto; font-size: var(--fs-12); color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.tc-bullet { --tc: var(--tc-bullet); } .tc-blitz { --tc: var(--tc-blitz); } .tc-rapid { --tc: var(--tc-rapid); }
.tc-classical { --tc: var(--tc-classical); } .tc-daily { --tc: var(--tc-daily); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--win); display: inline-block; }

.mode-tile { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3); border-radius: var(--r-2); text-decoration: none; color: var(--ink); border: 1px solid transparent; }
.mode-tile:hover { background: var(--sunken); color: var(--ink); }
.mode-tile .mode-icon { width: 40px; height: 40px; border-radius: var(--r-2); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.mode-tile b { display: block; font-size: var(--fs-15); font-weight: 600; }
.mode-tile span { font-size: var(--fs-13); color: var(--ink-3); }

/* difficulty tiers T1–T8 (§2.3) */
.tiers { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); border-radius: var(--r-2); overflow: hidden; border: 1px solid var(--rule-2); }
.tier { padding: var(--sp-2) var(--sp-3); min-height: 84px; display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
.tier .eyebrow { color: inherit; opacity: .85; }
.tier b { font-size: var(--fs-13); font-weight: 600; line-height: 1.25; }
.tier .mono { margin-top: auto; font-size: var(--fs-11); opacity: .9; }
.tier-1 { background: var(--depth-1); } .tier-2 { background: var(--depth-2); } .tier-3 { background: var(--depth-3); } .tier-4 { background: var(--depth-4); }
.tier-5 { background: var(--depth-5); color: var(--depth-ink); } .tier-6 { background: var(--depth-6); color: var(--depth-ink); }
.tier-7 { background: var(--depth-7); color: var(--depth-ink); } .tier-8 { background: var(--depth-8); color: var(--depth-ink); }
@media (max-width: 767.98px) { .tiers { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ------------------------------------------------------------------ tabs (§7.4) */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tabs [role="tab"] { height: 40px; padding: 0 var(--sp-3); border: 0; background: transparent; color: var(--ink-2); font-weight: 500; font-size: var(--fs-14); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tabs [role="tab"][aria-selected="true"] { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.tabs [role="tab"]:hover { color: var(--ink); }

/* ------------------------------------------------------------------ chips, pills, tags (§7.5) */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border: 1px solid var(--field); border-radius: var(--r-pill); font-size: var(--fs-12); font-weight: 500; color: var(--ink-2); background: transparent; }
.chip .icon { width: 14px; height: 14px; }
.chip[aria-pressed="true"], .chip-on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chip-off { text-decoration: line-through; border-style: dashed; color: var(--ink-3); }
button.chip { cursor: pointer; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: var(--fs-12); font-weight: 600; }
.pill-win { background: var(--win-soft); color: var(--win); } .pill-loss { background: var(--loss-soft); color: var(--loss); }
.pill-warn { background: var(--warn-soft); color: var(--warn); } .pill-info { background: var(--accent-soft); color: var(--accent); }
.pill-neutral { background: var(--sunken); color: var(--ink-2); }
.tag { display: inline-flex; align-items: center; height: 16px; padding: 0 5px; border-radius: var(--r-1); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; line-height: 1; vertical-align: middle; }
.tag-you { background: var(--self-soft); color: var(--self); }
.tag-bot { background: var(--sunken); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--field); }
.tag-mod { background: var(--accent-soft); color: var(--accent); }
.tag-admin { background: var(--loss); color: var(--card); }
.count-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--loss); color: var(--card); font-size: var(--fs-11); font-weight: 700; line-height: 1; }

/* ------------------------------------------------------------------ identity (§7.9) */
.avatar { width: 32px; height: 32px; border-radius: var(--r-2); flex: none; overflow: hidden; display: grid; place-items: center; font-family: var(--font-serif); font-style: italic; font-size: 18px; color: #FAF9F5; background: var(--accent); position: relative; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-24 { width: 24px; height: 24px; font-size: 14px; } .avatar-44 { width: 44px; height: 44px; font-size: 24px; } .avatar-96 { width: 96px; height: 96px; font-size: 52px; }
.avatar-bot { border-radius: 50%; background: var(--chrome); color: var(--brass); box-shadow: inset 0 0 0 2px var(--brass); }
/* default-avatar pigments: always the Day values in both modes (design.md §3.3) */
.pig-0 { background: #2A4A7F; } .pig-1 { background: #AD371C; } .pig-2 { background: #1D6A5A; } .pig-3 { background: #94600F; } .pig-4 { background: #6A3D7A; } .pig-5 { background: #6B4B2E; }
.presence { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--card); }
.presence-online { background: var(--win); } .presence-playing { background: var(--warn); }
.flag { width: 20px; height: 15px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); flex: none; object-fit: cover; display: inline-block; vertical-align: -2px; }
.flag-24 { width: 24px; height: 18px; }
.flag-rose { color: var(--brass-ink); width: 15px; height: 15px; }
.who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); text-decoration: none; }
a.who-name:hover { text-decoration: underline; }
.rating { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.rating .icon { width: 14px; height: 14px; }
.rating .prov { color: var(--ink-3); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: var(--fs-12); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta::before { content: ""; width: 7px; height: 6px; background: currentColor; }
.delta.up { color: var(--win); } .delta.up::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.delta.dn { color: var(--loss); } .delta.dn::before { clip-path: polygon(0 0, 100% 0, 50% 100%); }
.delta.eq { color: var(--ink-3); } .delta.eq::before { height: 2px; }

/* ------------------------------------------------------------------ dialogs, sheets (§7.6) */
.dialog { width: min(480px, calc(100vw - 2 * var(--sp-4))); max-height: calc(100dvh - 2 * var(--sp-6)); padding: 0; border: 1px solid var(--rule); border-radius: var(--r-4); background: var(--card); color: var(--ink); box-shadow: var(--shadow-2); }
.dialog-wide { width: min(720px, calc(100vw - 2 * var(--sp-4))); }
.dialog::backdrop { background: var(--scrim, rgba(10, 15, 22, .55)); } /* ::backdrop may not inherit custom properties (older engines) */
.dialog-body { padding: var(--sp-6); overflow-y: auto; max-height: inherit; }
.dialog-head { display: flex; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.dialog-head > div { flex: 1; }
.dialog-head .flavour { margin: var(--sp-1) 0 0; }
.dialog-close { margin: -8px -8px 0 0; }
.divider-or { display: flex; align-items: center; gap: var(--sp-3); color: var(--ink-3); font-size: var(--fs-13); margin: var(--sp-4) 0; }
.divider-or::before, .divider-or::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
@media (max-width: 767.98px) {
  .dialog.sheet-on-phone { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-4) var(--r-4) 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .dialog.sheet-on-phone .dialog-body::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--rule-2); margin: -12px auto var(--sp-4); }
}
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 40px; border-radius: 4px; border: 1px solid #747775; background: #FFFFFF; color: #1F1F1F; font-family: var(--font-ui); font-weight: 500; font-size: 14px; text-decoration: none; }
:root[data-theme="dark"] .google-btn { background: #131314; border-color: #8E918F; color: #E3E3E3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .google-btn { background: #131314; border-color: #8E918F; color: #E3E3E3; } }

/* ------------------------------------------------------------------ toasts, banners (§7.7) */
.toast { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4); background: var(--raised); border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: var(--r-2); box-shadow: var(--shadow-2); color: var(--ink); }
.toast b { display: block; font-size: var(--fs-14); }
.toast p { margin: 2px 0 0; font-size: var(--fs-13); color: var(--ink-2); }
.toast-win { border-left-color: var(--win); } .toast-loss { border-left-color: var(--loss); } .toast-warn { border-left-color: var(--warn); } .toast-brass { border-left-color: var(--brass); }
.banner { display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-2); font-size: var(--fs-14); }
.banner-info { background: var(--accent-soft); color: var(--accent); } .banner-warn { background: var(--warn-soft); color: var(--warn); }
.banner-loss { background: var(--loss-soft); color: var(--loss); } .banner-win { background: var(--win-soft); color: var(--win); }

/* ------------------------------------------------------------------ menus, tooltips (§7.8) */
.menu { min-width: 200px; padding: var(--sp-1); background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r-3); box-shadow: var(--shadow-2); }
.menu [role="menuitem"] { display: flex; align-items: center; gap: var(--sp-2); width: 100%; height: 36px; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-2); background: transparent; color: var(--ink); text-decoration: none; font-size: var(--fs-14); text-align: left; }
.menu [role="menuitem"]:hover, .menu [role="menuitem"]:focus-visible { background: var(--sunken); outline: none; }
.tooltip { position: absolute; z-index: var(--z-tooltip); max-width: 240px; padding: 6px 8px; border-radius: var(--r-2); background: var(--chrome); color: var(--chrome-ink); font-size: var(--fs-12); pointer-events: none; }

/* ------------------------------------------------------------------ tables (§7.12) */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
.table th { height: 32px; padding: 0 var(--sp-3); background: var(--sunken); text-align: left; font-size: var(--fs-11); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.table td { height: 40px; padding: 0 var(--sp-3); border-bottom: 1px solid var(--rule); }
.table tbody tr:nth-child(5n) td { border-bottom-color: var(--rule-2); }
.table tbody tr:hover td { background: var(--sunken); }
.table .r { text-align: right; }
.table tr.me td { background: var(--accent-soft); }
.table tr.me td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* ------------------------------------------------------------------ empty, loading, errors (§7.16) */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-10) var(--sp-4); color: var(--ink-2); }
.empty .icon { width: 48px; height: 48px; color: var(--brass); }
.empty h3 { font-family: var(--font-serif); font-weight: 700; font-size: var(--fs-18); }
.skeleton { background: var(--sunken); border-radius: var(--r-1); position: relative; overflow: hidden; min-height: 12px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--card) 55%, transparent), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.rule-star { display: flex; align-items: center; gap: 10px; color: var(--brass); }
.rule-star::before, .rule-star::after { content: ""; flex: 1; height: 1px; background: var(--rule-2); }
.rule-star .icon { width: 12px; height: 12px; }

/* sextant loading mark: the index arm sweeps (§11). Inline the mono/mark SVG with <g class="gg-arm">. */
.gg-arm { transform-box: view-box; transform-origin: 33px 12px; animation: sweep 1.6s var(--ease) infinite alternate; }
@keyframes sweep { from { transform: rotate(-8deg); } to { transform: rotate(18deg); } }

/* ------------------------------------------------------------------ game HUD primitives (§7.10) */
.hp { position: relative; height: 12px; border-radius: 2px; background: var(--sunken); box-shadow: inset 0 0 0 1px var(--rule-2); overflow: hidden; }
.hp-lost { position: absolute; inset: 0; background: repeating-linear-gradient(135deg, var(--sunken) 0 3px, color-mix(in srgb, var(--sunken) 55%, var(--ink-3)) 3px 4px); }
.hp-fill { position: absolute; inset: 0 auto 0 0; background: var(--self); transition: width var(--t-reveal) var(--ease); }
.hp-opp .hp-fill { inset: 0 0 0 auto; background: var(--opp); }
.hp-num { font-family: var(--font-mono); font-weight: 600; font-size: var(--fs-18); font-variant-numeric: tabular-nums; }
.hud-plate { background: var(--hud); border-radius: var(--r-3); box-shadow: var(--shadow-2); padding: var(--sp-3); }
.limb { width: 200px; height: 46px; overflow: visible; }
.limb .track { stroke: var(--sunken); }
.limb .fill { stroke: var(--brass); }
.limb.low .fill { stroke: var(--loss); }
.limb .ticks { stroke: var(--ink-3); }
.limb .index { fill: var(--ink); }
.clock-digits { font-family: var(--font-mono); font-weight: 600; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.clock-digits.low { color: var(--loss); }
