/* To Scale: gallery wall, floor line, wayfinding pictograms, measuring-tape yellow. */
:root {
  --wall: #1c1a17;
  --wall-2: #26231f;
  --floor: #34302a;
  --ink: #f3efe7;
  --ink-2: #b9b1a3;
  --ink-3: #a39a8a;
  --pict: #d8d1c3;
  --tape: #ffd23f;
  --tape-ink: #1c1a17;
  --good: #7fd18b;
  --mid: #ffd23f;
  --warn: #ff9f43;
  --bad: #ff6b5e;
  --card: #f4efe4;
  --card-ink: #1f1c18;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --num: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--wall); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--tape); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

.app {
  min-height: 100dvh; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column;
  padding: max(env(safe-area-inset-top), 8px) 16px max(env(safe-area-inset-bottom), 12px);
}

/* Header */
.bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; min-height: 52px; }
.mark { margin: 0; font: 800 1.25rem/1 var(--sans); letter-spacing: 0.02em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.mark-tick { width: 22px; height: 14px; background:
  linear-gradient(var(--tape), var(--tape)) 0 100% / 100% 3px no-repeat,
  linear-gradient(var(--tape), var(--tape)) 0 0 / 3px 100% no-repeat,
  linear-gradient(var(--tape), var(--tape)) 9.5px 6px / 3px 8px no-repeat,
  linear-gradient(var(--tape), var(--tape)) 100% 0 / 3px 100% no-repeat; }
.dayline { margin: 0; color: var(--ink-3); font: 500 0.85rem/1.2 var(--num); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; gap: 6px; }
@media (max-width: 359px) { .dayline .dn { display: none; } .mark { font-size: 1.1rem; } }
.chip, .icon-btn { min-width: 48px; height: 48px; border-radius: 24px; border: 1px solid #4a443b; background: transparent; font-weight: 700; cursor: pointer; }
.chip { font: 600 0.9rem/1 var(--num); padding: 0 12px; }
.icon-btn { font-size: 1.1rem; }

.pips { list-style: none; display: flex; gap: 6px; margin: 4px 0 6px; padding: 0; min-height: 6px; } /* height held before the pips are drawn */
.pips li { flex: 1; height: 6px; border-radius: 3px; background: #3a352e; }
.pips li.now { background: var(--ink-2); }
.pips li.s3 { background: var(--good); } .pips li.s2 { background: var(--mid); } .pips li.s1 { background: var(--warn); } .pips li.s0 { background: var(--bad); }

/* Play */
.main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.play { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ask { margin: 4px 0 8px; font: 600 clamp(1.15rem, 4.8vw, 1.4rem)/1.2 var(--serif); }

.stage {
  position: relative; flex: 1; min-height: 300px; border-radius: 14px; overflow: hidden;
  background: radial-gradient(120% 80% at 62% 18%, #3a352d 0%, var(--wall-2) 45%, var(--wall) 100%);
  touch-action: none; cursor: ns-resize; user-select: none; -webkit-user-select: none;
}
.floor { position: absolute; left: 0; right: 0; bottom: 0; height: 14%; background: linear-gradient(#3b362f, #2c2823); border-top: 2px solid #4d473d; }
.world { position: absolute; inset: 0; }
.world > * { position: absolute; transform-origin: 0 0; will-change: transform; }
/* Until game.js has placed a figure (its first place() writes a style attribute) it takes no room and stays hidden:
   no full-size mug or visitor before the day's objects arrive, and no jump when they do. */
.world > :not([style]) { visibility: hidden; width: 0; height: 0; }
.ref { fill: var(--pict); overflow: visible; transition: opacity .35s; }
.ref.off { opacity: 0; }
.mug { fill: #c9c1b2; }
.obj img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 2px;
  box-shadow: 0 10px 24px rgba(0,0,0,.55); pointer-events: none; }
/* Cut-out objects stand on the floor: no card edge, a soft cast shadow that follows the silhouette. */
.obj.cut img { border-radius: 0; box-shadow: none; filter: drop-shadow(0 4px 6px rgba(0,0,0,.45)) drop-shadow(0 14px 22px rgba(0,0,0,.35)); }
.obj.cut::after { left: 10%; right: 10%; bottom: -5px; height: 9px; background: radial-gradient(closest-side, rgba(0,0,0,.7), transparent); }
.obj::after { /* floor shadow */
  content: ""; position: absolute; left: 6%; right: 6%; bottom: -6px; height: 10px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0,0,0,.6), transparent); }
.ghost { z-index: 2; border: 2px dashed var(--tape); border-radius: 3px; opacity: 0; transition: opacity .3s; }
.ghost span { position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); background: var(--wall); padding: 3px 6px; border-radius: 4px; font: 600 0.75rem/1 var(--num); color: var(--tape); white-space: nowrap; }
.ghost.on { opacity: .9; }
.dim { z-index: 3; opacity: 0; transition: opacity .3s .2s; border-left: 2px solid var(--tape); }
.dim::before, .dim::after { content: ""; position: absolute; left: -7px; width: 12px; height: 2px; background: var(--tape); }
.dim::before { top: 0; } .dim::after { bottom: 0; }
.dim.h { border-left: 0; border-top: 2px solid var(--tape); }
.dim.h::before, .dim.h::after { left: auto; top: -7px; width: 2px; height: 12px; }
.dim.h::before { left: 0; } .dim.h::after { right: 0; bottom: auto; }
.dim span { position: absolute; top: 50%; left: 10px; transform: translateY(-50%); background: var(--tape); color: var(--tape-ink);
  font: 700 0.85rem/1 var(--num); padding: 5px 7px; border-radius: 4px; white-space: nowrap; }
.dim.h span { top: auto; bottom: 8px; left: 50%; transform: translateX(-50%); }
/* No room right of the object: the size sits above the line's top end, clear of the object. */
.dim.flip span { left: auto; right: -4px; top: -8px; transform: translateY(-100%); }
.dim.on { opacity: 1; }
.legend { position: absolute; left: 12px; bottom: 4px; margin: 0; font: 500 0.72rem/1.6 var(--num); color: var(--ink-3); transition: opacity .3s; }
/* At the reveal the measuring line speaks; the legend steps aside so the guess tag never lands on it. */
.play[data-phase="reveal"] .legend { opacity: 0; }

/* Controls */
.controls, .result { padding-top: 10px; }
.readout { display: block; text-align: center; font: 700 clamp(2rem, 10vw, 2.6rem)/1.1 var(--num); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.slider-wrap { padding: 4px 0 2px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 48px; background: transparent; margin: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px;
  background: repeating-linear-gradient(90deg, #5a5348 0 2px, transparent 2px 10%), #3a352e; }
input[type=range]::-moz-range-track { height: 8px; border-radius: 4px; background: #3a352e; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 34px; height: 34px; margin-top: -13px; border-radius: 50%;
  background: var(--tape); border: 3px solid var(--wall); box-shadow: 0 0 0 2px var(--tape); }
input[type=range]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--tape); border: 3px solid var(--wall); box-shadow: 0 0 0 2px var(--tape); }
input[type=range]:focus-visible { outline-offset: 0; }
.ticks { position: relative; height: 1.1em; font: 500 0.72rem/1 var(--num); color: var(--ink-3); }
.ticks span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.ticks span:last-child { transform: translateX(-70%); }
.ticks span:not([style]) { visibility: hidden; } /* labels show once game.js has placed them in the player's units */
.primary { display: block; width: 100%; min-height: 56px; margin-top: 12px; border: 0; border-radius: 28px; background: var(--tape); color: var(--tape-ink);
  font: 800 1.1rem/1 var(--sans); letter-spacing: 0.01em; cursor: pointer; }
.primary:active { transform: translateY(1px); }
.hint { margin: 8px 0 0; text-align: center; color: var(--ink-3); font-size: 0.85rem; }

/* Result */
.score-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.verdict { margin: 0; font: 700 1.35rem/1.15 var(--serif); }
.points { margin: 0; font: 700 1.35rem/1 var(--num); color: var(--tape); white-space: nowrap; }
.truth { margin: 4px 0 10px; color: var(--ink-2); font-size: 0.95rem; line-height: 1.4; }
.truth b { color: var(--ink); font-family: var(--num); }
.tape, .label-img { display: none; }
.label { background: var(--card); color: var(--card-ink); border-radius: 6px; padding: 12px 14px; }
.label p { margin: 0; }
.label-title { font: 700 1.02rem/1.25 var(--serif); }
.label-meta { margin-top: 3px !important; font-size: 0.86rem; line-height: 1.35; color: #4b453c; }
.label-credit { margin-top: 6px !important; font-size: 0.78rem; color: #5d564b; }
.label a { color: inherit; text-underline-offset: 2px; display: inline-block; padding: 6px 0; margin: -6px 0; }

/* End */
.end { padding: 6px 0 24px; }
.end-title { margin: 8px 0 0; font: 700 1.5rem/1.15 var(--serif); }
.end-total { margin: 6px 0 0; font: 800 3rem/1 var(--num); color: var(--tape); }
.end-total small { font-size: 1rem; color: var(--ink-3); font-weight: 600; }
.end-squares { margin: 10px 0 0; font-size: 1.6rem; letter-spacing: 0.1em; }
.end-actions { position: relative; }
.toast { margin: 8px 0 0; min-height: 1.2em; text-align: center; color: var(--ink-2); font-size: 0.9rem; }
.end-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.end-list li { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; background: #24211d; border-radius: 10px; padding: 8px; }
.end-list img { width: 56px; height: 56px; object-fit: contain; border-radius: 6px; background: #3a352e; }
.end-list a.t { color: var(--ink); text-decoration-color: #6b6356; text-underline-offset: 3px; display: inline-block; padding: 4px 0; }
.end-list .t { font: 600 0.92rem/1.25 var(--serif); }
.end-list .m { font: 500 0.78rem/1.3 var(--num); color: var(--ink-3); margin-top: 2px; }
.end-list .p { font: 700 1rem/1 var(--num); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; }
.stats div { background: #24211d; border-radius: 10px; padding: 10px; text-align: center; }
.stats dt { font-size: 0.75rem; color: var(--ink-3); }
.stats dd { margin: 4px 0 0; font: 700 1.3rem/1 var(--num); }
.next-in { margin: 14px 0 0; text-align: center; color: var(--ink-2); font: 500 0.95rem/1.4 var(--num); }
.archive { margin-top: 14px; border-top: 1px solid #3a352e; padding-top: 6px; }
.archive summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.archive ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.archive a { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 12px; border-radius: 10px; background: #24211d; color: var(--ink); text-decoration: none; font: 500 0.9rem/1 var(--num); }
.archive a span { color: var(--ink-3); }
.fineprint { margin: 18px 0 0; font-size: 0.78rem; line-height: 1.5; color: var(--ink-3); }
.fineprint + .fineprint { margin-top: 10px; }
.fineprint a { color: var(--ink-2); text-underline-offset: 2px; display: inline-block; padding: 12px 4px; margin: -12px -4px; }

/* Help */
.help { max-width: min(92vw, 420px); border: 0; border-radius: 16px; padding: 20px 20px 16px; background: var(--card); color: var(--card-ink); }
.help::backdrop { background: rgba(10, 9, 8, .7); }
.help h2 { margin: 0 0 8px; font: 700 1.35rem/1.2 var(--serif); }
.help p, .help li { line-height: 1.45; }
.help ol { padding-left: 1.2em; }
.help .primary { color: var(--tape-ink); }
.help :focus-visible { outline-color: #8a5a00; }
.defs { position: absolute; }

@media (min-width: 900px) {
  /* Desktop: the stage and one column of equal height. The column reads top to bottom in both phases:
     question or verdict, then the readout or the museum label, then the primary button level with the floor. */
  .app { max-width: 1180px; padding-top: 20px; }
  .play { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: auto minmax(0, 1fr);
    column-gap: 32px; margin-top: 10px; height: min(700px, calc(100dvh - 128px)); flex: none; }
  .stage { grid-column: 1; grid-row: 1 / 3; min-height: 0; }
  .ask { grid-column: 2; grid-row: 1; margin: 0; font-size: 2rem; line-height: 1.15; }
  .controls { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; justify-content: center; padding: 0; }
  .controls .readout { font-size: 3.4rem; }
  .controls .hint { order: -1; margin: 14px 0 0; text-align: left; }
  .controls .readout { margin-top: auto; }
  .controls .primary { margin-top: auto; }
  .controls .slider-wrap { margin: 18px 0 0; }
  .play[data-phase="reveal"] .ask { display: none; }
  .result { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; padding: 0; min-height: 0; }
  .result .score-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .result .verdict { font-size: 2rem; }
  .result .points { font-size: 2.6rem; }
  .result .truth { font-size: 1.02rem; margin: 10px 0 0; }
  .result > :not(.label) { flex: none; }
  .tape { display: block; position: relative; height: 66px; margin: 26px 0 0; }
  .tape-rule { position: absolute; left: 0; right: 0; top: 26px; height: 8px; border-radius: 4px;
    background: repeating-linear-gradient(90deg, #5a5348 0 2px, transparent 2px 10%), #3a352e; }
  .tape-ticks span { position: absolute; top: 42px; transform: translateX(-50%); font: 500 0.72rem/1 var(--num); color: var(--ink-3); white-space: nowrap; }
  .tape-ticks span:first-child { transform: none; } .tape-ticks span:last-child { transform: translateX(-100%); }
  .tape-span { position: absolute; top: 26px; height: 8px; background: rgba(255, 210, 63, .35); }
  .tape-m { position: absolute; top: 18px; width: 0; height: 24px; }
  .tape-m::before { content: ""; position: absolute; left: -1.5px; top: 0; width: 3px; height: 24px; border-radius: 2px; background: var(--tape); }
  .tape-m.you::before { background: none; border-left: 3px dashed var(--tape); width: 0; left: -1.5px; }
  .tape-m span { position: absolute; bottom: 28px; left: 0; transform: translateX(-50%); font: 700 0.75rem/1 var(--num); color: var(--tape); white-space: nowrap; }
  .tape-m.real span { color: var(--ink); }
  /* The label is a catalogue card: the object's own photo, full detail, above the museum's words. */
  .result .label { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin-top: 22px; padding: 16px 18px; }
  .label-img { display: block; flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; margin: 2px 0 14px; }
  .label-img.cut { filter: drop-shadow(0 6px 10px rgba(60, 45, 20, .28)); }
  .result .label-title { font-size: 1.2rem; }
  .result .label-meta { font-size: 0.95rem; }
  .result .primary { margin-top: 14px; }
  .end { max-width: 560px; margin: 0 auto; width: 100%; }
}
@media (min-width: 900px) and (max-height: 700px) { .tape { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
/* Short phones (iPhone SE 1st gen 320x568): keep Lock it in above the fold. */
@media (max-width: 899px) and (max-height: 620px) {
  .stage { min-height: 200px; } .ask { margin: 2px 0 6px; font-size: 1.05rem; }
  .readout { font-size: 1.8rem; } .controls { padding-top: 4px; } .primary { min-height: 48px; margin-top: 6px; }
  .hint { display: none; } .bar { min-height: 48px; } .pips { margin: 2px 0 4px; }
}
