/* Cap Guesser. Light: navy on white with an orange action. Dark: night navy with a sky blue action.
   Manrope for words and numbers, JetBrains Mono for the ruler and tickers; weights 400 and 500 only.
   One column on a phone; from 1024px the clue sits on the left five columns, the guess on the right six. */
:root {
  --bg: #ffffff;
  --surface: #f4f4f2;
  --paper: #ffffff;          /* dialogs */
  --ink: #1f2b4d;
  --muted: #646b81;
  --accent: #f7941d;         /* the mark */
  --action: #f7941d;         /* the main button */
  --action-ink: #1f2b4d;
  --close: #16875a;          /* app.js colours points with --close, --near and --far */
  --near: #b27a12;
  --far: #c2412d;
  --on-ink: #ffffff;         /* text on the answer pin */

  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --track: -0.035em;
  --thumb-w: 20px;
  --bar-h: 64px;
  --gut: 20px;
  --r: 12px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 180ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0d14;
    --surface: #131824;
    --paper: #131824;
    --ink: #e9edf3;
    --muted: #8891a1;
    --accent: #5ab9fc;
    --action: #5ab9fc;
    --action-ink: #0a0d14;
    --close: #4fd19a;
    --near: #f0b44c;
    --far: #f2765f;
    --on-ink: #0a0d14;
    color-scheme: dark;
  }
}

:root {
  --line: color-mix(in oklab, var(--ink) 11%, transparent);
  --line-strong: color-mix(in oklab, var(--ink) 22%, transparent);
  --rule: color-mix(in oklab, var(--ink) 16%, transparent);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, ol, dl, dd { margin: 0; }
ol { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in oklab, var(--accent) 30%, transparent); }
.muted { color: var(--muted); }

/* Header: one opaque bar with a hairline, the mark beside the name */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar__in {
  display: flex; align-items: center; justify-content: space-between;
  width: min(100% - 2 * var(--gut), 1280px); height: var(--bar-h); margin-inline: auto;
}
.wordmark {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 500; font-size: 1.25rem; letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none;
}
.mark {
  width: 20px; height: 20px; background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='6.5' cy='6.5' r='4.5'/%3E%3Ccircle cx='17.5' cy='6.5' r='4.5'/%3E%3Ccircle cx='6.5' cy='17.5' r='4.5'/%3E%3Crect x='13' y='13' width='9' height='9' rx='1.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='6.5' cy='6.5' r='4.5'/%3E%3Ccircle cx='17.5' cy='6.5' r='4.5'/%3E%3Ccircle cx='6.5' cy='17.5' r='4.5'/%3E%3Crect x='13' y='13' width='9' height='9' rx='1.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.bar-actions { display: flex; gap: 4px; margin-right: -10px; }

.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink);
  transition: background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.icon-btn:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.96); }
.icon-btn svg, .nudge svg, .foot__about svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn svg .fill, .foot__about svg .fill { fill: currentColor; stroke: none; }

.wrap {
  flex: 1 0 auto;
  width: min(100% - 2 * var(--gut), 34rem);
  margin: 0 auto;
  padding: 24px 0 calc(32px + env(safe-area-inset-bottom));
}

.status { padding: 96px 0; text-align: center; color: var(--muted); }

/* Round header and the weighted progress bar */
.round-head { display: flex; justify-content: space-between; font-size: 0.875rem; color: var(--muted); }
#roundLabel { color: var(--ink); font-weight: 500; }
.progress {
  display: grid;
  grid-template-columns: 1fr 2fr 2fr 2fr 3fr; /* widths match the weights */
  gap: 4px;
  margin: 12px 0 28px;
}
.progress li { height: 6px; border-radius: 3px; background: var(--rule); }
.progress li.current { background: var(--ink); }
.progress li.close { background: var(--close); }
.progress li.near { background: var(--near); }
.progress li.far { background: var(--far); }

/* Clue */
.company {
  font-weight: 500;
  font-size: clamp(2.5rem, 11vw, 4.5rem);
  letter-spacing: var(--track);
  line-height: 1;
}
.meta { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 0.9375rem; }
.ticker {
  padding: 1px 7px; border: 1px solid var(--rule); border-radius: 4px;
  font-family: var(--mono); font-size: 0.75rem; color: var(--ink);
}
.facts { margin-top: 20px; color: var(--muted); }
.facts + .clue-text { margin-top: 8px; }
.clue-text { margin-top: 20px; font-size: 1.125rem; line-height: 1.5; max-width: 40ch; }

