/* Soforth collection UI kit — sourced verbatim from the Longabout game's tokens
   (site/longabout/style.css) so hub and games render identically. Ships only the
   shared primitives: tokens, buttons, sheets, toasts, stats. Base first, so a page
   that links ONLY ui.css gets the correct reset + body hardening. */

:root {
  color-scheme: dark;
  --bg: oklch(0.115 0 0);
  --glow: oklch(0.82 0.17 118 / 0.6);
  --surface: oklch(0.16 0.006 110);
  --surface-raised: oklch(0.2 0.007 110);
  --tile: oklch(0.185 0.008 110);
  --tile-line: oklch(0.24 0.008 110);

  --ink: oklch(0.93 0.012 105);
  --muted: oklch(0.68 0.02 108);
  --faint: oklch(0.47 0.015 108);

  --moss: oklch(0.82 0.17 118);
  --moss-bright: oklch(0.88 0.19 118);
  --moss-deep: oklch(0.36 0.07 120);
  --moss-ink: oklch(0.22 0.05 120);
  --bone: oklch(0.92 0.02 100);
  --bone-ink: oklch(0.2 0.012 100);
  --wall: oklch(0.72 0.028 95);
  --danger: oklch(0.66 0.19 30);

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;

  --z-scrim: 20;
  --z-sheet: 30;
  --z-toast: 40;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --sheet-ms: 260ms;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  overscroll-behavior: none;
  /* suppress double-tap-to-zoom everywhere (pinch a11y zoom untouched) */
  touch-action: manipulation;
}

body {
  /* hard scroll lock: the app is one screen; stop iOS rubber-banding */
  position: fixed;
  inset: 0;
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI',
    Roboto, Inter, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  height: 100dvh;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- icon button ---------- */

.icon-btn {
  appearance: none;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 120ms ease;
}

.icon-btn:hover {
  background: var(--surface-raised);
  color: var(--ink);
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- pill button ---------- */

.pill {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 128px;
  height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--ink);
  position: relative;
  overflow: hidden;
  transition: background 150ms ease, color 150ms ease, transform 120ms ease,
    opacity 150ms ease;
}

.pill:hover {
  background: var(--surface-raised);
}

.pill:active {
  transform: scale(0.97);
}

.pill:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.pill.primary {
  background: var(--moss);
  color: var(--moss-ink);
}

.pill.primary:hover {
  background: var(--moss-bright);
}

.pill.ghost {
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--tile-line);
}

.pill.ghost:hover {
  color: var(--ink);
  background: var(--surface);
}

/* hold-to-clear progress fill */
.pill .hold-fill {
  position: absolute;
  inset: 0;
  background: var(--danger);
  opacity: 0.28;
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

.pill.holding .hold-fill {
  transform: scaleX(1);
  transition: transform 550ms linear;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  translate: -50% 12px;
  background: var(--surface-raised);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 550;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, translate 200ms var(--ease-out);
  z-index: var(--z-toast);
  max-width: min(88vw, 480px);
  text-align: center;
  box-shadow: 0 6px 24px oklch(0 0 0 / 0.45);
}

.toast.show {
  opacity: 1;
  translate: -50% 0;
  pointer-events: auto;
  cursor: default;
}

/* when a sheet is up, toasts drop in from the top instead */
body.sheet-open .toast {
  bottom: auto;
  top: calc(14px + env(safe-area-inset-top));
  translate: -50% -12px;
}

body.sheet-open .toast.show {
  translate: -50% 0;
}

.toast.action {
  cursor: pointer;
  color: var(--moss);
}

/* ---------- sheets ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.55);
  opacity: 0;
  transition: opacity var(--sheet-ms) ease;
  z-index: var(--z-scrim);
}

.scrim.show {
  opacity: 1;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  translate: -50% 105%;
  width: min(100%, 560px);
  background: var(--surface);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  padding: 26px 24px calc(24px + env(safe-area-inset-bottom));
  z-index: var(--z-sheet);
  transition: translate var(--sheet-ms) var(--ease-out);
  box-shadow: 0 -10px 40px oklch(0 0 0 / 0.5);
}

.sheet.open {
  translate: -50% 0;
}

.sheet h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}

.sheet .close-x {
  position: absolute;
  top: 16px;
  right: 16px;
}

.sheet .cta-row {
  display: flex;
  gap: 10px;
}

.sheet .cta-row .pill {
  flex: 1;
}

/* ---------- stats ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface-raised);
  border-radius: var(--radius-m);
  padding: 14px 8px 12px;
  text-align: center;
}

.stat .num {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.8rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat .lbl {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.best-line {
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
  margin-bottom: 18px;
  min-height: 1.4em;
}

.best-line b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- misc ---------- */

:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .scrim,
  .toast {
    transition-duration: 1ms;
  }

  .pill.holding .hold-fill {
    transition-duration: 550ms; /* hold progress is information, keep it */
  }
}

/* ---------- appearance control ---------- */

.scheme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.scheme-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.scheme-group {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-raised);
  border-radius: 999px;
}

.scheme-btn {
  appearance: none;
  border: 0;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  padding: 7px 14px;
  min-height: 34px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  transition: background 150ms ease, color 150ms ease;
}

.scheme-btn.on {
  background: var(--moss);
  color: var(--moss-ink);
}

@media (hover: hover) {
  .scheme-btn:not(.on):hover {
    color: var(--ink);
  }
}
