/* OpenDyslexic Font - local-first (SCORM/offline friendly) */
@font-face {
  font-family: 'OpenDyslexic';
  src:
    url('../assets/fonts/OpenDyslexic-Regular.woff2') format('woff2'),
    url('../assets/fonts/OpenDyslexic-Regular.woff') format('woff'),
    url('../assets/fonts/OpenDyslexic-Regular.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'OpenDyslexic';
  src:
    url('../assets/fonts/OpenDyslexic-Bold.woff2') format('woff2'),
    url('../assets/fonts/OpenDyslexic-Bold.woff') format('woff'),
    url('../assets/fonts/OpenDyslexic-Bold.otf') format('opentype');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

/* Base reset ensures predictable layout across browsers */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body, h1, h2, h3, h4, h5, h6, p, ul, ol {
  margin: 0;
  padding: 0;
}

ul, ol {
  list-style: none;
}

/* Brand tokens and shared values */
:root {
  /* Brand colors - WCAG 2.2 AA compliant */
  --color-primary: #283B87;
  --color-secondary: #1157DB;
  --color-accent: #F89621;
  --color-neutral: #70787C;
  --color-bg-dark: #1a1a2e;
  --color-bg-panel: rgba(26, 26, 46, 0.95);
  --color-text: #ffffff;
  --color-text-muted: #b0b0b0;
  --color-text-accent: #8EC5FF;
  --color-graph-line: #2CABE2;
  --color-meter-critical: #FF4444;
  --color-splash-start: #283B87;
  --color-splash-end: #1a1a2e;
  --color-outcome-fail-start: #f44336;
  --color-outcome-fail-end: #c62828;
  --color-positive: #4CAF50;

  /* Accessibility variables */
  --font-family-default: Arial, Verdana, "Helvetica Neue", sans-serif;
  --font-family-dyslexic: "OpenDyslexic", Arial, Verdana, sans-serif;
  --font-size-base: 16px;
  --font-size-scale: 1;
  --focus-outline-color: #A6D4FF;
  --focus-outline-width: 3px;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --border-radius: 8px;
  --shadow-soft: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-strong: 0 4px 16px rgba(0,0,0,0.5);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --color-meter-elevated: #E65100;
}

/* Full-viewport canvas with dark backdrop */
html, body {
  width: 100%;
  height: 100%;
}

body {
  overflow: auto;
  background: var(--color-bg-dark);
  color: var(--color-text);
  font-family: var(--font-family-default);
  font-size: 1rem;
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Game container - uses most of viewport with padding around edges */
#game-container {
  position: relative;
  width: 96vw;
  max-width: 1400px;
  height: 100%;
  min-height: 0;
  background: var(--color-bg-panel);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-strong);
  overflow: auto;
  container-type: inline-size;
  container-name: course;
}

/* Core screen behavior */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: auto;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 1;
}

.screen.fade-out {
  opacity: 0;
}

/* Shared backgrounds */
.splash-background,
.menu-background {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--color-splash-start) 0%, var(--color-splash-end) 100%);
  background-size: cover;
  background-position: center;
  filter: brightness(0.95);
}

.menu-background {
  filter: brightness(0.7);
}

/* Splash screen */
#splash-screen {
  align-items: center;
  justify-content: center;
}

.splash-content {
  position: relative;
  text-align: center;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.logo-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: var(--border-radius);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}
.logo-placeholder img {
  height: 120px;
  width: auto;
  object-fit: contain;
  display: block;
}

.splash-title {
  font-size: 3.2rem;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.splash-subtitle {
  font-size: 1.8rem;
  color: var(--color-text-muted);
}

.splash-cta {
  margin-top: 48px;
  font-size: 1.4rem;
  color: #fff;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 10px;
  min-height: 44px;
  min-width: 44px;
  padding: 12px 28px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
}

.splash-version {
  position: absolute;
  bottom: -60px;
  right: -24px;
  font-size: 1rem;
  color: var(--color-text-muted);
}

/* Main menu */
#main-menu {
  align-items: center;
  justify-content: center;
}

.menu-panel {
  position: relative;
  background: #1a1a2e;
  width: min(480px, 90%);
  padding: 50px 60px;
  border-radius: 16px;
  box-shadow: var(--shadow-strong);
  text-align: center;
  z-index: 1;
}

