/*
 * Draw simulator and probability notes.
 * Tokens follow the NAKWOL portal (src/styles/global.css). The header/footer marked
 * [data-portal-chrome] replicate the portal's BaseLayout so the page works standalone; when the
 * tool is hosted inside BaseLayout those elements are dropped and only main.sim-page is used.
 * style.css (shared with the replay page) keeps the stage and card animation rules.
 */
:root {
  --paper: #f5f3ee;
  --surface: #fbfaf7;
  --ink: #132033;
  --ink-muted: #66717b;
  --muted: #5e6871; /* ink-muted nudged darker for 4.5:1 on paper */
  --navy: #17232b;
  --navy-raised: #25333b;
  --gold: #a7834e;
  --gold-deep: #89673a;
  --gold-text: #7a5b30; /* gold for small text on light surfaces */
  --rule: #dedbd4;
  --danger: #9a3d2e;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --content-width: 1280px;
  --radius: 8px;
  --radius-card: 8px;
  --shadow-card: 0 2px 9px rgb(28 32 37 / 5%);
  --motion-fast: 140ms ease-out;
  --touch: 44px;
  --serif: 'Noto Serif KR', 'Nanum Myeongjo', 'Batang', serif;
  --sans: 'Pretendard', 'Noto Sans KR', system-ui, sans-serif;
}

