:root {
  --bg: #111216;
  --bar: #191a1f;
  --surface: #1e1f24;
  --surface-2: #27282e;
  --thumb: #2b2d33;
  --line: #34363d;
  --ink: #f7f7f8;
  --muted: #a3a5ad;
  --blue: #335fff;
  --blue-hi: #4a72ff;
  --good: #3fc679;
  --ok: #f5c242;
  --meh: #f28c38;
  --bad: #ef4d4d;
  --r: 12px;
  color-scheme: dark;
  font-family: "Builder Sans", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100dvh; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; color: inherit; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bar); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 980px; margin: 0 auto; height: 56px; padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand {
  display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink);
  font-weight: 800; font-size: 20px; letter-spacing: -0.3px; margin-right: auto;
}
.brand svg { width: 26px; height: 26px; }
.brand svg path { fill: var(--blue); }
.brand svg circle { fill: var(--bar); }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button {
  border: 0; background: none; padding: 6px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.seg button.active { background: var(--ink); color: var(--bg); }
.round {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface-2);
  font-weight: 700;
}
.round:hover, .seg button:not(.active):hover { color: var(--ink); }

main { max-width: 980px; margin: 0 auto; padding: 16px 16px 32px; }

/* ---------- progress ---------- */
#progress { display: flex; gap: 6px; margin: 2px 0 16px; align-items: center; min-height: 8px; }
.pip { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); transition: background .3s; }
.pip.current { background: var(--muted); }
.pip.g { background: var(--good); } .pip.y { background: var(--ok); }
.pip.o { background: var(--meh); }  .pip.r { background: var(--bad); }
.endless-bar { display: flex; justify-content: space-between; width: 100%; font-size: 14px; color: var(--muted); font-weight: 600; }
.endless-bar b { color: var(--ink); }
.hearts { letter-spacing: 2px; }

/* ---------- item page ---------- */
.item { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 760px) { .item { grid-template-columns: minmax(0, 1fr); gap: 16px; } }

.thumb {
  position: relative; aspect-ratio: 1; border-radius: var(--r); overflow: hidden;
  background: radial-gradient(120% 90% at 50% 30%, #3a3c44 0%, var(--thumb) 55%, #23242a 100%);
}
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .4s cubic-bezier(.2,.8,.2,1); }
.thumb:hover img { transform: scale(1.04); }
.type-chip {
  position: absolute; left: 12px; top: 12px; padding: 5px 10px; border-radius: 8px;
  background: rgb(17 18 22 / .75); backdrop-filter: blur(6px); font-size: 13px; font-weight: 600;
}

.details h2 { margin: 4px 0 6px; font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -0.4px; }
@media (max-width: 760px) { .details h2 { font-size: 24px; } }
.by { margin: 0 0 18px; color: var(--muted); display: flex; align-items: center; gap: 5px; font-size: 15px; }
.by b { color: var(--ink); font-weight: 600; }
.verified { width: 15px; height: 15px; fill: var(--blue); }
.year { margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--line); }

.price-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; display: block; margin-bottom: 8px; }

.price-input {
  display: flex; align-items: center; gap: 8px; background: var(--bg);
  border: 2px solid var(--line); border-radius: 10px; padding: 8px 14px; transition: border-color .15s;
}
.price-input:focus-within { border-color: var(--blue); }
.rs { font-weight: 800; color: var(--muted); font-size: 22px; }
#guess {
  flex: 1; min-width: 0; width: 100%; border: 0; outline: none; background: none; color: var(--ink);
  font: inherit; font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums;
}
#guess::placeholder { color: #50535b; }

#slider { width: 100%; margin: 16px 0 2px; appearance: none; background: none; height: 22px; }
#slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--blue) var(--fill, 40%), var(--surface-2) var(--fill, 40%)); }
#slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--surface-2); }
#slider::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--blue); }
#slider::-webkit-slider-thumb { appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .5); }
#slider::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; }
.slider-ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-weight: 600; padding: 0 2px; }

.btn-primary, .btn-secondary {
  display: block; width: 100%; margin-top: 16px; border: 0; border-radius: 10px; padding: 13px 20px;
  font-size: 17px; font-weight: 700; transition: background .15s, transform .08s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-hi); }