.menu-title {
  font-size: 2rem;
  margin-bottom: 36px;
  font-weight: 700;
}

.menu-brief,
.menu-help,
.decision-progress,
.meter-legend,
.graph-title,
.graph-axis-label {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.meter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: 0.75rem;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
}

.app-toast {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: 20;
  background: var(--color-bg-panel);
  color: var(--color-text);
  border: 2px solid var(--color-text-accent);
  border-radius: var(--border-radius);
  padding: var(--space-3) var(--space-4);
  max-width: 360px;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 10px;
  padding: 16px 28px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  border: 2px solid var(--color-secondary);
  color: var(--color-text-accent);
}

.btn-secondary:hover {
  background: var(--color-secondary);
  color: #0a1a30;
}

.btn-disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.modal[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.ending-content.ending-pending .ending-dynamic {
  opacity: 0;
}

.ending-content:not(.ending-pending) .ending-dynamic {
  animation: fadeIn 0.35s ease;
}

.btn-text {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  padding: 8px;
  text-decoration: none;
}

.btn-text:hover {
  text-decoration: underline;
}

.btn:focus-visible {
  outline: 3px solid var(--color-secondary);
  outline-offset: 2px;
}

.full-width {
  width: 100%;
}

.icon-button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.icon-button:focus-visible {
  outline: 3px solid var(--color-secondary);
  outline-offset: 2px;
}

.settings-button {
  height: 48px;
  padding: 0 14px;
  gap: 10px;
  font-weight: 700;
}

.icon-glyph {
  font-size: 1.2rem;
  line-height: 1;
}

.icon-label {
  font-size: 1rem;
  line-height: 1;
}

.choice-button {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  background: var(--color-primary);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  box-shadow: var(--shadow-soft);
  opacity: 0;
  transform: translateY(12px);
  flex-shrink: 0;
}

.choice-number {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--color-text-accent);
}

.choice-button:hover {
  background: #1f2f70;
  filter: brightness(1.02);
  transform: translateY(-1px);
}

.choice-button.visible {
  opacity: 1;
  transform: translateY(0);
}

.choice-button:focus-visible {
  outline: 3px solid var(--color-secondary);
  outline-offset: 2px;
}

/* Game screen — CSS grid (R2): top bar / stage / dialogue */
#game-screen {
  display: none;
  background: linear-gradient(135deg, #1a1a2e 0%, #0f1424 100%);
  width: 100%;
  height: 100%;
  min-height: 0;
  text-align: left;
  container-type: size;
  container-name: game;
}

#game-screen.active {
  display: grid;
  grid-template-rows: auto minmax(35%, 1fr) minmax(120px, auto);
  align-content: stretch;
  justify-items: stretch;
  align-self: stretch;
  align-items: stretch;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

#game-top-bar {
  grid-row: 1;
  min-height: 64px;
  max-width: 100%;
  padding: 8px 12px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  min-width: 0;
  overflow-x: clip;
}

.top-bar-leading {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.game-toolbar {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.top-actions {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
}

.top-actions .btn {
  width: auto;
  min-height: 44px;
}

.top-bar-more {
  position: relative;
  flex: 0 0 auto;
}

.top-bar-more-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 12rem;
  padding: var(--space-2, 8px);
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 8px);
  background: var(--color-bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-strong);
  z-index: 20;
}

.top-bar-more-menu .top-bar-tool {
  width: 100%;
  justify-content: flex-start;
  min-height: 44px;
}

.top-bar-more-menu[hidden],
.top-bar-more-trigger[hidden] {
  display: none !important;
}

#game-stage {
  grid-row: 2;
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  container-type: size;
  container-name: stage;
  z-index: 1;
}

#stage-background {
  position: absolute;
  inset: 0;
  background: url('../assets/images/backgrounds/blurred-classroom.png') center/cover no-repeat, linear-gradient(135deg, #283B87 0%, #1a1a2e 100%);
  filter: brightness(0.75);
  transform: scale(1.02);
  transform-origin: center;
}