/* Guess */
.guess { margin-top: 32px; }
.guess-label { display: block; text-align: center; font-size: 0.875rem; color: var(--muted); }
.guess-row { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; margin-top: 4px; }
.guess-input {
  width: 100%; min-width: 0; padding: 0 0 2px;
  border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--ink);
  text-align: center; font-weight: 500;
  font-size: clamp(3rem, 14vw, 4.5rem); letter-spacing: var(--track);
  font-variant-numeric: tabular-nums; line-height: 1.1;
  transition: border-color var(--dur) var(--ease);
}
.guess-input::placeholder { color: var(--rule); opacity: 1; }
.guess-input:hover { border-bottom-color: var(--rule); }
.guess-input:focus { outline: none; border-bottom-color: var(--ink); }
.guess-input:disabled { opacity: 1; -webkit-text-fill-color: var(--ink); }

.nudge {
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--ink);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.nudge:hover { border-color: var(--ink); transform: translateY(-1px); }
.nudge:active { transform: scale(.96); }
.nudge:disabled { opacity: 0.35; cursor: default; transform: none; }

/* The scale: a log ruler from $10M to $10T */
.scale { position: relative; margin-top: 24px; padding-top: 26px; /* room for the answer pin label */ }
.scale-inner { position: relative; margin: 0 calc(var(--thumb-w) / 2); }
.ruler { display: block; width: 100%; height: 40px; overflow: visible; }
.ruler line { stroke: var(--ink); vector-effect: non-scaling-stroke; }
.ruler .minor { stroke: var(--muted); opacity: 0.5; }

.slider {
  position: absolute; inset: 26px 0 auto; width: 100%; height: 40px; margin: 0;
  background: transparent; -webkit-appearance: none; appearance: none; touch-action: pan-y; cursor: grab;
}
.slider:active { cursor: grabbing; }
.slider:focus-visible { outline: none; }
.slider::-webkit-slider-runnable-track { height: 40px; background: transparent; }
.slider::-moz-range-track { height: 40px; background: transparent; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: var(--thumb-w); height: 40px;
  border: 2px solid var(--bg); border-radius: 6px; background: var(--ink); box-shadow: 0 0 0 1px var(--ink);
  transition: transform .15s var(--ease);
}
.slider::-moz-range-thumb {
  width: var(--thumb-w); height: 40px;
  border: 2px solid var(--bg); border-radius: 6px; background: var(--ink); box-shadow: 0 0 0 1px var(--ink);
}
.slider:hover::-webkit-slider-thumb { transform: translateY(-1px); }
.slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--ink), 0 0 0 4px color-mix(in oklab, var(--action) 40%, transparent); }
.slider:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 1px var(--ink), 0 0 0 4px color-mix(in oklab, var(--action) 40%, transparent); }
/* After reveal the handle shrinks to a needle so the answer pin and gap show. */
.scale.reveal .slider::-webkit-slider-thumb {
  border-color: transparent; box-shadow: none; transform: none; cursor: default;
  background: linear-gradient(var(--ink), var(--ink)) center / 3px 100% no-repeat;
}
.scale.reveal .slider::-moz-range-thumb {
  border-color: transparent; box-shadow: none; cursor: default;
  background: linear-gradient(var(--ink), var(--ink)) center / 3px 100% no-repeat;
}

.ticks { height: 20px; margin-top: 4px; font-family: var(--mono); font-size: 0.6875rem; color: var(--muted); }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

.band { position: absolute; top: 17px; height: 6px; border-radius: 3px; opacity: 0.4; transform-origin: var(--origin, left); }
.pin { position: absolute; top: -26px; width: 0; height: 66px; border-left: 2px solid var(--close); }
.pin-label {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  padding: 1px 8px; border-radius: 4px; background: var(--close); color: var(--on-ink);
  font-size: 0.75rem; font-weight: 500; white-space: nowrap;
}
.pin.edge-left .pin-label { left: -2px; transform: none; }
.pin.edge-right .pin-label { left: auto; right: 0; transform: none; }

/* Reveal: the one orchestrated moment */
.reveal .pin { animation: drop 360ms cubic-bezier(.2,.8,.2,1) both; }
.reveal .band { animation: stretch 420ms 120ms cubic-bezier(.2,.8,.2,1) both; }
.reveal .result { animation: fade 300ms 200ms both; }
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } }
@keyframes stretch { from { transform: scaleX(0); } }
@keyframes fade { from { opacity: 0; } }

/* Result */
.result { margin-top: 24px; }
.result-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px;
  padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.result-label { font-size: 0.8125rem; color: var(--muted); }
