:root {
  color-scheme: dark;
  --paper: #101923;
  --ink: #edf3f6;
  --muted: #a8bac8;
  --line: #364a5b;
  --green: #90dfcd;
  --gold: #edc887;
  --red: #ff9d99;
  --panel: #162330;
  --well: #111e29;
  --shadow: 0 12px 34px #040a1340;
  --stone-river: url('./assets/stone-river.png');
  font-family: 'Microsoft YaHei UI', 'Microsoft YaHei', system-ui, sans-serif;
  font-size: 16px;
}

body {
  background: radial-gradient(ellipse at 30% 0%, #203747 0, transparent 42rem), var(--paper);
}

button, input, select, textarea {
  border-color: var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #213241;
}

button:hover:enabled { border-color: #72a3b4; background: #2b4352; }
button.primary, .masthead nav .outline {
  border-color: var(--green);
  background: var(--green);
  color: #102824;
  font-weight: 750;
}
button.primary:hover:enabled, .masthead nav .outline:hover:enabled { background: #b7f2e3; }
button.primary:disabled { background: #304752; border-color: #466070; color: #c5d2dc; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.masthead, main, footer { max-width: 1450px; }
.masthead { padding-block: 15px; }
.brand { font-size: 1.3rem; letter-spacing: .14em; }
.brand-mark { color: var(--gold); font-size: 2.1rem; }
.brand small { color: var(--muted); font-size: .65rem; letter-spacing: .15em; }
.masthead nav { gap: 7px; }
.masthead nav button { font-size: .85rem; min-height: 42px; }
footer { justify-content: flex-end; font-size: .75rem; }
footer a { color: var(--gold); }

.welcome { gap: clamp(26px, 5vw, 88px); grid-template-columns: minmax(0, 1fr) minmax(420px, 560px); }
.welcome-copy { max-width: none; padding: 14px 0; }
.welcome-copy::after {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  margin-top: 20px;
  background: var(--stone-river) center / cover;
  border: 1px solid #aa875e8c;
  border-radius: 12px;
  box-shadow: var(--shadow);
  content: '';
}
.welcome-copy .eyebrow, .welcome-copy .hero-symbol, .welcome-copy p:last-child { display: none; }
.welcome h1 {
  color: #f3ead8;
  font-size: clamp(2.5rem, 5.2vw, 4.8rem);
  font-weight: 700;
  letter-spacing: .12em;
  line-height: 1.22;
  margin: 0 0 18px;
}
.welcome h1 em { color: var(--gold); font-size: .85rem; margin-top: 20px; letter-spacing: .25em; }
.welcome p { color: var(--muted); font-size: .95rem; line-height: 1.8; }
.sun-art { display: none; }
.setup { padding: clamp(16px, 3vw, 30px); border-color: var(--line); border-radius: 16px; background: var(--panel); }
.setup::before { display: none; }
.setup h2 { font-size: 1.4rem; letter-spacing: .06em; }
.form-group > label { color: var(--muted); font-size: .88rem; letter-spacing: .04em; }
.setup .segmented { gap: 6px; }
.setup .segmented button { min-height: 42px; font-size: .84rem; }
.segmented button.active, .stage-choice.active { border-color: var(--green); background: #263f46; color: #e8fff9; }
.stage-choice.active::after { background: var(--green); }
.stage-choice { padding: 10px 8px; min-height: 66px; font-size: .81rem; }
.stage-choice b { color: var(--gold); }
.stage-choice small { font-size: .67rem; }
.setup input, .setup select { background: var(--well); }
.setup input[type=checkbox] { accent-color: var(--green); }
.setup .setup-start, .setup .resume { font-size: .93rem; min-height: 46px; }
.setup .resume { color: var(--green); background: var(--well); }
.setup .setup-hint { font-size: .81rem; margin-top: 11px; }
.setup .online-entry, .setup [data-field="mode"][data-value="online"] { display: none; }
.setup details summary { font-size: .8rem !important; }

.title-row { padding-block: 3px 13px; margin-bottom: 13px; }
.title-row h1 { font-size: clamp(1.65rem, 3.4vw, 2.65rem); letter-spacing: .07em; }
.title-sub, .mission-text { font-size: .88rem; color: var(--muted); }
.eyebrow { font-size: .69rem; color: var(--gold); letter-spacing: .11em; }
.toolbar button, .toolbar .pill { font-size: .76rem; }
.pill.green { border-color: #456e72; background: #1d3a3d; color: #b4f1e2; }
.game-layout, .sidebar { gap: 16px; }
.table, .side-panel, .hand-body, .player, .turn-gate, .story-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.table { background: linear-gradient(155deg, #1c3241, #152431 58%); }
.table-heading { font-size: .78rem; letter-spacing: .06em; color: var(--ink); }
.table-heading > span:last-child { color: var(--gold); }
.revival, .hand-cards, .mini-hand { scrollbar-color: #648092 transparent; }
.revival { color: var(--muted); background: #0d192664; }
.revival-empty, .field-label small { color: var(--muted); font-size: .76rem; }
.field-label b { color: var(--ink); font-size: .88rem; }
.field-rule:hover:enabled { background: #63889223; }
.slot.empty { background: #0e1e2bba; border-color: #4b6475; }
.slot.empty::before { color: #a6bfce; }
.slot.legal { background: #254741; border-color: var(--green); outline: 1px solid var(--green); outline-offset: 1px; }
.slot.legal::after { color: var(--green); }
.sleeping, .bonus-slot {
  background: linear-gradient(155deg, #302d2a, #1a2c3a 68%);
  border-color: #857054;
  color: var(--gold);
}
.sleeping::before { border-color: #c6a26880; }
.sleeping .name, .sleeping small { color: #e8dfd0; }
.eternal-chip, .eternal-chip.cursed { background: #382936; border-color: #9b6575; color: #f5d9dc; }
.eternal-chip.blessed { background: #1d3939; border-color: #5a938c; color: #c1eee3; }
.curse-label { color: #eab6b9; }
.jewel-tag { color: var(--green); }
.river { position: relative; isolation: isolate; }
.river::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: 0 0 9px 9px;
  background: linear-gradient(#152431 0%, #152431d6 34%, #152431a8 100%), var(--stone-river) center bottom / cover;
  content: '';
}
.river-bonus { color: var(--gold); background: var(--well); border-color: var(--line); }
.river-bonus.danger { color: var(--red); background: #402d36; }
.stage-extra, .pending-banner { background: #1b343e; color: var(--ink); }
.pending-banner { border-bottom: 1px solid #587d83; font-size: .86rem; }
.hp-track { background: #304859; }
.puzzle-grid { background: #445868; }
.puzzle-cell { background: #152431; }

.hand-panel { margin-top: 16px; }
.hand-top { margin-bottom: 7px; }
.hand-top h2 { font-size: 1.1rem; }
.hand-top > small { font-size: .8rem; }
.hand-body { box-shadow: var(--shadow); }
.hand-cards > .card { flex-basis: 73px; width: 73px; }
.hand-actions { flex-basis: 156px; }
.hand-actions > button { font-size: .75rem; }
.action-note { color: var(--muted); font-size: .8rem; height: auto; min-height: 36px; margin-top: 7px; }
.card:not(.number-card) { background: #ebeadf; color: #273445; }
.card.rare { background: #f9e6b9; color: #6a4715; }
.card.skull { background: #312d43; color: #ffeddb; border-color: #a394ac; }
.card:not(.number-card):hover:enabled { color: #182536; background: #fff4dc; }
.card.skull:hover:enabled { color: #fff0df; background: #504760; }
.card.selected, .number-card.selected { outline: 2px solid var(--gold); outline-offset: 3px; }
.mini-hand .card { border-radius: 4px; }
.player { padding-inline: 10px; }
.player.active { border-color: #65a9a4; background: #1c373e; }
.player-title { height: auto; min-height: 20px; font-size: .86rem; }
.player-title > b { color: var(--ink) !important; }
.player-title > span, .player-meta { font-size: .72rem; }
.player-meta { min-height: 17px; }
.disc-btn, .player-details, .task-item { font-size: .76rem; }
.task-item.done { background: #233b42; color: #b7ebdc; }
.turn-gate { margin-top: 17px; padding: 28px 16px; }
.turn-gate p { font-size: .9rem; }
.starter-setup .choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.starter-setup .choices button { min-height: 44px; margin: 0; font-size: .84rem; }
.starter-cards { justify-content: center; }

.side-panel h2 { font-size: 1.2rem; }
.side-panel > .eyebrow { display: none; }
.goal-line, .jewel-recipe, .resources, .last-log { font-size: .81rem; }
.goal-line.done { color: var(--green); }
.progress-icon { background: var(--well); color: var(--muted); }
.progress-icon.earned, .jewel-recipe.available { background: #294742; border-color: var(--green); color: #cefbeb; }
.jewel-recipe { background: var(--well); }
.jewel-recipe:disabled { opacity: .73; }
.jewel-recipe.used { color: #a1aeb8; }
.jewel-recipe .gem { color: var(--gold); }
.last-log.recent-log { height: auto; min-height: 3.1em; line-height: 1.55; }
.story-bar { padding: 8px 12px; color: var(--muted); }
.story-bar, .story-bar button { font-size: .76rem; }
.status-banner { background: #1b3b40; }
.status-banner.lost { background: #402d36; }
.status-banner p { font-size: .86rem; }

dialog { background: var(--panel); color: var(--ink); border-color: var(--line); border-radius: 14px; }
dialog::backdrop { background: #070c15bd; }
.modal-inner p, .modal-inner ul, .modal-inner ol { color: var(--muted); font-size: .91rem; line-height: 1.7; }
.modal-inner a { color: var(--gold); }
.modal-inner .choices button, .modal-inner .modal-actions button { font-size: .84rem; min-height: 42px; }
.modal-title button { color: var(--ink); min-width: 44px; min-height: 44px; }
.log-line, .card-code { font-size: .81rem; }
#toast { background: #edf3f6; color: #152431; font-size: .9rem; }

@media (max-width: 1000px) {
  .welcome { grid-template-columns: minmax(0, 1fr); max-width: 640px; margin-inline: auto; }
  .welcome-copy { padding: 12px 0 0; text-align: center; max-width: none; }
  .welcome h1 { margin-bottom: 9px; }
  .welcome h1 br { display: none; }
  .welcome-copy::after { max-height: 285px; margin-inline: auto; }
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side-panel { margin: 0; }
}

@media (max-width: 650px) {
  html { scrollbar-gutter: auto; }
  .masthead { padding-block: 10px; }
  .masthead nav { flex-wrap: wrap; gap: 4px; }
  .masthead nav button, .masthead nav #helpBtn { min-height: 44px; font-size: .75rem; max-width: none; }
  .brand { font-size: 1.1rem; }
  .brand-mark { font-size: 1.6rem; }
  .brand small { font-size: .56rem; }
  .welcome { gap: 18px; padding-block: 2px 8px; }
  .welcome h1 { font-size: 2rem; letter-spacing: .04em; }
  .welcome h1 em { font-size: .72rem; margin-top: 8px; }
  .welcome-copy p { display: none; }
  .welcome-copy::after { height: clamp(106px, 30vw, 170px); margin-top: 12px; background-position: center 58%; }
  .stage-choice { padding-block: 7px; }
  .title-sub { font-size: .8rem; }
  .table-heading { font-size: .71rem; }
  .field-rule small, .river .field-label small { font-size: .64rem; }
  .river { grid-template-columns: 58px minmax(0, 1fr) 43px; }
  .field-track .number-card .card-num { font-size: clamp(19px, 6.2vw, 35px); }
  .sleeping .name { font-size: .59rem; }
  .sleeping small { font-size: .52rem; }
  .hand-body { display: grid; height: auto; min-height: 170px; padding: 8px 10px; }
  .hand-cards { height: 103px; min-height: 103px; }
  .hand-cards > .card { flex-basis: 66px; width: 66px; }
  .hand-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: auto; height: auto; }
  .hand-actions > button { font-size: .73rem; }
  .hand-actions > button:first-child { grid-column: auto; }
  .hand-top > small { font-size: .72rem; }
  .action-note { font-size: .77rem; }
  .player-title { font-size: .72rem; }
  .player-title > span, .player-meta { font-size: .65rem; }
  .disc-btn { font-size: .7rem; min-height: 44px; }
  .sidebar { grid-template-columns: minmax(0, 1fr); }
}
