:root {
  --ink: #121a2a;
  --muted: #5f6b7d;
  --navy: #102033;
  --navy-soft: #152b42;
  --line: #d9e1ea;
  --panel: #ffffff;
  --surface: #f4f7fb;
  --surface-strong: #edf2f7;
  --blue: #2176d2;
  --blue-dark: #155fac;
  --blue-soft: #e9f2ff;
  --green: #12753d;
  --green-soft: #eaf7ef;
  --red: #ba2d34;
  --red-soft: #fdecee;
  --amber-soft: #fff5df;
  --shadow: 0 12px 32px rgba(18, 26, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  min-height: 76px;
  background: var(--navy);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fbff;
  padding: 0 1.3rem;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  color: #f8fbff;
  min-width: 0;
  overflow: hidden;
}

.brand-lockup:hover,
.brand-lockup:focus {
  color: #f8fbff;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f8fbff;
  font-size: 1.7rem;
}

.brand-lockup strong {
  display: block;
  overflow: hidden;
  font-size: 1.45rem;
  letter-spacing: 0;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-lockup small {
  display: block;
  overflow: hidden;
  margin-top: 0.35rem;
  color: rgba(248, 251, 255, 0.74);
  font-size: 0.76rem;
  letter-spacing: 0.18rem;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.top-nav {
  align-items: center;
  gap: 0.65rem;
}

.top-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 46px;
  padding: 0 1.05rem;
  border-radius: 8px;
  color: rgba(248, 251, 255, 0.8);
  font-weight: 600;
}

.top-nav a.active {
  color: #fff;
  background: #244c78;
}

.top-nav i {
  font-size: 1.15rem;
}

.btn-icon {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.sidebar {
  position: sticky;
  top: 0;
  flex-direction: column;
  height: calc(100vh - 76px);
  padding: 1.5rem 1.25rem;
  border-right: 1px solid var(--line);
  background: #f7f9fc;
}

.side-menu {
  overflow-y: auto;
  padding-right: 0.25rem;
}

.side-menu section + section {
  margin-top: 1.45rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.side-menu h2 {
  margin: 0 0 0.65rem;
  color: #657286;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1rem;
  text-transform: uppercase;
}

.side-menu a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 43px;
  margin: 0.16rem 0;
  padding: 0.55rem 0.7rem;
  border-radius: 7px;
  color: #22324a;
  font-weight: 550;
}

.side-menu a i {
  width: 1.35rem;
  color: #677489;
  font-size: 1.12rem;
  text-align: center;
}

.side-menu a.active {
  color: #145fbd;
  background: var(--blue-soft);
  box-shadow: inset 3px 0 0 var(--blue);
}

.side-menu a.active i {
  color: #145fbd;
}

.rules-footer {
  margin-top: auto;
  padding-top: 1rem;
  color: #748196;
  font-size: 0.82rem;
}

.main-area {
  min-width: 0;
  background: var(--surface);
}

.page-container {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 1.75rem;
}

.content-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.4rem;
}

.content-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.85rem);
  font-weight: 800;
  line-height: 1.08;
}

.content-heading p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.breadcrumb-line,
.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
  color: #34435a;
  font-size: 0.95rem;
  font-weight: 650;
}

.eyebrow {
  color: #657286;
  font-size: 0.78rem;
  letter-spacing: 0.1rem;
  text-transform: uppercase;
}

.mode-tabs {
  display: inline-flex;
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.mode-tabs button {
  min-height: 43px;
  padding: 0 1.05rem;
  border: 0;
  border-right: 1px solid var(--line);
  color: #314057;
  background: transparent;
  font-weight: 650;
}

.mode-tabs button:last-child {
  border-right: 0;
}

.mode-tabs button.active {
  color: #fff;
  background: var(--blue);
}

.module-layout,
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
  align-items: start;
}

.trainer-card,
.reference-card,
.tool-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.trainer-card {
  padding: 1.55rem;
}

.reference-card {
  padding: 1.25rem;
}