body[data-mode] {
  font: 15px/1.6 var(--sans);
  color: var(--ink);
  background: var(--paper);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.container {
  width: min(var(--content-width), calc(100% - 48px));
  margin-inline: auto;
}

/* ---------- portal chrome ---------- */
.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: block;
  padding: 0;
  color: #f1efe9;
  background: linear-gradient(115deg, var(--navy), #1c2830 68%, var(--navy));
  border-bottom: 1px solid rgb(255 255 255 / 9%);
}
.site-header__inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: clamp(16px, 2.2vw, 36px);
}
.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #f4f0e8;
  text-decoration: none;
  white-space: nowrap;
}
.brand__mark {
  display: grid;
  place-items: center;
  color: #d1b37b;
}
.brand__mark img {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.brand__name {
  font-family: var(--serif);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: 0.035em;
}
.brand__name span {
  font-size: 0.9em;
}
.brand__divider {
  width: 1px;
  height: 22px;
  background: rgb(255 255 255 / 25%);
}
.brand__tagline {
  color: rgb(241 239 233 / 70%);
  font-size: 0.8rem;
}
.site-nav {
  align-self: stretch;
  display: flex;
  gap: clamp(14px, 2.2vw, 32px);
  margin-left: auto;
}
.site-nav__link {
  position: relative;
  display: grid;
  place-items: center;
  color: #e8e7e3;
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--motion-fast);
}
.site-nav__link:hover,
.site-nav__link.is-active {
  color: #e4c58b;
}
.site-nav__link.is-active::after {
  position: absolute;
  right: 2px;
  bottom: 10px;
  left: 2px;
  height: 3px;
  background: #c8a667;
  content: '';
}
.site-footer {
  margin-top: var(--space-12);
  color: #ebe8e0;
  background: linear-gradient(115deg, var(--navy), #1b2830 65%, #141e25);
}
.site-footer__inner {
  min-height: 112px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
}
.site-footer__motto {
  margin: 0;
  padding-left: var(--space-5);
  border-left: 1px solid rgb(255 255 255 / 20%);
  color: rgb(235 232 224 / 75%);
  font-size: 0.8rem;
}
.site-footer__note {
  margin: 0 0 0 auto;
  color: rgb(235 232 224 / 60%);
  font-size: 0.76rem;
}
.site-footer__copyright {
  margin: 0;
  padding: var(--space-3) 0 var(--space-5);
  border-top: 1px solid rgb(255 255 255 / 20%);
  color: rgb(235 232 224 / 60%);
  font-size: 0.76rem;
  text-align: center;
}
.site-header a:focus-visible,
.site-footer a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

/* ---------- page frame ---------- */
main.sim-page,
main.probability-notes {
  max-width: none;
  padding: 0 0 var(--space-12);
}
.hero {
  padding: var(--space-6) 0 var(--space-5);
}
.hero .eyebrow {
  margin: 0;
  color: var(--gold-text);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.hero h1 {
  margin: 4px 0 8px;
  font: 700 clamp(1.8rem, 3vw, 2.5rem) / 1.2 var(--serif);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.lead {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.caption {
  margin: var(--space-3) 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.7;
}
.sim-page h2,
.probability-notes h2 {
  margin: 0;
  font: 700 1.35rem/1.35 var(--serif);
  letter-spacing: -0.01em;
}
.sim-page h3 {
  margin: 0;
  font: 700 1.1rem/1.4 var(--serif);
}

/* Controls. Overrides the generic button rules in style.css. */
.sim-page button,
.sim-page select,
.sim-page input[type='number'],
dialog button {
  min-height: var(--touch);
  padding: 8px 16px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 0.92rem;
  transition:
    background var(--motion-fast),
    border-color var(--motion-fast),
    color var(--motion-fast);
}
.sim-page button:not(:disabled):hover,
dialog button:not(:disabled):hover {
  border-color: var(--gold);
}
.sim-page button:disabled,
.sim-page select:disabled,
.sim-page input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.sim-page :focus-visible,
dialog :focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
.sim-page .button-primary,
.sim-page .draw-actions .primary {
  border-color: var(--gold);
  color: #fffdf8;
  background: var(--gold);
  font-weight: 650;
}
.sim-page .button-primary:not(:disabled):hover {
  border-color: var(--gold-deep);
  background: var(--gold-deep);
}
.sim-page .button-quiet,
dialog .button-quiet {
  min-height: 38px;
  padding: 6px 14px;
  color: var(--ink);
  background: transparent;
  font-size: 0.86rem;
}
.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: auto !important;
  margin-top: var(--space-3);
  padding: 4px 0 !important;
  border: 0 !important;
  color: var(--gold-text) !important;
  background: none !important;
  font-size: 0.88rem !important;
  font-weight: 650;
  cursor: pointer;
}
.text-link:hover {
  color: var(--gold-deep) !important;
  text-decoration: underline;
  text-underline-offset: 4px;
}
progress {
  width: 100%;
  height: 6px;
  accent-color: var(--gold);
}

/* ---------- workspace: stage + settings ---------- */
.sim-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--space-6);
  align-items: start;
}
.sim-main {
  min-width: 0;
}
.sim-main > .sim-section {
  margin-top: var(--space-6);
}
.sim-sidebar {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.side-block {
  min-width: 0;
  margin: 0;
  padding: var(--space-5);
  border: 0;
  border-top: 1px solid var(--rule);
}
.side-block:first-child {
  border-top: 0;
}
.side-block[hidden] {
  display: none;
}
.sim-sidebar .side-title {
  float: left; /* lets a fieldset legend sit inside the block instead of on its border */
  width: 100%;
  margin: 0 0 var(--space-3);
  padding: 0;
  color: var(--ink);
  font: 700 0.95rem/1.4 var(--sans);
}
.sim-sidebar .side-title + * {
  clear: both;
}
.side-title small {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}
.side-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}
.sim-sidebar .side-row .side-title {
  float: none;
  width: auto;
  margin-bottom: var(--space-2);
}
#pity-summary {
  color: var(--gold-text);
  font-size: 0.86rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.pity-block .caption {
  margin-top: var(--space-2);
}
.mode-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  cursor: pointer;
  transition: border-color var(--motion-fast);
}
.mode-option:hover {
  border-color: #c5b18e;
}
.mode-option:has(:checked) {
  border-color: var(--gold);
  background: #fffdf8;
  box-shadow: inset 3px 0 0 var(--gold);
}
.mode-option input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--gold);
}
.mode-option span {
  display: grid;
  gap: 2px;
}
.mode-option strong {
  font-size: 0.95rem;
}
.mode-option small {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}
.model-note {
  margin-top: var(--space-2);
}
.exclusion-panel label {
  display: grid;
  gap: 6px;
  margin-bottom: var(--space-3);
  color: var(--muted);
  font-size: 0.84rem;
}
.exclusion-panel select {
  width: 100%;
}
.exclusion-panel .caption {
  margin-top: 0;
}

/* Selected banner button */
.selected-banner {
  position: relative;
  display: block;
  width: 100%;
  padding: 0 !important;
  overflow: hidden;
  border-color: var(--navy) !important;
  color: #f4f0e8 !important;
  background: var(--navy) !important;
  text-align: left;
}
.selected-banner:not(:disabled):hover {
  border-color: var(--gold) !important;
}
.selected-banner > span:not(.recruit-banner) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px 14px;
}
.selected-banner small {
  font-size: 0.8rem;
  white-space: nowrap;
}
.selected-banner small:last-child {
  color: #e4c58b;
}
.pack-choice .caption:empty {
  display: none;
}