#character-container {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 1200px);
  height: 100%;
  max-height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
  padding: 0 16px;
  animation: subtle-float 3s ease-in-out infinite;
}

#character-portrait,
#character-image {
  width: auto;
  height: auto;
  max-height: 100%;
  max-width: min(100%, 640px);
  object-fit: contain;
  object-position: bottom center;
  transition: opacity var(--transition-normal), transform 0.3s ease;
  filter:
    drop-shadow(0 0 10px rgba(0, 0, 0, 0.45))
    drop-shadow(0 4px 14px rgba(0, 0, 0, 0.35))
    drop-shadow(0 0 3px rgba(255, 255, 255, 0.45));
}

@container stage (min-height: 1px) {
  #character-container {
    animation: none;
  }

  #character-image {
    height: 90cqh;
    width: auto;
    min-height: 85cqh;
    max-height: 95cqh;
    max-width: 100%;
    object-fit: contain;
  }
}

#character-image.fading {
  opacity: 0;
  transform: scale(0.98);
}

#dialogue-box {
  grid-row: 3;
  position: relative;
  background: var(--color-bg-panel);
  border-top: 3px solid var(--color-primary);
  padding: 28px 16px 12px 16px;
  min-height: 0;
  max-height: min(42cqh, 400px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3;
  overflow: visible;
  flex-shrink: 1;
}

#nameplate {
  position: absolute;
  top: 0;
  left: 24px;
  transform: translateY(calc(-100% + 5px));
  background: var(--color-primary);
  padding: 8px 20px;
  border-radius: 10px;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
  z-index: 30;
}

#dialogue-text-area {
  position: relative;
  padding: 12px 16px 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  min-height: 4.8em;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: visible;
  text-align: left;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#narration-pause-btn,
.narration-pause-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin-top: var(--space-2, 8px);
  padding: 8px 16px;
  border: 2px solid var(--color-secondary);
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#narration-pause-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#narration-pause-btn {
  flex-shrink: 0;
  align-self: flex-start;
}

#previous-choice {
  min-height: auto;
  margin: 0;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

#previous-choice.empty {
  display: none;
}

#dialogue-text {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  font-size: 1.25rem;
  line-height: 1.6;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 4.8em;
  margin: 0;
}

#dialogue-text.visible {
  opacity: 1;
  transform: translateY(0);
}

#ctc-indicator {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 1.2rem;
  color: var(--color-text-muted);
}

#choice-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 2px 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  position: relative;
  z-index: 2;
}

#dialogue-box.choices-active {
  min-height: 0;
  max-height: min(52cqh, 460px);
}

#dialogue-box.choices-active #dialogue-text-area {
  flex: 0 0 auto;
  min-height: 0;
  max-height: none;
  overflow-y: visible;
}

#dialogue-box.choices-active #dialogue-text {
  min-height: 0;
}

#dialogue-box.choices-active #narration-pause-btn {
  display: none;
}

#dialogue-box.choices-active #choice-container {
  flex: 1 1 auto;
  min-height: 8rem;
  max-height: none;
}

#game-bottom-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 4px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

#dialogue-box.choices-active #game-bottom-bar {
  display: none;
}

/* Action buttons (Save, Load, Tips) */
.action-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.action-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.action-button:active {
  transform: translateY(0);
}

.action-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.action-label {
  letter-spacing: 0.5px;
}

/* Save button - green accent */
.save-btn {
  border-color: rgba(76, 175, 80, 0.5);
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.2), rgba(76, 175, 80, 0.1));
}

.save-btn:hover {
  border-color: rgba(76, 175, 80, 0.8);
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.4), rgba(76, 175, 80, 0.2));
}

/* Load button - blue accent */
.load-btn {
  border-color: rgba(33, 150, 243, 0.5);
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.2), rgba(33, 150, 243, 0.1));
}

.load-btn:hover {
  border-color: rgba(33, 150, 243, 0.8);
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.4), rgba(33, 150, 243, 0.2));
}

/* Tips button - yellow/gold accent */
.tips-btn {
  border-color: rgba(255, 193, 7, 0.5);
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.2), rgba(255, 193, 7, 0.1));
}

.tips-btn:hover {
  border-color: rgba(255, 193, 7, 0.8);
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.4), rgba(255, 193, 7, 0.2));
}