.reference-card.wide {
  max-width: 720px;
}

.reference-card h2,
.trainer-card h2 {
  margin: 0 0 1rem;
  font-size: 1.12rem;
  font-weight: 800;
}

.comparison-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1.25rem;
  align-items: center;
  margin-bottom: 1.1rem;
}

.stat-box {
  display: grid;
  min-height: 145px;
  place-items: center;
  border-radius: 8px;
}

.stat-strength {
  background: #eef6fd;
}

.stat-toughness {
  background: #fbefec;
}

.stat-box span {
  color: #657286;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-box strong {
  color: #081629;
  font-size: clamp(4.5rem, 12vw, 7rem);
  line-height: 0.9;
}

.versus {
  color: #a5afbf;
  font-size: 2rem;
  font-weight: 800;
  text-transform: uppercase;
}

.guidance-strip,
.feedback {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  padding: 1rem 1.2rem;
  border-radius: 8px;
}

.guidance-strip {
  background: var(--green-soft);
  color: #0e532d;
  font-size: 1.08rem;
}

.guidance-strip i {
  font-size: 2rem;
}

.guidance-strip span,
.feedback span {
  min-width: 0;
}

.feedback i {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
}

.feedback strong {
  display: block;
  font-size: 1.1rem;
}

.compact-feedback {
  margin-top: 0;
}

.feedback-correct {
  background: var(--green-soft);
}

.feedback-correct i {
  background: var(--green);
}

.feedback-wrong {
  background: var(--red-soft);
}

.feedback-wrong i {
  background: var(--red);
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.7rem;
}

.answer-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.answer-button,
.option-button {
  min-height: 82px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  font-size: 1.7rem;
  font-weight: 800;
}

.answer-button.selected {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 2px var(--blue);
}

.answer-button.correct-answer,
.option-button.correct-answer {
  border-color: var(--green);
  background: var(--green-soft);
  color: #0e532d;
  box-shadow: inset 0 0 0 2px var(--green);
}

.answer-button.wrong-answer,
.option-button.wrong-answer {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
  box-shadow: inset 0 0 0 2px var(--red);
}

.next-button {
  min-height: 58px;
  margin-top: 0.4rem;
  border-color: var(--blue-dark);
  background: var(--blue);
  font-weight: 800;
}

.reference-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
}

.reference-row:first-of-type {
  border-top: 0;
}

.reference-row span {
  color: #26354a;
}

.reference-row strong {
  font-size: 1rem;
}

.reference-row.tall {
  display: block;
}

.reference-row.tall small {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
}

.target-badge {
  display: inline-grid;
  min-width: 64px;
  min-height: 40px;
  place-items: center;
  border-radius: 6px;
}

.target-2 {
  background: var(--green-soft);
  color: var(--green);
}

.target-3 {
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.target-4 {
  background: #eef2f7;
}

.target-5 {
  background: var(--amber-soft);
  color: #80530d;
}

.target-6 {
  background: var(--red-soft);
  color: var(--red);
}

.mini-progress {
  width: 190px;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #ccd6e2;
}

.mini-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.progress-copy {
  color: #46546a;
  font-weight: 650;
}

.trainer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  min-height: 150px;
  padding: 1.2rem;
  text-align: left;
}

.tool-card:hover,
.tool-card:focus-visible {
  border-color: #9fb8d8;
}

.tool-icon {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 1.25rem;
}

.tool-card strong,
.tool-card small,
.tool-card em {
  display: block;
}

.tool-card strong {
  margin-bottom: 0.3rem;
  font-size: 1.15rem;
}

.tool-card small {
  color: var(--muted);
  font-size: 0.95rem;
}

.tool-card em {
  margin-top: 0.9rem;
  color: #657286;
  font-size: 0.86rem;
  font-style: normal;
  font-weight: 700;
}

.scenario-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.15rem;
}

.scenario-strip span,
.scenario-strip-item,
.keyword-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: var(--surface-strong);
  color: #314057;
  font-size: 0.9rem;
  font-weight: 750;
}

