:root {
  color-scheme: dark;
  --ink: #101f1d;
  --panel: #182b26;
  --line: #40564a;
  --paper: #f5ecd9;
  --quiet: #bbc9b9;
  --gold: #e8bd76;
  --gold-light: #f3d99e;
  --serif: Iowan Old Style, Palatino Linotype, Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 0;
  background: radial-gradient(ellipse 105% 42% at 50% 0%, #23382e, transparent 77%), var(--ink);
  color: var(--paper);
  font: 15px/1.5 var(--sans);
}
h1, h2, h3, p, dl, dd { margin: 0; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
#app-shell button, #app-shell button *,
#game .pile, #game .pile *,
.card-flight, .card-flight * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }

.wrap { width: min(1120px, calc(100% - 64px)); margin: 0 auto; }
.masthead { border-bottom: 1px solid #495b4c; background: #142621a8; }
.header-inner { min-height: 70px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 9px; font: 700 24px/1 var(--serif); white-space: nowrap; }
.brand span { color: var(--gold-light); font-weight: 400; }
.brand img { margin-right: 3px; }
.header-actions { display: flex; gap: 7px; align-items: center; white-space: nowrap; }

.button {
  min-height: 44px;
  padding: 8px 13px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--paper);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
}
.button > [aria-hidden="true"] { font-size: 17px; line-height: 1; }
.button.secondary { background: #23382e; border-color: #506354; }
.button.language-toggle { min-width: 44px; color: var(--gold-light); border-color: #77694a; }
.button.primary { background: var(--gold); color: #20271c; border-color: var(--gold-light); }
.button.reward-button { color: var(--gold-light); background: #273b30; border-color: #77694a; }
.button:disabled { opacity: .55; }
@media (hover: hover) {
  .button.secondary:hover:not(:disabled) { background: #334c3d; }
  .button.primary:hover:not(:disabled) { background: var(--gold-light); }
  .button.reward-button:hover:not(:disabled) { background: #3c4e3b; }
}
.button .question-icon {
  display: inline-grid; place-items: center; width: 17px; height: 17px;
  border: 1px solid #a8b29e; border-radius: 50%; font-size: 11px;
}

.intro { display: flex; justify-content: space-between; align-items: end; gap: 16px; padding: 24px 0 22px; }
.kicker {
  color: var(--gold); font-size: 10px; font-weight: 800;
  letter-spacing: .18em; text-transform: uppercase;
}
h1 {
  margin-top: 3px;
  font: 400 clamp(37px, 5.6vw, 63px)/1.03 var(--serif);
  letter-spacing: -.045em;
}
.lede { color: var(--quiet); font-size: 14px; margin-top: 8px; }
.start { min-width: 147px; margin-bottom: 2px; padding-inline: 17px; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 256px; gap: 16px; align-items: start; }
.game-board, .deal-panel, .wild-panel { border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.game-board, #result {
  --landscape: url("assets/valley.svg");
  --felt-base: #466350;
  --scene-panel: #23382d;
  --scene-rule: #647b62;
  --scene-accent: #e5c68e;
}
.game-board { min-width: 0; box-shadow: 0 14px 42px #08171155; }
:is(.game-board, #result)[data-theme="ridge"] {
  --landscape: url("assets/pine-ridge.svg");
  --felt-base: #365865;
  --scene-panel: #21363b;
  --scene-rule: #63818a;
  --scene-accent: #c4ddde;
}
:is(.game-board, #result)[data-theme="dusk"] {
  --landscape: url("assets/last-light.svg");
  --felt-base: #533840;
  --scene-panel: #352b34;
  --scene-rule: #86665f;
  --scene-accent: #f5bf8c;
}
.table-brief { padding: 11px 14px; border-radius: 12px 12px 0 0; background: var(--scene-panel); }
.table-brief-top { display: flex; justify-content: space-between; align-items: center; gap: 5px 10px; }
.table-brief h2 { color: var(--paper); font: 600 24px/1.1 var(--serif); }
#deal-strategy { margin-top: 4px; color: #e1e7d8; font-size: 12px; line-height: 1.35; }
.peak-progress { display: flex; gap: 7px; align-items: center; flex: 0 0 auto; font-size: 11px; color: var(--scene-accent); }
.peak-markers { display: flex; gap: 3px; }
.peak-markers span {
  width: 19px; height: 19px; display: grid; place-items: center; border: 1px solid var(--scene-rule);
  border-radius: 4px; font-size: 13px; font-weight: 750; line-height: 1;
}
.peak-markers .cleared-peak { color: #1e2e25; background: var(--scene-accent); border-color: var(--scene-accent); }
.peak-count strong { font-variant-numeric: tabular-nums; }
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  min-height: 58px; padding: 9px 0; background: #1b3029; border-top: 1px solid #40564a;
}
.stats > div { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.stats > div + div { border-left: 1px solid #43594b; }
.stats dt, .pile-label { font-size: 11px; font-weight: 700; color: var(--quiet); }
.stats dd { color: var(--gold-light); font: 600 21px/1.03 var(--serif); font-variant-numeric: tabular-nums; }

.felt {
  container-type: inline-size;
  background: linear-gradient(180deg, #13231e14, #0c1e1b32), var(--landscape) center / cover, var(--felt-base);
  border-block: 1px solid var(--scene-rule);
  padding: 20px min(3%, 26px) 11px;
}
.tableau {
  container-type: inline-size; position: relative; isolation: isolate;
  width: min(100%, 690px); margin: 0 auto;
  height: clamp(142px, 36cqw, 247px);
}
.table-card {
  position: absolute;
  top: calc(var(--row) * clamp(30px, 7cqw, 48px));
  left: calc((var(--column) * 10%) + 5%);
  z-index: calc(1 + var(--row));
  width: 9.35%;
  aspect-ratio: 7 / 10;
  transform: translateX(-50%);
  padding: 0;
}
.table-card.removed { opacity: 0; pointer-events: none; }
.table-card.dealt { animation: deal-in .24s ease-out; animation-delay: calc(var(--row) * 20ms + var(--column) * 5ms); }
.table-card.flipped { animation: turn-card .23s ease-out; }
@keyframes deal-in { from { filter: brightness(.76); } }
@keyframes turn-card { from { filter: brightness(.64); } }


.card-face, .card-back, .pile-empty {
  border: 1px solid #e2d3ab;
  border-radius: clamp(4px, 1cqw, 9px);
  box-shadow: 0 3px 4px #071c1680, 0 0 0 1px #263f35;
}
.card-face {
  position: relative;
  display: block;
  overflow: hidden;
  background: linear-gradient(150deg, #fff7e8, #ecdfc3);
  color: #172b24;
  font-family: var(--serif);
  text-align: left;
}
.table-card.card-face { position: absolute; }
.card-face.card-flight {
  position: fixed; z-index: 20; pointer-events: none; margin: 0;
  box-shadow: 0 6px 14px #08171178;
}
.card-flight .card-rank { font-size: clamp(16px, 4.5vw, 23px); }
.card-flight .card-pip { font-size: clamp(19px, 5.5vw, 30px); }
.card-face.red { color: #9a302b; }
.card-face::before { content: ''; position: absolute; inset: 3px; border: 1px solid #9b825b44; border-radius: 5px; pointer-events: none; }
.card-back {
  background: #243f35 url("assets/card-back.svg") center / 100% 100% no-repeat;
  border-color: #ad9665;
}
.card-rank {
  position: absolute; left: 12%; top: 9%;
  font-size: clamp(13px, 3.3cqw, 24px);
  line-height: 1; font-weight: 800; font-variant-numeric: lining-nums;
}
.card-corner { position: absolute; left: 13%; top: 36%; font-size: clamp(9px, 1.8cqw, 13px); line-height: 1; }
.card-pip { display: none; position: absolute; right: 9%; bottom: 5%; font-size: clamp(16px, 4.4cqw, 33px); line-height: 1; opacity: .89; }
.card-pips { position: absolute; inset: 29% 9% 9% 19%; pointer-events: none; }
.card-pips > span {
  position: absolute; left: var(--pip-x); top: var(--pip-y);
  transform: translate(-50%, -50%) rotate(var(--pip-turn));
  font-size: clamp(8px, 1.55cqw, 12px); line-height: 1;
}
.card-engraving {
  position: absolute; right: 7%; bottom: 7%; width: 61%; height: 77%;
  pointer-events: none;
}
.card-ace-suit {
  position: absolute; top: 54.5%; left: 62.5%;
  transform: translate(-50%, -50%); font-size: clamp(12px, 2.85cqw, 19px); line-height: 1;
}
.hinted { outline: 2px solid #ffe3a2; outline-offset: 1px; box-shadow: 0 0 14px 5px #ffe3a292; }
.table-card.tutorial-card { outline: 2px solid #ffe3a2; outline-offset: 1px; box-shadow: 0 0 12px 3px #ffe3a273; }
.table-card.misplayed-card { outline: 2px solid #e48b85; outline-offset: 1px; }
.table-card.tutorial-card::after,
.table-card.misplayed-card::after {
  position: absolute; left: 9%; bottom: 7%; display: grid; place-items: center;
  width: clamp(12px, 3cqw, 18px); aspect-ratio: 1;
  border-radius: 50%; font: 800 clamp(11px, 2.7cqw, 15px)/1 var(--sans); pointer-events: none;
}
.table-card.tutorial-card::after { content: '›'; color: #1c2b21; background: #efc77f; }
.table-card.misplayed-card::after { content: '×'; color: #fff5ec; background: #972d29; }
.table-card.tutorial-card:focus-visible,
.table-card.misplayed-card:focus-visible { outline-offset: 3px; }
.table-card.wild-eligible {
  outline: 2px solid #eac7fa; outline-offset: 0;
  box-shadow: 0 0 0 1px #684779, 0 0 10px #eac7fa88;
}
.table-card.wild-eligible::after {
  content: '✦'; position: absolute; left: 10%; bottom: 7%;
  color: #633779; font: 800 clamp(10px, 2.8cqw, 16px)/1 var(--sans); pointer-events: none;
}
.table-card.wild-eligible:focus-visible { outline-offset: 3px; }
@media (hover: hover) {
  .table-card.card-face:not(:disabled):not(.removed):hover,
  .draw:not(:disabled):hover { filter: brightness(1.16); }
}
.dealt[disabled], .card-face[disabled] { opacity: 1; }
.table-card.removed[disabled] { opacity: 0; }

.piles { display: flex; justify-content: center; align-items: start; gap: clamp(25px, 6cqw, 51px); }
.pile { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 77px; }
.draw, .waste { width: clamp(43px, 10cqw, 56px); aspect-ratio: 7 / 10; padding: 0; }
.draw { position: relative; box-shadow: -3px 3px 0 -1px #8a835c, -5px 5px 0 -1px #234237, 0 6px 9px #0b241a8c; }
.draw.cooling { opacity: .58; }
.pile-label { color: #f2edda; text-shadow: 0 1px 3px #0b1e18; }
.stock-count {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  color: #28261a; background: var(--gold-light); border: 1px solid #f5e2b2; border-radius: 7px;
  line-height: 1; min-width: 25px; padding: 4px 3px;
  font-size: 12px; font-weight: 800;
}
.waste .card-rank { font-size: clamp(18px, 3.3cqw, 24px); }
.waste .card-pip { font-size: clamp(20px, 4.4cqw, 29px); }
.pile-empty { background: #19382ca6; border: 1px dashed #b9ad7b; box-shadow: none; }
.pile-empty .stock-count { color: var(--quiet); background: transparent; border: 0; }
.waste.fresh { animation: reveal .19s ease-out both; }
.waste.wild-fresh { animation: reveal .19s ease-out both, wild-confirm .55s ease-out; }
@keyframes reveal { from { opacity: .45; transform: translateY(-3px); } }
@keyframes wild-confirm {
  0%, 28% { box-shadow: 0 0 0 3px #eac7fa, 0 0 20px 5px #eac7fac2; }
  100% { box-shadow: 0 3px 4px #071c1680, 0 0 0 1px #263f35; }
}

.table-footer {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 12px; align-items: center; padding: 11px 14px;
}
.table-status { display: grid; align-content: center; gap: 3px; min-height: 55px; }
#feedback { color: #e4e8d9; font-size: 12px; line-height: 1.4; }
.wild-status {
  width: fit-content; max-width: 100%; align-self: center; padding: 3px 7px;
  border-radius: 5px; font-size: 12px; line-height: 1.25; font-weight: 750;
}
.wild-status[data-state="ready"] { color: #faf0ff; background: #50355d; border: 1px solid #bd9bcf; }
.wild-status[data-state="spent"] { color: #dfd5e4; background: #303031; border: 1px solid #5c5060; }
.wild-status > [aria-hidden="true"] { margin-right: 2px; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-actions .button { padding-inline: 11px; }
.table-actions .button > [aria-hidden="true"] { color: var(--gold-light); }
.table-actions .button.primary > [aria-hidden="true"] { color: inherit; }

.game-side { display: grid; gap: 12px; }
.deal-panel, .wild-panel { padding: 15px; }
.game-side h2 {
  font: 600 22px/1.1 var(--serif);
  letter-spacing: -.015em;
}
.deals { display: grid; gap: 7px; margin-top: 12px; }
.deal-option {
  display: flex; align-items: center; align-self: stretch; gap: 10px; min-height: 55px; width: 100%;
  text-align: left; color: var(--paper); background: #20352c;
  border: 1px solid #42594b; border-radius: 8px; padding: 7px 9px;
}
.deal-option[aria-pressed="true"] { border-color: #ae9461; background: #304436; }
@media (hover: hover) { .deal-option:hover { background-color: #33493a; } }
.deal-number {
  display: grid; place-items: center; flex: 0 0 28px; height: 28px;
  border-radius: 50%; color: var(--gold-light); border: 1px solid #798063; font: 600 14px/1 var(--serif);
}
.deal-copy { display: grid; flex: 1; gap: 1px; min-width: 0; }
.deal-copy strong { font-size: 13px; line-height: 1.2; }
.deal-copy small { font-size: 10px; color: var(--quiet); }
.deal-finished { color: var(--gold-light); font-size: 14px; }
.wild-heading { display: flex; align-items: start; gap: 9px; }
.wild-icon { color: var(--gold-light); font-size: 23px; line-height: 1; }
.wild-heading p { color: var(--quiet); font-size: 12px; margin-top: 4px; }
.wild-panel .button { width: 100%; margin-top: 11px; }

.field-guide {
  border-top: 1px solid var(--line); margin-top: 25px; padding: 19px 0 32px;
  display: grid; grid-template-columns: 1fr 1.25fr; gap: clamp(18px, 4vw, 54px);
}
.field-guide h2 { font: 400 30px/1.05 var(--serif); margin-top: 3px; }
.field-guide h3 { color: var(--gold-light); font: 600 18px/1.15 var(--serif); }
.field-guide p:not(.kicker) { color: var(--quiet); font-size: 13px; max-width: 46ch; margin-top: 6px; }
.tips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding-top: 9px; }

dialog {
  width: min(430px, calc(100% - 28px)); max-height: calc(100% - 28px); overflow-y: auto;
  background: #20362c; border: 1px solid #927f55; border-radius: 14px;
  color: var(--paper); box-shadow: 0 18px 68px #081a15ba; padding: 18px 20px 20px;
}
dialog::backdrop { background: #091713c9; }
.dialog-header { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 7px; }
.dialog-header h2 { font: 400 30px/1.13 var(--serif); letter-spacing: -.02em; }
.close {
  flex: 0 0 44px; width: 44px; height: 44px; padding: 0;
  border-radius: 8px; border: 1px solid #647360; background: #2a4337;
  color: var(--paper); font-size: 24px; line-height: 1;
}
dialog p, .rules-list { color: #d7e1d1; font-size: 14px; }
.rules-list { padding-left: 21px; margin: 0 0 10px; }
.rules-list li + li { margin-top: 6px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 17px; }
.demo-note { color: var(--gold-light); font-weight: 700; margin: 0 0 8px; }
.result-wild-note { margin-top: 10px; color: #f6ddff; font-weight: 700; }
.result-review { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.result-review > div { padding: 8px 10px; border-radius: 7px; border: 1px solid #566d5c; background: #273e32; }
.result-review dt { color: var(--quiet); font-size: 12px; }
.result-review dd { color: var(--gold-light); font: 600 23px/1.13 var(--serif); }

@media (max-width: 950px) {
  .wrap { width: calc(100% - 40px); }
  .game-layout { grid-template-columns: minmax(0, 1fr) 218px; gap: 13px; }
  .table-footer { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .game-side { grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); align-items: start; }
  .wrap { width: calc(100% - 28px); }
  .field-guide { grid-template-columns: 1fr; }
  .tips { padding-top: 0; }
}
@media (max-width: 480px) {
  .wrap { width: calc(100% - 22px); }
  .header-inner { min-height: 59px; gap: 6px; padding-block: 5px; }
  .header-actions { gap: 5px; }
  .brand { font-size: clamp(16px, 4.8vw, 20px); gap: 5px; }
  .brand img { width: 31px; height: 31px; margin-right: 1px; }
  .masthead .button { padding-inline: 8px; font-size: 12px; }
  .masthead .question-icon { display: none; }
  .intro { display: grid; justify-content: stretch; gap: 9px; padding: 16px 0 12px; }
  h1 { font-size: clamp(34px, 9vw, 42px); }
  .lede { margin-top: 5px; font-size: 13px; }
  .start { justify-self: start; }
  .stats { min-height: 48px; padding-block: 7px; }
  .stats dd { font-size: 19px; }
  .table-brief { padding: 8px 10px; }
  .table-brief h2 { font-size: 20px; }
  .felt { padding: 13px 1.3% 9px; }
  /* Three vertical steps, the 7:10 card height, then a visible gap before the piles. */
  .tableau { height: calc(3 * clamp(30px, 7cqw, 48px) + 13.5cqw + 16px); }
  .table-card { width: 9.45%; }
  .card-face::before { inset: 2px; border-radius: 3px; }
  .card-rank { font: 750 14px/1 var(--sans); top: 9%; }
  .waste .card-rank { font-family: var(--serif); }
  .card-corner { display: none; }
  .card-pip { display: block; right: 11%; bottom: 7%; }
  .card-pips, .card-engraving, .card-ace-suit { display: none; }
  .piles { gap: 24px; }
  .draw, .waste { width: 48px; }
  .table-footer { padding: 8px 10px 10px; }
  .table-actions .button { flex: 1 0 auto; }
  .game-side { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .deals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .deal-panel, .wild-panel { padding: 11px; }
  .deal-option { display: grid; align-content: start; gap: 4px; padding: 7px; position: relative; }
  .deal-finished { position: absolute; top: 9px; right: 9px; }
  .deal-number { width: 22px; height: 22px; }
  .wild-panel .button { width: auto; }
  .field-guide { margin-top: 19px; padding-top: 15px; }
  .tips { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; }
}

/* Campaign navigation and the five chapter palettes. */
.intro-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 0 0 auto; }
.intro-actions .start { margin-bottom: 0; }
.level-route {
  color: var(--scene-accent); font-weight: 750; font-size: 10px;
  letter-spacing: .075em; margin-bottom: 3px;
}
.level-notes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, .72fr); gap: 6px 13px; margin-top: 4px; }
.level-notes #deal-strategy { margin: 0; }
.level-goal { color: var(--scene-accent); font-size: 11px; line-height: 1.4; font-weight: 700; align-self: center; }
:is(.game-board, #result)[data-theme="pass"] {
  --landscape: url("assets/echo-pass.svg");
  --felt-base: #52646b;
  --scene-panel: #2c383a;
  --scene-rule: #798a86;
  --scene-accent: #e1d5ae;
}
:is(.game-board, #result)[data-theme="summit"] {
  --landscape: url("assets/star-summit.svg");
  --felt-base: #383b56;
  --scene-panel: #2a3048;
  --scene-rule: #717995;
  --scene-accent: #dde1fa;
}
.route-panel { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.route-panel-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.route-panel-top strong { color: var(--gold-light); font-size: 12px; font-variant-numeric: tabular-nums; }
#trail-progress {
  display: block; width: 100%; height: 5px; border: 0; border-radius: 10px; margin: 10px 0 11px;
  overflow: hidden; background: #30473b; color: var(--gold);
}
#trail-progress::-webkit-progress-bar { background: #30473b; }
#trail-progress::-webkit-progress-value { background: var(--gold); }
#trail-progress::-moz-progress-bar { background: var(--gold); }
.chapter-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chapter-link, .chapter-option { --chapter-color: #d8b97b; --chapter-bg: #2d3c30; }
[data-chapter="ridge"] { --chapter-color: #b4d9df; --chapter-bg: #263e43; }
[data-chapter="pass"] { --chapter-color: #ece0b4; --chapter-bg: #3c4742; }
[data-chapter="dusk"] { --chapter-color: #edb18a; --chapter-bg: #413238; }
[data-chapter="summit"] { --chapter-color: #d1d9fa; --chapter-bg: #323949; }
.chapter-link {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center;
  text-align: start; width: 100%; min-height: 51px; padding: 6px 8px;
  color: var(--paper); border: 1px solid #4c5d51; border-radius: 7px; background: var(--chapter-bg);
}
.chapter-link[data-current="true"] { border-color: var(--chapter-color); }
.chapter-link-number {
  display: grid; place-items: center; width: 24px; height: 25px;
  border-radius: 5px; border: 1px solid #b8c3a05c; font: 600 15px/1 var(--serif); color: var(--chapter-color);
}
.chapter-link-copy { display: grid; gap: 1px; }
.chapter-link-copy strong { font-size: 12px; line-height: 1.18; }
.chapter-link-copy small { color: #d1ddcf; font-size: 10px; line-height: 1.22; }
.chapter-link-count { color: var(--chapter-color); font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (hover: hover) {
  .chapter-link:hover, .chapter-option:hover { border-color: var(--chapter-color); }
}
.map-dialog { width: min(650px, calc(100% - 28px)); }
.map-dialog .dialog-header { align-items: flex-start; margin-bottom: 14px; }
.map-dialog .dialog-header p { margin-top: 3px; }
.chapter-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.chapter-option {
  display: grid; place-content: center; gap: 2px; min-height: 46px; padding: 4px 2px;
  color: var(--chapter-color); background: var(--chapter-bg);
  border: 1px solid #627364; border-radius: 6px; font-weight: 700; line-height: 1.1;
}
.chapter-option strong { color: var(--paper); font-size: 10px; }
.chapter-option[aria-pressed="true"] { border-color: var(--chapter-color); box-shadow: inset 0 -3px var(--chapter-color); }
.map-brief { margin-top: 15px; }
.map-brief h3 { font: 600 25px/1.1 var(--serif); }
.map-brief p { margin-top: 4px; font-size: 13px; }
.map-brief .map-chapter-difficulty { color: var(--gold-light); font-size: 11px; font-weight: 700; }
.map-dialog .map-rules { margin-top: 10px; color: var(--quiet); font-size: 12px; }
.map-chapter-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.map-chapter-heading #map-chapter-progress {
  margin: 0; color: var(--gold-light); white-space: nowrap; font-size: 11px; font-weight: 700;
}
.map-dialog .deals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.map-dialog .deal-option { min-height: 60px; }
.map-dialog .deal-copy small { font-size: 11px; line-height: 1.2; }
.result-campaign, .result-goal, .result-best { margin-top: 10px; }
.result-campaign {
  padding: 9px 10px; border: 1px solid #a28c59; border-radius: 7px;
  background: #3b4532; color: #f5dfb6; font-weight: 650;
}
.result-goal { color: var(--gold-light); font-weight: 700; }
.result-best { padding-top: 8px; border-top: 1px solid #506758; }
.save-info { padding-top: 13px; border-top: 1px solid #40564a; grid-column: 1 / -1; }
.save-info p:not(.kicker) { max-width: 72ch; }

@media (max-width: 720px) {
  .game-side { grid-template-columns: 1fr; }
  .chapter-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .intro-actions { width: 100%; }
  .intro-actions .start { min-width: 132px; }
  .level-route { margin-bottom: 2px; }
  .level-notes { grid-template-columns: 1fr; gap: 3px; }
  .table-status { min-height: 30px; }
  body:has(#wild-panel:not([hidden])) .table-status { min-height: 55px; }
  .route-panel { padding: 11px; }
  .map-dialog { padding: 14px; }
  .map-dialog .deal-option { display: flex; align-items: flex-start; position: static; gap: 6px; min-height: 65px; }
  .map-dialog .deal-finished { position: static; }
  .map-dialog .deal-number { flex: 0 0 21px; height: 21px; }
}

.boot-state {
  min-height: 77vh; display: grid; align-items: center;
  padding: 24px 14px; text-align: center;
}
.boot-panel {
  width: min(100%, 470px); margin: 0 auto; padding: clamp(19px, 5vw, 34px);
  border: 1px solid var(--line); border-radius: 13px; background: var(--panel);
}
.boot-panel h1 { font-size: clamp(30px, 7vw, 43px); margin-bottom: 13px; }
.boot-panel p { color: var(--quiet); margin: 4px 0; }
.boot-panel .button { margin-top: 14px; }

#header-map-slot:empty { display: none; }
#app-shell[data-view="table"] .intro { display: none; }
#app-shell[data-view="table"] .game-layout { margin-top: 14px; }
.goal-summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "target history" "current current";
  column-gap: 6px; min-width: 0; align-self: center;
}
.goal-summary .level-goal { grid-area: target; }
.goal-summary .goal-progress { grid-area: current; }
.goal-summary .goal-history { grid-area: history; white-space: nowrap; }
.goal-progress, .goal-history { font-size: 11px; line-height: 1.4; }
.goal-progress { color: #e1e7d8; }
.goal-progress[data-progress="met"] { color: #e9d3a2; font-weight: 700; }
.goal-progress[data-progress="over"] { color: #f4afa1; }
.goal-history { color: #d5c397; }
.peak-summited { animation: summit-pulse .42s ease-out; }
@keyframes summit-pulse {
  from { box-shadow: 0 0 0 4px #ead19c88; }
  to { box-shadow: 0 0 0 8px #ead19c00; }
}

#result.victory {
  width: min(495px, calc(100% - 26px));
  padding-top: 0;
}
.victory .result-hero {
  align-items: flex-start;
  min-height: 155px;
  margin: 0 -20px 13px;
  padding: 17px 20px;
  border-radius: 13px 13px 0 0;
  border-bottom: 1px solid var(--scene-rule);
  background: linear-gradient(90deg, #142125ea 4%, #182624a8 55%, #1925252e), var(--landscape) center 49% / cover, var(--scene-panel);
}
.victory .result-trail {
  margin: 2px 0 7px; color: var(--scene-accent); font-size: 11px; font-weight: 750;
  letter-spacing: .09em; text-transform: uppercase;
}
.victory .result-hero h2 { font-size: clamp(30px, 8vw, 41px); }
.victory .result-scene-peaks { display: block; width: 156px; max-width: 100%; height: 42px; margin-top: 9px; color: var(--scene-accent); }
.result-chapter { margin-top: 10px; color: var(--gold-light); font-weight: 750; }

@media (max-width: 480px) {
  #app-shell[data-view="table"] .wrap { width: calc(100% - 14px); }
  #app-shell[data-view="table"] .game-layout { margin-top: 8px; }
  #app-shell[data-view="table"] .brand { font-size: 17px; }
  #app-shell[data-view="table"] .brand img { width: 29px; height: 29px; }
  #app-shell[data-view="table"] .brand span,
  #app-shell[data-view="table"] .table-home > [data-copy],
  #app-shell[data-view="table"] #help > [data-copy] { display: none; }
  #app-shell[data-view="table"] .masthead .button { padding-inline: 7px; min-width: 44px; }
  #app-shell[data-view="table"] #help .question-icon { display: inline-grid; }
  #app-shell[data-view="table"] #deal-strategy { min-height: 1.35em; }
  #app-shell[data-view="table"] .goal-summary { min-height: 31px; }
  #app-shell[data-view="table"] .table-card .card-rank {
    left: 9%; font-size: clamp(15px, 3.95vw, 17px);
  }
}
