:root {
  --wall: #f3efe6;
  --wall-deep: #e9e3d6;
  --ink: #1d1814;
  --ink-soft: #5d554b;
  --ink-faint: #8f877b;
  --line: #ddd6c7;
  --card: #fbf9f4;
  --slot: #ece7dc;
  --gilt: #b8975a;
  --t1: #f1e6c9;  --t1-line: #e2d2a6;
  --t2: #e6cf90;  --t2-line: #d2b76c;
  --t3: #cfa449;  --t3-line: #b58a33;
  --t4: #23483a;  --t4-line: #1a382d;
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--wall);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

/* The gallery wall: a soft wash of light from above, darker at the skirting. */
.wall {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -10%, #fffdf8 0%, transparent 60%),
    linear-gradient(180deg, transparent 55%, var(--wall-deep) 100%);
}

/* ── Masthead ─────────────────────────────────────────── */
.masthead {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  width: min(1080px, 100% - 32px); margin: 0 auto;
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font: 600 clamp(21px, 5.6vw, 32px)/1 var(--serif); letter-spacing: .02em; white-space: nowrap;
  color: var(--ink); text-decoration: none;
}
.masthead-actions { display: flex; justify-content: flex-end; gap: 2px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(29, 24, 20, .07); }

/* ── Room layout ──────────────────────────────────────── */
.room {
  flex: 1;
  width: min(1080px, 100% - 32px); margin: 0 auto;
  padding: 28px 0 32px;
  display: grid; gap: 28px;
}
@media (min-width: 940px) {
  .room { grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); gap: 56px; padding-top: 44px; align-items: start; }
  .exhibit { position: sticky; top: 28px; }
}