.btn-primary:active:not(:disabled), .btn-secondary:active { transform: scale(.98); }
.btn-primary:disabled { background: var(--surface-2); color: #6b6e76; cursor: default; }
.btn-secondary { background: var(--surface-2); }
.btn-secondary:hover { background: var(--line); }

/* ---------- reveal ---------- */
.actual { display: flex; align-items: baseline; gap: 8px; font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.actual .rs { font-size: 26px; color: var(--good); }
.scale { position: relative; height: 54px; margin: 18px 6px 6px; }
.scale-track { position: absolute; left: 0; right: 0; top: 26px; height: 6px; border-radius: 3px; background: var(--surface-2); }
.marker { position: absolute; top: 20px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; border: 3px solid var(--surface); transition: left .7s cubic-bezier(.2,.8,.2,1); }
.marker span { position: absolute; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; white-space: nowrap; }
.actual-m { background: var(--good); z-index: 1; }
.actual-m span { top: -20px; color: var(--good); }
.guess-m { background: var(--ink); }
.guess-m span { top: 20px; color: var(--muted); }
.reveal-foot { display: flex; align-items: end; justify-content: space-between; margin-top: 6px; }
.your { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.points { font-size: 30px; font-weight: 800; padding: 6px 14px; border-radius: 10px; font-variant-numeric: tabular-nums; }
.points.g { color: var(--good); background: rgb(63 198 121 / .14); }
.points.y { color: var(--ok); background: rgb(245 194 66 / .14); }
.points.o { color: var(--meh); background: rgb(242 140 56 / .14); }
.points.r { color: var(--bad); background: rgb(239 77 77 / .14); }
#r-note { margin: 12px 0 0; color: var(--muted); font-weight: 600; }

/* ---------- done ---------- */
#done { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.done-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.done-head h2 { margin: 0; font-size: 26px; font-weight: 800; }
#done-extra { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
#done-score { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
#done-score small { font-size: 20px; color: var(--muted); }
#done-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface-2); border-radius: 10px; overflow: hidden; position: relative; }
.tile .tthumb { aspect-ratio: 1; background: var(--thumb); }
.tile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .tbody { padding: 8px 10px 10px; }
.tile .tname { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .tprice { font-size: 14px; font-weight: 700; margin-top: 2px; }
.tile .tguess { font-size: 12px; color: var(--muted); }
.tile .tpts { position: absolute; right: 8px; top: 8px; font-size: 13px; font-weight: 800; padding: 3px 8px; border-radius: 7px; background: rgb(17 18 22 / .8); }
.tile .tpts.g { color: var(--good); } .tile .tpts.y { color: var(--ok); }
.tile .tpts.o { color: var(--meh); } .tile .tpts.r { color: var(--bad); }
.done-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .done-actions { grid-template-columns: 1fr; gap: 0; } }

footer { margin-top: 28px; text-align: center; font-size: 12px; color: #6b6e76; }

/* ---------- dialog / toast ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink);
  max-width: 420px; width: calc(100% - 32px); padding: 22px;
}
dialog::backdrop { background: rgb(0 0 0 / .6); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 10px; font-weight: 800; }
dialog p { color: #d3d4d8; line-height: 1.45; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; font-weight: 600; }
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 10;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
}

/* ---------- motion ---------- */
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.rise { animation: rise .3s ease-out both; }
@keyframes bump { 50% { transform: scale(1.12); } }
.bump { animation: bump .35s ease-out; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- phones: keep the price box on screen ---------- */
@media (max-width: 760px) {
  .thumb { aspect-ratio: auto; height: min(40vh, calc(100vw - 32px)); }
  .details h2 { margin-top: 0; }
  .by { margin-bottom: 12px; }
  .price-box { padding: 14px; }
  #guess { font-size: 28px; }
  #done-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tile .tname { font-size: 12px; }
  .tile .tprice { font-size: 13px; }
  .tile .tguess { font-size: 11px; }
  .done-head { flex-direction: column-reverse; align-items: flex-start; gap: 4px; }
}