.game-toolbar .action-button {
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Escalation meter */
#escalation-meter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 1;
  min-width: 0;
}

@container course (max-width: 1200px) {
  #escalation-meter .meter-legend {
    display: none;
  }
}

.escalation-label {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-text-muted);
}

.escalation-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.escalation-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

.escalation-segment {
  width: 50px;
  height: 16px;
  background: var(--color-neutral);
  border-radius: 2px;
  transition: background-color 0.5s ease, transform 0.3s ease, filter 0.2s ease;
}

.escalation-segment.level-1 { background: var(--color-secondary); }
.escalation-segment.level-2 { background: var(--color-accent); }
.escalation-segment.level-3 { background: var(--color-meter-elevated); animation: pulse 1s infinite; }
.escalation-segment.level-4 { background: var(--color-meter-critical); animation: pulse 0.5s infinite; }

.escalation-value {
  font-size: 0.9rem;
  color: #fff;
  font-weight: 700;
}

/* Data-level based fill for initial view */
#escalation-meter[data-level="0"] .escalation-segment:nth-child(-n+0) { background: var(--color-neutral); }
#escalation-meter[data-level="1"] .escalation-segment:nth-child(-n+1) { background: var(--color-secondary); }
#escalation-meter[data-level="2"] .escalation-segment:nth-child(-n+2) { background: var(--color-accent); }
#escalation-meter[data-level="3"] .escalation-segment:nth-child(-n+3) { background: var(--color-meter-elevated); animation: pulse 1s infinite; }
#escalation-meter[data-level="4"] .escalation-segment:nth-child(-n+4) { background: var(--color-meter-critical); animation: pulse 0.5s infinite; }

.meter-flash .escalation-segment.level-1,
.meter-flash .escalation-segment.level-2,
.meter-flash .escalation-segment.level-3,
.meter-flash .escalation-segment.level-4 {
  filter: brightness(1.2);
  transform: scale(1.02);
}

@keyframes meter-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(248, 150, 33, 0);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(248, 150, 33, 0.5);
  }
}

.escalation-segment.pulsing {
  animation: meter-pulse 1s ease infinite;
}

@keyframes subtle-float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.modal .modal-content {
  background: var(--color-bg-panel);
  border-radius: 12px;
  width: min(500px, 90%);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-strong);
  transform: scale(0.9) translateY(-20px);
  transition: transform 0.3s ease;
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  min-width: 24px;
  min-height: 24px;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.credits-body {
  gap: 14px;
}

.credits-lead {
  margin: 0;
  color: #fff;
  font-weight: 700;
  line-height: 1.35;
}

.credits-list {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.credits-list dt {
  margin: 0;
  color: var(--color-text-muted);
  font-weight: 600;
}

.credits-list dd {
  margin: 4px 0 0 0;
  color: #fff;
  font-weight: 500;
}

.form-section h3 {
  margin-bottom: 12px;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #fff;
  font-weight: 600;
}

.slider-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-control input[type="range"] {
  flex: 1;
  accent-color: var(--color-secondary);
}

.setting-group {
  margin-bottom: 20px;
}

.setting-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.volume-slider {
  flex: 1;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-neutral);
  border-radius: 4px;
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-secondary);
  cursor: pointer;
  transition: transform 0.2s;
}

.volume-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--color-secondary);
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.volume-value {
  min-width: 40px;
  text-align: right;
  font-size: 0.9rem;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.tab-toggle {
  display: flex;
  gap: 8px;
}

.save-slot {
  border: 1px solid var(--color-neutral);
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 12px;
  transition: border-color var(--transition-fast);
}

.save-slot:hover {
  border-color: var(--color-secondary);
}

.slot-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #fff;
}

.slot-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.save-slot.slot-selected {
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 1px var(--color-secondary);
}

.modal-content-wide {
  max-width: min(920px, 96vw);
}

#resources-modal .modal-content {
  width: min(720px, 94vw);
  transform: none;
}

#resources-modal.active .modal-content {
  transform: none;
}

.resources-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.resources-intro {
  margin: 0;
  color: var(--color-text-muted);
}

