/* RANKD: a facts label on a cobalt field. Heavy black rules, one condensed grotesque,
   numbers that line up. The label stays paper-white in both themes, like a real one. */
:root {
  --field: #1f3bff;          /* the cobalt behind everything */
  --field-ink: #ffffff;      /* text on the field */
  --brand: #1f3bff;          /* PEAK, exact hits */
  --paper: #fffef8;
  --paper-2: #f2f0e7;
  --ink: #111111;
  --ink-2: #55534d;
  --cooked: #b83a0e;         /* COOKED, a burnt orange */
  --near: #f2b100;
  --miss: #d8d4c7;
  --shadow: rgba(8, 14, 70, 0.55);
  --font: "Libre Franklin", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --gl: max(16px, env(safe-area-inset-left, 0px));
  --gr: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --field: #0b1446; --field-ink: #e9ecff; --shadow: rgba(0, 0, 0, 0.6); color-scheme: dark; }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--field);
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1.2px);
  background-size: 6px 6px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--near); outline-offset: 3px; }

.app { min-height: 100dvh; padding: max(12px, env(safe-area-inset-top, 0px)) var(--gr) max(28px, env(safe-area-inset-bottom, 0px)) var(--gl); }
.stage { max-width: 460px; margin: 0 auto; }

/* header */
.top { max-width: 460px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--field-ink); }
.logo { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 0; cursor: pointer; color: var(--field-ink); }
.logo-mark { width: 26px; height: 26px; fill: currentColor; }
.logo-word { font-weight: 900; font-size: 26px; letter-spacing: -0.035em; line-height: 1; }
.top-right { display: flex; gap: 8px; }
.chip { background: transparent; border: 2px solid currentColor; color: var(--field-ink); padding: 5px 10px 6px; font-size: 13px; font-weight: 700; cursor: pointer; }
.chip:hover { background: rgba(255, 255, 255, 0.12); }

/* screens */
.screen { display: none; }
.app[data-screen="start"] [data-for="start"],
.app[data-screen="play"] [data-for="play"],
.app[data-screen="reveal"] [data-for="reveal"],
.app[data-screen="summary"] [data-for="summary"],
.app[data-screen="archive"] [data-for="archive"],
.app[data-screen="loading"] [data-for="loading"] { display: block; animation: enter 0.28s ease-out; }

/* the label */
.label { background: var(--paper); border: 2px solid var(--ink); padding: 10px 12px 14px; box-shadow: 8px 8px 0 var(--shadow); }
.label.slim { padding-block: 16px; }
.label-top { padding-bottom: 2px; }
.label-title { margin: 0; font-weight: 900; font-size: clamp(36px, 10vw, 48px); letter-spacing: -0.03em; line-height: 0.95; }
.label-title .of { color: var(--ink-2); font-weight: 800; }
.label-sub { margin-top: 6px; font-size: 15px; font-weight: 500; color: var(--ink-2); }
.rule { background: var(--ink); }
.r8 { height: 10px; margin: 8px 0 6px; }
.r4 { height: 5px; margin: 6px 0; }
.r1 { height: 1px; margin: 8px 0; }
.lede { margin: 6px 0 4px; font-size: 17px; line-height: 1.38; text-wrap: pretty; }
.fine { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.t-peak { color: var(--brand); font-weight: 900; }
.t-cooked { color: var(--cooked); font-weight: 900; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 800; font-size: 14px; padding: 2px 0 4px; border-bottom: 1px solid var(--ink); font-variant-numeric: tabular-nums; }

/* today's list on the start screen */
.today { list-style: none; margin: 0; padding: 0; }
.today li { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--ink); }
.today li:last-child { border-bottom: 0; }
.today .q { font-weight: 700; font-size: 15px; line-height: 1.25; min-width: 0; }
.today .s { font-weight: 900; font-variant-numeric: tabular-nums; }
.kind { display: inline-block; width: max-content; background: var(--ink); color: var(--paper); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; padding: 3px 6px 2px; }
.kind.poll { background: var(--brand); }
.kind.wild { background: var(--cooked); }