.lesson-list {
  display: grid;
  gap: 0.75rem;
}

.lesson-row {
  display: grid;
  gap: 0.3rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
}

.lesson-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.lesson-row strong {
  color: var(--ink);
}

.lesson-row span,
.source-note {
  color: var(--muted);
}

.reference-tags {
  align-items: flex-start;
}

.empty-state.compact {
  min-height: 120px;
}

.dice-controls,
.dice-entry {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
}

.dice-controls label,
.dice-entry label {
  color: #657286;
  font-size: 0.82rem;
  font-weight: 800;
}

.dice-controls .form-select {
  min-width: 170px;
  margin-top: 0.25rem;
}

.toggle-control {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 0.45rem;
}

.toggle-control input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--blue);
}

.dice-entry input {
  display: block;
  width: 180px;
  margin-top: 0.25rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  color: var(--ink);
  background: #fbfdff;
  font-weight: 700;
}

.keyword-chip {
  margin-bottom: 1rem;
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.stacked-options {
  display: grid;
  gap: 0.75rem;
}

.option-button {
  min-height: 64px;
  padding: 0.85rem 1rem;
  text-align: left;
  font-size: 1rem;
  font-weight: 700;
}

.option-button.selected {
  border-color: var(--blue);
}

.dice-line {
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
}

.dice-line span {
  display: block;
  margin-bottom: 0.45rem;
  color: #657286;
  font-size: 0.88rem;
  font-weight: 750;
}

.dice-line strong {
  display: inline-grid;
  width: 34px;
  height: 34px;
  margin-right: 0.35rem;
  place-items: center;
  border-radius: 7px;
  background: #eef2f7;
}

.dice-line strong.pass {
  background: var(--green-soft);
  color: var(--green);
}

.dice-line strong.fail {
  background: var(--red-soft);
  color: var(--red);
}

.dice-line strong.die-result,
.dice-line strong.save-die,
.dice-line strong.wound-die {
  position: relative;
  display: inline-grid;
  width: 38px;
  height: 38px;
  padding: 0;
}

.die-face {
  position: relative;
  display: block;
  width: 26px;
  height: 26px;
}

.pip {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  transform: translate(-50%, -50%);
}

.die-1 .pip-1,
.die-2 .pip-1,
.die-3 .pip-2,
.die-5 .pip-3 {
  left: 50%;
  top: 50%;
}

.die-2 .pip-2,
.die-3 .pip-3,
.die-4 .pip-4,
.die-5 .pip-5,
.die-6 .pip-6 {
  left: 78%;
  top: 78%;
}

.die-3 .pip-1,
.die-4 .pip-1,
.die-5 .pip-1,
.die-6 .pip-1 {
  left: 22%;
  top: 22%;
}

.die-4 .pip-2,
.die-5 .pip-2,
.die-6 .pip-4 {
  left: 78%;
  top: 22%;
}

.die-4 .pip-3,
.die-5 .pip-4,
.die-6 .pip-3 {
  left: 22%;
  top: 78%;
}

.die-6 .pip-2 {
  left: 22%;
  top: 50%;
}

.die-6 .pip-5 {
  left: 78%;
  top: 50%;
}

.die-1 .pip-1,
.die-2 .pip-1,
.die-2 .pip-2,
.die-3 .pip-1,
.die-3 .pip-2,
.die-3 .pip-3,
.die-4 .pip-1,
.die-4 .pip-2,
.die-4 .pip-3,
.die-4 .pip-4,
.die-5 .pip-1,
.die-5 .pip-2,
.die-5 .pip-3,
.die-5 .pip-4,
.die-5 .pip-5,
.die-6 .pip-1,
.die-6 .pip-2,
.die-6 .pip-3,
.die-6 .pip-4,
.die-6 .pip-5,
.die-6 .pip-6 {
  opacity: 1;
}

.result-icon {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: #fff;
  font-size: 0.68rem;
  line-height: 1;
}

.dice-line strong.wound-die.wound {
  background: var(--red-soft);
  color: var(--red);
}

.dice-line strong.wound-die.no-wound {
  background: var(--green-soft);
  color: var(--green);
}

.resolution-card.outcome-colours-off .dice-line strong.pass,
.resolution-card.outcome-colours-off .dice-line strong.fail,
.resolution-card.outcome-colours-off .dice-line strong.wound-die.wound,
.resolution-card.outcome-colours-off .dice-line strong.wound-die.no-wound {
  background: #eef2f7;
  color: #314057;
}

.resolution-card.outcome-colours-off .result-icon {
  background: #fff;
  color: #657286;
}

.empty-state,
.loading-panel {
  display: grid;
  min-height: 320px;
  place-items: center;
  text-align: center;
}

.empty-state i {
  color: var(--blue-dark);
  font-size: 2rem;
}

.empty-state h1,
.empty-state h2 {
  margin: 0.75rem 0 0.35rem;
}

.empty-state p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
}