/* ---------- recruit screen (stage + draw controls) ---------- */
.recruit-screen {
  position: relative;
  container: recruit-screen / inline-size;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #2d3b44;
  border-radius: var(--radius-card);
  color: #f4f0e8;
  background: var(--navy);
  box-shadow: 0 8px 28px rgb(23 35 43 / 18%);
}
.recruit-screen #stage {
  border-radius: 0;
}
#idle-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--game-ink, #f4f0e8);
  font: 2cqw var(--serif);
  background: linear-gradient(transparent, #17232b66);
}
#idle-hint[hidden] {
  display: none;
}
#idle-hint small {
  font: 1cqw/2 var(--sans);
}
.recruit-screen .draw-controls {
  position: absolute;
  z-index: 4;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  column-gap: var(--space-4);
  padding: var(--space-8) var(--space-5) var(--space-3);
  background: linear-gradient(transparent, rgb(23 35 43 / 92%) 55%);
}
.recruit-screen .draw-actions {
  grid-column: 2;
  display: flex;
  gap: var(--space-3);
}
.recruit-screen .draw-actions button {
  display: grid;
  gap: 2px;
  min-width: 148px;
  padding: 10px 24px;
  border-color: rgb(228 197 139 / 70%);
  border-radius: 6px;
  color: var(--navy);
  background: #f4f0e8;
  font-weight: 700;
  box-shadow: 0 2px 10px rgb(0 0 0 / 25%);
}
.recruit-screen .draw-actions .primary {
  border-color: #c8a667;
  color: #fffdf8;
  background: linear-gradient(180deg, #b38f58, var(--gold-deep));
}
.recruit-screen .draw-actions button:not(:disabled):hover {
  border-color: #fff;
}
.recruit-screen .draw-actions small {
  font: 500 0.74rem/1.3 var(--sans);
  opacity: 0.85;
}
.recruit-screen .options {
  grid-column: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0 var(--space-3);
}
.recruit-screen .options label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--touch);
  color: #e8e7e3;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
}
.recruit-screen .options input {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
}
.recruit-screen #sim-status {
  grid-column: 1 / -1;
  margin: var(--space-2) 0 0;
  color: rgb(244 240 232 / 80%);
  font-size: 0.8rem;
  text-align: center;
}
#sim-status[data-error='true'] {
  color: #ffd9c9;
  font-weight: 650;
}
.recruit-screen #skip {
  top: 3%;
  bottom: auto;
}
.recruit-screen #result-hint {
  bottom: 24%;
}
body[data-mode='simulator'] .draw-card[data-new='true'][data-open='true']::after {
  position: absolute;
  top: 10%;
  right: 4%;
  color: var(--game-ink);
  font: 1cqw Georgia, serif;
  text-shadow: 0 1px 3px #000;
  content: 'NEW';
}

/* ---------- content sections ---------- */
.sim-section {
  min-width: 0;
  margin-top: var(--space-6);
  padding: var(--space-6);
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.sim-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-6);
}
.sim-split > .sim-section {
  margin-top: var(--space-6);
}
.panel-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
}
.heading-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.heading-actions > span,
.heading-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

