/* Timbrel: a concert hall. Oxblood velvet and brass in the dark (the default,
   like every Goldfish Water Cooler game), program paper in the light. The edge
   is a row of tambourine jingles, since a timbrel is a frame drum with jingles.
   Archivo for the wordmark, labels and buttons; Fraunces for the clue text,
   like program notes. */

:root {
  --bg: #f6efe4;
  --panel: #fffaf2;
  --panel-2: #f3e8d8;
  --rule: #d9c7b0;
  --ink: #2a1a20;
  --ink-soft: #6e5a5f;
  --accent: #d9a441;
  --accent-strong: #c08a24;
  --on-accent: #2a1a20;
  --correct: #2f9157;
  --family: #c9a21a;
  --miss: #c2453d;
  --key-white: #fffdf8;
  --key-edge: #b9a68f;
  --key-black: #2a1a20;
  --key-on-black: #8a5f12;
  --shadow: 0 10px 30px rgb(60 30 20 / 0.14);
  --wordmark: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --body: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --notes: 'Fraunces', Georgia, 'Times New Roman', serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1116; --panel: #26181f; --panel-2: #301f28; --rule: #4b3441;
    --ink: #f4e9df; --ink-soft: #c4afb2; --accent: #e3b45c; --accent-strong: #f0c877; --on-accent: #1b1116;
    --correct: #5cbf80; --family: #e8c94f; --miss: #e0675d;
    --key-white: #efe6da; --key-edge: #1b1116; --key-black: #120a0e; --key-on-black: #a87520;
    --shadow: 0 12px 34px rgb(0 0 0 / 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1116; --panel: #26181f; --panel-2: #301f28; --rule: #4b3441;
  --ink: #f4e9df; --ink-soft: #c4afb2; --accent: #e3b45c; --accent-strong: #f0c877; --on-accent: #1b1116;
  --correct: #5cbf80; --family: #e8c94f; --miss: #e0675d;
  --key-white: #efe6da; --key-edge: #1b1116; --key-black: #120a0e; --key-on-black: #a87520;
  --shadow: 0 12px 34px rgb(0 0 0 / 0.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.5 var(--body); }
h1, h2, h3, p, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 0.18em; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

/* The edge: brass jingles on an oxblood frame. */
.edge {
  height: 8px;
  background:
    radial-gradient(circle at 8px 4px, #f6d98d 0 1.4px, #c9923a 1.6px 3px, transparent 3.3px) 0 0 / 16px 8px repeat-x,
    #6d1f30;
}

.wrap { max-width: 40rem; margin-inline: auto; padding: 0 16px; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: 18px 0 16px; }
.title { flex: 1; min-width: 0; }
.wordmark { font: 850 2.125rem/1 var(--wordmark); font-stretch: 125%; letter-spacing: -0.01em; }
.wordmark .dot { color: var(--accent); }
.edition { margin-top: 6px; font-size: 14px; color: var(--ink-soft); }
.icon-button {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--rule); background: var(--panel); color: var(--ink);
}
.icon-button:hover { border-color: var(--accent); }
.icon-button svg { width: 18px; height: 18px; }

.intro { font-family: var(--notes); font-size: 1.0625rem; color: var(--ink-soft); margin-bottom: 14px; }

/* ---------- the clue ladder ---------- */
.clues { display: flex; flex-direction: column; gap: 10px; }
.clue {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 16px; padding: 12px 14px;
}
.clue:not(.open) { background: transparent; border-style: dashed; color: var(--ink-soft); padding-block: 9px; }
.clue.newest { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.clue-head { display: flex; align-items: center; gap: 10px; }
.clue-num {
  width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%;
  font: 750 13px/1 var(--body); background: var(--panel-2); border: 1px solid var(--rule);
}
.clue.open .clue-num { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.clue-icon { font-size: 1.1rem; line-height: 1; filter: saturate(0.9); }
.clue:not(.open) .clue-icon { opacity: 0.45; filter: grayscale(1); }
.clue-title { font: 700 0.9375rem/1.2 var(--body); font-stretch: 112%; }
.clue-body { margin-top: 12px; }
.clue-text { font: 400 1.125rem/1.45 var(--notes); }

/* play buttons: a triangle, a spinner while samples load, dancing bars while playing */
.play {
  display: inline-flex; align-items: center; gap: 10px; min-height: 46px; padding: 10px 18px 10px 14px;
  border-radius: 10px; border: 1.5px solid var(--ink); background: var(--panel-2);
  font: 750 1rem/1 var(--body); font-stretch: 112%;
}
.play:hover { background: var(--bg); }
.play.small { min-height: 40px; padding: 8px 14px 8px 11px; font-size: 0.9375rem; }
.play-icon { width: 18px; height: 18px; position: relative; flex: none; }
.play-icon::before {
  content: ''; position: absolute; inset: 1px 0 1px 3px; background: var(--accent);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.play.loading .play-icon::before {
  inset: 0; clip-path: none; background: none; border-radius: 50%;
  border: 2.5px solid var(--rule); border-top-color: var(--accent); animation: spin 0.8s linear infinite;
}
.play.playing .play-icon::before {
  inset: 2px 1px; clip-path: none;
  background: linear-gradient(var(--accent) 0 0) 0 100% / 4px 60% no-repeat,
              linear-gradient(var(--accent) 0 0) 50% 100% / 4px 100% no-repeat,
              linear-gradient(var(--accent) 0 0) 100% 100% / 4px 40% no-repeat;
  animation: bars 0.9s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
@keyframes bars {
  0%, 100% { background-size: 4px 60%, 4px 100%, 4px 40%; }
  33% { background-size: 4px 100%, 4px 45%, 4px 80%; }
  66% { background-size: 4px 35%, 4px 75%, 4px 100%; }
}

/* the range keyboard */
.range svg { display: block; width: 100%; height: auto; }
.kb-white { fill: var(--key-white); stroke: var(--key-edge); stroke-width: 0.8; }
.kb-white.on { fill: var(--accent); }
.kb-black { fill: var(--key-black); }
.kb-black.on { fill: var(--key-on-black); }
.kb-c { fill: #6d1f30; } /* oxblood shows on both an ivory key and a lit brass one */
.range figcaption { margin-top: 8px; font-size: 0.9375rem; color: var(--ink-soft); }
.range figcaption b { color: var(--ink); font-weight: 750; }

/* the reveal's photo, from Wikipedia */
.photo { border-radius: 12px; overflow: hidden; background: #fff; border: 1px solid var(--rule); }
.photo img { display: block; width: 100%; max-height: 240px; object-fit: contain; }

/* ---------- guessing ---------- */
.guess-form { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.combo { position: relative; }
.guess-input {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 10px;
  border: 1.5px solid var(--ink); background: var(--panel); font-size: 1.0625rem;
}
.guess-input::placeholder { color: var(--ink-soft); }
.suggestions {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 6px); padding: 6px;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow);
}
.suggestions li { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.suggestions li:hover, .suggestions li.active { background: var(--panel-2); }
.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.primary, .secondary {
  min-height: 46px; padding: 0 20px; border-radius: 10px;
  font: 750 1rem/1 var(--body); font-stretch: 112%;
}
.primary { background: var(--accent); color: var(--on-accent); border: 1.5px solid var(--accent); }
.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.secondary { background: transparent; border: 1.5px solid var(--ink); }
.secondary:hover { background: var(--panel-2); }
.guesses-left { margin-left: auto; font-size: 14px; color: var(--ink-soft); }
.status { min-height: 1.5em; margin-top: 10px; font-size: 0.9375rem; color: var(--ink-soft); }

.guesses { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.guess {
  display: flex; align-items: baseline; gap: 10px; padding: 8px 12px;
  border-radius: 10px; background: var(--panel); border: 1px solid var(--rule);
}
.guess-name { font-weight: 750; }
.guess-note { margin-left: auto; font-size: 0.875rem; color: var(--ink-soft); text-align: right; }
.guess.correct .guess-note { color: var(--correct); font-weight: 700; }
.guess.family .guess-note { color: var(--family); font-weight: 700; }
.guess.miss .guess-note { color: var(--miss); }

/* ---------- the reveal ---------- */
.result {
  margin-bottom: 16px; padding: 18px 16px; background: var(--panel);
  border: 1px solid var(--rule); border-top: 4px solid var(--accent); border-radius: 16px;
  scroll-margin-top: 12px;
}
.result-kicker { font: 750 0.8125rem/1.2 var(--body); font-stretch: 112%; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.result-name { margin-top: 6px; font: 850 2.25rem/1 var(--wordmark); font-stretch: 125%; }
.result-family { margin-top: 4px; color: var(--ink-soft); }
.result-body { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.extract { font: 400 1.0625rem/1.5 var(--notes); }
.result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.wiki-link { font-size: 0.9375rem; font-weight: 700; }
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
.next { font-size: 0.9375rem; color: var(--ink-soft); }

/* ---------- dialogs ---------- */
dialog {
  width: min(26rem, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--rule); border-radius: 16px;
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(10 5 8 / 0.6); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog-head h2 { font: 750 1.25rem/1.2 var(--body); font-stretch: 112%; }
.help-list { display: flex; flex-direction: column; gap: 10px; }
.help-list li { display: grid; grid-template-columns: 1.6rem 1fr; gap: 8px; }
.help-list p, .help-note { font-size: 0.9375rem; }
.help-note { margin-top: 14px; color: var(--ink-soft); }
.numbers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; font-size: 0.8125rem; color: var(--ink-soft); }
.numbers b { display: block; font: 850 1.75rem/1.1 var(--body); color: var(--ink); }
#stats h3 { margin: 18px 0 8px; font: 750 0.9375rem/1.2 var(--body); font-stretch: 112%; }
.spread { display: flex; flex-direction: column; gap: 5px; }
.spread li { display: flex; align-items: center; gap: 8px; }
.spread-n { width: 1rem; font-weight: 700; text-align: center; }
.bar {
  width: var(--w); min-width: 1.8rem; padding: 2px 8px; border-radius: 6px; text-align: right;
  background: var(--panel-2); border: 1px solid var(--rule); font-weight: 750; font-size: 0.875rem;
}
.bar.today { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 10px; white-space: pre-line;
  background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: var(--shadow); z-index: 30;
}

/* ---------- footer ---------- */
.foot { margin: 36px 0 28px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 0.875rem; color: var(--ink-soft); }
.foot p + p { margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  .play.loading .play-icon::before, .play.playing .play-icon::before { animation: none; }
}