.offcanvas {
  background: #f7f9fc;
}

.offcanvas .brand-lockup {
  color: var(--ink);
}

.offcanvas .brand-lockup:hover,
.offcanvas .brand-lockup:focus {
  color: var(--ink);
}

.offcanvas .brand-mark {
  color: var(--blue-dark);
  background: var(--blue-soft);
}

.offcanvas .brand-lockup small {
  color: #657286;
}

@media (max-width: 991.98px) {
  .topbar {
    min-height: 68px;
    padding: 0 0.5rem;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .brand-lockup strong {
    font-size: 1.15rem;
  }

  .brand-lockup small {
    font-size: 0.66rem;
    letter-spacing: 0.12rem;
  }

  .app-shell {
    display: block;
    min-height: calc(100vh - 68px);
  }

  .page-container {
    padding: 1rem;
  }

  .content-heading,
  .content-heading.with-actions {
    display: block;
  }

  .mode-tabs {
    display: flex;
    max-width: 100%;
    width: 100%;
    margin-top: 1rem;
    overflow: hidden;
  }

  .mode-tabs button {
    flex: 0 0 25%;
    min-width: 0;
    padding: 0 0.2rem;
    font-size: 0.84rem;
  }

  .module-layout,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .trainer-actions {
    display: block;
    margin-top: 1rem;
  }

  .trainer-actions .progress-copy {
    display: block;
    margin-top: 0.75rem;
  }

  .reference-card {
    order: 2;
  }

  .comparison-panel {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .versus {
    text-align: center;
  }

  .stat-box {
    min-height: 120px;
  }

  .answer-grid,
  .answer-grid.compact,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .answer-button {
    min-height: 64px;
  }

  .mini-progress {
    width: 120px;
  }
}

@media (max-width: 575.98px) {
  .trainer-card,
  .reference-card {
    width: 100%;
    max-width: 360px;
    padding: 1rem;
  }

  .content-heading,
  .module-progress,
  .mode-tabs,
  .module-main {
    width: 100%;
    max-width: 360px;
  }

  .content-heading h1 {
    font-size: 1.85rem;
  }

  .guidance-strip,
  .feedback {
    align-items: flex-start;
  }

  .guidance-strip strong {
    display: block;
  }

  .topbar .container-fluid {
    justify-content: flex-start;
    gap: 0.5rem;
    padding-left: 0;
    padding-right: 0;
  }

  .topbar .brand-lockup {
    max-width: calc(100vw - 78px);
  }

  .topbar .brand-lockup small {
    display: none;
  }

  .module-progress {
    justify-content: space-between !important;
    width: 100%;
  }

  .module-progress .mini-progress {
    flex: 0 1 110px;
  }

  .guidance-strip,
  .feedback {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .guidance-strip span,
  .feedback span {
    overflow-wrap: anywhere;
  }

  .dice-controls,
  .dice-entry {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dice-controls .form-select,
  .dice-entry input {
    width: 100%;
  }
}
