/* Maneledle — a cassette J-card on warm paper. */

:root {
  --paper: #f2ebdf;
  --paper-2: #e9e0d0;
  --card: #fbf7f0;
  --ink: #1f1a15;
  --ink-2: #5d5348;
  --ink-3: #93877a;
  --rule: #d6cbb9;
  --accent: #a3271d;        /* vișiniu */
  --accent-ink: #fff6ee;
  --gold: #b9862a;          /* artist match */
  --gold-soft: #f3e3bf;
  --win: #2f6b45;
  --win-soft: #d9e8d6;
  --miss-soft: #f1d7d1;
  --tape: #2a231d;
  --tape-off: #d9cfbf;
  --shadow: 0 1px 0 rgba(31, 26, 21, .06), 0 10px 30px -18px rgba(31, 26, 21, .35);

  --display: "Fraunces", Georgia, serif;
  --sans: "Inter Tight", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17130f;
    --paper-2: #201b16;
    --card: #1f1a15;
    --ink: #f0e7d8;
    --ink-2: #b9ad9c;
    --ink-3: #807466;
    --rule: #3a3129;
    --accent: #d2463a;
    --accent-ink: #1a0c09;
    --gold: #d9a649;
    --gold-soft: #3d2f15;
    --win: #6cbf86;
    --win-soft: #1d3324;
    --miss-soft: #3a1e1a;
    --tape: #f0e7d8;
    --tape-off: #3a3129;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
.mono { font-family: var(--mono); font-feature-settings: "zero" 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.page {
  max-width: 500px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Masthead ------------------------------------------------------------ */
.masthead {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1.5px solid var(--ink);
  position: relative;
}
.masthead::after {           /* the double rule of a printed label */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -5px;
  border-bottom: 1px solid var(--ink);
}
.brand { text-align: center; }
.wordmark {
  margin: 0;
  font: italic 700 40px/1 var(--display);
  font-variation-settings: "opsz" 144;
  letter-spacing: -.02em;
}
.wordmark span {
  font-style: normal;
  font-weight: 400;
  color: var(--accent);
}
.edition {
  margin: 6px 0 0;
  font: 500 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: transparent;
  display: grid; place-items: center;
  font: 600 18px/1 var(--display);
}
.icon-btn:hover { background: var(--ink); color: var(--paper); }

.notice {
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--ink-3);
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-2);
}
.notice b { color: var(--ink); }

/* Deck: tape strip + transport ---------------------------------------- */
.deck {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
}
.tape { position: relative; }
.tape-cells {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 3px;
  height: 34px;
}
.cell {
  border-radius: 2px;
  background: var(--tape-off);
  position: relative;
  overflow: hidden;
}
.cell.open { background: var(--tape); }
.cell .fill {
  position: absolute; inset: 0;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
}
.cell.open.played .fill { transform: scaleX(1); }
.tape-ticks {
  position: relative;
  height: 18px;
  margin-top: 6px;
  font: 500 10.5px/1 var(--mono);
  color: var(--ink-3);
}
.tick {
  position: absolute;
  top: 4px;
  transform: translateX(-100%);
  padding-right: 1px;
}
.tick.reached { color: var(--ink); }
.tick::before {
  content: "";
  position: absolute;
  right: 0; top: -8px;
  height: 5px;
  border-right: 1px solid currentColor;
}

.transport {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-top: 8px;
}
.time { font-size: 13px; color: var(--ink-2); }
.time:last-child { text-align: right; }
.play {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: var(--paper);
  display: grid; place-items: center;
  transition: transform .12s ease;
}
.play:hover { transform: scale(1.04); }
.play:active { transform: scale(.97); }
.play svg { width: 28px; height: 28px; }
.play .i-stop, .play.playing .i-play { display: none; }
.play.playing .i-stop { display: block; }
.play.loading { opacity: .5; }

/* Guesses ------------------------------------------------------------- */
.guesses {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 6px;
}
.guess {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--rule);
  font-size: 15px;
}
.guess .n { font: 500 12px/1 var(--mono); color: var(--ink-3); }
.guess .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guess .label small { color: var(--ink-2); font-size: 13px; }
.guess.current { border-bottom: 1.5px solid var(--ink); }
.guess.current .n { color: var(--ink); }
.guess.skip .label { color: var(--ink-3); font-style: italic; }
.guess.wrong { background: var(--miss-soft); border-radius: 6px; border-color: transparent; }
.guess.artist { background: var(--gold-soft); border-radius: 6px; border-color: transparent; }
.guess.correct { background: var(--win-soft); border-radius: 6px; border-color: transparent; }