.resources-job-aid-preview {
  width: 100%;
  color: var(--color-text);
  background: transparent;
  border: none;
  padding: 0;
}

.job-aid-content {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--color-text);
}

.job-aid-heading {
  font-size: 1.15rem;
  margin: 0 0 4px;
  color: var(--color-accent);
}

.job-aid-subheading {
  margin: 0 0 14px;
  font-weight: 600;
  color: var(--color-text);
}

.job-aid-section {
  margin: 14px 0 6px;
  font-size: 1rem;
  color: var(--color-accent);
}

.job-aid-section-positive {
  color: #81C784;
}

.job-aid-section-negative {
  color: #FF8A80;
}

.job-aid-list {
  margin: 0 0 8px;
  padding-left: 1.25rem;
  list-style: disc;
}

.job-aid-list li {
  margin-bottom: 4px;
  color: var(--color-text);
}

.job-aid-techniques {
  margin: 0 0 8px;
}

.job-aid-techniques dt {
  font-weight: 700;
  margin-top: 6px;
  color: var(--color-text);
}

.job-aid-techniques dd {
  margin: 0 0 4px 0;
  padding-left: 0;
  color: var(--color-text-muted);
}

.job-aid-paragraph {
  margin: 0 0 8px;
  color: var(--color-text);
}

.job-aid-footer {
  margin: 14px 0 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 10px;
}

.resources-open-tab {
  align-self: flex-start;
}

.setting-note {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--color-accent);
}

/* Tips modal */
.tips-list {
  gap: 12px;
}

.tip-card {
  background: rgba(255, 255, 255, 0.04);
  padding: 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.tip-card h3 {
  margin-bottom: 6px;
}

.tip-card p {
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Ending screen - New two-column layout */
#ending-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 32px;
  overflow-y: auto;
}

#ending-screen.active {
  display: flex;
  align-self: stretch;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  justify-content: flex-start;
  overflow-y: auto;
}

.ending-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  max-width: 1000px;
  width: 95%;
  margin: 0 auto;
  padding: 0;
  gap: 20px;
}

/* Header row: Badge + Title on left, Stats on right */
.ending-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ending-header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.ending-title-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.outcome-badge {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: badge-appear 0.6s ease-out;
}

.outcome-badge.success {
  background: linear-gradient(135deg, #4CAF50, #2E7D32);
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.4);
}

.outcome-badge.partial {
  background: linear-gradient(135deg, #F89621, #E65100);
  box-shadow: 0 4px 16px rgba(248, 150, 33, 0.4);
}

.outcome-badge.failure {
  background: linear-gradient(135deg, var(--color-outcome-fail-start), var(--color-outcome-fail-end));
  box-shadow: 0 4px 16px rgba(244, 67, 54, 0.4);
}

.badge-icon {
  font-size: 2.5rem;
  color: white;
}

.badge-icon::before {
  content: '✓';
}

.outcome-badge.failure .badge-icon::before {
  content: '✕';
}

.outcome-badge.partial .badge-icon::before {
  content: '!';
}

@keyframes badge-appear {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

#outcome-title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

#outcome-description {
  font-size: 1.1rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* Compact 2x2 stats grid on the right */
.ending-header-right {
  flex-shrink: 0;
}

#outcome-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

#outcome-stats .stat {
  background: rgba(255, 255, 255, 0.05);
  padding: 12px 16px;
  border-radius: 10px;
  text-align: center;
  min-width: 110px;
}

#outcome-stats .stat-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
  line-height: 1.3;
}

#outcome-stats .stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

/* Two-column feedback section */
.ending-feedback-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.feedback-column {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 18px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.feedback-column-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 14px 0;
  color: #fff;
}

.feedback-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.feedback-positive .feedback-icon {
  color: #4CAF50;
}

.feedback-positive .feedback-column-title {
  color: #81C784;
}

.feedback-improve .feedback-icon {
  color: #F89621;
}

.feedback-improve .feedback-column-title {
  color: #FFB74D;
}

.feedback-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feedback-list li {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  padding-left: 18px;
  position: relative;
}

.feedback-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.feedback-positive .feedback-list li {
  color: #A5D6A7;
}

.feedback-improve .feedback-list li {
  color: #FFCC80;
}