/* buttons */
.btn { display: block; width: 100%; margin-top: 12px; background: var(--ink); color: var(--paper); border: 0; padding: 14px 16px 15px; font-size: 19px; font-weight: 900; letter-spacing: 0.02em; text-transform: uppercase; cursor: pointer; }
.btn:hover { background: var(--brand); }
.btn:active { transform: translateY(2px); }
.btn.on-brand { background: var(--paper); color: var(--ink); border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--shadow); margin-top: 18px; }
.btn.on-brand:hover { background: var(--ink); color: var(--paper); }
.under-link { display: block; margin: 20px auto 0; background: none; border: 0; color: var(--field-ink); font-weight: 700; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* play */
.prompt { margin: 8px 0 0; font-weight: 900; font-size: clamp(25px, 6.6vw, 32px); letter-spacing: -0.02em; line-height: 1.05; text-wrap: balance; }
.unit { margin-top: 6px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.current { background: var(--ink); color: var(--paper); padding: 12px 14px 15px; margin: 2px 0 8px; min-height: 86px; }
.current.drop { animation: drop 0.32s cubic-bezier(.2, .9, .3, 1.2); }
.current-count { font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.7; }
.current-name { margin-top: 4px; font-weight: 900; font-size: clamp(26px, 7.6vw, 38px); letter-spacing: -0.02em; line-height: 1.02; overflow-wrap: anywhere; }
.current.done .current-name { font-size: 22px; }

.slots { list-style: none; margin: 0; padding: 0; position: relative; }
.slot { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 54px; border-top: 1px solid var(--ink); position: relative; background: var(--paper); }
.slot:first-child { border-top-width: 2px; }
.slot-btn { all: unset; position: absolute; inset: 0; cursor: pointer; }
.slot-btn:focus-visible { outline: 3px solid var(--brand); outline-offset: -3px; }
.slot.open:hover, .slot.open:focus-within { background: #ebeefe; }
.slot .lbl { font-weight: 900; font-size: 15px; letter-spacing: 0.04em; padding-left: 2px; }
.slot .lbl small { display: block; font-size: 11px; font-weight: 700; color: var(--ink-2); letter-spacing: 0.08em; }
.slot.peak .lbl { color: var(--brand); }
.slot.cooked .lbl { color: var(--cooked); }
.slot .name { font-weight: 800; font-size: 18px; line-height: 1.15; min-width: 0; overflow-wrap: anywhere; }
.slot.open .name { color: #9a978d; font-weight: 600; font-size: 15px; }
.slot .val { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; padding-right: 2px; }
.slot.just { animation: stamp 0.45s ease-out; }
.slot .you { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.reveal .slot { min-height: 60px; padding-block: 6px; }

.mk { display: inline-block; flex: none; width: 13px; height: 13px; border: 2px solid var(--ink); background: transparent; vertical-align: -1px; }
.mk.hit { background: var(--brand); border-color: var(--brand); }
.mk.near { background: var(--near); border-color: var(--near); }
.mk.miss { background: var(--paper); border-color: #9a978d; }

.crowd { font-size: 15px; line-height: 1.4; min-height: 1.4em; }
.crowd b { font-weight: 900; }
.source { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--ink); font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.source b { color: var(--ink); }
.source a { font-weight: 800; color: var(--brand); }

/* summary */
.sum-rows { list-style: none; margin: 0; padding: 0; }
.sum-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--ink); }
.sum-rows li:last-child { border-bottom: 0; }
.sum-rows .q { font-weight: 700; font-size: 15px; line-height: 1.25; min-width: 0; }
.sum-rows .s { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; }
.sum-rows .marks { grid-column: 1 / -1; display: flex; gap: 5px; }
.share-text { margin: 12px 0 0; padding: 10px 12px; background: var(--paper-2); font-family: var(--font); font-size: 15px; line-height: 1.45; white-space: pre-wrap; border: 1px solid var(--ink); }

/* archive */
.archive { list-style: none; margin: 0; padding: 0; }
.archive li { border-bottom: 1px solid var(--ink); }
.archive li:last-child { border-bottom: 0; }
.archive button { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 11px 2px; cursor: pointer; }
.archive button:hover { background: #ebeefe; }
.archive button:focus-visible { outline: 3px solid var(--brand); outline-offset: -3px; }
.archive .n { font-weight: 900; font-variant-numeric: tabular-nums; }
.archive .d { font-weight: 600; }
.archive .s { font-weight: 900; font-variant-numeric: tabular-nums; }

/* help */
.help { border: 0; padding: 0; background: transparent; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
.help::backdrop { background: rgba(5, 8, 40, 0.6); }
.help p { margin: 4px 0; font-size: 16px; }
.key { display: grid; gap: 6px; font-weight: 700; font-size: 15px; }
.key span { display: flex; align-items: center; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 14px; font-weight: 700; font-size: 15px; box-shadow: 4px 4px 0 var(--shadow); z-index: 10; max-width: calc(100vw - 32px); }

/* start: streak and unlockable colors, on the field */
.field-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; color: var(--field-ink); }
.streak { font-weight: 700; font-size: 16px; }
.streak b { font-weight: 900; font-size: 24px; margin-right: 3px; }
.swatches { display: flex; gap: 8px; }
.swatch { position: relative; width: 30px; height: 30px; padding: 0; border: 2px solid var(--field-ink); cursor: pointer; box-shadow: 3px 3px 0 var(--shadow); }
.swatch.on { outline: 3px solid var(--field-ink); outline-offset: 2px; }
.swatch:disabled { cursor: not-allowed; filter: saturate(0.3) brightness(0.8); }
.swatch .lock { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 900; color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.7); }
.unlock-note { margin-top: 8px; color: var(--field-ink); opacity: 0.85; font-size: 14px; font-weight: 600; }

/* play: the shot clock */
.current-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.clock { font-weight: 900; font-size: 15px; font-variant-numeric: tabular-nums; }
.fuse { height: 6px; margin-top: 12px; background: rgba(255, 255, 255, 0.18); overflow: hidden; }
.fuse i { display: block; height: 100%; background: var(--paper); transform-origin: left center; }
.current.last { background: var(--brand); }
.current.hurry .fuse i { background: var(--near); }
.current.hurry .clock { color: var(--near); animation: pulse 0.45s ease-in-out infinite alternate; }
.current.hurry .current-name { animation: jitter 0.14s linear infinite; }
.current.slam { animation: slam 0.34s cubic-bezier(.2, 1.6, .4, 1); }
.slot.auto { background: #fbe3d7; }

/* reveal: the countdown */
.run-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.run-score b { display: inline-block; font-weight: 900; font-size: 20px; color: var(--brand); }
.run-score b.bump { animation: bump 0.35s ease-out; }
.reveal { perspective: 700px; }
.reveal .slot { grid-template-columns: 76px minmax(0, 1fr) auto 46px; cursor: pointer; }
.reveal .slot.waiting .name { color: #a19e94; font-weight: 600; font-size: 16px; }
.reveal .slot.waiting .you { color: #b7b4aa; }
.reveal .slot.waiting .val { color: #c8c5bb; }
.reveal .slot.pending { animation: throb 0.42s ease-in-out infinite alternate; }
.reveal .slot.flipped { animation: flip 0.42s cubic-bezier(.2, .9, .3, 1.15); }
.reveal .slot.flipped.m-hit { background: color-mix(in srgb, var(--brand) 9%, var(--paper)); }
.stamp { justify-self: end; margin-right: 2px; min-width: 38px; padding: 3px 5px 2px; border: 2px solid currentColor; text-align: center; font-weight: 900; font-size: 15px; transform: rotate(-8deg); animation: stampin 0.32s cubic-bezier(.2, 1.8, .4, 1) both; }
.stamp.hit { color: var(--brand); }
.stamp.near { color: #a87700; }
.stamp.miss { color: var(--cooked); }
.verdict { font-weight: 900; font-size: 22px; letter-spacing: -0.01em; line-height: 1.1; margin: 6px 0 8px; }
.verdict:empty { margin: 0; }
.verdict.show { animation: pop 0.42s cubic-bezier(.2, 1.6, .4, 1) both; }
.verdict.perfect { color: var(--brand); font-size: 30px; }
.verdict.cooked { color: var(--cooked); }
.upset { font-weight: 600; margin-bottom: 4px; }
.upset-tag { display: inline-block; margin-right: 6px; padding: 2px 6px 1px; background: var(--near); color: var(--ink); font-weight: 900; font-size: 12px; letter-spacing: 0.12em; transform: rotate(-3deg); }

/* effects layers */
.flash { position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: 0; }
.flash.on { animation: flashk 0.45s ease-out forwards; }
.fx { position: fixed; inset: 0; z-index: 21; pointer-events: none; overflow: hidden; }
.spark { position: fixed; display: block; }
.stage.shake { animation: shake 0.45s ease-out; }
.stage.shake-big { animation: shake-big 0.7s ease-out; }

@keyframes slam { 0% { transform: scale(1.1) rotate(-1.5deg); opacity: 0.5; } 100% { transform: none; opacity: 1; } }
@keyframes jitter { 0%, 100% { transform: translate(0); } 25% { transform: translate(-1px, 1px); } 50% { transform: translate(1px, -1px); } 75% { transform: translate(-1px, -1px); } }
@keyframes pulse { to { opacity: 0.45; } }
@keyframes bump { 40% { transform: scale(1.5); } }
@keyframes throb { from { background: var(--paper); } to { background: color-mix(in srgb, var(--near) 35%, var(--paper)); } }
@keyframes flip { from { transform: rotateX(75deg); } }
@keyframes stampin { from { transform: scale(2.2) rotate(-16deg); opacity: 0; } }
@keyframes pop { from { transform: scale(1.5); opacity: 0; } }
@keyframes flashk { from { opacity: 1; } to { opacity: 0; } }
@keyframes shake { 0%, 100% { transform: translate(0); } 20% { transform: translate(-7px, 3px); } 40% { transform: translate(6px, -4px); } 60% { transform: translate(-4px, 2px); } 80% { transform: translate(3px, -1px); } }
@keyframes shake-big { 0%, 100% { transform: translate(0) rotate(0); } 12% { transform: translate(-12px, 5px) rotate(-0.8deg); } 26% { transform: translate(10px, -6px) rotate(0.6deg); } 42% { transform: translate(-8px, 4px) rotate(-0.4deg); } 58% { transform: translate(6px, -3px); } 76% { transform: translate(-3px, 2px); } }
@keyframes enter { from { transform: translateY(10px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } }
@keyframes stamp { 0% { background: #c9d1ff; } 100% { background: var(--paper); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

[hidden] { display: none !important; }
