:root {
  --bg: #ecf4f3;
  --surface: #ffffff;
  --surface-2: #e0eeec;
  --surface-3: #bfd6d3;
  --ink: #0b2126;
  --muted: #456066;
  --accent: #0d6e6e;
  --accent-hover: #084f4f;
  --accent-ink: #ffffff;
  --link: #0a5c5c;
  --ok-bg: #e2f5ee;
  --ok-ink: #09523e;
  --warn-bg: #fdebe8;
  --warn-ink: #962116;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --step-small: clamp(0.85rem, 0.83rem + 0.1vw, 0.92rem);
  --step-body: clamp(1.02rem, 0.99rem + 0.18vw, 1.1rem);
  --step-lead: clamp(1.14rem, 1.08rem + 0.22vw, 1.24rem);
  --step-h2: clamp(1.55rem, 1.24rem + 1.45vw, 2.2rem);
  --step-head: clamp(2.1rem, 1.5rem + 3vw, 3.6rem);
  --gap: 10px;
  --pad: 22px;
  --max-w: 1392px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.52;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: var(--step-body);
  overflow-x: clip;
}

img { display: block; max-width: 100%; height: auto; }

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1.5px;
}
a:hover { color: var(--accent-hover); }

a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, h3, h4 {
  margin: 0 0 0.46em;
  font-family: var(--font-sans);
  font-weight: 700;
  color: inherit;
  letter-spacing: -0.025em;
}
h1 { font-size: var(--step-head); line-height: 1.05; }
h2 { font-size: var(--step-h2); line-height: 1.12; }
h3, h4 { font-size: var(--step-lead); line-height: 1.22; }

p, ul, ol, dl, table, pre { margin: 0 0 1rem; }
p, li { max-width: 66ch; overflow-wrap: anywhere; }
p:last-child, ul:last-child, ol:last-child { margin-bottom: 0; }

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  color: var(--ink);
  padding: 0.12em 0.4em;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.board-shell {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--pad);
}

.top-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.brand-tile {
  background: var(--ink);
  color: #ffffff;
  padding: 11px 18px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  font-size: var(--step-body);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand-tile:hover { background: var(--accent); color: #ffffff; }

.nav-tile {
  background: var(--surface);
  padding: 8px 18px;
  min-height: 46px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}
.nav-tile a {
  color: var(--ink);
  text-decoration: none;
  font-size: var(--step-small);
  font-weight: 600;
}
.nav-tile a:hover, .nav-tile a[aria-current="page"] {
  color: var(--accent);
  text-decoration: underline;
}

.cta-tile, .btn-primary, .btn-ghost, .btn-dark {
  padding: 11px 20px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--step-small);
  text-decoration: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-sans);
}
.cta-tile, .btn-primary { background: var(--accent); color: var(--accent-ink); }
.cta-tile:hover, .btn-primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: var(--surface-2); color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: #ffffff; }
.btn-dark { background: var(--ink); color: #ffffff; }
.btn-dark:hover { background: var(--accent); color: #ffffff; }

.board-section { margin-top: clamp(56px, 6vw, 96px); }
.board-section--first { margin-top: 0; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
}

.tile {
  background: var(--surface);
  color: var(--ink);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}
.tile--top { justify-content: flex-start; }
.tile-elev { background: var(--surface-2); }
.tile-photo { padding: 0; position: relative; overflow: hidden; min-height: 260px; }
.tile-photo img { width: 100%; height: 100%; min-height: 260px; object-fit: cover; }
.photo-strip { background: var(--ink); color: #ffffff; padding: 9px 14px; font-size: var(--step-small); }

.c-12 { grid-column: span 12; }
.c-8  { grid-column: span 8; }
.c-7  { grid-column: span 7; }
.c-6  { grid-column: span 6; }
.c-5  { grid-column: span 5; }
.c-4  { grid-column: span 4; }
.c-3  { grid-column: span 3; }
.c-2  { grid-column: span 2; }

.hero-lead {
  font-size: var(--step-lead);
  line-height: 1.48;
  margin: 0.6rem 0 1.1rem;
  max-width: 64ch;
}
.stat-note { font-size: var(--step-small); color: var(--muted); margin: 0; }
.stat-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 16px; }
.stat-pill { background: var(--surface-2); padding: 11px 14px; display: flex; flex-direction: column; gap: 3px; }
.stat-pill span { font-size: var(--step-small); color: var(--muted); }
.stat-pill strong { font-size: 0.98rem; font-weight: 700; }

.check-list { margin: 10px 0 14px; padding-left: 1.2em; display: grid; gap: 8px; list-style: square; }
.steps-list { counter-reset: step; list-style: none; padding: 0; display: grid; gap: 10px; }
.steps-list li { counter-increment: step; padding-left: 2.3em; position: relative; }
.steps-list li::before {
  content: counter(step); position: absolute; left: 0; top: 0.1em; width: 1.65em; height: 1.65em;
  display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; font-size: var(--step-small);
}

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; margin: 10px 0 12px; font-size: var(--step-small); font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--surface-3); vertical-align: top; }
.data-table th { font-weight: 700; background: var(--surface-2); }