/* Interactive escalation graph */
#escalation-path {
  width: 100%;
  margin: 8px 0;
}

.graph-container {
  position: relative;
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 20px 16px;
  min-height: 120px;
  overflow: visible;
}

.escalation-path canvas {
  width: 100%;
  height: 100px;
  display: block;
}

.graph-annotations {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.graph-annotation {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  width: 28px;
  height: 28px;
  padding: 0;
  font-family: inherit;
  border-radius: 50%;
  background: rgba(44, 171, 226, 0.4);
  border: 2px solid #2CABE2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  color: #fff;
  font-weight: bold;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.graph-annotation:hover {
  transform: scale(1.2);
}

/* De-escalating choice - green */
.graph-annotation.positive {
  background: rgba(76, 175, 80, 0.5);
  border-color: var(--color-positive);
}

.graph-annotation.positive:hover {
  background: rgba(76, 175, 80, 0.7);
}

/* Escalating/neutral choice - orange */
.graph-annotation.improve {
  background: rgba(248, 150, 33, 0.5);
  border-color: #F89621;
}

.graph-annotation.improve:hover {
  background: rgba(248, 150, 33, 0.7);
}

.graph-tooltip {
  position: absolute;
  background: rgba(20, 20, 35, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 12px 16px 12px 20px;
  font-size: 0.9rem;
  color: #fff;
  max-width: 240px;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-5px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  border-left: 4px solid #2CABE2;
  backdrop-filter: blur(4px);
}

.graph-tooltip.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Positive/de-escalating tooltip */
.graph-tooltip.positive {
  background: rgba(20, 30, 22, 0.98);
  border-left-color: #4CAF50;
  border-color: rgba(76, 175, 80, 0.3);
}

/* Improve/escalating tooltip */
.graph-tooltip.improve {
  background: rgba(35, 25, 18, 0.98);
  border-left-color: #F89621;
  border-color: rgba(248, 150, 33, 0.3);
}

.graph-tooltip-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: #fff;
  font-size: 0.95rem;
}

.graph-tooltip.positive .graph-tooltip-title {
  color: #81C784;
}

.graph-tooltip.improve .graph-tooltip-title {
  color: #FFB74D;
}

.graph-tooltip-text {
  color: #d0d0d0;
  line-height: 1.5;
}

/* Collapsible detailed feedback */
.outcome-feedback-details {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.feedback-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  user-select: none;
  transition: background 0.2s ease;
}

.feedback-summary:hover {
  background: rgba(255, 255, 255, 0.05);
}

.feedback-summary::-webkit-details-marker {
  display: none;
}

.summary-icon {
  font-size: 1.3rem;
}

.summary-arrow {
  margin-left: auto;
  transition: transform 0.2s ease;
}

.outcome-feedback-details[open] .summary-arrow {
  transform: rotate(180deg);
}

.feedback-content {
  padding: 4px 24px 20px 24px;
}

#outcome-feedback-text {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--color-text-muted);
  margin: 0;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
}

/* Action buttons */
.ending-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 12px;
  width: 100%;
  max-width: 500px;
  align-self: center;
}

.ending-actions .btn {
  flex: 1;
  padding: 16px 28px;
  font-size: 1.1rem;
}

/* Improved Return to Menu button readability */
.ending-actions .btn-secondary {
  background: rgba(17, 87, 219, 0.15);
  border: 2px solid var(--color-secondary);
  color: #fff;
}

.ending-actions .btn-secondary:hover {
  background: var(--color-secondary);
  color: #fff;
}

/* Responsive adjustments for smaller screens */
@container course (max-width: 1280px) {
  .game-toolbar .action-label,
  .accessibility-toggle .accessibility-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .game-toolbar .action-button,
  .accessibility-toggle {
    min-width: 44px;
    padding: 8px 10px;
  }
}

@container course (max-width: 1100px) {
  #game-top-bar .icon-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  #game-top-bar .top-actions .btn {
    font-size: 0.85rem;
    padding: 8px 10px;
  }
}

