/* Piconacci — a museum gallery after hours: dark wall, gilt frames, wall-label type.
   Single deliberate dark look. */
:root {
  --wall: #14161b;
  --wall-2: #1b1e25;
  --panel: #22262e;
  --line: #333844;
  --ink: #ece7de;
  --ink-2: #a9a59d;
  --gilt: #c9a45c;
  --gilt-2: #8a6f3a;
  --match: #3f9a68;
  --close: #dcb544;
  --close-ink: #241d08;
  --miss: #353a45;

  --display: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --body: "Public Sans", "Helvetica Neue", Arial, sans-serif;

  --radius: 10px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% -10%, #262a33 0%, transparent 60%),
    var(--wall);
  color: var(--ink);
  font: 400 15px/1.5 var(--body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: env(safe-area-inset-top, 0px) env(safe-area-inset-bottom, 0px);
}
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
a { color: var(--gilt); }
:focus-visible { outline: 2px solid var(--gilt); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--ink-2); font-size: 13px; }
.eyebrow {
  margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-2);
}
.eyebrow--won { color: var(--match); }

/* ---------- masthead ---------- */
.masthead { padding-block: 20px 8px; }
.masthead__inner {
  max-width: 720px; margin: 0 auto;
  display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; gap: 12px;
}
.brand { text-align: center; }
.brand__name {
  margin: 0; font: 700 clamp(34px, 7vw, 46px)/1 var(--display);
  letter-spacing: -.01em;
}
.brand__name {
  display: inline-flex; align-items: center; gap: 12px;
}
.brand__logo { height: 1em; width: auto; flex: none; }
.brand__name em { font-style: italic; font-weight: 500; color: var(--gilt); }
.brand__sub {
  margin: 6px 0 0; font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; cursor: pointer;
  display: grid; place-items: center; font-weight: 600; font-size: 17px;
  transition: border-color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--gilt); background: var(--wall-2); }
.icon-btn svg { width: 18px; height: 18px; fill: var(--ink); }