/* Metrics row */
.metrics,
.forecast {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-4);
}
.forecast {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.metrics > div,
.forecast > div {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
  padding-left: var(--space-4);
  border-left: 1px solid var(--rule);
}
.metrics > div:first-child,
.forecast > div:nth-child(odd) {
  padding-left: 0;
  border-left: 0;
}
.metrics span,
.forecast span {
  color: var(--muted);
  font-size: 0.82rem;
}
.metrics strong,
.forecast strong {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.metrics small,
.forecast small {
  color: var(--muted);
  font-size: 0.8rem;
}
.forecast > div {
  padding-block: var(--space-3);
  border-top: 1px solid var(--rule);
}
.forecast > div:nth-child(-n + 2) {
  border-top: 0;
  padding-top: 0;
}
.totals-block {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px dashed var(--rule);
}
.totals-block .panel-heading {
  margin-bottom: var(--space-4);
}
.stats-panel > .caption {
  margin-top: var(--space-5);
}

/* Auto draw */
.auto-panel form label,
.target-select {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}
.auto-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.auto-actions input {
  width: 160px;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.auto-panel progress {
  margin-top: var(--space-4);
}
.auto-panel [data-error='true'] {
  color: var(--danger);
  font-weight: 650;
}
.auto-showcase {
  position: relative;
  overflow: hidden;
  margin-top: var(--space-5);
  padding: var(--space-5);
  border-radius: var(--radius-card);
  color: #f4f0e8;
  background: var(--navy);
}
.auto-showcase > :not(.auto-glow) {
  position: relative;
}
.auto-showcase .eyebrow {
  color: #e4c58b;
}
.auto-countline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  margin: 4px 0;
}
.auto-countline > strong {
  font: 700 2.6rem/1.2 var(--serif);
  font-variant-numeric: tabular-nums;
}
.auto-countline > span {
  color: rgb(244 240 232 / 80%);
}
.auto-live-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  font-size: 0.9rem;
}
.auto-live-metrics strong {
  color: #ffe4a0;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}
.auto-showcase > p:last-child {
  min-height: 24px;
  margin: var(--space-3) 0 0;
  font-size: 0.84rem;
}
.auto-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 75% 60%, var(--gold), transparent 70%);
  opacity: 0;
  pointer-events: none;
}
.auto-showcase[data-phase='running'] .eyebrow::after {
  content: ' · 진행 중';
}
.auto-showcase[data-phase='saving'] .eyebrow::after {
  content: ' · 저장 중';
}
.auto-showcase[data-phase='done'] .eyebrow::after {
  content: ' · 저장 완료';
}
.auto-showcase[data-phase='error'] .eyebrow::after {
  content: ' · 저장 실패';
}

/* Target forecast */
.target-select {
  margin-bottom: var(--space-4);
}
.target-select select {
  width: 100%;
}
#forecast-mode {
  margin: 0 0 var(--space-4);
  color: var(--ink);
}

/* Collection */
.collection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: var(--space-3);
}
.collection figure {
  margin: 0;
  padding: var(--space-2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
}
.collection img {
  width: 100%;
  height: 150px;
  object-fit: contain;
}
.collection figcaption {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: 6px;
  font-size: 0.84rem;
}
.collection figcaption strong {
  color: var(--gold-text);
}
.collection .empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: var(--space-6);
  border: 1px dashed var(--rule);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

/* Tables */
.table-scroll,
.pool-scroll {
  overflow: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}
.data-table thead th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface);
}
.data-table tbody tr:hover {
  background: #f8f5ee;
}
.history-panel tr[data-grade='legend'] td:nth-child(2) {
  color: var(--gold-text);
  font-weight: 700;
}
.pool-scroll {
  max-height: 440px;
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.pool-table caption {
  padding: 10px 12px;
  color: var(--ink);
  font-weight: 650;
  text-align: left;
  background: var(--paper);
}
.pool-table thead {
  position: sticky;
  z-index: 1;
  top: 0;
}
.pool-table th:not(:first-child),
.pool-table td:not(:first-child) {
  text-align: right;
}
.pool-table td strong,
.pool-table td small {
  display: block;
}
.pool-table td strong {
  font-weight: 600;
}
.pool-table td small {
  color: var(--muted);
  font-size: 0.78rem;
}
.pool-table tr[data-grade='legend'] td strong {
  color: var(--gold-text);
}
.pool-table tr[data-excluded='true'] td strong {
  color: var(--muted);
  text-decoration: line-through;
}
.pool-more {
  margin-top: var(--space-3);
}
.pool-more summary,
.model-details summary {
  min-height: var(--touch);
  align-content: center;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
}

/* Rules */
.model-details {
  margin-top: var(--space-6);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.8;
}
.model-details p {
  max-width: 820px;
}
.model-details a {
  color: var(--ink);
}

/* ---------- dialogs ---------- */
dialog {
  width: min(480px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: var(--space-6);
  border: 1px solid var(--rule);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 20px 60px rgb(23 35 43 / 25%);
}
dialog::backdrop {
  background: rgb(23 35 43 / 60%);
}
dialog p {
  font-size: 0.92rem;
  line-height: 1.7;
}
dialog h2 {
  margin: 0;
  font: 700 1.3rem/1.35 var(--serif);
  word-break: keep-all;
}
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.dialog-heading > div {
  min-width: 0;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-5);
}
dialog .button-danger {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}
.pack-dialog {
  width: min(980px, calc(100% - 32px));
}
.pack-dialog h3 {
  margin: var(--space-6) 0 var(--space-3);
  font: 700 0.95rem/1.4 var(--sans);
}
.banner-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}
.banner-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  padding: var(--space-2) !important;
  border: 1px solid var(--rule) !important;
  border-radius: 8px !important;
  color: var(--ink) !important;
  background: #fff !important;
  text-align: left;
}
.banner-tile:not(:disabled):hover {
  border-color: #c5b18e !important;
}
.banner-tile[aria-pressed='true'] {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 1px var(--gold);
}
.banner-tile small {
  padding: 4px 4px 2px;
  color: var(--muted);
  font-size: 0.78rem;
}
.selection-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  display: none;
  padding: 3px 8px;
  border-radius: 4px;
  color: #fffdf8;
  background: var(--gold-deep);
  font-size: 0.74rem;
}
.banner-tile[aria-pressed='true'] .selection-badge {
  display: block;
}
.model-dialog {
  width: min(720px, calc(100% - 32px));
}
.model-dialog h3 {
  margin: var(--space-6) 0 var(--space-2);
  font: 700 1.1rem/1.4 var(--serif);
}
.model-table caption {
  padding-bottom: var(--space-2);
  color: var(--muted);
  font-size: 0.84rem;
  text-align: left;
}
.model-table th small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}
.model-table tbody th {
  color: var(--ink);
  font-weight: 650;
}
.model-table td {
  font-size: 1.2rem;
}
.model-uncertainty {
  padding: var(--space-4);
  border-left: 3px solid var(--gold);
  background: var(--paper);
}
.model-uncertainty strong {
  display: block;
}
.evidence-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch);
  padding: 8px 16px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}