.chip {
  font: 500 10.5px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 6px;
  border-radius: 3px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.chip.wrong { color: var(--accent); }
.chip.artist { color: var(--gold); }
.chip.correct { color: var(--win); }
.chip.skip { color: var(--ink-3); }

/* Controls ------------------------------------------------------------ */
.controls { display: grid; gap: 10px; }
.search { position: relative; }
#guess-input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: 16px var(--sans);
}
#guess-input::placeholder { color: var(--ink-3); }
#guess-input:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.suggestions {
  position: absolute;
  left: 0; right: 0; bottom: calc(100% + 6px);
  margin: 0; padding: 4px;
  list-style: none;
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
  z-index: 10;
}
.suggestions li {
  padding: 9px 10px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.suggestions li .t { font-weight: 500; }
.suggestions li .a { font-size: 13px; color: var(--ink-2); }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--paper-2); }
.suggestions mark { background: none; color: var(--accent); font-weight: 600; }
.suggestions .empty { color: var(--ink-3); cursor: default; }

.actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.btn {
  height: 48px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  border: 1.5px solid var(--ink);
  padding: 0 16px;
}
.btn.solid { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.solid:hover:not(:disabled) { filter: brightness(1.07); }
.btn.solid:disabled { background: var(--tape-off); border-color: var(--tape-off); color: var(--ink-3); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--paper-2); }
.btn .mono { font-weight: 500; font-size: 13px; color: var(--ink-2); margin-left: 4px; }
.btn.wide { width: 100%; }

/* Result -------------------------------------------------------------- */
.result {
  text-align: center;
  padding: 22px 16px;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
}
.result-kicker {
  margin: 0;
  font: 500 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}
.result.won .result-kicker { color: var(--win); }
.result-title {
  margin: 10px 0 4px;
  font: italic 600 30px/1.1 var(--display);
  font-variation-settings: "opsz" 100;
}
.result-artist { margin: 0; color: var(--ink-2); }
.result-actions { display: grid; gap: 8px; margin-top: 18px; }
.next { margin: 14px 0 0; font-size: 12px; color: var(--ink-3); }

.colophon {
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
}

/* Dialogs ------------------------------------------------------------- */
.sheet {
  width: min(440px, calc(100vw - 32px));
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  padding: 22px 20px 18px;
}
.sheet::backdrop { background: rgba(23, 19, 15, .45); }
.sheet h2 { margin: 0 0 14px; font: italic 600 26px/1.1 var(--display); }
.sheet h3 {
  margin: 20px 0 10px;
  font: 500 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.rules { padding-left: 20px; margin: 0; display: grid; gap: 8px; }
.rules li::marker { font-family: var(--mono); color: var(--accent); }
.fine { font-size: 13px; color: var(--ink-2); margin: 16px 0; }
.sheet form { margin-top: 18px; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; text-align: center; }
.stat-row div { display: flex; flex-direction: column-reverse; gap: 4px; }
.stat-row dd { margin: 0; font: 600 28px/1 var(--display); }
.stat-row dt { font-size: 11px; color: var(--ink-2); line-height: 1.2; }
.dist { display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: center; font: 500 12px/1 var(--mono); }
.bar span:first-child { color: var(--ink-2); }
.bar i {
  display: block;
  min-width: 26px;
  padding: 5px 6px;
  background: var(--tape-off);
  font-style: normal;
  text-align: right;
  border-radius: 2px;
}
.bar.hit i { background: var(--accent); color: var(--accent-ink); }

.toast {
  position: fixed;
  left: 50%; top: 18px;
  transform: translate(-50%, -20px);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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