@font-face {
  font-family: "Noto Sans HK";
  src: url("fonts/NotoSansHK.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f5f0e5;
  --card-paper: #f7ecd5;
  --paper-shadow: #e6dfce;
  --ink: #1e3233;
  --ink-quiet: #526363;
  --line: #c9bda9;
  --petrol: #20464b;
  --ink-dark: #112c31;
  --vermilion: #a33824;
  --apricot: #f1a774;
  --sans: "Noto Sans HK", "PingFang HK", "Microsoft JhengHei", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { min-width: 0; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
button, a, select { touch-action: manipulation; }
:focus-visible { outline: 3px solid #dd8852; outline-offset: 4px; }
[hidden] { display: none !important; }
h1, h2, h3, p, figure, ol, ul, dl, dd { margin: 0; }
img { display: block; max-width: 100%; }
button { border: 0; border-radius: 0; background: none; }
::selection { background: #b3cecf; color: #192928; }

dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  margin: auto;
  padding: clamp(22px, 4vw, 36px);
  border: 1px solid var(--ink);
  border-top: 5px solid var(--petrol);
  border-radius: 3px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 18px 64px #142b2640;
}
dialog::backdrop { background: rgb(17 37 30 / 65%); }
dialog h2, dialog h3 { font: 700 1.7rem/1.3 var(--sans); }
dialog p { margin-top: 12px; color: var(--ink-quiet); }
dialog img { margin-inline: auto; object-fit: contain; max-height: 240px; mix-blend-mode: multiply; }

.wrap { width: min(1240px, calc(100% - clamp(40px, 8vw, 120px))); margin-inline: auto; }
.topbar { border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: stretch; justify-content: space-between; gap: 24px; min-height: 66px; }
.wordmark {
  display: flex; align-items: center; align-self: center; gap: 9px;
  color: var(--ink); text-decoration: none; font: 800 1.2rem/1 var(--sans);
  white-space: nowrap;
}
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px;
  color: var(--paper); background: var(--vermilion);
  border-radius: 2px; box-shadow: inset 0 0 0 2px var(--vermilion), inset 0 0 0 3px #f4debc; font: 700 1.05rem/1 var(--sans);
}
.wordmark small { margin-left: 3px; font: 700 .65rem/1.25 var(--sans); letter-spacing: .12em; }
.tabs { display: flex; gap: clamp(12px, 3vw, 42px); align-items: stretch; }
.tabs button {
  position: relative; padding: 0 2px; white-space: nowrap;
  font: 650 .88rem/1.4 var(--sans); color: var(--ink-quiet);
}
.tabs button[aria-current="page"] { color: var(--ink-dark); }
.tabs button[aria-current="page"]::after {
  content: ""; position: absolute; right: 0; left: 0; bottom: -1px;
  height: 3px; background: var(--vermilion);
}
.tabs button:hover, .wordmark:hover { color: var(--vermilion); }
.kicker { font: 700 .65rem/1.3 var(--sans); letter-spacing: .15em; color: var(--vermilion); }
.hero {
  position: relative; display: grid; grid-template-columns: 1.22fr 1fr;
  min-height: clamp(204px, 22vw, 272px); align-items: center;
  border-bottom: 1px solid var(--ink);
}
.hero-copy { min-width: 0; padding: 30px 0 34px; }
.hero-copy .kicker { display: flex; align-items: center; gap: 10px; }
.hero-copy .kicker::before { content: ""; width: 27px; height: 1px; background: var(--vermilion); }
.hero h1 {
  margin: 12px 0 13px; color: var(--ink);
  font: 750 clamp(1.625rem, 3.65vw, 3rem)/1.2 var(--sans); letter-spacing: .04em;
}
.hero-desc { max-width: 34em; color: var(--ink-quiet); font-size: clamp(.92rem, 1.13vw, 1.06rem); }
.hero-plate {
  align-self: stretch; display: flex; align-items: center; justify-content: flex-end;
  gap: clamp(0px, 1.1vw, 18px); min-width: 0;
}
.hero-plate img { width: min(65%, 235px); height: clamp(166px, 19vw, 230px); object-fit: contain; mix-blend-mode: multiply; }
.hero-plate figcaption {
  position: relative; align-self: flex-end; margin: 0 0 24px; padding: 8px 0 0;
  border-top: 1px solid var(--line); white-space: nowrap;
  color: var(--ink); font: 700 .95rem/1.4 var(--sans);
}
.hero-plate small { display: block; margin-bottom: 5px; color: var(--vermilion); font: 700 .57rem/1.2 var(--sans); letter-spacing: .12em; }
.hero-plate i { display: block; color: var(--ink-quiet); font: .78rem/1.5 var(--sans); }

.play-layout { display: grid; grid-template-columns: minmax(210px, .88fr) minmax(0, 3.23fr); gap: clamp(22px, 3vw, 48px); align-items: start; padding: 28px 0 34px; }
.sidebar { min-width: 0; }
.sidebar h2 { margin: 5px 0 12px; font: 750 1.25rem/1.4 var(--sans); letter-spacing: .02em; }
.mode-block { padding: 4px 0 23px; border-bottom: 1px solid var(--line); }
.mode-switch {
  display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; padding: 3px; gap: 2px;
  border: 1px solid var(--line); border-radius: 4px; background: #eeeade;
}
.mode-switch button {
  min-width: 0; min-height: 39px; padding: 7px 12px; border-radius: 2px; text-align: left;
  font: 650 .82rem/1.35 var(--sans); color: var(--ink-quiet);
}
.pool-field, .guide-filters label {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  color: var(--ink-quiet); font: 650 .79rem/1.4 var(--sans);
}
.pool-field { flex-wrap: wrap; margin-top: 14px; }
.pool-field label { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.pool-field select, .guide-filters :is(select, input) {
  min-width: 0; max-width: 100%; min-height: 38px; padding: 5px 8px; border: 1px solid #a69e8b;
  border-radius: 3px; color: var(--ink); background: #fffaf0; font: 600 .82rem/1.4 var(--sans);
}
.pool-field select:disabled { background: #ebe6d9; }
.mode-desc { margin-top: 11px; max-width: 32em; color: var(--ink-quiet); font: 400 .82rem/1.65 var(--sans); }
.mode-switch button[aria-pressed="true"] { background: var(--petrol); color: #fff7e4; }
.mode-switch button:hover:not([aria-pressed="true"]) { background: #e3e2d3; }
.route-block { padding-top: 22px; }
.route { list-style: none; margin: 14px 0 0; padding: 0; }
.route li { position: relative; display: flex; gap: 12px; min-height: 52px; align-items: flex-start; padding: 0 0 12px; color: var(--ink-quiet); }
.route li:not(:last-child)::before { position: absolute; z-index: 0; content: ""; width: 1px; top: 25px; bottom: -4px; left: 14px; background: var(--line); }
.route li:last-child { padding-bottom: 0; min-height: 42px; }
.route-num {
  z-index: 1; display: grid; place-items: center; flex: 0 0 29px; height: 29px; margin-top: 1px;
  border: 1px solid var(--line); border-radius: 50%; color: var(--ink-quiet); background: var(--paper);
  font: 600 .72rem/1 var(--sans);
}
.route-copy { display: grid; gap: 2px; padding-top: 1px; }
.route-copy b { font: 650 .93rem/1.4 var(--sans); }
.route-copy small { font: 500 .73rem/1.45 var(--sans); color: var(--ink-quiet); }
.route .is-active .route-num { border-color: var(--vermilion); background: var(--vermilion); color: #fffaf0; }
.route .is-active .route-copy b { color: var(--vermilion); }
.route .is-done .route-num { border-color: var(--petrol); background: var(--petrol); color: var(--paper); }

.table {
  color: #fff8e9; padding: clamp(18px, 2.4vw, 35px); min-width: 0;
  background-color: var(--petrol);
  background-image: radial-gradient(ellipse at 35% 28%, #7aa4a821, transparent 68%),
                    repeating-linear-gradient(103deg, #fffefa04 0 1px, transparent 1px 4px);
  border: 1px solid #153439; border-radius: 7px; box-shadow: inset 0 0 0 3px #d8d9af0a;
}
.table .kicker { color: #e9b28c; }
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid #f1f1d13e; padding-bottom: 16px; }
.table h2 { color: #fff7e8; margin-top: 4px; font: 700 clamp(1.5rem, 2.35vw, 2.2rem)/1.35 var(--sans); letter-spacing: .04em; }
.metrics { display: flex; align-items: center; }
.metrics > div { text-align: left; padding: 0 clamp(9px, 1.55vw, 24px); border-left: 1px solid #f0edcd38; }
.metrics > div:first-child { border: 0; }
.metrics > div:last-child { padding-right: 0; }
.metrics small { display: block; color: #d1dbcb; font-size: .7rem; letter-spacing: .04em; }
.metrics b, .metrics > div > span { display: block; margin-top: 3px; color: #fff9e8; font: 600 clamp(1.04rem, 1.6vw, 1.45rem)/1.18 var(--sans); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The paper exhibit and the dark answer surface are separate reading areas. */
.board { min-width: 0; }
.challenge-layout {
  display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr);
  gap: clamp(16px, 2.3vw, 32px); align-items: start;
  padding: clamp(18px, 2.1vw, 31px) 0;
}
.exhibit {
  position: sticky; top: 15px; min-width: 0; overflow: hidden; padding: clamp(13px, 1.8vw, 24px);
  background: var(--card-paper); color: var(--ink); border: 1px solid #d3be96; border-radius: 3px;
  box-shadow: 2px 3px 0 #182f32, 3px 4px 0 #a69376;
}
.exhibit::before {
  content: ""; position: absolute; pointer-events: none; inset: 4px;
  border: 1px solid #b9a68380;
}
.exhibit-label { color: var(--vermilion); font: 700 .72rem/1.35 var(--sans); letter-spacing: .11em; }
.exhibit-art {
  display: grid; place-items: center; width: 100%; height: clamp(105px, 12vw, 174px);
  margin: 7px 0 11px; padding: 4px;
}
.exhibit-art img { width: 100%; height: 100%; min-height: 0; object-fit: contain; mix-blend-mode: multiply; }
.exhibit h3 {
  position: relative; padding-top: 11px; border-top: 1px solid #bfa983;
  color: #233638; font: 750 clamp(1.01rem, 1.37vw, 1.32rem)/1.55 var(--sans);
  overflow-wrap: anywhere; text-wrap: pretty;
}
.exhibit h3 + p, .exhibit h3 + small { display: block; margin-top: 8px; color: var(--ink-quiet); font-size: .81rem; }
.mystery-mark {
  position: relative; display: grid; place-items: center;
  height: min(100%, 110px); aspect-ratio: 1; padding-left: .11em;
  border: 3px double #a58d66; border-radius: 50%; outline: 1px dotted #b09a79; outline-offset: 5px;
  color: #675b48; font: 650 clamp(2.25rem, 4.9vw, 4.65rem)/1 var(--sans);
  background: repeating-linear-gradient(43deg, transparent 0 4px, #ab906718 4px 5px);
}
.answer-panel { min-width: 0; }
.answer-title { margin: 0 0 12px; color: #f6efdf; font: 700 clamp(1.02rem, 1.4vw, 1.3rem)/1.45 var(--sans); }
.timeline-list { position: relative; display: grid; align-items: stretch; gap: 7px; }
.timeline-list::before { content: ""; position: absolute; left: 9px; top: 21px; bottom: 21px; width: 1px; background: #adc5be91; }
.timeline-entry {
  position: relative; display: grid; grid-template-columns: min-content minmax(0,1fr); align-items: baseline;
  gap: 9px; min-width: 0; padding: 8px 0 8px 27px; color: #f1ecdf;
  font: 550 .86rem/1.5 var(--sans);
}
.timeline-entry::before {
  content: ""; position: absolute; z-index: 1; left: 5px; top: 17px; width: 9px; height: 9px;
  border: 1px solid #e7d7ad; border-radius: 50%; background: #345358;
}
.timeline-entry .entry-year { color: #f4d9a6; font: 700 1.04rem/1.45 var(--sans); white-space: nowrap; }
.timeline-entry span { overflow-wrap: anywhere; }
.timeline-entry.is-new { color: #fff8e7; background: #f4d5ab17; border-radius: 2px; padding-right: 5px; }
.timeline-entry.is-new::before { background: #e0b478; box-shadow: 0 0 0 3px #f4d5ab29; }
.gap-choice {
  position: relative; z-index: 1; width: calc(100% - 22px); margin-left: 22px;
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; min-height: 35px;
  border: 1px dashed #aec4bcb8; border-radius: 3px; text-align: left;
  background: #2f5658; color: #f1f5e8; font: 650 .81rem/1.45 var(--sans);
  transition: background .13s, border-color .13s;
}
.gap-choice::before {
  content: "+"; flex: 0 0 16px; line-height: 1; font: 700 1rem/1 var(--sans); color: #f5c88d;
}
.gap-choice:hover:not(:disabled), .gap-choice:focus-visible { background: #3c6366; border-color: #f5d7ac; }
.clue-list { display: grid; gap: 7px; margin-bottom: 12px; counter-reset: clue; }
.clue-list:empty { display: none; }
.clue {
  position: relative; min-width: 0; padding: 9px 11px 9px 15px; border-left: 2px solid #c9ad83;
  background: #f3e4c70d; color: #f5efdf; font: 500 .87rem/1.55 var(--sans);
  overflow-wrap: anywhere;
}
#more-clue { margin: 0 0 12px; color: #f1d4a8; border-color: #c3ad88a6; }
.choice-list { display: grid; gap: 8px; }
.person-choice {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 43px; padding: 8px 13px;
  border: 1px solid #b3c5ba; border-radius: 3px; text-align: left;
  background: #e9e7d9; color: #17343a; font: 700 1rem/1.45 var(--sans);
}
.person-choice::before {
  content: ""; width: 10px; height: 10px; flex: 0 0 10px;
  border: 1px solid #82948b; border-radius: 50%; background: #f4ecdd;
}
.person-choice:hover:not(:disabled), .person-choice:focus-visible { background: #fff2d6; border-color: #d9b275; }
.person-choice.is-correct, .person-choice.is-wrong { border-left-width: 4px; }
.person-choice.is-correct { background: #d3e5d9; border-color: #547c6d; }
.person-choice.is-correct::before { color: #245842; content: "✓"; border: 0; background: none; }
.person-choice.is-wrong { background: #efd9cc; border-color: #b7674d; }
.person-choice.is-wrong::before { color: #843e31; content: "×"; border: 0; background: none; }
/* The deck preview and every concealed card share the same printed back. */
.classic-setup {
  display: grid; grid-template-columns: minmax(95px, 160px) minmax(0, 1fr); align-items: center;
  justify-content: center; gap: clamp(20px, 3vw, 46px); max-width: 630px; margin-inline: auto;
  padding: clamp(20px, 3vw, 42px) 0;
}
.deck-preview {
  position: relative; display: grid; place-items: center; width: min(100%, 135px);
  aspect-ratio: 864 / 1184; border-radius: 5px; justify-self: center;
  box-shadow: 3px 3px #263d3c, 4px 4px #d5c296, 6px 6px #29403f, 7px 7px #ae9872;
}
.deck-options { min-width: 0; }
.deck-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.deck-choice {
  display: flex; gap: 8px; align-items: center; justify-content: center; min-height: 44px; padding: 8px;
  border-radius: 3px; border: 1px solid #94aaa5; color: #e6ede6; background: #294d51;
  font: 650 .88rem/1.5 var(--sans); text-align: center;
}
.deck-choice[aria-pressed="true"] { background: #f7ead1; color: #233f42; border-color: #e6c697; }
.deck-choice:hover:not([aria-pressed="true"]) { border-color: #f5e9cf; background: #355b60; }
.deck-description { margin-top: 10px; color: #e5eadf; font-size: .85rem; line-height: 1.65; }
.classic-board {
  display: grid; justify-content: center; align-items: start;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 116px));
  padding: clamp(18px, 2.5vw, 32px) 0; gap: clamp(6px, 1vw, 14px);
}
.classic-board[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 135px)); }
.memory-card {
  display: block; width: 100%; min-width: 0; position: relative; padding: 0; aspect-ratio: 864 / 1184;
  border-radius: 5px; perspective: 850px; transition: transform .15s ease;
}
@media (hover: hover) {
  .memory-card:not(.is-up):not(:disabled):hover { transform: translateY(-3px); }
}
.memory-turn {
  display: block; position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform .38s cubic-bezier(.2,.65,.25,1);
}
.memory-card.is-up .memory-turn { transform: rotateY(180deg); }
.memory-back, .memory-face {
  display: flex; position: absolute; inset: 0; border: 1px solid #d8c395; border-radius: 5px;
  overflow: hidden; align-items: center; justify-content: center;
  background: var(--card-paper); backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 3px 5px #0b202566; transition: visibility 0s linear .18s;
}
.deck-preview, .memory-back { background: #183e35; border: 2px solid #ddc79a; }
.deck-preview::after, .memory-back::after {
  content: ""; position: absolute; inset: 4px; border: 1px solid #a88f65;
  border-radius: 2px; pointer-events: none;
}
.deck-preview img, .memory-back img { display: block; width: 76%; height: auto; object-fit: contain; }
.memory-face img { width: 100%; height: 100%; object-fit: cover; }
.memory-number {
  position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); color: #f3dfb5;
  font: 650 clamp(.625rem, .85vw, .78rem)/1.2 var(--sans); font-variant-numeric: tabular-nums;
}
.memory-face { flex-direction: column; transform: rotateY(180deg); visibility: hidden; }
.memory-card.is-up .memory-back { visibility: hidden; }
.memory-card.is-up .memory-face { visibility: visible; }
.classic-board[data-deck="people"] .memory-face { padding: 6px 5px; }
.classic-board[data-deck="people"] .memory-face img {
  height: 0; min-height: 0; flex: 1 1 auto; object-fit: contain; mix-blend-mode: multiply;
}
.memory-name {
  display: block; width: 100%; min-width: 0; margin-top: 3px; padding-top: 3px; border-top: 1px solid #bbab8e;
  color: var(--ink-dark); text-align: center; overflow-wrap: anywhere; font: 700 clamp(.72rem, 1vw, .95rem)/1.3 var(--sans);
}
.memory-card.is-matched { opacity: 0; pointer-events: none; transition: opacity .28s ease .25s; }
.classic-between {
  padding: clamp(25px, 5vw, 60px) 12px; text-align: center; color: #e6ecdf;
}
.classic-between h3 { color: #f4e2b9; font: 700 clamp(1.25rem, 2.4vw, 1.8rem)/1.5 var(--sans); }
.classic-between p { margin-top: 7px; }
.table-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-top: 15px; border-top: 1px solid #f1f1d13e;
}
.table-tools p { flex: 1 1 140px; color: #e0e7d7; font-size: .81rem; }
.action-row, .modal-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 39px; padding: 7px 15px; border: 1px solid transparent; border-radius: 3px; font: 700 .85rem/1.4 var(--sans); }
.btn.primary { color: #fff9ed; background: var(--petrol); }
.btn.primary:hover:not(:disabled) { background: #2d5559; }
.table .btn.primary { color: #283525; background: #f4c79a; }
.table .btn.primary:hover:not(:disabled) { background: #ffdbb6; }
.btn.subtle { border-color: #a3b29c80; color: #f3f1dc; background: transparent; }
.btn.subtle:hover:not(:disabled) { border-color: #e8edcc; background: #f6f0c511; }
.btn.outline { border-color: #a6ad96; color: var(--petrol); background: var(--paper); }
.btn.outline:hover:not(:disabled) { background: #e8e8d9; border-color: var(--petrol); }
.btn:disabled { opacity: .48; }

.panel { padding: 27px 0 38px; min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: end; gap: 12px; padding: 0 0 20px; }
.panel h2 { margin-top: 5px; font: 750 clamp(1.6rem, 3.2vw, 2.3rem)/1.3 var(--sans); }
#guide-count { color: var(--ink-quiet); font: 600 .86rem/1.4 var(--sans); }
.guide-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 20px; margin: 0 0 16px; }
.guide-filters :is(select, input) { min-width: 100px; }
.guide-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: clamp(12px, 1.7vw, 23px); }
.guide-card {
  position: relative; display: flex; min-width: 0; align-items: stretch; flex-direction: column;
  overflow: hidden; padding: 0; background: #f2ebd9; border: 1px solid var(--line); border-radius: 3px;
  text-align: left; transition: border-color .15s, transform .15s;
}
.guide-card img {
  width: 100%; height: clamp(120px, 14vw, 190px); padding: 9px; object-fit: contain; mix-blend-mode: multiply;
}
.guide-card:not(:disabled):hover { border-color: var(--petrol); transform: translateY(-2px); }
.guide-card .history-portrait, #modal-body .history-portrait,
.classic-board[data-deck="people"] .memory-face .history-portrait { mix-blend-mode: normal; }
#modal-body .portrait-credit { margin: 0 0 14px; color: var(--ink-quiet); font-size: .78rem; overflow-wrap: anywhere; }
.portrait-credit a { color: inherit; text-decoration: underline; text-underline-offset: .15em; }
.guide-caption { display: grid; align-content: start; flex: 1; gap: 4px; border-top: 1px solid var(--line); background: var(--paper); padding: 10px 14px; }
.guide-caption small { color: var(--vermilion); font: 700 .65rem/1.4 var(--sans); letter-spacing: .08em; }
.guide-caption strong { font: 750 1.05rem/1.4 var(--sans); }
.guide-meta { color: var(--ink-quiet); font: 550 .76rem/1.5 var(--sans); }
.guide-card.is-unseen .guide-caption small { color: var(--ink-quiet); }
.history-list { border-top: 1px solid var(--line); }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.history-info { display: grid; flex: 1; }
.history-info strong { font: 700 1.1rem/1.45 var(--sans); }
.history-info small, .history-stats { color: var(--ink-quiet); font-size: .84rem; }
.history-stats { text-align: right; }
.empty-state { padding: clamp(25px, 5vw, 60px) 18px; color: var(--ink-quiet); background: #eeeada; text-align: center; border-bottom: 1px solid var(--line); }
.empty-state h3 { margin: 0 0 8px; color: var(--ink); font: 750 1.23rem/1.5 var(--sans); }
.empty-state p { margin: 0 auto; max-width: 42ch; font-size: .92rem; }
.empty-state .btn { margin: 16px 0 0; }
#modal-body { margin-top: 12px; color: var(--ink-quiet); font-size: .92rem; }
#modal-body img { width: min(100%, 210px); margin: 14px auto; }
#modal-body ul, #modal-body ol { padding-left: 1.3em; margin-top: 10px; }
.modal-actions { justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; }
.footer { display: flex; justify-content: space-between; gap: 10px; padding: 14px 0 24px; border-top: 1px solid var(--line); color: var(--ink-quiet); font: 600 .66rem/1.6 var(--sans); letter-spacing: .065em; }

@media (max-width: 900px) {
  .wrap { width: calc(100% - 44px); }
  .play-layout { grid-template-columns: minmax(172px, .9fr) minmax(0, 2.9fr); gap: 20px; }
  .hero-plate { gap: 0; }
  .guide-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 730px) {
  .wrap { width: calc(100% - 34px); }
  .top-inner { min-height: 56px; gap: 10px; }
  .tabs { gap: clamp(10px, 2.7vw, 20px); }
  .tabs button { font-size: .79rem; }
  .wordmark small { display: none; }
  .hero { grid-template-columns: minmax(0, 1.25fr) minmax(100px, .75fr); min-height: 144px; }
  .hero-copy { padding: 20px 0; }
  .hero h1 { margin: 8px 0; }
  .hero-desc { max-width: 28em; font-size: .82rem; }
  .hero-plate { position: relative; justify-content: center; }
  .hero-plate img { width: min(100%, 155px); height: 146px; margin: 0 auto; }
  .hero-plate figcaption { display: none; }
  .play-layout { display: flex; flex-direction: column; align-items: stretch; gap: 16px; padding-top: 17px; }
  .sidebar { display: contents; }
  .mode-block { order: 0; display: grid; grid-template-columns: minmax(0,1fr) auto;
    grid-template-areas: "heading pool" "modes modes" "copy copy"; gap: 7px 10px;
    align-items: center; border: 0; padding: 0; }
  .mode-block > .kicker { display: none; }
  .mode-block h2 { grid-area: heading; margin: 0; font-size: 1rem; }
  .pool-field { grid-area: pool; justify-self: end; margin: 0; }
  .pool-field select { min-height: 33px; }
  .mode-switch { grid-area: modes; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .mode-switch button { padding-inline: 4px; text-align: center; }
  .mode-desc { grid-area: copy; max-width: none; margin: 0; font-size: .78rem; }
  .table { order: 1; width: 100%; padding: 18px; }
  .table h2 { font-size: 1.59rem; }
  .route-block { order: 2; padding: 6px 0 0; border: 0; }
  .route-block .route { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .route li::before { display: none; }
  .route { margin-top: 8px; }
  .route li { min-height: 45px; padding-bottom: 8px; }
  .panel { padding-top: 20px; }
}
@media (max-width: 510px) {
  .wrap { width: calc(100% - 24px); }
  .wordmark { gap: 6px; font-size: 1.05rem; }
  .brand-mark { width: 25px; height: 25px; font-size: 1.08rem; }
  .top-inner { min-height: 49px; }
  .hero { grid-template-columns: 1.47fr .83fr; min-height: 123px; }
  .kicker { font-size: .6rem; letter-spacing: .1em; }
  .hero-copy .kicker { gap: 6px; font-size: .54rem; }
  .hero-copy .kicker::before { width: 14px; }
  .hero-plate img { max-height: 120px; }
  .hero-desc { font-size: .76rem; }
  .table { padding: 14px 13px; }
  .table-head { align-items: center; gap: 6px; padding-bottom: 12px; }
  .table h2 { font-size: 1.27rem; }
  .metrics > div { padding-inline: 7px; }
  .metrics small { font-size: .59rem; letter-spacing: 0; }
  .metrics b, .metrics > div > span { font-size: .93rem; }
  .table-tools { align-items: flex-start; gap: 9px; padding-top: 12px; }
  .table-tools p { flex: 1 1 100%; font-size: .78rem; }
  .btn { padding: 7px 11px; min-height: 38px; font-size: .78rem; }
  .action-row { gap: 6px; }
  .mode-switch button { min-height: 34px; padding-inline: 5px; font-size: .78rem; }
  .mode-block { gap: 7px; }
  .mode-block h2 { font-size: .94rem; }
  .mode-desc { font-size: .75rem; }
  .challenge-layout { grid-template-columns: minmax(0, 1fr); padding: 14px 0; gap: 16px; }
  .exhibit { position: relative; top: auto; display: grid; grid-template-columns: minmax(64px, 25%) minmax(0,1fr); column-gap: 13px; align-items: center; padding: 12px; }
  .exhibit-label { grid-column: 2; align-self: end; }
  .exhibit-art { grid-column: 1; grid-row: 1 / span 3; margin: 0; height: 90px; padding: 3px; }
  .exhibit h3 { grid-column: 2; margin-top: 5px; padding-top: 4px; font-size: .95rem; }
  .exhibit h3 + p, .exhibit h3 + small { grid-column: 2; }
  .mystery-mark { height: auto; width: min(86%, 67px); font-size: 2rem; }
  .answer-title { margin-bottom: 7px; }
  .route-block .route { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .route li { gap: 8px; }
  .route-copy b { font-size: .86rem; }
  .guide-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .guide-card img { height: 112px; }
  .guide-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .guide-filters label { display: grid; gap: 4px; }
  .guide-filters label:first-child { grid-column: 1 / -1; }
  .guide-filters input[type="search"] { max-width: none; }
  .guide-filters :is(select, input) { min-width: 0; width: 100%; }
  .classic-setup { grid-template-columns: minmax(64px, 28%) minmax(0,1fr); gap: 16px; padding: 20px 0; }
  .deck-switch { gap: 4px; }
  .deck-choice { padding: 6px 3px; min-height: 36px; font-size: .76rem; }
  .deck-description { margin-top: 7px; font-size: .75rem; }
  .classic-board[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 89px)); }
  .classic-board[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 84px)); }
  .classic-board[data-count="8"], .classic-board[data-count="10"], .classic-board[data-count="12"] { grid-template-columns: repeat(4, minmax(0, 85px)); }
  .memory-number { bottom: 7%; }
  .memory-name { font-size: .69rem; }
  .guide-meta { font-size: .72rem; }
  .guide-caption { padding: 8px; }
  .guide-caption strong { font-size: .9rem; }
  .guide-caption small { font-size: .58rem; }
  .history-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; }
  .history-info { grid-column: 1; }
  .history-stats { grid-column: 1; text-align: left; }
  .history-row .btn { grid-column: 2; grid-row: 1/3; }
}
@media (max-width: 370px) {
  .table-head { flex-wrap: wrap; row-gap: 8px; }
  .classic-board[data-deck="people"][data-count="8"], .classic-board[data-deck="people"][data-count="10"], .classic-board[data-deck="people"][data-count="12"] { grid-template-columns: repeat(3, minmax(0, 87px)); }
  .memory-back, .memory-face { border-radius: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .memory-back, .memory-face { transition-delay: 0s; }
}

#export-run, #export-paused { margin-top: 16px; }
#modal-body .profile-meta { color: var(--vermilion); font-weight: 700; letter-spacing: .04em; }
#modal-body .result-detail p:nth-of-type(2) { color: var(--ink); font: 700 1.1rem/1.65 var(--sans); }

.source-link {
  display: inline-block; margin-top: 12px; padding-block: 4px; color: var(--vermilion);
  font: 700 .83rem/1.5 var(--sans); text-decoration: underline; text-underline-offset: .18em;
  overflow-wrap: anywhere;
}
.source-link:hover { color: var(--ink-dark); }

.guide-filters input { min-width: 0; max-width: 15em; font-family: var(--sans); }

.match-view { display: grid; grid-template-columns: minmax(170px, .88fr) minmax(0, 3.23fr); gap: clamp(22px, 3vw, 48px); align-items: start; }
.match-rules h2 { font-size: 1.3rem; }
.match-rules p { margin-top: 10px; font-size: .89rem; line-height: 1.8; color: var(--ink-quiet); }
.match-table h3 { color: #fff7e8; font-size: clamp(1.35rem, 2.3vw, 2rem); line-height: 1.4; }
.match-table .table-head { min-height: 52px; }
.match-question-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 20px 0 8px; color: #f4d6aa; font-size: .86rem; }
#match-timer { font-variant-numeric: tabular-nums; }
#match-clue { margin: 0 0 18px; max-width: 37em; color: #fff7e8; font-size: clamp(1.08rem, 2vw, 1.45rem); font-weight: 650; line-height: 1.65; }
#match-status { margin: 17px 0; color: #f2f0df; }
#match-portrait { display: flex; align-items: center; gap: 13px; margin: 0 0 16px; padding-top: 12px; border-top: 1px solid #f1f1d13e; }
#match-portrait img { flex: none; width: 82px; height: 98px; object-fit: contain; }
#match-portrait figcaption { min-width: 0; overflow-wrap: anywhere; font: 450 .77rem/1.55 var(--sans); color: #e0e7d7; }
#match-portrait strong, #match-portrait-credit { display: block; }
#match-portrait strong { color: #fff7e8; font-size: 1rem; }
#match-portrait a[href] { color: #f4d6aa; text-underline-offset: .15em; }
#match-connection { margin: 12px 0; color: #ffdbb6; }
#match-options .is-selected { outline: 2px solid #f5cf98; outline-offset: 1px; }
#match-online-link { text-decoration: none; }
@media (max-width: 730px) {
  .match-view { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .match-rules p { margin-top: 4px; }
}
@media (max-width: 510px) {
  .top-inner { flex-wrap: wrap; gap: 0 12px; }
  .top-inner .wordmark { min-height: 42px; }
  .tabs { flex: 1 0 auto; justify-content: space-between; gap: 10px; }
  .tabs button { min-height: 42px; }
}