/* ---------- stage ---------- */
.stage {
  max-width: 720px; margin: 0 auto; padding-block: 12px 40px;
  display: flex; flex-direction: column; gap: 22px;
}
.play { display: flex; flex-direction: column; gap: 12px; }
.counter {
  margin: 0; text-align: right; font-weight: 600; font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.search { position: relative; }
.search input {
  width: 100%; height: 52px; padding: 0 48px 0 20px;
  border-radius: 26px; border: 1px solid transparent;
  background: var(--ink); color: #15171c; font-size: 17px;
}
.search input::placeholder { color: #6e6a63; }
.search input:focus { outline: none; border-color: var(--gilt); box-shadow: 0 0 0 3px rgba(201,164,92,.35); }
.search input:disabled { opacity: .5; cursor: not-allowed; }
.search__icon {
  position: absolute; right: 18px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%);
  fill: none; stroke: #44484f; stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.suggestions {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  max-height: min(60vh, 420px); overflow-y: auto;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
}
.suggestion {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
}
.suggestion:hover, .suggestion.is-active { background: var(--miss); }
.suggestion__title { font-weight: 600; }
.suggestion__meta { font-size: 13px; color: var(--ink-2); }
.suggestion--empty { color: var(--ink-2); cursor: default; }
.suggestion--empty:hover { background: none; }

.legend {
  margin: 4px 0 0; padding: 0; list-style: none;
  display: flex; justify-content: center; gap: 18px; font-size: 13px; color: var(--ink-2);
}
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.swatch--miss { background: var(--miss); box-shadow: inset 0 0 0 1px #4a505d; }
.swatch--close { background: var(--close); }
.swatch--match { background: var(--match); }

/* ---------- frames (artwork images) ---------- */
.frame {
  position: relative; overflow: hidden; flex: none;
  background: #0e1014;
  border: 3px solid var(--gilt-2);
  box-shadow: inset 0 0 0 2px #0b0c0f, 0 0 0 1px #4b3c1f, 0 8px 18px rgba(0,0,0,.4);
  display: grid; place-items: center;
}
.frame img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .4s;
}
.frame--loaded img { opacity: 1; }
.frame__mono { font: italic 500 22px/1 var(--display); color: var(--gilt); }
.frame--thumb { width: 64px; height: 64px; }
.frame--hero {
  width: 100%; aspect-ratio: 4 / 5; max-width: 100%;
  border-width: 8px; border-color: var(--gilt);
  box-shadow: inset 0 0 0 3px #0b0c0f, 0 0 0 1px var(--gilt-2), 0 24px 50px rgba(0,0,0,.55);
}
.frame--hero img { object-fit: contain; background: #0e1014; }
.frame--hero .frame__mono { font-size: 64px; }

/* ---------- mystery placeholder ---------- */
.mystery {
  display: grid; grid-template-columns: 120px 1fr; gap: 20px; align-items: center;
  padding: 20px; border: 1px dashed var(--line); border-radius: var(--radius);
}
.mystery__frame { padding: 8px; background: var(--gilt-2); }
.mystery__canvas {
  aspect-ratio: 4 / 5; display: grid; place-items: center;
  background: repeating-linear-gradient(45deg, #1a1d23 0 6px, #1e2128 6px 12px);
  font: italic 500 48px/1 var(--display); color: var(--gilt);
}
.mystery__text { margin: 6px 0 0; color: var(--ink-2); max-width: 46ch; }

/* ---------- guesses ---------- */
.guesses { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 18px; }
.guess {
  padding: 16px; border-radius: 14px; background: var(--wall-2);
  border: 1px solid var(--line);
}
.guess--won { border-color: var(--match); }
.guess--new { animation: rise .45s ease-out; }
.guess__head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.guess__label { min-width: 0; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; }
.guess__num {
  grid-row: span 2; align-self: start; margin-top: 3px;
  font-size: 12px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.guess__title {
  margin: 0; font: 600 19px/1.2 var(--display); text-wrap: balance;
  overflow-wrap: anywhere;
}
.guess__artist { margin: 3px 0 0; color: var(--ink-2); font-size: 14px; }

.tiles {
  margin: 0; padding: 0; list-style: none;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
.tile {
  min-width: 0; min-height: 84px; padding: 10px 8px;
  border-radius: var(--radius); text-align: center;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px;
  background: var(--miss);
}
.tile--match { background: var(--match); }
.tile--close { background: var(--close); color: var(--close-ink); }
.tile__label { font-size: 12px; font-weight: 500; opacity: .85; }
.tile__value {
  font-weight: 700; font-size: 15px; line-height: 1.2; overflow-wrap: anywhere;
  display: inline-flex; align-items: center; gap: 4px; justify-content: center; flex-wrap: wrap;
}
.tile--year .tile__value { font-size: 20px; font-variant-numeric: tabular-nums; }
.tile__note { font-size: 11px; font-weight: 500; opacity: .85; }
.tile__arrow {
  width: 0; height: 0; display: inline-block;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
}
.tile__arrow--up { border-bottom: 8px solid currentColor; }
.tile__arrow--down { border-top: 8px solid currentColor; }
.guess--new .tile { animation: flip .5s ease-out both; }
.guess--new .tile:nth-child(2) { animation-delay: .06s; }
.guess--new .tile:nth-child(3) { animation-delay: .12s; }
.guess--new .tile:nth-child(4) { animation-delay: .18s; }
.guess--new .tile:nth-child(5) { animation-delay: .24s; }
.guess--new .tile:nth-child(6) { animation-delay: .30s; }
.guess--new .tile:nth-child(7) { animation-delay: .36s; }
.guess--new .tile:nth-child(8) { animation-delay: .42s; }

/* ---------- result ---------- */
.result {
  display: block;
  padding: 24px; border-radius: 16px; background: var(--wall-2); border: 1px solid var(--line);
}
.result__label { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.result__title { margin: 4px 0 0; font: 600 clamp(24px, 4vw, 32px)/1.15 var(--display); text-wrap: balance; }
.result__artist { margin: 0; font-weight: 600; font-size: 16px; }
.result__bio { margin: 0; color: var(--ink-2); font-size: 13px; }
.result__facts {
  margin: 10px 0 6px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px;
  border-top: 1px solid var(--line); padding-top: 12px;
}
.result__facts dt { color: var(--ink-2); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; padding-top: 2px; }
.result__facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.result__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.countdown { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.link { font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }

.btn {
  height: 42px; padding: 0 18px; border-radius: 21px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; font-weight: 600; font-size: 14px;
}
.btn:hover { border-color: var(--gilt); }
.btn--primary { background: var(--gilt); border-color: var(--gilt); color: #1a1508; }
.btn--primary:hover { background: #d8b673; }

/* ---------- dialogs ---------- */
.sheet {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 28px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink);
}
.sheet::backdrop { background: rgba(6,7,9,.7); }
.sheet h2 { margin: 0 0 12px; font: 600 28px/1.1 var(--display); }
.sheet p { margin: 0 0 12px; }
.sheet__close-form { position: absolute; top: 14px; right: 14px; margin: 0; }
.sheet__close { width: 34px; height: 34px; font-size: 20px; }
.rules { margin: 0 0 14px; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; }
.rules dt { font-weight: 700; }
.rules dd { margin: 0; color: var(--ink-2); }

.stats__row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin-bottom: 20px; }
.stats__row strong { display: block; font: 600 30px/1 var(--display); font-variant-numeric: tabular-nums; }
.stats__row span { font-size: 12px; color: var(--ink-2); }
.stats__heading { margin: 0 0 10px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.dist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.dist li { display: grid; grid-template-columns: 20px 1fr; align-items: center; gap: 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.dist__bar {
  width: var(--w); min-width: 24px; padding: 2px 8px; text-align: right; font-weight: 700;
  background: var(--miss); border-radius: 4px;
}
.dist--today .dist__bar { background: var(--match); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 50; padding: 10px 18px; border-radius: 20px;
  background: var(--ink); color: #15171c; font-weight: 600; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

.colophon {
  max-width: 720px; margin: 0 auto; padding-block: 20px 32px;
  border-top: 1px solid var(--line); text-align: center; font-size: 12px; color: var(--ink-2);
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes flip { from { transform: rotateX(90deg); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 600px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .result__art { max-width: 260px; width: 100%; margin: 0 auto; }
  .mystery { grid-template-columns: 84px 1fr; padding: 16px; }
  .stats__row strong { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