@container course (max-width: 480px) {
  #game-container {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }

  .escalation-segment {
    width: 28px;
  }

  .escalation-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  #game-top-bar {
    padding: 6px 8px;
    gap: 4px;
  }

  .top-actions .btn {
    font-size: 0.8rem;
    padding: 6px 8px;
    min-height: 44px;
  }
}

@container course (max-width: 720px) {
  .game-toolbar .action-label,
  .accessibility-toggle .accessibility-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .game-toolbar .action-button {
    min-width: 44px;
    padding: 8px 10px;
  }
}

@media (max-width: 900px) {
  #escalation-meter .meter-legend {
    display: none;
  }

  .choice-button {
    font-size: 0.95rem;
    padding: 12px 14px;
  }
}

@media (max-height: 720px) {
  #ending-screen.active {
    justify-content: flex-start;
    padding: 12px 16px;
  }

  .ending-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .ending-header-right {
    width: 100%;
  }

  #outcome-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #outcome-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 768px) {
  .ending-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .ending-header-right {
    width: 100%;
  }

  #outcome-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .ending-feedback-columns {
    grid-template-columns: 1fr;
  }
}

/* Utility helpers */
.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.5s ease;
}

.fade-out {
  animation: fadeOut 0.5s ease;
}

.pulse {
  animation: pulse 1.6s ease-in-out infinite;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

/* ============================================
   ACCESSIBILITY STYLES
   ============================================ */

/* Font size scaling */
html {
  font-size: calc(var(--font-size-base) * var(--font-size-scale));
}

html.font-size-small { --font-size-scale: 0.875; }
html.font-size-medium { --font-size-scale: 1; }
html.font-size-large { --font-size-scale: 1.25; }
html.font-size-xlarge { --font-size-scale: 1.5; }
html.font-size-large #choice-container,
html.font-size-xlarge #choice-container {
  max-height: min(46vh, 420px);
}

html.font-size-large .choice-button,
html.font-size-xlarge .choice-button {
  font-size: 1rem;
  line-height: 1.5;
}

/* Dyslexia-friendly font */
body.dyslexia-font {
  font-family: var(--font-family-dyslexic);
  letter-spacing: 0.05em;
  word-spacing: 0.1em;
  line-height: 1.8;
}

body.dyslexia-font #dialogue-text {
  line-height: 2;
}

/* High contrast mode */
body.high-contrast {
  --color-bg-dark: #000000;
  --color-bg-panel: #000000;
  --color-text: #ffffff;
  --color-text-muted: #ffffff;
  --color-primary: #0000ff;
  --color-secondary: #ffff00;
  --color-accent: #ffff00;
  --color-neutral: #ffffff;
}

body.high-contrast .btn-primary {
  background: #0000ff;
  border: 2px solid #ffffff;
}

body.high-contrast .btn-secondary {
  background: transparent;
  border: 2px solid #ffff00;
  color: #ffff00;
}

body.high-contrast .choice-button {
  background: #000000;
  border: 3px solid #ffff00;
  color: #ffffff;
}

body.high-contrast .choice-button:hover,
body.high-contrast .choice-button:focus {
  background: #ffff00;
  color: #000000;
}

body.high-contrast #dialogue-box {
  background: #000000;
  border-top: 4px solid #ffff00;
}

body.high-contrast #nameplate {
  background: #0000ff;
  border: 2px solid #ffffff;
}

body.high-contrast .modal-content {
  background: #000000;
  border: 2px solid #ffffff;
}

body.high-contrast .resources-job-aid-preview,
body.high-contrast .job-aid-content,
body.high-contrast .job-aid-list li,
body.high-contrast .job-aid-paragraph,
body.high-contrast .job-aid-subheading,
body.high-contrast .job-aid-techniques dt {
  color: #ffffff;
  background: #000000;
}

body.high-contrast .job-aid-heading,
body.high-contrast .job-aid-section {
  color: #ffff00;
}

body.high-contrast .job-aid-techniques dd,
body.high-contrast .job-aid-footer,
body.high-contrast .resources-intro {
  color: #ffff00;
}

body.high-contrast .escalation-segment {
  border: 1px solid #ffffff;
}

body.high-contrast .escalation-segment.pulsing,
body.high-contrast .escalation-segment.level-4,
body.high-contrast #escalation-meter[data-level="3"] .escalation-segment,
body.high-contrast #escalation-meter[data-level="4"] .escalation-segment {
  animation: none;
}

