  :root {
    --bg: #0b0d12;
    --panel: #121622;
    --panel2: #171c2b;
    --text: #e9ecf5;
    --muted: #a7afc7;
    --border: rgba(255,255,255,0.10);
    --accent: #6ea8fe;
    --accent2: #8bd3ff;
    --warn: #ffcc66;
    --ui-scale: 1;
    --sub-options-scale: 1;
  }

  * { box-sizing: border-box; }
  html, body {
    margin: 0; padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  }

  .app-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .app-header {
    padding: 1.5% 2% 1% 2%;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0));
  }

  .mode-pill {
    display: inline-block;
    margin-bottom: 0.55rem;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(139, 211, 255, 0.36);
    background: rgba(110, 168, 254, 0.14);
    color: var(--accent2);
    font-size: calc(11px * var(--ui-scale));
    letter-spacing: 0.02em;
  }

  .app-title { font-size: calc(18px * var(--ui-scale)); font-weight: 650; letter-spacing: 0.2px; }
  .app-subtitle { margin-top: calc(6px * var(--ui-scale)); font-size: calc(13px * var(--ui-scale)); color: var(--muted); }

  .app-main {
    flex: 1;
    padding: 1.5%;
    display: flex;
    min-height: 0;
    overflow: hidden;
  }
  .app-footer {
    padding: 1% 1.5%;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: calc(12px * var(--ui-scale));
  }

  .view { display: none; width: 100%; min-height: 0; overflow: hidden; }
  .view-active { display: block; width: 100%; min-height: 100%; overflow: hidden; }
  #view-home.view-active {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    align-items: center;
    justify-content: center;
  }
  .grid-2 {
    display: flex;
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    align-items: center;
    justify-content: center;
  }
  #view-player.view-active { display: flex; flex-direction: column; min-height: 0; }

  /* Primary options grid */
  .primary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: clamp(0.5rem, 1.4vmin, 1.2rem);
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
  }

  .card {
    container-type: size;
    background: var(--panel);
    border: max(0.06rem, 0.12cqi) solid var(--border);
    border-radius: clamp(0.55rem, 1.2cqi, 1.2rem);
    padding: clamp(0.65rem, 4cqi, 1.8rem);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: clamp(0.4rem, 1.8cqi, 0.9rem);
    min-height: 0;
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
    user-select: none;
  }
  .card:hover { transform: translateY(-0.08em); border-color: rgba(255,255,255,0.18); background: var(--panel2); }
  .card-title {
    font-size: clamp(1rem, 8cqi, 2.1rem);
    line-height: 1.12;
    font-weight: 650;
    max-width: 100%;
  }
  .card-desc {
    margin-top: 0;
    font-size: clamp(0.76rem, 4.1cqi, 1.35rem);
    color: var(--muted);
    line-height: 1.3;
    max-width: 100%;
  }

  /* Buttons */
  .btn {
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    padding: 1% 1.4%;
    border-radius: calc(0.9vw * var(--ui-scale));
    cursor: pointer;
    font-size: calc(13px * var(--ui-scale));
  }
  .btn:hover { border-color: rgba(255,255,255,0.18); background: var(--panel2); }
  .btn:disabled { opacity: 0.45; cursor: not-allowed; }

  .btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
  }

  /* Player layout */
  .player-toolbar {
    display: flex;
    align-items: center;
    gap: 1.2%;
    margin: 0 0 1.2% 0;
    width: 100%;
  }

  .player-meta { display: flex; flex-direction: column; gap: 4px; }
  .player-title { font-weight: 650; font-size: calc(16px * var(--ui-scale)); }
  .player-status { font-size: calc(12px * var(--ui-scale)); color: var(--muted); }

  .player-layout {
    display: grid;
    gap: 1.2%;
    width: 100%;
    margin: 0;
    flex: 1;
    min-height: 0;
  }

  .player-layout--single {
    grid-template-columns: 1fr;
  }

  .player-layout--split {
    grid-template-columns: 58% 42%;
    align-items: stretch;
  }

  .video-pane {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: calc(1.2vw * var(--ui-scale));
    padding: 1.2%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 220ms ease, opacity 220ms ease;
  }

  .video-el {
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: calc(0.9vw * var(--ui-scale));
    background: #000;
    object-fit: contain;
  }

  .video-hint {
    margin-top: 1%;
    font-size: calc(12px * var(--ui-scale));
    color: var(--muted);
  }

  .sub-pane {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: calc(1.2vw * var(--ui-scale));
    padding: 1.2%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateX(0);
    transition: transform 240ms ease, opacity 240ms ease;
  }
  .sub-pane--hidden { display: none; }

  .is-desktop .sub-pane {
    transform: translateX(10px);
    opacity: 0;
  }

  .is-desktop .player-layout--revealed .video-pane {
    transform: translateX(-8px);
  }

  .is-desktop .player-layout--revealed .sub-pane {
    transform: translateX(0);
    opacity: 1;
  }

  .sub-pane-title {
    font-size: calc(13px * var(--ui-scale));
    font-weight: 650;
    margin-bottom: calc(10px * var(--ui-scale));
    color: var(--muted);
  }

  .sub-options-list {
    display: flex;
    flex-direction: column;
    gap: 1%;
    flex: 1;
    min-height: 0;
    overflow: auto;
    font-size: calc(14px * var(--ui-scale) * var(--sub-options-scale));
  }

  .sub-options-list--fill .sub-option {
    flex: 1 1 0;
    min-height: 0;
  }

  .sub-option {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.75em;
    padding: 0.72em 0.9em;
    border-radius: 0.85em;
    border: max(0.06rem, 0.09em) solid var(--border);
    background: rgba(255,255,255,0.03);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  }

  .sub-option:hover {
    border-color: rgba(110,168,254,0.55);
    box-shadow: 0 0 0 0.14em rgba(110,168,254,0.08);
    background: rgba(110,168,254,0.06);
  }

  .sub-option-label {
    font-size: 1em;
    font-weight: 600;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .sub-option-time {
    font-size: 0.79em;
    color: var(--muted);
    white-space: nowrap;
  }

  .sub-option .btn {
    font-size: 0.9em;
    padding: 0.55em 0.9em;
    border-radius: 0.7em;
    justify-self: end;
    white-space: nowrap;
  }

  .sub-option--active {
    border-color: rgba(110,168,254,0.75);
    box-shadow: 0 0 0 0.2em rgba(110,168,254,0.12);
    background: rgba(110,168,254,0.08);
  }

  .sub-option--locked .sub-option-label::after {
    content: " • locked";
    font-weight: 500;
    color: var(--warn);
    font-size: 0.86em;
  }

  .sub-pane-footnote {
    margin-top: 1%;
    font-size: calc(12px * var(--ui-scale));
    color: var(--muted);
  }

  .sub-context {
    margin-top: 1%;
    display: flex;
    flex-direction: column;
    gap: 0.6%;
  }

  .sub-context-label {
    font-size: calc(12px * var(--ui-scale));
    font-weight: 600;
    color: var(--muted);
  }

  .sub-context-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: calc(0.8vw * var(--ui-scale));
    padding: 1%;
    background: rgba(255,255,255,0.03);
    color: var(--text);
    font: inherit;
    resize: none;
    min-height: 12%;
  }

  .sub-context-input:focus {
    outline: none;
    border-color: rgba(110,168,254,0.65);
    box-shadow: 0 0 0 2px rgba(110,168,254,0.12);
  }

  .muted { color: var(--muted); }

  .is-mobile .primary-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-rows: minmax(0, 1fr);
    width: min(96vw, 42rem);
    height: 100%;
    max-height: 100%;
    gap: clamp(0.4rem, 1.2vh, 0.85rem);
  }

  .is-mobile .player-layout--split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

  .is-mobile .sub-pane {
    transform: translateY(8px);
    opacity: 0;
  }

  .is-mobile .player-layout--revealed .sub-pane {
    transform: translateY(0);
    opacity: 1;
  }

  @media (pointer: coarse) and (orientation: portrait) {
    .primary-grid {
      grid-template-columns: 1fr;
      grid-template-rows: none;
      grid-auto-rows: minmax(0, 1fr);
      width: min(96vw, 42rem);
      height: 100%;
      max-height: 100%;
      gap: clamp(0.4rem, 1.2vh, 0.85rem);
    }

    .player-layout--split {
      grid-template-columns: 1fr;
      grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    }

    .sub-pane {
      transform: translateY(8px);
      opacity: 0;
    }

    .player-layout--revealed .sub-pane {
      transform: translateY(0);
      opacity: 1;
    }
  }

  /* ── Outcome screen (Screen 5) ── */
  #view-outcome.view-active {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .outcome-card {
    width: min(680px, 92vw);
    max-height: 88vh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  .outcome-header {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
  }

  .outcome-code {
    font-size: calc(12px * var(--ui-scale));
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .outcome-name {
    font-size: calc(22px * var(--ui-scale));
    font-weight: 700;
    color: var(--text);
  }

  .outcome-body { display: flex; flex-direction: column; gap: 1.25rem; }

  .outcome-section { display: flex; flex-direction: column; gap: 0.35rem; }

  .outcome-label {
    font-size: calc(11px * var(--ui-scale));
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .outcome-text {
    font-size: calc(14px * var(--ui-scale));
    line-height: 1.6;
    color: var(--text);
  }

  .outcome-route {
    font-size: calc(13px * var(--ui-scale));
    color: var(--accent2);
    font-weight: 600;
  }

  .outcome-collingridge {
    background: var(--panel2);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 0.9rem 1.1rem;
  }

  .outcome-footer {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
  }

  .outcome-done {
    font-size: calc(13px * var(--ui-scale));
    color: var(--muted);
    text-align: center;
  }

  @media (max-width: 43.75em) {
    .card, .video-pane, .sub-pane { border-radius: 4vw; }
    .btn { border-radius: 3vw; }
    .sub-context-input { border-radius: 3vw; }
  }


/* ═══════════════════════════════════════════════════════════════════
   9-PAGE UX REDESIGN — appended 2026-04-11
   All rules use existing CSS variables. No changes to rules above.
═══════════════════════════════════════════════════════════════════ */

/* ── View layout base ── */
.view-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  width: 100%;
}

/* ── Primary button ── */
.btn-primary {
  background: var(--accent);
  color: #0b0d12;
  border-color: transparent;
  font-weight: 650;
}
.btn-primary:hover:not(:disabled) { background: var(--accent2); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Page-level header / footer ── */
.page-header {
  padding: clamp(0.75rem, 2vw, 1.5rem) clamp(1rem, 3vw, 2rem);
  width: 100%;
  max-width: min(960px, 96vw);
}
.page-title {
  font-size: calc(22px * var(--ui-scale));
  font-weight: 700;
  color: var(--text);
}
.page-footer {
  padding: clamp(0.75rem, 2vw, 1.5rem) clamp(1rem, 3vw, 2rem);
  width: 100%;
  max-width: min(960px, 96vw);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ── Landing ── */
.landing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(1.1rem * var(--ui-scale));
  text-align: center;
  max-width: min(680px, 90vw);
  padding: 2rem;
}
.landing-title {
  font-size: calc(54px * var(--ui-scale));
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.landing-subtitle {
  font-size: calc(17px * var(--ui-scale));
  color: var(--accent2);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.landing-desc {
  font-size: calc(14px * var(--ui-scale));
  color: var(--muted);
  line-height: 1.65;
  max-width: 480px;
}
.landing-actions {
  display: flex;
  gap: calc(0.9rem * var(--ui-scale));
  flex-wrap: wrap;
  justify-content: center;
  margin-top: calc(0.4rem * var(--ui-scale));
}

/* ── Video pages ── */
.video-page-layout {
  display: flex;
  flex-direction: column;
  width: min(1100px, 96vw);
  height: 100%;
  min-height: 0;
  gap: clamp(0.5rem, 1vh, 1rem);
  padding: clamp(0.5rem, 1vw, 1rem);
}
.video-page-header { padding: 0.25rem 0.5rem; }
.video-page-pane {
  flex: 1;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(10px * var(--ui-scale));
  padding: clamp(0.75rem, 1.5vw, 1.25rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}
.video-page-pane .video-el {
  flex: 1;
  min-height: 0;
  width: 100%;
  border-radius: calc(6px * var(--ui-scale));
  background: #000;
}
.video-controls {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── Card selected state ── */
.card--selected {
  border-color: var(--accent) !important;
  background: rgba(110, 168, 254, 0.10) !important;
  box-shadow: 0 0 0 2px rgba(110, 168, 254, 0.22);
}

/* ── Role decision grid ── */
.decision-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.5rem, 1.2vmin, 1rem);
  width: min(900px, 92vw);
  max-height: 62vh;
  overflow-y: auto;
  padding: 0.25rem;
}
.decision-option { cursor: pointer; }

/* ── Dynamic tension ── */
.tension-card {
  width: min(740px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(10px * var(--ui-scale));
  padding: clamp(1.25rem, 3vw, 2.25rem);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.tension-header {
  font-size: calc(19px * var(--ui-scale));
  font-weight: 700;
  color: var(--text);
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.tension-body { display: flex; flex-direction: column; gap: 0.9rem; }
.tension-block { display: flex; flex-direction: column; gap: 0.25rem; }
.tension-label {
  font-size: calc(10px * var(--ui-scale));
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.tension-value {
  font-size: calc(13px * var(--ui-scale));
  color: var(--text);
  line-height: 1.55;
}
.tensions-list { display: flex; flex-direction: column; gap: 0.45rem; }
.tension-item {
  background: var(--panel2);
  border-left: 3px solid var(--warn);
  border-radius: 0 5px 5px 0;
  padding: 0.55rem 0.85rem;
  font-size: calc(12px * var(--ui-scale));
  color: var(--text);
  line-height: 1.5;
}

/* ── Final scenario ── */
.scenario-card {
  width: min(700px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(10px * var(--ui-scale));
  padding: clamp(1.25rem, 3vw, 2.25rem);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.scenario-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.scenario-tag {
  font-size: calc(10px * var(--ui-scale));
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.scenario-title {
  font-size: calc(22px * var(--ui-scale));
  font-weight: 700;
  color: var(--text);
}
.scenario-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: calc(13px * var(--ui-scale));
  line-height: 1.65;
  color: var(--text);
}
.scenario-collingridge {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: calc(6px * var(--ui-scale));
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.scenario-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

/* ── Explore outcomes menu ── */
.explore-card {
  width: min(600px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(10px * var(--ui-scale));
  padding: clamp(1.25rem, 3vw, 2.25rem);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-height: 86vh;
  overflow-y: auto;
}
.explore-links { display: flex; flex-direction: column; gap: 0.65rem; }
.explore-link {
  cursor: pointer;
  text-align: left;
  padding: 0.85rem 1.1rem;
  font-size: calc(13px * var(--ui-scale));
}
.explore-link:hover { border-color: var(--accent); }

/* ── Participant stats ── */
.stats-card {
  width: min(700px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(10px * var(--ui-scale));
  padding: clamp(1.25rem, 3vw, 2.25rem);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.stats-content { display: flex; flex-direction: column; }
.stats-grid { display: flex; flex-direction: column; gap: 0.8rem; }
.stat-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto;
  align-items: center;
  gap: 0.85rem;
}
.stat-label { font-size: calc(12px * var(--ui-scale)); color: var(--text); line-height: 1.3; }
.stat-bar-wrap { height: 7px; background: rgba(255,255,255,0.07); border-radius: 4px; overflow: hidden; }
.stat-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.5s ease; min-width: 2px; }
.stat-count { font-size: calc(11px * var(--ui-scale)); color: var(--muted); white-space: nowrap; }

/* ── Reusable outcome text classes (used in scenario body) ── */
.outcome-label {
  font-size: calc(10px * var(--ui-scale));
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.outcome-text {
  font-size: calc(12px * var(--ui-scale));
  color: var(--text);
  line-height: 1.6;
  margin-top: 0.25rem;
}

@media (max-width: 43.75em) {
  .decision-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr auto; }
  .stat-bar-wrap { display: none; }
}