.result-value { font-size: 1.75rem; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.result-value.actual { color: var(--close); }
.result-sub { font-size: 0.875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.points { text-align: right; }
.source { margin-top: 12px; font-size: 0.8125rem; color: var(--muted); }
.source a {
  color: var(--ink); text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--line-strong); transition: text-decoration-color var(--dur);
}
.source a:hover { text-decoration-color: currentColor; }

/* Buttons: they step up 1px on hover and press in on click */
.primary, .secondary {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 56px; border-radius: var(--r);
  font-weight: 500; font-size: 1.125rem;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.primary { margin-top: 32px; border: 1px solid transparent; background: var(--action); color: var(--action-ink); }
.primary:hover { background: color-mix(in oklab, var(--action) 88%, var(--ink)); transform: translateY(-1px); }
.primary:active, .secondary:active { transform: translateY(1px) scale(.985); }
.primary:disabled { opacity: 0.5; cursor: default; transform: none; background: var(--action); }
.secondary { border: 1px solid var(--line-strong); background: var(--bg); }
.secondary:hover { border-color: var(--ink); transform: translateY(-1px); }

/* Summary */
.summary-head { display: flex; justify-content: space-between; font-size: 0.875rem; color: var(--muted); }
#summaryNumber { color: var(--ink); font-weight: 500; }
.total {
  margin: 12px 0 20px;
  font-size: clamp(5.5rem, 30vw, 10rem); font-weight: 500;
  letter-spacing: -0.05em; line-height: 0.9; font-variant-numeric: tabular-nums;
}
.total-max { margin-left: 8px; font-size: 1.5rem; letter-spacing: 0; color: var(--muted); }

.rows { border-top: 1px solid var(--line); }
.rows li { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.row-name { font-weight: 500; }
.row-weight { margin-left: 8px; font-size: 0.8125rem; color: var(--muted); font-weight: 400; }
.row-detail { grid-column: 1; font-size: 0.875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-points {
  grid-row: 1 / span 2; grid-column: 2; align-self: center;
  font-size: 1.375rem; font-weight: 500; font-variant-numeric: tabular-nums;
}
.row-bar { grid-column: 1 / -1; height: 4px; margin-top: 8px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.row-bar span { display: block; height: 100%; }
.close-bg { background: var(--close); }
.near-bg { background: var(--near); }
.far-bg { background: var(--far); }

.share { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.share .primary { margin-top: 0; }

.streak { font-weight: 500; }
.next { margin-top: 4px; color: var(--muted); font-family: var(--mono); font-size: 0.875rem; font-variant-numeric: tabular-nums; }

/* Footer: one small link to the about page */
.foot { padding: 0 var(--gut) calc(20px + env(safe-area-inset-bottom)); text-align: center; }
.foot__about {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8125rem; color: var(--muted); text-decoration: none;
  transition: color var(--dur) var(--ease);
}
.foot__about svg { width: 16px; height: 16px; }
.foot__about:hover { color: var(--ink); }

/* Dialogs */
.sheet {
  width: min(34rem, calc(100% - 32px)); max-height: calc(100dvh - 32px);
  padding: 24px 24px 28px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--paper); color: var(--ink);
}
.sheet::backdrop { background: rgb(5 7 10 / 0.5); }
.sheet p + p { margin-top: 12px; }
.sheet strong { font-family: var(--mono); font-weight: 400; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin: -6px -10px 12px 0; }
.sheet-head h2 { font-size: 1.75rem; font-weight: 500; letter-spacing: -0.02em; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; text-align: center; }
.stats dd { font-size: 2rem; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stats dt { font-size: 0.8125rem; color: var(--muted); line-height: 1.3; }
.stats div { display: flex; flex-direction: column-reverse; }

.preview-bar {
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--near); color: #ffffff;
  font-size: 0.875rem; font-weight: 500; text-align: center;
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-weight: 500; font-size: 0.9375rem;
}

@media (min-width: 640px) { :root { --gut: 48px; --bar-h: 72px; } }

/* Desktop: the clue on the left, the guess on the right, on 12 columns of a 1280 column */
@media (min-width: 1024px) {
  :root { --gut: 80px; }
  .wrap { width: min(100% - 2 * var(--gut), 1280px); padding-top: 40px; }
  .round, .summary { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; align-items: start; }
  .round__top { grid-column: 1 / -1; }
  .round .progress { margin-bottom: 64px; }
  .clue { grid-column: 1 / span 5; }
  .play-side { grid-column: 7 / span 6; }
  .play-side .guess { margin-top: 0; }
  .summary__main { grid-column: 1 / span 5; }
  .summary__side { grid-column: 7 / span 6; }
}
@media (max-width: 1023px) { .summary__side { margin-top: 20px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 360px) {
  .result-value { font-size: 1.375rem; }
  .share { grid-template-columns: 1fr; }
}
