/* Inter (variable, weights 100-900), served from this site so visitors'
   browsers don't contact Google. Inter is (c) The Inter Project Authors,
   SIL Open Font License 1.1: https://openfontlicense.org */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(assets/fonts/inter-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: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(assets/fonts/inter-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --page: #f4f2ee;
  --card: #fbfaf8;
  --ink: #29261f;
  --ink-2: #5e5c55;
  --ink-3: #9b988f;
  --line: #e2dfd7;
  --chip: #f1efe9;
  --chip-hover: #e8e5dd;
  --danger: #b23a2a;
  --danger-bg: #fbe9e5;
  --good: #2f7a3d;
  --field: #fff;            /* inputs, buttons, dropdown */
  --on-ink: #fff;           /* text on --ink backgrounds */
  --chip-border: #c9c5bb;
  --chip-border-hover: #aaa69b;
  --backdrop: #29261f66;
  --pattern: url(assets/pattern-light.png);
  --radius-card: 40px;
  --font: "Inter", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
/* Dark mode: warm off-black, never pure black. */
:root[data-theme="dark"] {
  --page: #1a1815;
  --card: #24211d;
  --ink: #ece7de;
  --ink-2: #a9a397;
  --ink-3: #736d63;
  --line: #38342e;
  --chip: #2e2b26;
  --chip-hover: #39352f;
  --danger: #e2735f;
  --danger-bg: #3d241e;
  --good: #72c07e;
  --field: #2b2823;
  --on-ink: #1a1815;
  --chip-border: #4d4840;
  --chip-border-hover: #6b655b;
  --backdrop: #0d0c0a99;
  --pattern: url(assets/pattern-dark.png);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* Pattern tile is 1024px; shown at 0.35 scale. */
html { background: var(--page) var(--pattern) 0 0 / 358.4px 358.4px repeat; }
body {
  margin: 0; min-height: 100vh; padding: 40px 24px;
  font: 14px/1.45 var(--font); color: var(--ink);
  display: flex; flex-direction: column; align-items: center;
}
button { font: inherit; color: inherit; }

/* ---------- card ---------- */
/* Auto margins center the card (and footer) vertically, but never push it
   off the top when the screen is shorter than the card. */
.card {
  margin-top: auto;
  width: min(1120px, 100%);
  background: var(--card);
  border-radius: var(--radius-card);
  /* --glow is set by app.js and cycles through the barcode's colors. */
  box-shadow:
    0 1px 2px #0000000d,
    0 26px 70px -14px color-mix(in srgb, var(--glow, #000) 70%, transparent),
    0 0 140px -10px color-mix(in srgb, var(--glow, #000) 40%, transparent);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-rows: 1fr auto auto;
}
.info { padding: 52px 40px 28px 52px; min-height: 380px; }
.game {
  padding: 20px 48px 28px 40px; margin: 36px 0 12px; /* top lines up the header with the title */
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
}

/* ---------- title + artist ---------- */
/* The title uses Helvetica Neue Bold where it's installed (Mac, iOS, many
   design setups); everyone else gets Inter like the rest of the page. The
   face is picked by its exact name: asking for the "Helvetica Neue" family
   can return a condensed cut on Windows when one is installed alongside. */
@font-face {
  font-family: "Title Helvetica";
  src: local("Helvetica Neue Bold"), local("HelveticaNeue-Bold");
  font-weight: 700;
}
.title {
  font-family: "Title Helvetica", "Inter", Arial, sans-serif;
  font-size: 60px; line-height: 1; font-weight: 700; letter-spacing: -0.02em; margin: 0; overflow-wrap: anywhere;
  text-wrap: balance; /* "It Was a / Good Day", not "It Was a Good / Day" */
}
/* A light title color (yellow) on the light card gets a faint outline. */
.title.pale { text-shadow: 0 0 1px #3a2a1066, 0 1px 1px #3a2a1040; }
.title.long { font-size: 50px; }
.title.xlong { font-size: 40px; line-height: 1.05; }
.hidden-title { letter-spacing: 0.06em; color: var(--ink); }
.artist-slot { margin: 8px 0 22px; min-height: 30px; }
.artist-name { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.hint { margin: 0 0 12px; color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.hint::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- reveal chips ---------- */
/* app.js splits the chips into rows (see layoutChips) so a chip never jumps
   to the next line when it's clicked and shows "Reveal for". */
.chips { display: flex; flex-direction: column; gap: 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.chip-measure { position: absolute; visibility: hidden; pointer-events: none; display: flex; width: max-content; left: 0; top: 0; }
.chip {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 9px 13px 10px; border-radius: 12px; cursor: pointer; text-align: left;
  background: var(--chip); border: 1.5px dashed var(--chip-border);
  transition: background .15s, border-color .15s, transform .1s;
}
.chip:hover { background: var(--chip-hover); border-color: var(--chip-border-hover); }
.chip:active { transform: scale(.97); }
.chip:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.chip .k { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.chip .c { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chip .c::before { content: "−"; }
.chip.armed { background: var(--danger-bg); border: 1.5px solid var(--danger); }
.chip.armed .c { color: var(--danger); font-weight: 700; }
.chip.armed .c::before { content: "Reveal for −"; font-weight: 400; }
.chip.artist-chip { flex-direction: row; align-items: baseline; gap: 10px; padding: 7px 14px; }
.chip.artist-chip .k { font-size: 13px; }
.chip.about-chip { flex-basis: 100%; }

.item { display: flex; flex-direction: column; gap: 1px; padding: 9px 4px 10px; }
.item.new, .artist-name.new { animation: pop .45s ease-out; }
.item .k { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.item .v { font-size: 13px; }
.item.about { flex-basis: 100%; max-width: 60ch; }
/* Redacted parts of the About text, uncovered once the game is over. */
.redact {
  display: inline-block; vertical-align: -2px; min-height: 1.1em; padding: 0 6px; border-radius: 4px;
  background: var(--ink); color: var(--card); font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; line-height: 1.5;
}
.redact.blank { width: 5.5em; }
.unredacted { background: var(--chip); border-radius: 3px; padding: 0 1px; margin: 0 -1px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.item.free .k::after { content: " · free"; color: var(--good); font-weight: 400; letter-spacing: 0; text-transform: none; }
@keyframes pop { from { opacity: 0; transform: translateY(3px); } }

/* Solved: everything shown, evenly spaced. */
.chips.solved { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 24px; align-items: start; }
.chips.solved .item.about { grid-column: 1 / -1; }

/* ---------- game panel ---------- */
.g-head { display: flex; align-items: center; justify-content: space-between; color: var(--ink-2); font-size: 12px; }
.day-nav { display: flex; justify-content: space-between; margin: -4px 0 -6px; }
.day-nav button {
  border: 0; background: none; padding: 2px 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; color: var(--ink-2);
}
.day-nav button:hover, .day-nav button:focus-visible { color: var(--ink); }
.g-head .icons { display: flex; gap: 2px; align-items: center; }
.icon-btn {
  border: 0; background: none; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px;
}
.icon-btn:hover { background: var(--chip); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.streak { display: inline-flex; align-items: center; gap: 3px; margin-right: 6px; font-weight: 700; color: var(--ink); }
.streak svg { width: 16px; height: 16px; }
.tag { font-size: 11px; background: var(--chip); padding: 2px 7px; border-radius: 6px; margin-left: 6px; }

.score-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.score-label { font-size: 12px; color: var(--ink-2); }
.score { font-size: 54px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.score.bump { animation: bump .4s ease-out; }
@keyframes bump { 30% { color: var(--danger); transform: translateY(2px); } }
.log { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--ink-2); text-align: right; max-height: 76px; overflow: hidden; }
.log li:first-child { color: var(--ink); }

/* search */
.search { position: relative; }
.search-row { display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--field); font: inherit; font-size: 15px; color: var(--ink);
}
.search input:focus { outline: none; border-color: var(--ink); }
.search input.chosen { border-color: var(--ink); font-weight: 700; }
.btn {
  height: 44px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--field); cursor: pointer; font-weight: 700; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover { background: #3d392f; }
.btn.small { height: 34px; padding: 0 12px; font-size: 12px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: default; border-color: var(--line); }
.btn.armed { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
.results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none; background: var(--field); border-radius: 14px;
  box-shadow: 0 10px 30px -8px #00000040, 0 0 0 1px #0000000f; display: none;
}
.results.open { display: block; }
.results li { padding: 8px 10px; border-radius: 9px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.results li .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results li .a { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 1; text-align: right; }
.results li mark { background: none; color: inherit; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
.results li.sel { background: var(--chip); }
.results li.used { opacity: .4; cursor: default; }
.results .empty { color: var(--ink-2); cursor: default; justify-content: flex-start; }
.search-error { color: var(--danger); font-size: 12px; min-height: 0; margin: 4px 2px 0; }

.dots { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.dot.used { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
/* A guess spent on a frame joker. */
.dot.spent { background: transparent; border-radius: 3px; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.dot.hit { background: var(--good); }
.dots span:last-child { margin-left: 4px; }

.guesses { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.guesses li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.guesses li .g { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guesses li .g s { color: var(--ink-2); }
.guesses li .note { color: var(--good); white-space: nowrap; }
.guesses li .cost { color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

.jokers { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }

/* result */
.result h2 { font-size: 34px; line-height: 1.05; margin: 4px 0 2px; font-weight: 800; letter-spacing: -0.02em; }
.result h2 .pts { color: var(--ink-3); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 300px; margin: 10px 0 0; }
.stats div { display: flex; flex-direction: column; gap: 1px; }
.stats dt { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.stats dd { margin: 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn.watch { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.btn.watch .yt { width: 22px; height: auto; flex: none; }
.result .sub { color: var(--ink-2); margin: 0; }
.result .big { display: flex; gap: 28px; margin: 6px 0 2px; }
.result .big div { display: flex; flex-direction: column; }
.result .big b { font-size: 40px; line-height: 1; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.result .big span { font-size: 12px; color: var(--ink-2); }
.result .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.countdown { font-size: 12px; color: var(--ink-2); }
.reset-link {
  align-self: flex-start; border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--ink-3); text-decoration: underline; text-underline-offset: 2px;
}
.reset-link:hover { color: var(--ink-2); }
.reset-link.armed { color: var(--danger); font-weight: 700; }
.countdown b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- barcode ---------- */
.bar-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 52px 10px; }
.mode { display: inline-flex; gap: 2px; }
.mode button {
  border: 0; background: none; cursor: pointer; padding: 3px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}
.mode button.on { background: var(--chip); color: var(--ink); }
.bar-note { font-size: 12px; color: var(--ink-3); margin-left: auto; }
.barcode { --bar-h: 170px; grid-column: 1 / -1; display: flex; height: var(--bar-h); position: relative;
  /* Round the barcode to the card's corners itself, rather than clipping the
     whole card, so the search dropdown can hang past the card's edge. The
     negative top inset leaves room for the hover tooltip above the bars. */
  clip-path: inset(-60px 0 0 0 round 0 0 var(--radius-card) var(--radius-card));
}
.barcode i { flex: 1 1 0; min-width: 0; transition: transform .08s; }
.barcode i:hover { transform: scaleX(4) scaleY(1.04); z-index: 2; box-shadow: 0 0 0 .5px #fff, 0 2px 8px #0008; }
.barcode.solved i { cursor: pointer; }
.frame {
  flex: 0 0 0; overflow: hidden; position: relative; z-index: 3; transition: flex-basis .7s cubic-bezier(.2, .8, .2, 1);
}
.frame img { height: 100%; width: 100%; object-fit: cover; display: block; }
/* Each frame takes its natural width, but all frames together never take
   more than about half the barcode (wider ones are cropped to fit). */
.frame.in { flex-basis: min(calc(var(--bar-h) * var(--ratio, 1.7778)), calc(48% / var(--nframes, 1))); margin: 0 3px; }
/* A thin gap of card color on both sides sets the frames apart from the bars. */
.frame { transition: flex-basis .7s cubic-bezier(.2, .8, .2, 1), margin .7s; }
/* After solving all frames show, so they start narrower to leave the stripes
   visible, and open to full width on hover. */
.barcode.solved .frame.in { flex-basis: min(calc(var(--bar-h) * var(--ratio, 1.7778) * .55), calc(30% / var(--nframes, 1))); transition-duration: .35s; }
.barcode.solved .frame.in:hover { flex-basis: min(calc(var(--bar-h) * var(--ratio, 1.7778)), 40%); }
.tip {
  position: absolute; bottom: calc(100% + 10px); transform: translateX(-50%); z-index: 5; display: none;
  background: var(--ink); color: var(--on-ink); font-size: 12px; font-weight: 700; padding: 6px 9px; border-radius: 7px;
  white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums;
}
.tip::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--ink); }
.tip .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; box-shadow: 0 0 0 1px #fff7; }

.footer { color: var(--ink-2); font-size: 12px; margin: 18px 0 auto; transition: color .8s; }
.footer.on-dark { color: #fbfaf8e6; }
.footer.on-light { color: #5e5c55; }

/* ---------- theme + motion toggles, beside the card ---------- */
.card { position: relative; }
.side {
  position: absolute; left: calc(100% + 16px); top: 26px;
  display: flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: 999px;
  background: var(--card); box-shadow: 0 1px 2px #0000001a, 0 6px 18px -8px #00000050;
}
.side button {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--ink-2); background: none;
  transition: color .15s, background .15s;
}
.side button:hover { color: var(--ink); background: var(--chip); }
.side button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.side svg { width: 20px; height: 20px; }
#motion-btn .slash { display: none; }
.reduce-motion #motion-btn .slash { display: inline; }
#sound-btn .cross, #sound-btn[aria-pressed="true"] .waves { display: none; }
#sound-btn[aria-pressed="true"] .cross { display: inline; }
.side button[aria-pressed="true"] { color: var(--ink); }
/* No room beside the card: sit above its top-right corner instead. */
@media (max-width: 1240px) {
  body { padding-top: 72px; }
  .side { left: auto; right: 6px; top: auto; bottom: calc(100% + 12px); flex-direction: row; }
}

/* Reduce motion (the toggle, or the system setting): no animations. The
   glow is handled in app.js. */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation: none !important; transition: none !important;
}

/* ---------- dialogs + toast ---------- */
.dialog {
  border: 0; border-radius: 24px; padding: 28px 30px; width: min(440px, calc(100% - 32px));
  background: var(--card); color: var(--ink); box-shadow: 0 30px 80px -20px #00000066;
  max-height: calc(100vh - 32px); overflow: hidden auto;
}
.dialog::backdrop { background: var(--backdrop); }
.dialog h2 { margin: 0 0 10px; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.dialog ul { padding-left: 18px; }
.dialog li { margin: 6px 0; }
.dialog form { margin-top: 18px; display: flex; justify-content: flex-end; }
.danger-zone { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 12px; }
.muted { color: var(--ink-2); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 18px; }
.stat-grid div { display: flex; flex-direction: column; align-items: center; background: var(--chip); border-radius: 12px; padding: 10px 4px; }
.stat-grid b { font-size: 24px; font-weight: 800; }
.stat-grid span { font-size: 11px; color: var(--ink-2); text-align: center; }
.dist { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.dist div { display: flex; align-items: center; gap: 8px; }
/* Fixed-width label, then a track the bar fills a share of, so every bar
   starts at the same place however long it is. */
.dist .lbl { flex: none; width: 72px; color: var(--ink-2); }
.dist .track { flex: 1; min-width: 0; display: flex; }
.dist .bar { height: 16px; background: var(--ink); border-radius: 4px; min-width: 2px; color: var(--on-ink); font-size: 11px; padding: 0 5px; display: flex; align-items: center; }
.archive-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 50vh; overflow: auto; }
.archive-list li { display: flex; }
.archive-list button {
  flex: 1; display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 0; border-radius: 10px;
  background: none; cursor: pointer; text-align: left;
}
.archive-list button:hover { background: var(--chip); }
.archive-list .st { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.archive-list .won { color: var(--good); }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 12px; font-weight: 700; transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  body { padding: 64px 10px 16px; }
  .card { grid-template-columns: 1fr; --radius-card: 26px; }
  .info { padding: 30px 24px 10px; min-height: 0; }
  .game { border-left: 0; border-top: 1px solid var(--line); margin: 8px 24px 12px; padding: 20px 0 8px; }
  .title { font-size: 44px; }
  .title.long { font-size: 36px; }
  .title.xlong { font-size: 30px; }
  /* The barcode is the main clue: put it first on small screens. */
  .barcode { --bar-h: 120px; order: -2; clip-path: inset(0 round var(--radius-card) var(--radius-card) 0 0); }
  .bar-head { order: -1; padding: 10px 24px 0; }
  .bar-note { display: none; }
  .chips.solved { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