/* FAQ Accordion */
.faq-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.faq-tile { background: var(--surface-2); color: var(--ink); }
.faq-tile summary {
  list-style: none; padding: 16px 20px; min-height: 58px; display: flex;
  align-items: center; justify-content: space-between; gap: 14px; font-weight: 600; cursor: pointer;
}
.faq-tile summary::-webkit-details-marker { display: none; }
.faq-plus { width: 14px; height: 14px; position: relative; flex-shrink: 0; }
.faq-plus::before, .faq-plus::after { content: ""; position: absolute; background: currentColor; transition: transform 150ms ease; }
.faq-plus::before { top: 6px; left: 0; width: 14px; height: 2px; }
.faq-plus::after { top: 0; left: 6px; width: 2px; height: 14px; }
.faq-tile[open] { background: var(--ink); color: #ffffff; }
.faq-tile[open] .faq-plus::after { transform: rotate(90deg); }
.faq-ans { padding: 0 20px 18px; }
.faq-ans p { margin: 0; color: inherit; }

/* Score Planner ([data-ui]) */
[data-ui].ui-split {
  display: grid;
  grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
  background: var(--surface);
  border: 2px solid var(--ink);
}
[data-ui] .ui-controls {
  padding: 18px; background: var(--surface-2); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
}
[data-ui] .ctrl-field { display: flex; flex-direction: column; gap: 4px; }
[data-ui] .ctrl-field label { font-size: var(--step-small); font-weight: 600; }
[data-ui] select {
  width: 100%; min-height: 40px; padding: 6px 10px; background: var(--surface);
  color: var(--ink); border: 1.5px solid var(--ink); font-family: var(--font-sans); font-size: var(--step-small);
}
[data-ui] .ui-output { padding: 22px; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; }
[data-ui] .ui-kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
[data-ui] .ui-kpi { background: var(--surface-2); padding: 12px 14px; }
[data-ui] .ui-kpi span { display: block; font-size: var(--step-small); color: var(--muted); margin-bottom: 3px; }
[data-ui] .ui-kpi strong { display: block; font-size: var(--step-lead); font-weight: 800; font-family: var(--font-mono); }
[data-ui] .ui-verdict { background: var(--ok-bg); color: var(--ok-ink); padding: 14px 16px; border-left: 5px solid var(--accent); }
[data-ui] .ui-verdict.is-warn { background: var(--warn-bg); color: var(--warn-ink); border-left-color: #b93829; }
[data-ui] .ui-verdict strong { display: block; margin-bottom: 4px; }
[data-ui] .ui-verdict p { margin: 0; font-size: var(--step-small); }

/* Adsterra Static Slots */
.ad-slot { margin: 22px 0; background: var(--surface); padding: 10px 12px; overflow: hidden; }
.ad-leader, .ad-300 { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 82px; }
.ad-n, .ad-native { display: block; width: 100%; }
.ad-slot-label { display: block; font-size: var(--step-small); color: var(--muted); margin-bottom: 6px; }
.ad-slot-pending { display: none; }

/* Playable 7-Bed Medical Ward (.pg) */
.tile.game-first { padding: 12px 16px 18px; justify-content: flex-start; }
h1.game-h1 {
  max-width: none; width: 100%; font-size: clamp(1.3rem, 1.12rem + 0.9vw, 1.68rem);
  line-height: 1.12; font-weight: 800; text-align: center; margin: 2px 0 6px;
}

.game-stage {
  display: grid;
  grid-template-columns: 316px minmax(0, 1fr) 316px;
  grid-template-areas:
    "left main right"
    "left body right";
  gap: var(--gap);
  align-items: start;
}
.game-stage-main { grid-area: main; min-width: 0; }
.game-stage-body { grid-area: body; min-width: 0; }
.game-rail { min-width: 0; position: sticky; top: 14px; align-self: start; }
.game-rail--left { grid-area: left; }
.game-rail--right { grid-area: right; }
.game-rail .ad-slot { margin: 0; padding: 10px 8px; }
.game-rail .ad-300 { min-height: 274px; }

.pg {
  --t-skin: #d9822b;
  --t-organ: #c93b2b;
  --t-bone: #7d6b4f;
  --t-dna: #0d6e6e;
  --t-nuc: #0b4f6c;
  --t-atom: #6b21a8;
  max-width: 760px; margin: 0 auto; display: grid; gap: 10px; color: var(--ink);
}
.pg [hidden] { display: none !important; }
.pg button, .pg select, .pg input { font: inherit; color: inherit; }
.pg button { cursor: pointer; }
.pg-flag { margin: 0; padding: 6px 10px; background: var(--ink); color: #ffffff; font-size: 0.82rem; text-align: center; }
.pg-flag a { color: #7ef2e6; }

.pg-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.pg-top-right { display: flex; align-items: center; gap: 8px; }
.pg-tabs { display: inline-flex; border: 2px solid var(--ink); }
.pg-tab { min-height: 38px; padding: 6px 14px; border: 0; background: var(--surface); font-weight: 700; font-size: var(--step-small); }
.pg-tab + .pg-tab { border-left: 2px solid var(--ink); }
.pg-tab.is-on { background: var(--accent); color: #ffffff; }
.pg-clock {
  font-family: var(--font-mono); font-weight: 700; font-size: 1.05rem;
  padding: 5px 10px; background: var(--surface-2); border: 2px solid var(--ink); min-width: 72px; text-align: center;
}
.pg-clock.is-low { background: var(--warn-bg); color: var(--warn-ink); border-color: #b93829; }
.pg-tool { min-height: 38px; padding: 6px 10px; border: 2px solid var(--surface-3); background: var(--surface); font-size: var(--step-small); font-weight: 600; }

.pg-beds { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.bed-pill {
  padding: 5px 4px; text-align: center; font-size: 0.76rem; font-weight: 700;
  background: var(--surface-2); border: 1.5px solid var(--surface-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bed-pill.is-cur { border: 2px solid var(--ink); background: #fff9db; }
.bed-pill.is-done { background: var(--ok-bg); border-color: var(--accent); color: var(--ok-ink); }
.bed-pill.is-miss { background: var(--warn-bg); border-color: #d99b94; color: var(--warn-ink); }

.pg-timerbar { height: 7px; background: var(--surface-3); overflow: hidden; }
.pg-timerbar span { display: block; height: 100%; width: 100%; background: var(--accent); transition: width 100ms linear; }
.pg-timerbar span.is-low { background: #c93b2b; }

.pg-cat { display: grid; gap: 3px; padding: 12px 14px; background: var(--surface-2); border-left: 6px solid var(--accent); }
.pg-eyebrow { font-size: 0.8rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.pg-catname { font-size: clamp(1.15rem, 1.04rem + 0.7vw, 1.48rem); line-height: 1.2; font-weight: 800; }
.pg-rule { font-size: var(--step-small); color: var(--muted); }

.pg-answer { margin: 0; }
.pg-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
.pg-input-row input {
  width: 100%; min-height: 50px; padding: 10px 14px; font-size: max(16px, 1rem);
  background: var(--surface); border: 2.5px solid var(--ink); border-radius: 0;
}
.pg-input-row input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.2); }

.pg-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 50px;
  padding: 8px 16px; border: 2px solid var(--ink); background: var(--surface); font-weight: 700; text-decoration: none;
}
.pg-btn:hover:not(:disabled) { background: var(--ink); color: #ffffff; }
.pg-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pg-btn.is-main { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.pg-btn.is-main:hover:not(:disabled) { background: var(--accent-hover); }

.pg-feedback {
  margin: 0; padding: 9px 12px; font-size: var(--step-small); font-weight: 600;
  background: var(--ok-bg); color: var(--ok-ink); border-left: 5px solid var(--accent);
}
.pg-feedback.is-miss { background: var(--warn-bg); color: var(--warn-ink); border-left-color: #c93b2b; }

.pg-main { display: grid; grid-template-columns: minmax(0, 236px) minmax(0, 1fr); gap: 14px; align-items: start; }
.pg-gauge { width: 100%; max-width: 236px; margin: 0 auto; }
.pg-gauge svg { display: block; width: 100%; height: auto; font-family: var(--font-sans); }

.pg-side { display: grid; gap: 10px; align-content: start; }
.pg-scorebox {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px; background: var(--surface-2);
}
.pg-scorenum { font-family: var(--font-mono); font-size: 1.55rem; font-weight: 800; display: inline-block; margin-right: 2px; }
.pg-deepnum { display: block; font-size: 1.05rem; font-weight: 800; color: var(--accent); }
.pg-small { margin: 0; font-size: var(--step-small); color: var(--muted); }

.pg-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.pg-log:empty { display: none; }
.pg-logrow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px;
  padding: 8px 11px; background: var(--surface-2); border-left: 4px solid var(--accent); font-size: var(--step-small);
}
.pg-logrow.is-miss { border-left-color: #c93b2b; }
.pg-logname { font-weight: 700; }
.pg-logpts { font-family: var(--font-mono); font-weight: 800; }
.pg-logzebras { grid-column: 1 / -1; font-size: 0.78rem; color: var(--muted); }

.pg-result { display: grid; gap: 10px; padding: 16px; border: 2.5px solid var(--ink); background: var(--surface); }
.pg-result-head { font-size: var(--step-lead); font-weight: 800; border-left: 5px solid var(--accent); padding-left: 10px; margin: 0; }
.pg-btnrow { display: flex; flex-wrap: wrap; gap: 8px; }

.pg-catpick { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; }
.pg-catpick label { font-weight: 700; font-size: var(--step-small); }
.pg-catpick select { min-height: 42px; padding: 6px 10px; font-size: 16px; border: 2px solid var(--ink); background: var(--surface); }

.pg-fold { border: 1.5px solid var(--surface-3); background: var(--surface); }
.pg-fold summary { padding: 10px 14px; font-weight: 700; cursor: pointer; font-size: var(--step-small); }
.pg-fold > ul, .pg-fold > div { margin: 0; padding: 0 14px 12px; font-size: var(--step-small); }
.pg-fold > ul { padding-left: 30px; display: grid; gap: 5px; }

.pg-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.pg-facts div { padding: 8px 6px; background: var(--surface-2); text-align: center; }
.pg-facts strong { display: block; font-family: var(--font-mono); font-size: 1.15rem; font-weight: 800; }
.pg-facts span { font-size: 0.75rem; color: var(--muted); }

.pg-bars { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.pg-bars li { display: grid; grid-template-columns: 6.2em 1fr 2.2em; gap: 8px; align-items: center; font-size: 0.8rem; }
.pg-bars i { display: block; height: 12px; min-width: 2px; background: var(--accent); }
.pg-bars b { text-align: right; font-family: var(--font-mono); }

/* Archive & Specialty study helpers */
.arch-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.arch-list a {
  display: grid; grid-template-columns: 6.5em minmax(0, 1fr) auto; gap: 8px; align-items: center;
  min-height: 46px; padding: 9px 12px; background: var(--surface-2); color: var(--ink); text-decoration: none; border-left: 4px solid var(--surface-3);
}
.arch-list a:hover { border-left-color: var(--accent); background: var(--ok-bg); }
.arch-score { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); }
.arch-score.is-done { color: var(--accent); font-weight: 700; }

.study summary { cursor: pointer; font-weight: 700; font-size: var(--step-small); padding: 8px 0; }
.study-list { list-style: none; margin: 6px 0 0; padding: 0; columns: 2; column-gap: 16px; font-size: 0.82rem; }
.study-list li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dotted var(--surface-3); break-inside: avoid; }
.study-list b { font-family: var(--font-mono); font-size: 0.74rem; color: var(--accent); }

.mini-embed { margin-top: 12px; }
.mini-embed iframe { width: 100%; height: 420px; border: 2px solid var(--ink); background: #0b2126; display: block; }

/* Footer */
.footer-board {
  margin-top: clamp(64px, 8vw, 120px);
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
}
.footer-wordmark {
  background: var(--ink); color: #ffffff; padding: 24px; display: flex; align-items: flex-end; min-height: 170px;
}
.footer-wordmark span { font-size: clamp(2.1rem, 5vw, 4.4rem); font-weight: 800; line-height: 0.92; letter-spacing: -0.04em; }
.footer-cta-tile {
  background: var(--accent); color: #ffffff; padding: 22px; min-height: 170px;
  text-decoration: none; display: flex; flex-direction: column; justify-content: space-between;
}
.footer-cta-tile:hover { background: var(--accent-hover); color: #ffffff; }
.footer-cta-tile strong { font-size: var(--step-lead); }
.footer-cta-arrow { align-self: flex-end; }
.footer-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.footer-list a { text-decoration: none; color: var(--ink); font-size: var(--step-small); }
.footer-list a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 1259px) {
  .game-stage {
    grid-template-columns: minmax(0, 1fr) 316px;
    grid-template-areas:
      "main right"
      "body left";
  }
  .game-rail { position: static; }
}

@media (max-width: 980px) {
  .top-bar { grid-template-columns: 1fr auto; }
  .nav-tile { grid-column: 1 / -1; order: 3; }
  .game-stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "right"
      "body"
      "left";
  }
  .game-rail .ad-slot { margin: 8px 0; }
  [data-ui].ui-split { grid-template-columns: 1fr; }
  .c-3, .c-2 { grid-column: span 6; }
}

@media (max-width: 680px) {
  :root { --pad: 14px; --gap: 6px; }
  .nav-tile { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; gap: 16px; padding: 6px 12px; scrollbar-width: none; }
  .nav-tile::-webkit-scrollbar { display: none; }
  .tile-grid, .footer-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .c-12, .c-8, .c-7, .c-6, .c-5, .c-4 { grid-column: span 2; }
  .c-3, .c-2 { grid-column: span 1; }
  .tile { padding: 16px; }
  .tile.game-first { padding: 8px 10px 14px; }
  h1.game-h1 { font-size: 1.18rem; margin: 2px 0 4px; }
  .pg-input-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .pg-btn { padding: 8px 11px; min-height: 46px; font-size: 0.88rem; }
  .pg-input-row input { min-height: 46px; padding: 8px 10px; }
  .pg-main { grid-template-columns: 1fr; }
  .pg-gauge { max-width: 220px; }
  [data-ui] .ui-controls, [data-ui] .ui-kpi-grid, .arch-list { grid-template-columns: 1fr; }
  .study-list { columns: 1; }
  .pg-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