.evidence-link:hover {
  background: #fffdf8;
}
.evidence-link .caption {
  margin: 0;
}

/* ---------- probability notes page ---------- */
.probability-notes .heading {
  padding: var(--space-8) 0 var(--space-4);
}
.probability-notes .heading h1 {
  margin: 6px 0 0;
  font: 700 clamp(1.9rem, 3.4vw, 2.75rem) / 1.2 var(--serif);
}
.probability-notes > * {
  width: min(880px, calc(100% - 48px));
  margin-inline: auto;
}
.notes-section {
  margin-top: var(--space-6);
  padding: var(--space-6);
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  scroll-margin-top: 88px;
}
.notes-section h2 {
  margin: 4px 0 var(--space-4);
}
.notes-section > p,
.notes-section li {
  max-width: 76ch;
}
.notes-lead {
  border-top: 3px solid var(--gold);
}
.notes-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  margin-top: var(--space-5);
}
.notes-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  text-underline-offset: 4px;
}
.notes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.notes-table th,
.notes-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}
.notes-table thead th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.notes-table caption {
  padding: var(--space-2) 0;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: left;
}
.notes-section details {
  padding: var(--space-2) 0;
  border-top: 1px solid var(--rule);
}
.notes-section summary {
  min-height: var(--touch);
  align-content: center;
  font-weight: 650;
  cursor: pointer;
}
.notes-formula {
  padding: var(--space-3) var(--space-4);
  border-radius: 6px;
  background: var(--paper);
}
.notes-section a {
  color: var(--ink);
}
.notes-section li {
  margin: var(--space-3) 0;
}
#notes-status:empty {
  display: none;
}
#notes-status[data-error='true'] {
  color: var(--danger);
  font-weight: 650;
}

/* ---------- stage text on small stages ----------
 * The stage scales its text with the stage width (cqw). On phones that drops card names to
 * about 6px, so each label gets a readable floor. Only the simulator page is affected. */
body[data-mode='simulator'] .stage-title {
  left: max(3%, 14px);
  font-size: max(12px, 2cqw);
}
body[data-mode='simulator'] .card-name {
  font-size: max(9.5px, 1.8cqw);
  white-space: nowrap;
}
body[data-mode='simulator'] #result-hint {
  font-size: max(12px, 2cqw);
}
body[data-mode='simulator'] .card-conversion span {
  font-size: max(8px, 1.1cqw);
}
body[data-mode='simulator'] .draw-card[data-new='true'][data-open='true']::after {
  font-size: max(7px, 1cqw);
}