/* ── The exhibit ──────────────────────────────────────── */
.exhibit { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.picture-light {
  width: 62%; height: 46px; margin-bottom: -22px;
  background: radial-gradient(50% 100% at 50% 0%, rgba(255, 244, 214, .95), transparent 72%);
  filter: blur(6px);
}
.frame {
  position: relative; max-width: 100%;
  padding: clamp(9px, 1.6vw, 15px);
  background: linear-gradient(135deg, #3b2e23 0%, #241b14 45%, #382b20 100%);
  box-shadow:
    inset 0 0 0 1px #57463566, inset 0 2px 0 #6a574533,
    0 2px 3px rgba(40, 28, 16, .25),
    0 22px 28px -14px rgba(40, 28, 16, .5),
    0 48px 60px -30px rgba(40, 28, 16, .35);
}
.canvas {
  position: relative; overflow: hidden; background: #171310;
  outline: 2px solid var(--gilt); outline-offset: 0;
  box-shadow: 0 0 0 3px #1a1410;
  min-width: 200px; min-height: 160px;
}
.canvas img {
  display: block;
  max-width: 100%;
  max-height: min(58dvh, 620px);
  width: auto; height: auto;
  opacity: 0;
  transition: transform 1.1s var(--ease), opacity .6s ease;
  user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none;
}
.canvas.ready img { opacity: 1; }
.canvas-loading {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px;
  color: #a89c8b; font: italic 500 17px var(--serif);
}
.canvas.ready .canvas-loading { display: none; }
@media (max-width: 939px) {
  .canvas img { max-height: 44dvh; }
  .placard.pending { display: none; }
  .room { gap: 18px; padding-top: 20px; }
}

.view-note {
  min-height: 18px; margin-top: 14px;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint);
}

/* Museum label */
.placard {
  width: min(340px, 100%); margin-top: 10px;
  padding: 14px 18px 15px;
  background: var(--card);
  border: 1px solid #e6e0d2;
  box-shadow: 0 1px 0 #fff inset, 0 6px 14px -8px rgba(40, 28, 16, .3);
  text-align: left;
}
.placard h2 { margin: 0; font: 600 23px/1.15 var(--serif); }
.placard .years { margin: 2px 0 8px; font-size: 12px; color: var(--ink-faint); }
.placard .title { margin: 0; font: italic 500 19px/1.25 var(--serif); }
.placard .meta { margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: var(--ink-soft); }
.placard a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--gilt); }
.placard.pending h2 { font-style: italic; font-weight: 500; color: var(--ink-soft); }
.placard.reveal { animation: rise .7s var(--ease) both; }
.verdict {
  display: inline-block; margin-bottom: 8px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--t4);
}
.verdict.lost { color: #8a3b2a; }

/* ── Play column ──────────────────────────────────────── */
.play { min-width: 0; text-align: center; }
.modes { display: inline-flex; gap: 6px; }
.mode {
  padding: 6px 15px; border-radius: 999px;
  background: transparent; border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 500; color: var(--ink-soft);
  transition: background .15s, color .15s, border-color .15s;
}
.mode:hover { border-color: #bdb4a2; }
.mode[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.eyebrow {
  margin: 16px 0 4px;
  font-size: 11px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft);
}
.lede { margin: 0 auto 18px; max-width: 34ch; color: var(--ink-soft); font-size: 14.5px; }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.row {
  height: 56px; padding: 0 13px;
  display: flex; align-items: center; gap: 10px;
  border-radius: 8px; border: 1px solid transparent;
  background: var(--slot); border-color: #e2dccf;
}
.row.turn {
  background: transparent; border: 1px dashed #c9c0ae;
  color: var(--ink-faint); font: italic 500 16px var(--serif);
}
.row.filled { animation: settle .45s var(--ease) both; }
.row.t0 { background: #e9e5dc; border-color: #dcd6c9; color: var(--ink-soft); }
.row.t1 { background: var(--t1); border-color: var(--t1-line); }
.row.t2 { background: var(--t2); border-color: var(--t2-line); }
.row.t3 { background: var(--t3); border-color: var(--t3-line); }
.row.t4 { background: var(--t4); border-color: var(--t4-line); color: #f6f1e4; }
.row.filled, .row.t0, .row.t1, .row.t2, .row.t3, .row.t4 { height: auto; min-height: 56px; padding: 8px 13px; }
.row .body { flex: 1; min-width: 0; display: grid; gap: 1px; }
.row .name { font: italic 600 18px/1.2 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .facts { display: flex; flex-wrap: wrap; column-gap: 10px; font-size: 11.5px; line-height: 1.35; opacity: .82; }
.row .facts b { font-weight: 600; }
.row .year { flex: none; display: grid; justify-items: end; line-height: 1.2; font-variant-numeric: tabular-nums; }
.row .year b { font-size: 14px; font-weight: 600; }
.row .year span { font-size: 10.5px; letter-spacing: .04em; opacity: .8; white-space: nowrap; }
.row .year.same span { opacity: 1; font-weight: 600; }

.bars { display: inline-flex; gap: 2px; flex: none; }
.bars i { width: 3px; height: 14px; border-radius: 1px; background: currentColor; opacity: .2; }
.bars i.on { opacity: 1; }

/* Guess input */
.guess { display: flex; gap: 8px; margin-top: 14px; }
.combo { position: relative; flex: 1; min-width: 0; }
#guess-input {
  width: 100%; height: 46px; padding: 0 14px;
  background: #fff; border: 1px solid #cfc7b6; border-radius: 8px;
  font-size: 16px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#guess-input::placeholder { color: var(--ink-faint); }
#guess-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(184, 151, 90, .28); }
.suggestions {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 5;
  margin: 0; padding: 4px; list-style: none; text-align: left;
  background: #fff; border: 1px solid #d8d0bf; border-radius: 10px;
  box-shadow: 0 14px 30px -12px rgba(40, 28, 16, .35);
  max-height: 300px; overflow: auto;
}
.suggestions li {
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
}
.suggestions li span { font: italic 500 17px/1.25 var(--serif); }
.suggestions li small { color: var(--ink-faint); font-size: 11.5px; white-space: nowrap; }
.suggestions li[aria-selected="true"] { background: #f1ecdf; }

.btn {
  height: 46px; padding: 0 20px; border: 0; border-radius: 8px;
  background: var(--ink); color: #fff; font-weight: 600; font-size: 14px;
  transition: opacity .15s, transform .1s;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn:not(:disabled):active { transform: scale(.98); }
.btn-wide { width: 100%; }

.after { margin-top: 14px; animation: rise .6s var(--ease) both; }
.next { margin: 12px 0 0; font-size: 13px; color: var(--ink-soft); }
.next span { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }

.colophon {
  width: min(1080px, 100% - 32px); margin: 0 auto; padding: 14px 0 22px;
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-faint); text-align: center;
}

/* ── Sheets (dialogs) ─────────────────────────────────── */
.sheet {
  width: min(420px, calc(100% - 28px)); max-height: min(86dvh, 720px);
  padding: 26px 24px 22px; border: 0; border-radius: 14px;
  background: var(--card); color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(20, 14, 8, .55);
}
.sheet::backdrop { background: rgba(29, 24, 20, .45); backdrop-filter: blur(2px); }
.sheet[open] { animation: rise .35s var(--ease) both; }
.sheet h2 { margin: 0 0 14px; text-align: center; font: 600 26px/1 var(--serif); letter-spacing: .02em; }
.sheet h3 { margin: 22px 0 10px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.sheet p { margin: 0 0 12px; font-size: 14px; }
.sheet-sub { text-align: center; color: var(--ink-faint); margin-top: -8px !important; font-size: 12.5px !important; }
.sheet-close {
  position: absolute; top: 10px; right: 12px; width: 34px; height: 34px;
  background: none; border: 0; border-radius: 50%; font-size: 22px; line-height: 1; color: var(--ink-soft);
}
.sheet-close:hover { background: rgba(29, 24, 20, .07); }
.legend { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.legend li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: #f1ede3; border-radius: 7px; font-size: 13.5px;
}
.legend li span:not(.bars) { color: var(--ink-faint); }
.sw { width: 13px; height: 13px; border-radius: 3px; flex: none; border: 1px solid; }
.sw.t0 { background: #e9e5dc; border-color: #cfc8b9; }
.sw.t1 { background: var(--t1); border-color: var(--t1-line); }
.sw.t2 { background: var(--t2); border-color: var(--t2-line); }
.sw.t3 { background: var(--t3); border-color: var(--t3-line); }
.sw.t4 { background: var(--t4); border-color: var(--t4-line); }

.figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.figures b { display: block; font: 600 32px/1.1 var(--serif); }
.figures span { font-size: 11px; color: var(--ink-soft); }
.dist { display: grid; gap: 5px; }
.dist div { display: grid; grid-template-columns: 14px 1fr; gap: 8px; align-items: center; font-size: 12px; }
.dist i {
  display: block; min-width: 22px; padding: 2px 7px; border-radius: 4px;
  background: #d9d2c2; color: var(--ink); font-style: normal; font-weight: 600; text-align: right;
}
.dist i.hit { background: var(--t4); color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes settle { from { opacity: 0; transform: scale(.98); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