body.enhanced-focus {
  --focus-outline-width: 5px;
}

body.text-spacing {
  letter-spacing: 0.12em;
  word-spacing: 0.16em;
  line-height: 1.5;
}

@media (forced-colors: active) {
  body,
  #game-container,
  .modal-content,
  #dialogue-box {
    background: Canvas;
    color: CanvasText;
  }

  .btn,
  .choice-button,
  .modal-close {
    border: 2px solid ButtonText;
    background: ButtonFace;
    color: ButtonText;
  }

  *:focus-visible {
    outline: 3px solid Highlight;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

body.reduced-motion #character-container {
  animation: none;
}

body.reduced-motion #character-image,
body.reduced-motion #character-image.fading {
  opacity: 1;
  transform: none;
}

body.reduced-motion .pulse {
  animation: none;
}

body.reduced-motion .choice-button {
  opacity: 1;
  transform: none;
}

body.reduced-motion .choice-button.visible {
  opacity: 1;
  transform: none;
}

/* Enhanced focus indicators */
*:focus-visible {
  outline: var(--focus-outline-width) solid var(--focus-outline-color);
  outline-offset: 2px;
}

body.high-contrast *:focus-visible {
  outline: 4px solid #ffff00;
  outline-offset: 2px;
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: var(--border-radius);
  z-index: 10000;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 10px;
}

/* Click to continue indicator - positioned inline with bottom bar */
.click-to-continue {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  background: rgba(17, 87, 219, 0.35);
  border: 1px solid #5a9aff;
  border-radius: var(--border-radius);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  animation: ctc-pulse 2s ease-in-out infinite;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.click-to-continue.visible {
  display: flex;
}

.click-to-continue-icon {
  font-size: 1.1rem;
}

@keyframes ctc-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

body.reduced-motion .click-to-continue {
  animation: none;
  opacity: 1;
}

/* Accessibility quick-access — top bar tool (R3) */
.accessibility-toggle {
  position: static;
  min-width: 44px;
  min-height: 44px;
  height: auto;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--color-primary);
  border: 2px solid var(--color-secondary);
  color: #ffffff;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease, transform 0.2s ease;
}

.accessibility-toggle:hover {
  transform: translateY(-1px);
  background: var(--color-secondary);
}

.accessibility-toggle:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

.accessibility-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.accessibility-label {
  font-weight: 700;
  line-height: 1;
}

/* Screen reader only class */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ARIA live region styling */
.aria-live-region {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Accessibility modal specific styles */
#accessibility-modal {
  justify-content: flex-start;
  padding: 24px;
}

#accessibility-modal .modal-content {
  width: min(520px, 92%);
}

#accessibility-modal .modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

@media (max-width: 600px) {
  #accessibility-modal {
    justify-content: center;
    padding: 16px;
  }
}

.a11y-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.a11y-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.a11y-section h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  color: var(--color-secondary);
}

.a11y-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.a11y-option-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.a11y-option-label span:first-child {
  font-weight: 600;
  color: #ffffff;
}

.a11y-option-label span:last-child {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 56px;
  height: 28px;
  background: var(--color-neutral);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.toggle-switch.active {
  background: var(--color-secondary);
}

.toggle-switch.active::after {
  transform: translateX(28px);
}

.toggle-switch:focus-visible {
  outline: 3px solid var(--focus-outline-color);
  outline-offset: 2px;
}

/* Button group for font size */
.btn-group {
  display: flex;
  gap: 4px;
}

.btn-group .btn-option {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--color-neutral);
  border-radius: 6px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-group .btn-option:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-group .btn-option.active {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: #ffffff;
}

.btn-group .btn-option:focus-visible {
  outline: 2px solid var(--focus-outline-color);
  outline-offset: 1px;
}

/* Keyboard shortcuts help */
.keyboard-shortcuts {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

.shortcut-key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.shortcut-key kbd {
  background: var(--color-bg-dark);
  border: 1px solid var(--color-neutral);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: monospace;
  font-size: 0.85rem;
  color: #ffffff;
}

.shortcut-action {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