/* ---------- responsive ---------- */
@container recruit-screen (max-width: 860px) {
  .recruit-screen .draw-controls {
    position: relative;
    grid-template-columns: 1fr;
    padding: var(--space-4);
    background: var(--navy);
  }
  .recruit-screen .draw-actions,
  .recruit-screen .options {
    grid-column: 1;
    justify-content: center;
  }
  .recruit-screen .options {
    margin-top: var(--space-2);
  }
  .recruit-screen #sim-status {
    grid-column: 1;
  }
  .recruit-screen #result-hint {
    bottom: 12%;
  }
}
@media (max-width: 1100px) {
  .brand__tagline,
  .brand__divider {
    display: none;
  }
  .sim-workspace {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: var(--space-5);
  }
  .metrics > div:nth-child(4) {
    padding-left: 0;
    border-left: 0;
  }
}
@media (max-width: 960px) {
  /* Single column: stage, then settings, then records. */
  .sim-workspace {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .sim-main {
    display: contents;
  }
  .sim-workspace .recruit-screen {
    order: 1;
  }
  .sim-sidebar {
    order: 2;
    margin-top: var(--space-6);
  }
  .sim-main > .stats-panel {
    order: 3;
  }
  .sim-sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sim-sidebar .side-block:nth-child(2) {
    border-top: 0;
    border-left: 1px solid var(--rule);
  }
  .sim-sidebar .side-block:nth-child(4) {
    border-left: 1px solid var(--rule);
  }
  .sim-split {
    grid-template-columns: 1fr;
    gap: 0;
  }
}
@media (max-width: 860px) {
  .container,
  .probability-notes > * {
    width: calc(100% - 36px);
  }
  .site-header__inner {
    min-height: 60px;
    flex-wrap: wrap;
    padding-top: 6px;
  }
  .site-nav {
    width: 100%;
    height: 44px;
    margin-left: 0;
    overflow-x: auto;
  }
  .site-nav__link.is-active::after {
    bottom: 2px;
  }
  .banner-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .container,
  .probability-notes > * {
    width: calc(100% - 32px);
  }
  .brand__name {
    font-size: 1.1rem;
  }
  .hero {
    padding-top: var(--space-6);
  }
  .sim-sidebar {
    grid-template-columns: 1fr;
  }
  .sim-sidebar .side-block {
    border-left: 0 !important;
    border-top: 1px solid var(--rule) !important;
  }
  .sim-sidebar .side-block:first-child {
    border-top: 0 !important;
  }
  .sim-section,
  .notes-section {
    padding: var(--space-4);
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metrics > div:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
  }
  .metrics > div:nth-child(4) {
    padding-left: var(--space-4);
    border-left: 1px solid var(--rule);
  }
  .metrics > div:last-child {
    grid-column: 1 / -1;
  }
  .metrics strong,
  .forecast strong {
    font-size: 1.45rem;
  }
  .recruit-screen .draw-actions {
    width: 100%;
  }
  .recruit-screen .draw-actions button {
    flex: 1;
    min-width: 0;
    padding-inline: var(--space-3);
  }
  .recruit-screen #skip {
    top: auto;
    bottom: 3%;
  }
  #idle-hint {
    font-size: 4cqw;
  }
  #idle-hint small {
    font-size: 2.4cqw;
  }
  .heading-actions {
    width: 100%;
    justify-content: space-between;
  }
  .auto-actions input,
  .auto-actions button {
    flex: 1;
  }
  .collection {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
  }
  .collection img {
    height: 100px;
  }
  .collection figcaption {
    flex-direction: column;
    gap: 0;
  }
  .banner-grid {
    grid-template-columns: 1fr;
  }
  dialog {
    padding: var(--space-4);
  }
  .site-footer__note {
    margin-left: 0;
  }
}
/* Laptops at 125-150% scaling report about 1280x600 to 1536x730. Keep the draw buttons on the
 * first screen: tighten the header block and cap the stage by the window height. */
@media (min-width: 961px) and (max-height: 860px) {
  .hero {
    padding: var(--space-4) 0 var(--space-3);
  }
  .hero h1 {
    margin: 2px 0 4px;
    font-size: 1.8rem;
  }
  .lead {
    font-size: 0.92rem;
  }
  .sim-workspace .recruit-screen {
    width: min(100%, max(600px, calc((100dvh - 200px) * 16 / 9)));
    margin-inline: auto;
  }
}
@media (max-width: 560px) {
  /* Full-bleed stage on phones: about 10% more room for the cards. */
  .sim-workspace .recruit-screen {
    margin-inline: -16px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
