:root {
  color-scheme: light;
  --bg: #111821;
  --ink: #17202d;
  --muted: #6b7484;
  --line: rgba(44, 55, 73, 0.18);
  --panel: rgba(255, 255, 255, 0.94);
  --accent: #147f86;
  --accent-2: #bd6d25;
  --accent-3: #6e57c8;
  --gold: #d8b65f;
  --soft: #eaf7f3;
  --warn: #fff1d8;
  --bad: #b4332b;
  --good: #176f3f;
  --glass: rgba(255, 255, 255, 0.82);
  --game-dark: rgba(14, 21, 32, 0.92);
  --shadow-sm: 0 10px 28px rgba(14, 21, 32, 0.12);
  --shadow-md: 0 18px 42px rgba(14, 21, 32, 0.18);
  --shadow-glow: 0 0 0 1px rgba(216, 182, 95, 0.2), 0 18px 50px rgba(30, 210, 220, 0.12);
  --ui-choice: url("/static/visual/ui/choice_button_normal.png");
  --ui-choice-active: url("/static/visual/ui/choice_button_selected.png");
  --ui-bubble: url("/static/visual/ui/conversation_textbox_small.png");
  --ui-bubble-large: url("/static/visual/ui/conversation_textbox_large.png");
  --ui-name-plate: url("/static/visual/ui/character_name_plate.png");
  --ui-result: url("/static/visual/ui/chapter_clear_result_frame.png");
  --ui-timer: url("/static/visual/ui/mock_timer_frame.png");
  --ui-review-card: url("/static/visual/ui/review_queue_card_frame.png");
  --ui-unlock: url("/static/visual/ui/unit_unlock_key_light.png");
  --ui-question-analysis-hud: url("/static/visual/ui/question_analysis_hud.png");
  --ui-srs-vault: url("/static/visual/ui/srs_vault_room_and_boxes.png");
  --fx-correct: url("/static/visual/ui/correct_teal_check_light.png");
  --fx-wrong: url("/static/visual/ui/incorrect_red_noise.png");
  --fx-repair: url("/static/visual/ui/weakness_repair_effect.png");
  --bg-quiz-battle-terminal: url("/static/visual/backgrounds/quiz-battle-terminal.png");
  --anim-sparkle: url("/static/visual/animations/conversation_sparkle_8f.png");
  --anim-scan: url("/static/visual/animations/log_analysis_scan_line_8f.png");
  --anim-unlock: url("/static/visual/animations/story_chapter_unlock_8f.png");
  --anim-review-transfer: url("/static/visual/animations/review_card_add_8f.png");
  --anim-srs-level: url("/static/visual/animations/srs_box_level_up_8f.png");
  --anim-mock-gate-open: url("/static/visual/animations/mock_gate_open_12f.png");
  --anim-null-repair: url("/static/visual/animations/weakness_overcome_repair_8f.png");
  --map-road: url("/static/visual/extras/map_circuit_road.png");
  --map-city-node: url("/static/visual/extras/map_city_node.png");
  --map-forest-node: url("/static/visual/extras/map_forest_node.png");
  --map-gate-node: url("/static/visual/extras/map_gate_node.png");
  --map-portal-node: url("/static/visual/extras/map_portal_node.png");
  --rank-star: url("/static/visual/extras/rank_star_badge.png");
  --result-ranks: url("/static/visual/badges/result_ranks.png");
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(10, 16, 25, 0.9), rgba(18, 24, 33, 0.48) 360px, rgba(247, 245, 240, 0.94) 780px),
    url("/static/visual/backgrounds/story-city.jpg") top center / cover fixed no-repeat,
    var(--bg);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.6;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.86), rgba(0, 0, 0, 0.12) 72%, transparent);
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid rgba(23, 111, 115, 0.35);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.topbar {
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 52px);
  border-bottom: 1px solid rgba(216, 182, 95, 0.32);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(90deg, rgba(30, 210, 220, 0.16), transparent 18%, transparent 82%, rgba(216, 182, 95, 0.16)),
    linear-gradient(135deg, rgba(12, 18, 30, 0.98), rgba(37, 31, 58, 0.92) 48%, rgba(16, 26, 38, 0.96)),
    var(--game-dark);
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.24), inset 0 -1px 0 rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent) 0 0 / 220px 100% no-repeat,
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 220px 100%, 28px 28px, 28px 28px;
  opacity: 0.82;
  animation: topbar-scan 8s linear infinite;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto clamp(16px, 4vw, 48px) -1px clamp(16px, 4vw, 48px);
  height: 3px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, transparent, rgba(30, 210, 220, 0.92), rgba(216, 182, 95, 0.92), rgba(110, 87, 200, 0.82), transparent);
  box-shadow: 0 0 18px rgba(30, 210, 220, 0.38);
}

.topbar-corner {
  position: absolute;
  z-index: 1;
  top: 12px;
  bottom: 12px;
  width: 74px;
  pointer-events: none;
  opacity: 0.9;
  background:
    url("/static/visual/extras/small_spark_burst.png") center / 46px 46px no-repeat,
    linear-gradient(135deg, transparent 0 30%, rgba(30, 210, 220, 0.22) 31% 34%, transparent 35%),
    linear-gradient(45deg, transparent 0 66%, rgba(216, 182, 95, 0.35) 67% 70%, transparent 71%);
  filter: drop-shadow(0 0 12px rgba(30, 210, 220, 0.22));
}

.topbar-corner-left {
  left: 8px;
  transform: scaleX(-1);
}

.topbar-corner-right {
  right: 8px;
}

@keyframes topbar-scan {
  from {
    background-position: -240px 0, 0 0, 0 0;
  }
  to {
    background-position: calc(100% + 240px) 0, 28px 0, 0 28px;
  }
}

.brand {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: max-content;
  padding: 6px 16px 6px 7px;
  border: 1px solid rgba(216, 182, 95, 0.28);
  border-radius: 18px 8px 18px 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04)),
    rgba(7, 12, 22, 0.38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 12px 28px rgba(0, 0, 0, 0.18);
  text-decoration: none;
  color: #fff;
}

.brand::after {
  content: "";
  position: absolute;
  right: -9px;
  top: 50%;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(216, 182, 95, 0.48);
  background: linear-gradient(135deg, rgba(30, 210, 220, 0.72), rgba(110, 87, 200, 0.72));
  box-shadow: 0 0 14px rgba(30, 210, 220, 0.34);
  transform: translateY(-50%) rotate(45deg);
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border: 1px solid rgba(216, 182, 95, 0.64);
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.18), transparent 54%),
    linear-gradient(135deg, rgba(30, 210, 220, 0.34), rgba(110, 87, 200, 0.42)),
    #1b2434;
  border-radius: 14px;
  box-shadow: 0 0 0 3px rgba(30, 210, 220, 0.08), 0 0 24px rgba(30, 210, 220, 0.2);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  pointer-events: none;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.08);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: clamp(18px, 1.7vw, 24px);
  line-height: 1.05;
  text-shadow: 0 0 18px rgba(30, 210, 220, 0.26);
}

.brand small,
.eyebrow,
.meta,
.list-head p,
dt {
  color: var(--muted);
  font-size: 13px;
}

.topnav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.topnav a,
.topnav button,
.back-link,
.image-links a {
  border: 1px solid rgba(216, 182, 95, 0.3);
  border-radius: 6px;
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.topnav a,
.topnav button {
  position: relative;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 18px rgba(0, 0, 0, 0.14);
}

.topnav a::before,
.topnav button::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  width: 6px;
  height: 6px;
  border: 1px solid rgba(30, 210, 220, 0.6);
  background: rgba(30, 210, 220, 0.32);
  transform: translateY(-50%) rotate(45deg);
  opacity: 0.76;
}

.topnav a,
.topnav button {
  padding-left: 22px;
  padding-right: 10px;
  font-size: 13px;
}

.topnav a:hover::before,
.topnav button:hover::before {
  background: rgba(216, 182, 95, 0.86);
  border-color: rgba(216, 182, 95, 0.92);
  box-shadow: 0 0 12px rgba(216, 182, 95, 0.44);
}

.topnav form {
  margin: 0;
}

.topnav button {
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font: inherit;
}

.topnav span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 48px) 96px;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.site-footer a {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto 56px;
}

.flash-list {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.flash-list p {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  font-weight: 700;
}

.summary {
  position: relative;
  overflow: visible;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 28px;
  align-items: end;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(216, 182, 95, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(239, 250, 250, 0.82)),
    var(--glass);
  box-shadow: var(--shadow-glow);
  margin-bottom: 22px;
}

.summary::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 3px;
  background: linear-gradient(90deg, rgba(30, 210, 220, 0.9), rgba(216, 182, 95, 0.86), rgba(110, 87, 200, 0.72));
  border-radius: 999px;
}

.visual-bg {
  min-height: 280px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.94) 0 45%, rgba(255, 255, 255, 0.72) 70%, rgba(255, 255, 255, 0.28)),
    var(--visual-bg) center / cover no-repeat;
  box-shadow: var(--shadow-sm);
}

.visual-bg > * {
  position: relative;
  z-index: 1;
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.summary-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(216, 182, 95, 0.34);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(236, 247, 247, 0.96));
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 8px 18px rgba(14, 21, 32, 0.08);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.summary-actions a:hover,
.topnav a:hover,
.topnav button:hover,
.back-link:hover,
.image-links a:hover {
  border-color: rgba(30, 210, 220, 0.62);
  box-shadow: 0 10px 24px rgba(30, 210, 220, 0.14);
  transform: translateY(-1px);
}

html[data-visual-mode="rpg"] .summary-actions a.rpg-mode-only,
body[data-visual-mode="rpg"] .summary-actions a.rpg-mode-only {
  display: inline-flex !important;
}

.companion-stage {
  position: relative;
  display: grid;
  place-items: end center;
  width: 170px;
  min-height: 138px;
  align-self: stretch;
}

.companion-stage.compact-stage {
  width: 164px;
  min-height: 166px;
}

.companion-large {
  position: relative;
  z-index: 2;
  max-width: 128px;
  max-height: 146px;
  object-fit: contain;
  filter: drop-shadow(0 14px 12px rgba(29, 36, 48, 0.18));
}

.compact-stage .companion-large {
  max-width: 126px;
  max-height: 138px;
}

.companion-small,
.companion-item {
  position: absolute;
  right: 4px;
  bottom: 4px;
  z-index: 3;
  width: 54px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 8px 8px rgba(29, 36, 48, 0.2));
}

.companion-small {
  left: 0;
  right: auto;
  width: 62px;
  height: 62px;
}

.panel-art {
  float: right;
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin: 0 0 8px 12px;
  filter: drop-shadow(0 8px 8px rgba(29, 36, 48, 0.14));
}

.side-companion {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.side-companion img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.side-companion p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

@keyframes companion-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@keyframes companion-float-alt {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(4px, -5px); }
}

@keyframes pulse-soft {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.08); opacity: 1; }
}

@keyframes celebrate-pop {
  0%, 100% { transform: rotate(-1deg) scale(1); }
  50% { transform: rotate(2deg) scale(1.04); }
}

@keyframes focus-breath {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 14px 12px rgba(29, 36, 48, 0.18)); }
  50% { transform: scale(1.025); filter: drop-shadow(0 16px 16px rgba(112, 75, 143, 0.24)); }
}

.float-a {
  animation: companion-float 4.8s ease-in-out infinite;
}

.float-b {
  animation: companion-float-alt 5.6s ease-in-out infinite;
}

.pulse-soft {
  animation: pulse-soft 2.8s ease-in-out infinite;
}

.celebrate {
  animation: celebrate-pop 3.2s ease-in-out infinite;
}

.focus-breath {
  animation: focus-breath 3.6s ease-in-out infinite;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

h1,
h2 {
  letter-spacing: 0;
  line-height: 1.25;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
}

h2 {
  margin: 0;
  font-size: 20px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
}

.metrics.compact {
  grid-template-columns: repeat(2, minmax(96px, 1fr));
}

.metrics div {
  min-width: 82px;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(240, 247, 246, 0.92));
  border: 1px solid rgba(216, 182, 95, 0.25);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.metrics span {
  display: block;
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
}

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

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(216, 182, 95, 0.2);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.user-progress {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-progress p {
  margin: 0;
  color: var(--muted);
}

.dashboard-hero p {
  max-width: 700px;
  color: var(--muted);
}

.dashboard-command {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 24px;
}

.dashboard-command > article,
.dashboard-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.dashboard-command > article span {
  color: var(--accent);
  font-weight: 900;
}

.dashboard-command h2,
.dashboard-command p {
  margin: 4px 0 0;
}

.dashboard-command p,
.dashboard-panel p {
  color: var(--muted);
}

.dashboard-grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, 0.9fr));
  gap: 12px;
  margin-bottom: 24px;
}

.dashboard-panel.primary {
  border-color: #9ac7b5;
  background: #f4fbf7;
}

.dashboard-panel h3 {
  margin: 10px 0 6px;
}

.dashboard-panel a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-top: 10px;
  padding: 7px 12px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.dashboard-panel p {
  margin: 8px 0 0;
}

.dashboard-panel p strong {
  display: inline-flex;
  min-width: 54px;
  color: var(--ink);
}

.filters label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.filters select,
.filters input[type="number"],
.filters button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
}

.filters button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}

.filters .check {
  display: flex;
  align-items: center;
  min-height: 38px;
  color: var(--ink);
}

.quiz-command-panel,
.mock-setup-panel {
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
  padding: 18px;
  border: 1px solid rgba(216, 182, 95, 0.26);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(238, 250, 250, 0.88)),
    radial-gradient(circle at 90% 8%, rgba(30, 210, 220, 0.18), transparent 34%),
    #fff;
  box-shadow: var(--shadow-sm);
}

.quiz-command-panel::after,
.mock-setup-panel::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -26px;
  width: 220px;
  height: 220px;
  pointer-events: none;
  background: url("/static/visual/items/truth-key.png") center / contain no-repeat;
  opacity: 0.08;
  filter: saturate(1.2);
  transform: rotate(-10deg);
}

.mock-setup-panel::after {
  background-image: url("/static/visual/effects/mock-pass.png");
}

.quiz-command-panel > *,
.mock-setup-panel > * {
  position: relative;
  z-index: 1;
}

.quiz-config,
.mock-config {
  display: grid;
  grid-template-columns: 120px 160px 130px 150px minmax(220px, 1fr) 130px;
  gap: 12px;
  align-items: end;
  margin: 0;
  padding: 14px;
  background: rgba(11, 18, 30, 0.035);
  border-color: rgba(23, 111, 115, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.mock-config {
  grid-template-columns: 110px 180px 140px 130px minmax(220px, 1fr) 150px;
}

.quiz-config .field-wide {
  min-width: 0;
}

.quiz-start-actions,
.mock-start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.quiz-config .quiz-start-actions {
  grid-column: 5 / -1;
  justify-content: flex-end;
}

.mock-config .mock-start-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.quiz-start-actions button,
.mock-start-actions button {
  min-width: 120px;
}

.filters .primary-action,
.mock-start-actions .primary-action {
  border-color: rgba(23, 111, 115, 0.82);
  background:
    linear-gradient(135deg, rgba(23, 111, 115, 0.98), rgba(30, 145, 151, 0.96)),
    var(--accent);
  box-shadow: 0 10px 24px rgba(23, 111, 115, 0.22);
}

.quiz-shortcuts,
.mode-link-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.quiz-shortcuts a,
.mode-link-strip a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid rgba(216, 182, 95, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(14, 21, 32, 0.06);
}

.quiz-shortcuts a {
  border-color: rgba(23, 111, 115, 0.24);
  color: var(--accent);
}

body[data-endpoint="adventure"] .story-hero > * {
  min-width: 0;
}

body[data-endpoint="adventure"] .story-hero .metrics.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body[data-endpoint="adventure"] .story-hero .metrics div {
  min-width: 0;
  overflow-wrap: anywhere;
}

body[data-endpoint="adventure"] .story-hero .guide-line {
  flex-wrap: wrap;
}

body[data-endpoint="adventure"] .story-hero .guide-line p {
  flex: 1 1 100px;
  min-width: 0;
  overflow-wrap: anywhere;
}

body[data-endpoint="adventure"] .story-node {
  min-width: 0;
}

body[data-endpoint="adventure"] .mode-link-strip a {
  justify-content: center;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  text-align: center;
  overflow-wrap: anywhere;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.question-list {
  display: grid;
  gap: 8px;
}

.question-row {
  display: grid;
  grid-template-columns: 96px 42px 58px minmax(0, 1fr) minmax(260px, 0.55fr);
  gap: 10px;
  align-items: center;
  min-height: 68px;
  padding: 12px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(239, 249, 249, 0.92));
  border: 1px solid rgba(44, 55, 73, 0.14);
  border-radius: 8px;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.question-row::before {
  content: "";
  width: 4px;
  align-self: stretch;
  grid-row: 1;
  grid-column: 1;
  justify-self: start;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--gold));
  transform: translateX(-7px);
}

.source-citation {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.source-citation.compact {
  font-size: 12px;
}

.question-row:hover,
.choice:hover {
  border-color: var(--accent);
}

.question-row:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.period,
.subject,
.qtype {
  white-space: nowrap;
  font-size: 13px;
}

.subject,
.qtype {
  justify-self: start;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.subject-A {
  background: var(--soft);
  color: var(--accent);
}

.subject-B,
.qtype {
  background: var(--warn);
  color: var(--accent-2);
}

.question-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.question-page {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.question-side,
.question-card,
.explanation,
.empty {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(246, 249, 247, 0.94));
  border: 1px solid rgba(216, 182, 95, 0.22);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.question-side {
  padding: 16px;
  position: sticky;
  top: 96px;
}

.question-side dl {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
}

.question-side dt,
.question-side dd {
  margin: 0;
}

.question-card {
  padding: clamp(18px, 4vw, 34px);
}

.question-card h1 {
  font-size: clamp(22px, 3vw, 34px);
  max-width: 900px;
}

.image-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
}

.question-figures {
  display: grid;
  gap: 14px;
  margin: 18px 0 4px;
}

.question-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, max-content));
  gap: 12px;
  align-items: start;
}

.question-image-card {
  display: grid;
  gap: 8px;
  max-width: min(100%, 720px);
  padding: 10px;
  border: 1px solid rgba(24, 132, 139, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--accent);
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(24, 52, 70, 0.08);
}

.question-image-card span {
  font-size: 13px;
}

.question-image-card img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
}

.question-image-card.has-image-preview,
.choice-image.has-image-preview {
  cursor: zoom-in;
}

.question-image-card.has-image-preview {
  position: relative;
}

.question-image-card.has-image-preview::after,
.choice-body:has(.choice-image.has-image-preview)::after {
  content: "拡大";
  display: inline-grid;
  width: fit-content;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border: 1px solid rgba(24, 132, 139, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--accent);
  font-size: 12px;
  font-weight: 1000;
  line-height: 1;
}

.choice-image-gallery {
  margin-top: 2px;
}

.choice-image-reference span {
  color: var(--ink);
}

.exam-supplement-figure {
  margin: 0;
  padding: clamp(14px, 3vw, 22px);
  border: 1px solid rgba(25, 130, 136, 0.22);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 250, 250, 0.96));
  box-shadow: 0 14px 32px rgba(24, 52, 70, 0.08);
}

.exam-supplement-figure figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  color: var(--ink);
  font-weight: 900;
}

.exam-supplement-figure figcaption > span {
  display: inline-grid;
  place-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(24, 132, 139, 0.12);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0;
}

.exam-supplement-figure p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.memory-flow {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 42px minmax(150px, 1fr) 42px minmax(110px, 1fr);
  gap: 8px;
  align-items: center;
  margin: 16px 0;
}

.memory-node {
  min-height: 58px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 2px solid rgba(24, 132, 139, 0.28);
  border-radius: 12px;
  background:
    radial-gradient(circle at top, rgba(70, 240, 255, 0.18), transparent 58%),
    #fff;
  color: var(--ink);
  font-weight: 900;
  text-align: center;
}

.memory-arrow {
  height: 2px;
  background: linear-gradient(90deg, rgba(24, 132, 139, 0.2), rgba(24, 132, 139, 0.9));
  position: relative;
}

.memory-arrow::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-top: 2px solid rgba(24, 132, 139, 0.9);
  border-right: 2px solid rgba(24, 132, 139, 0.9);
  transform: translateY(-50%) rotate(45deg);
}

.memory-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
  border: 1px solid rgba(44, 55, 73, 0.12);
  border-radius: 12px;
}

.memory-access-table {
  width: 100%;
  min-width: 460px;
  border-collapse: collapse;
  background: #fff;
}

.memory-access-table th,
.memory-access-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(44, 55, 73, 0.1);
  color: var(--ink);
  text-align: left;
}

.memory-access-table thead th {
  background: rgba(24, 132, 139, 0.08);
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
}

.memory-access-table tbody th {
  font-weight: 900;
}

.memory-access-table tbody td {
  font-weight: 800;
}

.memory-access-table tr:last-child th,
.memory-access-table tr:last-child td {
  border-bottom: 0;
}

.figure-formula {
  margin-top: 12px !important;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(13, 20, 32, 0.06);
  color: var(--ink) !important;
  font-weight: 800;
}

.binary-solver-figure {
  overflow: hidden;
}

.binary-solver-head {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.binary-solver-head > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(24, 132, 139, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.binary-solver-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.binary-solver-head strong {
  color: var(--ink);
  font-size: clamp(22px, 4vw, 36px);
  line-height: 1.1;
}

.binary-solver-head small {
  margin-left: 2px;
  font-size: 0.58em;
}

.binary-weight-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px;
  margin: 14px 0 4px;
}

.binary-weight-cell {
  position: relative;
  display: grid;
  gap: 6px;
  min-height: 116px;
  padding: 12px 10px;
  border: 2px solid rgba(111, 124, 145, 0.2);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 247, 0.94));
  box-shadow: 0 12px 28px rgba(24, 52, 70, 0.08);
  text-align: center;
}

.binary-weight-cell::before {
  content: "";
  position: absolute;
  inset: 9px 12px auto;
  height: 7px;
  border-radius: 999px;
  background: rgba(111, 124, 145, 0.16);
}

.binary-weight-cell.is-on {
  border-color: rgba(24, 132, 139, 0.42);
  background:
    radial-gradient(circle at 50% 18%, rgba(70, 240, 255, 0.28), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(234, 251, 249, 0.95));
}

.binary-weight-cell.is-on::before {
  background: linear-gradient(90deg, rgba(40, 215, 198, 0.98), rgba(70, 240, 255, 0.92));
  box-shadow: 0 0 14px rgba(70, 240, 255, 0.52);
}

.binary-weight-cell .weight-label {
  margin-top: 12px;
  color: var(--muted);
  font-weight: 900;
}

.binary-weight-cell b {
  color: var(--ink);
  font-size: 42px;
  line-height: 1;
}

.binary-weight-cell small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.binary-weight-cell em {
  justify-self: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(111, 124, 145, 0.12);
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.binary-weight-cell.is-on em {
  background: rgba(24, 132, 139, 0.12);
  color: var(--accent);
}

.solver-steps {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding-left: 22px;
  color: var(--ink);
  line-height: 1.65;
}

.solver-steps li::marker {
  color: var(--accent);
  font-weight: 900;
}

html[data-visual-mode="rpg"] .binary-solver-figure,
body[data-visual-mode="rpg"] .binary-solver-figure {
  border-color: rgba(70, 240, 255, 0.34);
  background:
    radial-gradient(circle at 86% 0%, rgba(143, 91, 255, 0.18), transparent 34%),
    radial-gradient(circle at 10% 10%, rgba(70, 240, 255, 0.22), transparent 32%),
    linear-gradient(145deg, rgba(8, 14, 28, 0.94), rgba(17, 27, 45, 0.9));
  box-shadow: 0 0 28px rgba(70, 240, 255, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

html[data-visual-mode="rpg"] .binary-solver-figure figcaption,
html[data-visual-mode="rpg"] .binary-solver-figure p,
html[data-visual-mode="rpg"] .binary-solver-head strong,
html[data-visual-mode="rpg"] .solver-steps,
body[data-visual-mode="rpg"] .binary-solver-figure figcaption,
body[data-visual-mode="rpg"] .binary-solver-figure p,
body[data-visual-mode="rpg"] .binary-solver-head strong,
body[data-visual-mode="rpg"] .solver-steps {
  color: #f3fbff !important;
}

html[data-visual-mode="rpg"] .binary-solver-head > div,
body[data-visual-mode="rpg"] .binary-solver-head > div {
  border-color: rgba(70, 240, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
}

html[data-visual-mode="rpg"] .binary-solver-head span,
html[data-visual-mode="rpg"] .binary-weight-cell .weight-label,
html[data-visual-mode="rpg"] .binary-weight-cell small,
body[data-visual-mode="rpg"] .binary-solver-head span,
body[data-visual-mode="rpg"] .binary-weight-cell .weight-label,
body[data-visual-mode="rpg"] .binary-weight-cell small {
  color: rgba(243, 251, 255, 0.72);
}

html[data-visual-mode="rpg"] .binary-weight-cell,
body[data-visual-mode="rpg"] .binary-weight-cell {
  border-color: rgba(70, 240, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(8, 14, 28, 0.88), rgba(14, 23, 39, 0.78)),
    var(--ui-choice) center / 100% 100% no-repeat;
}

html[data-visual-mode="rpg"] .binary-weight-cell.is-on,
body[data-visual-mode="rpg"] .binary-weight-cell.is-on {
  border-color: rgba(70, 240, 255, 0.7);
  box-shadow: 0 0 18px rgba(70, 240, 255, 0.22);
}

html[data-visual-mode="rpg"] .binary-weight-cell b,
body[data-visual-mode="rpg"] .binary-weight-cell b {
  color: #f3fbff;
  text-shadow: 0 0 18px rgba(70, 240, 255, 0.24);
}

.truth-table-figure {
  overflow: hidden;
}

.truth-table-wrap {
  overflow-x: auto;
  margin: 16px 0 4px;
  border: 1px solid rgba(24, 132, 139, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.truth-table-board {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  color: var(--ink);
  text-align: center;
}

.truth-table-board th,
.truth-table-board td {
  padding: 12px 14px;
  border: 1px solid rgba(44, 55, 73, 0.12);
  font-weight: 900;
}

.truth-table-board thead th {
  background: rgba(24, 132, 139, 0.1);
  color: var(--accent);
  font-size: 13px;
}

.truth-table-board tbody th {
  background: rgba(44, 55, 73, 0.06);
}

.truth-table-board td:nth-child(n+3) {
  font-size: 18px;
}

html[data-visual-mode="rpg"] .truth-table-figure,
body[data-visual-mode="rpg"] .truth-table-figure {
  border-color: rgba(70, 240, 255, 0.34);
  background:
    radial-gradient(circle at 90% 8%, rgba(143, 91, 255, 0.2), transparent 34%),
    radial-gradient(circle at 6% 10%, rgba(70, 240, 255, 0.2), transparent 34%),
    linear-gradient(145deg, rgba(8, 14, 28, 0.94), rgba(17, 27, 45, 0.9));
  box-shadow: 0 0 28px rgba(70, 240, 255, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

html[data-visual-mode="rpg"] .truth-table-figure figcaption,
html[data-visual-mode="rpg"] .truth-table-figure p,
html[data-visual-mode="rpg"] .truth-table-figure .solver-steps,
body[data-visual-mode="rpg"] .truth-table-figure figcaption,
body[data-visual-mode="rpg"] .truth-table-figure p,
body[data-visual-mode="rpg"] .truth-table-figure .solver-steps {
  color: #f3fbff !important;
}

html[data-visual-mode="rpg"] .truth-table-wrap,
body[data-visual-mode="rpg"] .truth-table-wrap {
  border-color: rgba(70, 240, 255, 0.24);
  background:
    linear-gradient(180deg, rgba(8, 14, 28, 0.88), rgba(14, 23, 39, 0.78)),
    var(--ui-choice) center / 100% 100% no-repeat;
}

html[data-visual-mode="rpg"] .truth-table-board,
body[data-visual-mode="rpg"] .truth-table-board {
  color: #f3fbff;
}

html[data-visual-mode="rpg"] .truth-table-board th,
html[data-visual-mode="rpg"] .truth-table-board td,
body[data-visual-mode="rpg"] .truth-table-board th,
body[data-visual-mode="rpg"] .truth-table-board td {
  border-color: rgba(70, 240, 255, 0.16);
}

html[data-visual-mode="rpg"] .truth-table-board thead th,
body[data-visual-mode="rpg"] .truth-table-board thead th {
  background: rgba(70, 240, 255, 0.12);
  color: #7df6ff;
}

html[data-visual-mode="rpg"] .truth-table-board tbody th,
body[data-visual-mode="rpg"] .truth-table-board tbody th {
  background: rgba(255, 255, 255, 0.07);
}

@media (max-width: 720px) {
  .memory-flow {
    grid-template-columns: 1fr;
  }

  .memory-arrow {
    width: 2px;
    height: 24px;
    margin: 0 auto;
    background: linear-gradient(180deg, rgba(24, 132, 139, 0.2), rgba(24, 132, 139, 0.9));
  }

  .memory-arrow::after {
    right: auto;
    left: 50%;
    top: auto;
    bottom: -1px;
    transform: translateX(-50%) rotate(135deg);
  }

  .binary-solver-head {
    grid-template-columns: 1fr;
  }

  .binary-weight-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .binary-weight-cell {
    min-height: 104px;
  }
}

.choices {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.choice {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(44, 55, 73, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.94)),
    var(--ui-choice) center / 100% 100% no-repeat,
    #fff;
  color: var(--ink);
  padding: 10px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(14, 21, 32, 0.06);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.choice span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(30, 210, 220, 0.16), rgba(216, 182, 95, 0.2));
  color: var(--accent);
  font-weight: 800;
}

.choice b {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.choice-body {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.choice-image-label {
  display: inline-flex;
  width: fit-content;
  min-height: 30px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid rgba(24, 132, 139, 0.22);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(30, 210, 220, 0.18), rgba(216, 182, 95, 0.18)),
    #fff;
  color: var(--accent);
  font-size: 14px;
  font-weight: 1000;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(14, 21, 32, 0.08);
}

.choice-image {
  display: block;
  width: min(100%, 360px);
  max-height: 260px;
  object-fit: contain;
  border: 1px solid rgba(24, 132, 139, 0.18);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(14, 21, 32, 0.08);
}

.choice-image:focus-visible {
  outline: 4px solid rgba(70, 240, 255, 0.72);
  outline-offset: 3px;
}

.image-preview-modal[hidden] {
  display: none;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 28px);
}

.image-preview-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(5, 9, 16, 0.78);
}

.image-preview-panel {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(96vw, 1180px);
  max-height: 92svh;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(70, 240, 255, 0.34);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(239, 249, 250, 0.96)),
    #fff;
  box-shadow: 0 32px 90px rgba(5, 9, 16, 0.38);
}

.image-preview-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(24, 132, 139, 0.16);
}

.image-preview-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(18px, 3vw, 26px);
}

.image-preview-head button {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid rgba(24, 132, 139, 0.28);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.image-preview-frame {
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: auto;
  padding: clamp(10px, 2vw, 18px);
}

.image-preview-frame img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(92svh - 96px);
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
}

body.image-preview-open {
  overflow: hidden;
}

.battle-result-dashboard {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  margin: 18px 0;
  padding: clamp(16px, 3vw, 24px);
  border: 1px solid rgba(70, 240, 255, 0.28);
  border-radius: 18px;
  background:
    radial-gradient(circle at 18% 22%, rgba(70, 240, 255, 0.16), transparent 32%),
    linear-gradient(135deg, rgba(7, 11, 22, 0.94), rgba(21, 17, 42, 0.9));
  color: #fff;
  box-shadow: var(--rpg-shadow-cyan);
}

.battle-result-core span,
.battle-result-meters span {
  color: var(--rpg-gold);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0;
  text-transform: uppercase;
}

.battle-result-core h2 {
  margin: 6px 0 8px;
  color: #fff;
  font-size: clamp(24px, 4vw, 40px);
}

.battle-result-core p {
  margin: 0;
  color: rgba(238, 248, 255, 0.78);
  font-weight: 800;
  line-height: 1.7;
}

.battle-result-meters {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.battle-result-meters article {
  display: grid;
  gap: 5px;
  min-height: 112px;
  align-content: center;
  padding: 12px;
  border: 1px solid rgba(70, 240, 255, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.battle-result-meters strong {
  color: #fff;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1;
}

.battle-result-meters small {
  color: rgba(238, 248, 255, 0.68);
  font-weight: 800;
}

.battle-result-meters i {
  display: block;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(70, 240, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.battle-result-meters em {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rpg-cyan), var(--rpg-gold));
}

@media (max-width: 820px) {
  .battle-result-dashboard {
    grid-template-columns: 1fr;
  }

  .battle-result-meters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .battle-result-meters {
    grid-template-columns: 1fr;
  }
}

.choice-text-fallback {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.choice.correct {
  border-color: var(--good);
  background:
    linear-gradient(rgba(238, 248, 241, 0.72), rgba(238, 248, 241, 0.86)),
    var(--ui-choice-active) center / 100% 100% no-repeat,
    #eef8f1;
}

.choice.wrong.selected {
  border-color: var(--bad);
  background:
    linear-gradient(rgba(255, 240, 238, 0.72), rgba(255, 240, 238, 0.9)),
    var(--fx-wrong) right center / auto 150% no-repeat,
    #fff0ee;
}

.result {
  min-height: 48px;
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  background: #f2f3f1;
  color: var(--muted);
}

.result.ok {
  background:
    linear-gradient(rgba(238, 248, 241, 0.68), rgba(238, 248, 241, 0.9)),
    var(--fx-correct) right center / auto 170% no-repeat,
    #eef8f1;
  color: var(--good);
}

.result.ng {
  background:
    linear-gradient(rgba(255, 240, 238, 0.72), rgba(255, 240, 238, 0.92)),
    var(--fx-wrong) right center / auto 170% no-repeat,
    #fff0ee;
  color: var(--bad);
}

.attempt-form {
  margin-top: 12px;
}

.attempt-form button,
.auth-panel button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.explanation {
  margin-top: 14px;
  padding: 14px 18px;
}

.explanation summary {
  cursor: pointer;
  font-weight: 800;
}

.explanation p {
  overflow-wrap: anywhere;
}

.explanation-main h2,
.choice-explanation-list h2 {
  margin: 14px 0 8px;
  font-size: 18px;
}

.choice-explanation-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.choice-explanation-list article {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.choice-explanation-list article > span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-weight: 900;
}

.choice-explanation-list article.is-correct {
  border-color: rgba(23, 111, 115, 0.34);
  background: linear-gradient(135deg, rgba(241, 255, 252, 0.96), #fff);
}

.choice-explanation-list article.is-wrong {
  border-color: rgba(183, 69, 84, 0.22);
}

.choice-explanation-list h3,
.choice-explanation-list p {
  margin: 0;
}

.choice-explanation-list p {
  margin-top: 4px;
  color: var(--muted);
}

.empty {
  padding: 24px;
}

.empty.slim {
  padding: 12px 14px;
  margin-bottom: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-panel {
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stat-panel p {
  margin: 8px 0 0;
  color: var(--muted);
}

.stat-panel .big-number {
  color: var(--ink);
  font-size: 38px;
  font-weight: 850;
  line-height: 1.1;
}

.quiz-mode-guide {
  margin-bottom: 24px;
}

.quiz-mode-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.quiz-mode-grid article {
  min-height: 160px;
  padding: 16px;
  border: 1px solid rgba(23, 111, 115, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(244, 251, 247, 0.9)),
    radial-gradient(circle at top right, rgba(72, 199, 184, 0.12), transparent 44%);
  box-shadow: var(--shadow-sm);
}

.quiz-mode-grid span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.quiz-mode-grid h3 {
  margin: 10px 0 8px;
}

.quiz-mode-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.below {
  margin-top: 26px;
}

.weak-list {
  display: grid;
  gap: 8px;
}

.weak-list a {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
}

.weak-list strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weak-list span {
  color: var(--muted);
  font-size: 13px;
}

.review-list {
  display: grid;
  gap: 8px;
}

.review-row {
  position: relative;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 210px 92px;
  gap: 12px;
  align-items: center;
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
}

.review-row.due {
  border-color: #9ac7b5;
  background: #f4fbf7;
}

.review-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-row span,
.review-row em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.review-row .box-level {
  display: inline-flex;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-weight: 800;
}

.review-coach {
  margin-bottom: 22px;
}

.review-coach-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.review-coach-grid article {
  padding: 16px;
  border: 1px solid rgba(23, 111, 115, 0.14);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.review-coach-main {
  background:
    linear-gradient(145deg, rgba(244, 251, 247, 0.96), rgba(255, 255, 255, 0.96)),
    radial-gradient(circle at top right, rgba(72, 199, 184, 0.14), transparent 42%);
}

.review-coach-grid article > span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.review-coach-grid h3 {
  margin: 10px 0 6px;
}

.review-coach-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.box-meter {
  display: grid;
  gap: 7px;
}

.box-meter p {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.box-meter strong {
  color: var(--ink);
}

.challenge-form,
.challenge-results {
  display: grid;
  gap: 12px;
}

.challenge-card,
.result-row,
.quality-grid article {
  padding: 16px;
  border: 1px solid rgba(216, 182, 95, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(246, 249, 247, 0.94));
  box-shadow: var(--shadow-sm);
}

.challenge-head {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.challenge-head > span,
.result-row > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(216, 182, 95, 0.4);
  background:
    linear-gradient(135deg, rgba(30, 210, 220, 0.28), rgba(110, 87, 200, 0.42)),
    var(--ink);
  color: #fff;
  font-weight: 900;
}

.challenge-head h2 {
  font-size: 18px;
}

.challenge-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.challenge-choices label {
  display: grid;
  grid-template-columns: 18px 38px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 50px;
  padding: 8px;
  border: 1px solid rgba(44, 55, 73, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.challenge-choices label:hover {
  border-color: rgba(30, 210, 220, 0.42);
  box-shadow: 0 8px 20px rgba(30, 210, 220, 0.12);
  transform: translateY(-1px);
}

.challenge-choices span {
  font-weight: 900;
}

.challenge-choices b,
.result-row strong {
  overflow-wrap: anywhere;
}

.challenge-choices .choice-body {
  align-items: center;
}

.challenge-choices label.has-choice-image {
  align-items: start;
  grid-template-columns: 18px 42px minmax(0, 1fr);
  min-height: 220px;
  padding: 12px;
}

.challenge-choices label.has-choice-image > span {
  position: sticky;
  top: 8px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(30, 210, 220, 0.18), rgba(216, 182, 95, 0.2)),
    #fff;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(24, 132, 139, 0.16);
}

.challenge-choices label.has-choice-image .choice-image {
  width: 100%;
  max-height: 240px;
}

.challenge-choices label.has-choice-image .choice-image-label {
  margin-bottom: 2px;
}

.challenge-submit {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.challenge-submit button,
.challenge-submit a,
.result-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.result-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 86px;
  gap: 12px;
  align-items: center;
}

.result-row.ok > span {
  background: var(--good);
}

.result-row.ng > span {
  background: var(--accent-2);
}

.result-row p {
  margin: 4px 0 0;
  color: var(--muted);
}

.mock-readiness,
.next-step {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mock-readiness div {
  display: grid;
  place-items: center;
  min-height: 86px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent);
}

.mock-readiness span {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.mock-setup-hero {
  align-items: center;
}

.mock-official-rules {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
  padding: 18px;
  border: 1px solid rgba(23, 111, 115, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(238, 250, 250, 0.9)),
    radial-gradient(circle at 86% 10%, rgba(72, 199, 184, 0.16), transparent 40%);
  box-shadow: var(--shadow-sm);
}

.mock-official-rules h2,
.mock-official-rules p {
  margin: 0;
}

.mock-official-rules h2 {
  margin-bottom: 6px;
}

.mock-time-split,
.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mock-time-split article,
.resource-grid article {
  padding: 13px;
  border: 1px solid rgba(23, 111, 115, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}

.mock-time-split span,
.resource-grid span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.mock-time-split strong {
  display: block;
  margin: 5px 0;
  font-size: 18px;
}

.mock-time-split small,
.resource-grid p {
  color: var(--muted);
  line-height: 1.6;
}

.mock-warnings {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.mock-warnings p {
  margin: 0;
  padding: 11px 13px;
  border: 1px solid rgba(216, 182, 95, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 249, 232, 0.96), rgba(255, 255, 255, 0.94));
  color: #7c5a15;
  font-weight: 800;
}

.setup-preview {
  margin-bottom: 22px;
}

.mock-distribution {
  margin-bottom: 24px;
}

.mock-distribution-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.mock-distribution-grid article {
  min-height: 130px;
  padding: 14px;
  border: 1px solid rgba(23, 111, 115, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(244, 251, 247, 0.9)),
    radial-gradient(circle at top right, rgba(110, 87, 200, 0.12), transparent 48%);
  box-shadow: var(--shadow-sm);
}

.mock-distribution-grid span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.mock-distribution-grid h3 {
  margin: 8px 0 6px;
  font-size: 16px;
}

.mock-distribution-grid p {
  margin: 0;
  color: var(--muted);
}

.mock-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid #9ac7b5;
  border-radius: 8px;
  background: #f4fbf7;
}

.mock-control article {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.mock-timer {
  display: grid;
  place-items: center;
  min-height: 64px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.mock-control.is-warning .mock-timer {
  background: var(--accent-2);
}

.mock-control h2,
.mock-control p {
  margin: 0;
}

.mock-control p {
  color: var(--muted);
}

.mock-control-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mock-control-actions button,
.question-tools a {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.exam-rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.exam-rules article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.exam-rules span {
  color: var(--accent);
  font-weight: 900;
}

.exam-rules h2 {
  margin: 6px 0;
  font-size: 16px;
}

.exam-rules p {
  margin: 4px 0 0;
  color: var(--muted);
}

.mock-plan {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.mock-plan article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mock-plan h2 {
  margin-bottom: 6px;
  font-size: 16px;
}

.mock-plan p {
  margin: 0;
  color: var(--muted);
}

.mock-tactics {
  margin-bottom: 22px;
}

.mock-tactics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mock-tactics-grid article {
  min-height: 158px;
  padding: 16px;
  border: 1px solid rgba(23, 111, 115, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(244, 251, 247, 0.92)),
    radial-gradient(circle at top right, rgba(72, 199, 184, 0.14), transparent 44%);
  box-shadow: var(--shadow-sm);
}

.mock-tactics-grid span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.mock-tactics-grid h3 {
  margin: 10px 0 8px;
}

.mock-tactics-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.mock-profile {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.mock-profile article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mock-profile span {
  color: var(--accent);
  font-weight: 900;
}

.mock-profile h2 {
  margin: 6px 0;
  font-size: 16px;
}

.mock-profile p {
  margin: 4px 0 0;
  color: var(--muted);
}

.mock-resource-strip,
.glossary-search-panel,
.glossary-group {
  margin-bottom: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-sm);
}

.resource-grid h3 {
  margin: 8px 0 6px;
}

.glossary-search-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.35fr) auto minmax(0, 1fr);
  gap: 16px;
  align-items: end;
}

.glossary-search-status {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 12px;
  border: 1px solid rgba(23, 111, 115, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #eefafb);
  color: var(--muted);
  font-weight: 900;
}

.glossary-search-status strong {
  color: var(--accent);
  font-size: 24px;
}

.glossary-filter-stack {
  display: grid;
  gap: 10px;
}

.glossary-category-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.glossary-category-board button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid rgba(23, 111, 115, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.glossary-category-board button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glossary-category-board button b {
  display: inline-flex;
  min-width: 32px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
}

.glossary-category-board button[aria-pressed="true"] {
  border-color: rgba(23, 111, 115, 0.5);
  background: linear-gradient(135deg, rgba(23, 111, 115, 0.12), rgba(70, 240, 255, 0.1));
}

.glossary-unit-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.glossary-unit-filter button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgba(23, 111, 115, 0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.glossary-unit-filter button[aria-pressed="true"] {
  border-color: rgba(23, 111, 115, 0.46);
  background: var(--accent);
  color: #fff;
}

.glossary-search-panel label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.glossary-search-panel input {
  width: 100%;
}

.glossary-index {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.glossary-index a,
.glossary-index span {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid rgba(23, 111, 115, 0.18);
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-weight: 900;
  text-decoration: none;
}

.glossary-index span {
  color: rgba(107, 119, 139, 0.55);
  background: rgba(241, 245, 249, 0.65);
}

.glossary-index small,
.glossary-group h2 small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.glossary-group h2 {
  margin-top: 0;
}

.glossary-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.glossary-card {
  padding: 14px;
  border: 1px solid rgba(23, 111, 115, 0.14);
  border-radius: 8px;
  background: #fff;
}

.glossary-card span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.glossary-card h3 {
  margin: 8px 0 6px;
}

.glossary-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.glossary-card dl {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.glossary-card dl div {
  padding: 9px;
  border: 1px solid rgba(23, 111, 115, 0.1);
  border-radius: 8px;
  background: rgba(241, 248, 249, 0.72);
}

.glossary-card dt {
  color: var(--accent);
  font-size: 12px;
  font-weight: 1000;
}

.glossary-card dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

.glossary-card a {
  display: inline-flex;
  margin-top: 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

body[data-visual-mode="rpg"] .glossary-hero,
html[data-visual-mode="rpg"] .glossary-hero {
  border-color: rgba(70, 240, 255, 0.3);
  background:
    linear-gradient(90deg, rgba(7, 11, 22, 0.9) 0 52%, rgba(16, 22, 42, 0.68) 76%, rgba(255, 255, 255, 0.92)),
    radial-gradient(circle at 22% 24%, rgba(70, 240, 255, 0.18), transparent 38%),
    url("/static/visual/backgrounds/quiz-battle-terminal.png") center / cover no-repeat;
  color: #f6fdff;
}

body[data-visual-mode="rpg"] .glossary-hero h1,
body[data-visual-mode="rpg"] .glossary-hero p,
html[data-visual-mode="rpg"] .glossary-hero h1,
html[data-visual-mode="rpg"] .glossary-hero p {
  color: #f6fdff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.38);
}

body[data-visual-mode="rpg"] .glossary-search-panel,
body[data-visual-mode="rpg"] .glossary-group,
html[data-visual-mode="rpg"] .glossary-search-panel,
html[data-visual-mode="rpg"] .glossary-group {
  border-color: rgba(70, 240, 255, 0.22);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(238, 250, 251, 0.9)),
    radial-gradient(circle at top right, rgba(70, 240, 255, 0.12), transparent 44%);
  box-shadow: 0 14px 36px rgba(14, 21, 32, 0.12), 0 0 18px rgba(70, 240, 255, 0.12);
}

body[data-visual-mode="rpg"] .glossary-category-board button,
html[data-visual-mode="rpg"] .glossary-category-board button {
  border-color: rgba(70, 240, 255, 0.18);
  background:
    linear-gradient(135deg, rgba(7, 11, 22, 0.08), rgba(70, 240, 255, 0.08)),
    rgba(255, 255, 255, 0.92);
}

body[data-visual-mode="rpg"] .glossary-card,
html[data-visual-mode="rpg"] .glossary-card {
  border-color: rgba(70, 240, 255, 0.24);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 251, 252, 0.94)),
    radial-gradient(circle at top right, rgba(143, 91, 255, 0.1), transparent 40%);
}

.question-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.question-tools label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.question-tools a {
  text-decoration: none;
}

.question-palette {
  position: sticky;
  bottom: 12px;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-md);
}

.question-palette a {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  text-decoration: none;
  font-weight: 900;
}

.question-palette a.answered {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.question-palette a.marked {
  border-color: var(--accent-2);
  background: var(--warn);
  color: var(--accent-2);
}

.next-step {
  grid-template-columns: 70px minmax(0, 1fr) auto;
}

.next-step p {
  margin: 4px 0 0;
  color: var(--muted);
}

.next-step a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.progress-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.progress-detail article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.progress-detail span {
  display: block;
  color: var(--accent);
  font-size: 28px;
  font-weight: 900;
}

.progress-detail h2 {
  margin-top: 4px;
}

.progress-detail p {
  margin-bottom: 0;
  color: var(--muted);
}

.plan-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.plan-controls label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.plan-controls input {
  width: 150px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  font: inherit;
}

.plan-controls button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.study-plan {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.study-plan article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.study-plan .study-focus {
  border-color: #9ac7b5;
  background: #f4fbf7;
}

.study-plan span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.study-plan h3 {
  margin: 10px 0 6px;
}

.study-plan p {
  margin: 0;
  color: var(--muted);
}

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

.roadmap-grid article {
  padding: 16px;
  border: 1px solid rgba(216, 182, 95, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(242, 248, 247, 0.92));
  box-shadow: var(--shadow-sm);
}

.roadmap-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.roadmap-head span {
  color: var(--accent);
  font-weight: 900;
}

.progress-bar {
  height: 10px;
  margin: 12px 0;
  border-radius: 999px;
  background: rgba(14, 21, 32, 0.12);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #20cad2, var(--gold));
  box-shadow: 0 0 18px rgba(30, 210, 220, 0.42);
}

.roadmap-grid p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.recommendation-grid,
.quest-grid,
.achievement-grid,
.result-diagnosis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.recommendation-grid article,
.quest-grid article,
.achievement-grid article,
.result-diagnosis > div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.recommendation-grid span,
.quest-grid span,
.achievement-grid span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.recommendation-grid h3,
.quest-grid h3,
.achievement-grid h3 {
  margin: 10px 0 6px;
}

.recommendation-grid p,
.quest-grid p,
.achievement-grid p,
.result-diagnosis p {
  margin: 0;
  color: var(--muted);
}

.achievement-grid article {
  opacity: 0.68;
}

.achievement-grid article.unlocked {
  border-color: #9ac7b5;
  background: #f4fbf7;
  opacity: 1;
}

.achievement-grid article.unlocked span {
  background: var(--accent);
  color: #fff;
}

.badge-icon {
  display: block;
  width: 54px;
  height: 54px;
  object-fit: contain;
  margin-bottom: 10px;
}

.result-diagnosis {
  margin-bottom: 18px;
}

.result-badges {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.result-badges article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-badges span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.result-badges h2 {
  margin: 6px 0;
  font-size: 16px;
}

.result-badges p {
  margin: 0;
  color: var(--muted);
}

.result-diagnosis a {
  display: block;
  margin-top: 8px;
  color: var(--accent);
  font-weight: 800;
}

.review-action-grid {
  margin-bottom: 18px;
}

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

.mastery-grid article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mastery-grid h3 {
  margin: 0 0 10px;
}

.mastery-grid p {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 54px;
  gap: 8px;
  margin: 8px 0 0;
  color: var(--muted);
}

.mastery-grid strong {
  color: var(--ink);
  text-align: right;
}

.mastery-grid em {
  color: var(--accent);
  font-style: normal;
  text-align: right;
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.quality-grid article,
.quality-action-grid article,
.quality-table p,
.quality-reasons p,
.unmapped-samples a {
  min-width: 0;
}

.quality-grid p {
  margin: 8px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.quality-grid strong {
  color: var(--ink);
  font-size: 22px;
}

.quality-action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.quality-action-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.quality-action-grid h3 {
  margin: 0 0 6px;
}

.quality-action-grid p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.credit-list,
.policy-list {
  display: grid;
  gap: 14px;
  max-width: 920px;
}

.credit-list article,
.policy-list article,
.contact-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.credit-list article,
.policy-list article {
  padding: 18px;
}

.credit-list h2,
.policy-list h2,
.contact-note h2 {
  margin-top: 0;
}

.credit-list p,
.policy-list p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.contact-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.42fr);
  gap: 18px;
  padding: 18px;
}

.contact-form {
  display: grid;
  gap: 14px;
}

.contact-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.contact-form input,
.contact-form select,
.contact-form textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.contact-form textarea {
  resize: vertical;
  line-height: 1.7;
}

.contact-form button {
  justify-self: start;
}

.contact-honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.contact-note {
  padding: 16px;
  border-radius: 8px;
  background: #f7faf9;
}

.contact-note p,
.form-error-list p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.form-error-list {
  padding: 12px;
  border: 1px solid rgba(184, 57, 57, 0.26);
  border-radius: 8px;
  background: rgba(184, 57, 57, 0.08);
}

.quality-table,
.quality-reasons {
  display: grid;
  gap: 8px;
}

.quality-table p,
.quality-reasons p {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.quality-table strong,
.quality-reasons strong,
.unmapped-samples strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.quality-table span,
.quality-reasons span {
  color: var(--accent);
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.unmapped-samples {
  display: grid;
  gap: 8px;
}

.unmapped-samples a {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.unmapped-samples span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.story-hero p {
  max-width: 700px;
  color: var(--muted);
}

.guide-line {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
}

.guide-line p {
  margin: 0;
}

.story-map {
  display: grid;
  gap: 14px;
}

.story-section {
  margin-bottom: 26px;
}

.curriculum-part {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.arc-grid,
.cast-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.arc-grid article,
.cast-card {
  min-height: 180px;
  padding: 16px;
  border: 1px solid rgba(216, 182, 95, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(241, 248, 248, 0.92));
  box-shadow: var(--shadow-sm);
}

.arc-grid span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.arc-grid h3,
.cast-card h3 {
  margin: 12px 0 8px;
  line-height: 1.35;
}

.arc-grid p,
.cast-card p,
.cast-card small {
  color: var(--muted);
}

.cast-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.cast-tags span {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.cast-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cast-card {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
}

.cast-card:hover,
.dashboard-panel:hover,
.roadmap-grid article:hover,
.challenge-card:hover {
  border-color: rgba(30, 210, 220, 0.45);
  box-shadow: var(--shadow-glow);
}

.cast-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 2px solid var(--ink);
  border-radius: 50% 50% 34% 34%;
  color: var(--ink);
  font-weight: 900;
  overflow: visible;
  box-shadow: 0 8px 0 rgba(29, 36, 48, 0.12);
  isolation: isolate;
}

.cast-avatar.portrait {
  width: 112px;
  height: 132px;
  border-radius: 52% 52% 36% 36%;
  align-self: start;
}

.cast-avatar.portrait::before {
  top: 48px;
  left: 34px;
  width: 8px;
  height: 9px;
  box-shadow: 32px 0 0 var(--ink);
}

.cast-avatar.portrait::after {
  left: 45px;
  bottom: 44px;
  width: 22px;
}

.cast-avatar.portrait span {
  transform: translateY(48px);
  max-width: 92px;
  font-size: 13px;
}

.cast-avatar::before,
.cast-avatar::after {
  content: "";
  position: absolute;
  background: var(--ink);
}

.cast-avatar::before {
  top: 25px;
  left: 21px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  box-shadow: 22px 0 0 var(--ink);
}

.cast-avatar::after {
  left: 28px;
  bottom: 19px;
  width: 16px;
  height: 4px;
  border-radius: 999px;
}

.cast-avatar span {
  position: relative;
  z-index: 2;
  transform: translateY(24px);
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.cast-avatar.image-avatar {
  overflow: hidden;
  background: #f8faf8;
}

.cast-avatar.image-avatar::before,
.cast-avatar.image-avatar::after,
.cast-avatar.image-avatar span::before,
.cast-avatar.image-avatar span::after {
  display: none;
}

.cast-avatar.image-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}

.cast-avatar.image-avatar span {
  opacity: 0;
}

.guide-avatar {
  flex: 0 0 auto;
  width: 112px;
  height: 132px;
}

.avatar-bit,
.cast-bit .cast-avatar {
  border-radius: 24px 24px 30px 30px;
  background:
    radial-gradient(circle at 50% -10%, #ffd990 0 13px, transparent 14px),
    linear-gradient(180deg, #e6fff8 0 28%, transparent 29%),
    linear-gradient(135deg, #b7f1df 0 45%, #ffffff 45% 58%, #ffd990 58%);
}

.avatar-bit::after,
.cast-bit .cast-avatar::after {
  width: 18px;
  height: 5px;
  left: 27px;
  bottom: 18px;
}

.avatar-bit span::before,
.cast-bit .cast-avatar span::before {
  content: "";
  position: absolute;
  top: -62px;
  left: calc(50% - 1px);
  width: 2px;
  height: 12px;
  background: var(--ink);
  box-shadow: 0 -5px 0 2px #ffd990;
}

.avatar-bit span::after,
.cast-bit .cast-avatar span::after {
  content: "";
  position: absolute;
  left: -24px;
  bottom: -9px;
  width: 12px;
  height: 14px;
  border-radius: 0 0 999px 999px;
  background: #176f73;
  box-shadow: 68px 0 0 #176f73;
}

.avatar-nana,
.cast-nana .cast-avatar {
  border-radius: 50% 50% 32px 32px;
  background:
    radial-gradient(circle at 18% 13%, #543325 0 20%, transparent 21%),
    radial-gradient(circle at 82% 13%, #543325 0 20%, transparent 21%),
    linear-gradient(180deg, #543325 0 26%, transparent 27%),
    linear-gradient(135deg, #ffd7c6 0 44%, #fff 44% 56%, #a9d4ff 56%);
}

.avatar-nana::after,
.cast-nana .cast-avatar::after {
  background: #a8452d;
}

.avatar-gate,
.cast-gate .cast-avatar {
  border-radius: 50%;
  color: #fff;
  background:
    radial-gradient(circle at 50% 16%, #8bf1ff 0 7px, transparent 8px),
    linear-gradient(135deg, #1d2430 0 45%, #33415d 45% 60%, #704b8f 60%);
}

.avatar-gate::before,
.cast-gate .cast-avatar::before {
  top: 30px;
  background: #8bf1ff;
  box-shadow: 22px 0 0 #8bf1ff;
}

.avatar-gate::after,
.cast-gate .cast-avatar::after {
  left: 31px;
  width: 10px;
  height: 8px;
  border-radius: 2px 2px 8px 8px;
  background: #704b8f;
}

.avatar-gate span::before,
.cast-gate .cast-avatar span::before {
  content: "";
  position: absolute;
  top: -68px;
  left: -26px;
  width: 14px;
  height: 34px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #1d2430;
  transform: rotate(-32deg);
  box-shadow: 80px 46px 0 -1px #1d2430;
}

.avatar-gate span::after,
.cast-gate .cast-avatar span::after {
  content: "";
  position: absolute;
  top: -16px;
  left: -32px;
  width: 18px;
  height: 4px;
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 86px 0 0 var(--ink);
}

.avatar-trace,
.cast-trace .cast-avatar {
  border-radius: 26px 26px 32px 32px;
  background:
    radial-gradient(circle at 50% 8%, #176f73 0 5px, transparent 6px),
    repeating-linear-gradient(90deg, transparent 0 7px, rgba(29, 36, 48, 0.12) 7px 8px),
    linear-gradient(135deg, #ffe6a8 0 38%, #fff 38% 52%, #d2c2ff 52%);
}

.avatar-trace::before,
.cast-trace .cast-avatar::before {
  box-shadow: 22px 0 0 var(--ink), 11px -10px 0 #176f73;
}

.avatar-airi,
.cast-airi .cast-avatar {
  border-radius: 48% 48% 30px 30px;
  background:
    radial-gradient(ellipse at 12% 22%, #22d5c9 0 20%, transparent 21%),
    radial-gradient(ellipse at 88% 22%, #22d5c9 0 20%, transparent 21%),
    linear-gradient(180deg, #213344 0 26%, transparent 27%),
    linear-gradient(135deg, #ffd7e8 0 42%, #fff 42% 56%, #1fb8b2 56%);
}

.avatar-airi::after,
.cast-airi .cast-avatar::after {
  background: #176f73;
}

.avatar-airi span::before,
.cast-airi .cast-avatar span::before {
  content: "";
  position: absolute;
  top: -72px;
  left: -32px;
  width: 8px;
  height: 74px;
  border-radius: 999px;
  background: #22d5c9;
  box-shadow: 90px 0 0 #22d5c9;
}

.avatar-airi span::after,
.cast-airi .cast-avatar span::after {
  content: "";
  position: absolute;
  top: -52px;
  left: -8px;
  width: 14px;
  height: 4px;
  border-radius: 999px;
  background: #ff6fb0;
  box-shadow: 44px 0 0 #ff6fb0;
}

.avatar-lumina,
.cast-lumina .cast-avatar {
  border-radius: 54% 54% 42% 42%;
  background:
    radial-gradient(circle at 25% 40%, #ffc5db 0 7px, transparent 8px),
    radial-gradient(circle at 75% 40%, #ffc5db 0 7px, transparent 8px),
    linear-gradient(135deg, #f7fffc 0 43%, #ffffff 43% 60%, #d7ddff 60%);
}

.avatar-lumina::after,
.cast-lumina .cast-avatar::after {
  left: 30px;
  width: 12px;
  height: 6px;
  background: #176f73;
}

.avatar-lumina span::before,
.cast-lumina .cast-avatar span::before {
  content: "";
  position: absolute;
  top: -70px;
  right: -26px;
  width: 18px;
  height: 54px;
  border-radius: 80% 20% 80% 20%;
  background: #f7fffc;
  border: 2px solid var(--ink);
  transform: rotate(16deg);
  box-shadow: -76px 16px 0 -2px #f7fffc;
}

.avatar-lumina span::after,
.cast-lumina .cast-avatar span::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -2px;
  width: 28px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #b7f1df;
  transform: rotate(-26deg);
}

.avatar-rex,
.cast-rex .cast-avatar {
  border-radius: 32px 32px 16px 16px;
  color: #fff;
  background:
    radial-gradient(circle at 50% 8%, #62d4ff 0 4px, transparent 5px),
    radial-gradient(circle at 36px 38px, #62d4ff 0 7px, transparent 8px),
    linear-gradient(135deg, #141824 0 36%, #4a315f 36% 56%, #2f3c53 56% 72%, #5f6b7a 72%);
}

.avatar-rex::before,
.cast-rex .cast-avatar::before {
  background: #62d4ff;
  box-shadow: 22px 0 0 #62d4ff;
}

.avatar-rex::after,
.cast-rex .cast-avatar::after {
  background: #fff;
}

.avatar-rex span::before,
.cast-rex .cast-avatar span::before {
  content: "";
  position: absolute;
  top: -70px;
  left: -28px;
  width: 22px;
  height: 24px;
  border-radius: 6px 16px 8px 18px;
  border: 2px solid var(--ink);
  background: #4a315f;
  transform: rotate(-24deg);
  box-shadow: 78px 34px 0 -1px #4a315f;
}

.avatar-sera,
.cast-sera .cast-avatar {
  border-radius: 50% 50% 20px 20px;
  background:
    radial-gradient(circle at 16% 70%, #bcefb1 0 8px, transparent 9px),
    linear-gradient(180deg, #d7dde8 0 24%, transparent 24%),
    linear-gradient(135deg, #f3d4e5 0 44%, #fff 44% 58%, #8fa4c9 58%);
}

.avatar-sera::after,
.cast-sera .cast-avatar::after {
  background: #704b8f;
}

.avatar-sera span::after,
.cast-sera .cast-avatar span::after {
  content: "";
  position: absolute;
  left: -30px;
  bottom: -2px;
  width: 18px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 50% 50% 40% 40%;
  background:
    radial-gradient(circle at 5px 4px, var(--ink) 0 2px, transparent 3px),
    radial-gradient(circle at 13px 4px, var(--ink) 0 2px, transparent 3px),
    #bcefb1;
}

.story-node {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.story-node.locked {
  opacity: 0.58;
}

.story-node.done {
  border-color: #9ac7b5;
  background: #f4fbf7;
}

.story-node:not(.locked):hover {
  box-shadow: var(--shadow-md);
}

.chapter-head,
.story-node > p {
  grid-column: 1 / -1;
}

.story-node p {
  margin: 0;
}

.chapter-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chapter-orb {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(29, 36, 48, 0.12);
  overflow: hidden;
}

.chapter-orb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.chapter-cast {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chapter-cast span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.chapter-cast img {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(23, 111, 115, 0.18);
}

.chapter-progress-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chapter-progress-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.chapter-progress-meta span:first-child {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.hero-meta {
  margin-top: -4px;
}

.chapter-party {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.chapter-party article {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chapter-party h3,
.chapter-party p,
.chapter-party strong {
  margin: 0;
}

.chapter-party p {
  color: var(--muted);
  font-size: 13px;
}

.chapter-party strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 13px;
}

.chapter-beats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.chapter-beats p {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.chapter-beats strong {
  color: var(--ink);
}

.chapter-orb.kind-binary {
  background: #176f73;
}

.chapter-orb.kind-logic {
  background: #4857a8;
}

.chapter-orb.kind-trace {
  background: #a8452d;
}

.chapter-orb.kind-stack {
  background: #587c43;
}

.chapter-orb.kind-security {
  background: #704b8f;
}

.mission,
.reward {
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.mission strong,
.reward strong {
  color: var(--ink);
}

.mini-game {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.mini-game p {
  margin-top: 5px;
  color: var(--muted);
}

.game-playbook {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.game-playbook article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.game-playbook h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.game-playbook p,
.game-playbook ol {
  margin: 0;
  color: var(--muted);
}

.game-playbook ol {
  padding-left: 20px;
}

.game-screen {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-height: 136px;
  padding: 12px;
  border: 2px solid #172130;
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 12%, rgba(98, 212, 255, 0.2), transparent 24%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    #172130;
  background-size: 18px 18px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 10px 24px rgba(23, 33, 48, 0.18);
}

.game-screen::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: var(--anim-scan) 0 50% / 800% auto no-repeat;
  opacity: 0.2;
  mix-blend-mode: screen;
  animation: sprite-8 1.25s steps(8) infinite;
}

.game-screen span {
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.game-screen.kind-binary span:nth-child(-n + 2),
.game-screen.kind-logic span:nth-child(3),
.game-screen.kind-trace span:nth-child(-n + 3),
.game-screen.kind-stack span:nth-child(3),
.game-screen.kind-security span:nth-child(-n + 3) {
  background: rgba(183, 241, 223, 0.22);
  border-color: rgba(183, 241, 223, 0.8);
}

.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.story-actions a,
.story-actions button,
.story-actions span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

.story-node.done {
  position: relative;
  overflow: hidden;
}

.story-node.done::after {
  content: "";
  pointer-events: none;
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 112px;
  height: 112px;
  background: var(--anim-unlock) 0 0 / 800% 100% no-repeat;
  opacity: 0.6;
  animation: sprite-8 1.15s steps(8) infinite;
}

.story-actions button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.story-actions form {
  margin: 0;
}

.game-form {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.game-form label {
  display: grid;
  grid-template-columns: 18px 48px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.94)),
    var(--ui-choice) center / 100% 100% no-repeat,
    #fff;
  cursor: pointer;
}

.game-form input {
  margin: 0;
}

.game-form label span {
  display: block;
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 900;
}

.game-form label b {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.game-form button,
.game-form .login-play {
  justify-content: center;
  text-align: center;
}

.game-form .login-play {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.interactive-game {
  grid-template-columns: minmax(0, 1fr) 148px;
}

.binary-console,
.token-console,
.trace-console,
.stack-console,
.log-console {
  display: grid;
  gap: 8px;
}

.binary-console {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #172130;
}

.lamp-button {
  display: grid;
  place-items: center;
  min-height: 74px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.lamp-button span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 900;
}

.lamp-button.active {
  border-color: #b7f1df;
  background: rgba(183, 241, 223, 0.26);
}

.lamp-button.active span {
  background: #b7f1df;
  color: #172130;
}

.token-console {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.stack-console {
  grid-template-columns: 1fr;
}

.stack-console .challenge-token {
  min-height: 46px;
}

.log-console {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 10px;
  border-radius: 8px;
  background: #172130;
}

.log-console div {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  color: #fff;
}

.log-console span {
  color: #b7f1df;
  font-weight: 900;
}

.challenge-token {
  display: grid;
  gap: 6px;
  min-height: 74px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.challenge-token span {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 900;
}

.challenge-token b {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.challenge-token.active {
  border-color: var(--accent);
  background: var(--soft);
}

.interactive-game.needs-answer {
  outline: 2px solid var(--bad);
  outline-offset: 3px;
  border-radius: 8px;
}

.chapter-hero,
.learning-phase {
  margin-bottom: 26px;
}

.chapter-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 16px;
}

.chapter-effect {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(150px, 24vw);
  max-height: 140px;
  object-fit: contain;
  opacity: 0.92;
  pointer-events: none;
}

.chapter-head.wide {
  align-items: flex-start;
}

.chapter-head.wide h1 {
  margin-bottom: 8px;
}

.chapter-head.wide p {
  max-width: 820px;
  color: var(--muted);
}

.scene-list {
  display: grid;
  gap: 10px;
}

.scene-card {
  position: relative;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.scene-card.playing-voice {
  border-color: rgba(23, 111, 115, 0.42);
  background:
    linear-gradient(135deg, rgba(238, 250, 250, 0.98), rgba(255, 255, 255, 0.96)),
    var(--panel);
  box-shadow: 0 0 0 3px rgba(23, 111, 115, 0.08), var(--shadow-md);
}

.scene-card.playing-voice::after {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  border: 1px solid rgba(104, 77, 181, 0.18);
  border-radius: 8px;
  animation: voice-pulse 1.35s ease-in-out infinite;
}

.cast-avatar.mini {
  width: 54px;
  height: 54px;
  border-radius: 14px;
}

.cast-avatar.mini.avatar-airi span::before,
.cast-avatar.mini.avatar-airi span::after {
  display: none;
}

.cast-avatar.mini::before,
.cast-avatar.mini::after {
  top: 19px;
  width: 6px;
  height: 6px;
}

.cast-avatar.mini::before {
  left: 15px;
  box-shadow: 17px 0 0 var(--ink);
}

.cast-avatar.mini::after {
  left: 21px;
  bottom: 13px;
  width: 12px;
  height: 3px;
}

.cast-avatar.mini span {
  transform: translateY(18px);
  max-width: 42px;
  font-size: 10px;
}

.cast-avatar.image-avatar {
  overflow: visible;
  border-color: transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.cast-avatar.image-avatar img {
  border-radius: 0;
  object-fit: contain;
  filter: drop-shadow(0 8px 8px rgba(29, 36, 48, 0.18));
}

.cast-avatar.image-avatar.mini {
  overflow: hidden;
  border: 1px solid rgba(29, 36, 48, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 5px 0 rgba(29, 36, 48, 0.08);
}

.cast-avatar.image-avatar.mini img {
  inset: -10% -14%;
  width: 128%;
  height: 128%;
  object-fit: cover;
  object-position: 50% 16%;
  filter: none;
}

.scene-card p {
  margin: 0;
}

.lesson-card-grid,
.lesson-flow-grid,
.chapter-mission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.lesson-card-grid article,
.lesson-flow-grid article,
.chapter-mission-grid > div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.lesson-flow-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lesson-flow-grid small {
  color: var(--accent);
  font-weight: 900;
}

.lesson-card-grid span,
.lesson-flow-grid span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.lesson-card-grid h3,
.lesson-flow-grid h3,
.chapter-mission-grid h3 {
  margin: 12px 0 8px;
}

.lesson-card-grid p,
.lesson-flow-grid p,
.chapter-mission-grid p {
  color: var(--muted);
}

.exam-bridge {
  display: grid;
  gap: 8px;
}

.lesson-checkpoints {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.lesson-checkpoints h3 {
  margin: 0;
  font-size: 16px;
}

.lesson-checkpoints p {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.lesson-checkpoints span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  font-size: 13px;
}

.deep-dive-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.deep-dive-grid article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.deep-dive-grid small {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-weight: 900;
}

.deep-dive-grid h3 {
  margin: 10px 0 8px;
}

.deep-dive-grid p,
.deep-dive-grid li {
  color: var(--muted);
}

.deep-dive-grid ul {
  margin: 12px 0 0;
  padding-left: 22px;
}

.exam-bridge p {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.visual-note {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(340px, 1.1fr) minmax(300px, 0.9fr);
  gap: 14px;
  align-items: stretch;
}

.visual-note-art {
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.visual-note-art img {
  width: 100%;
  max-height: 140px;
  object-fit: contain;
}

.visual-board,
.visual-caption {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.visual-board {
  display: grid;
  gap: 14px;
  background:
    linear-gradient(90deg, rgba(45, 116, 125, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(45, 116, 125, 0.08) 1px, transparent 1px),
    #ffffff;
  background-size: 28px 28px;
}

.visual-path {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.visual-path span {
  position: relative;
  min-height: 82px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 2px solid rgba(45, 116, 125, 0.24);
  border-radius: 8px;
  background: rgba(245, 247, 242, 0.92);
  color: var(--ink);
  font-weight: 900;
  text-align: center;
}

.visual-path span:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -12px;
  top: 50%;
  width: 14px;
  height: 2px;
  background: var(--accent);
}

.visual-answer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

.visual-answer small {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 900;
  text-transform: uppercase;
}

.visual-answer strong {
  flex: 0 0 auto;
  font-size: 24px;
}

.visual-answer p,
.visual-caption p,
.practice-ladder p,
.exam-drill-grid p {
  margin: 0;
  color: var(--muted);
}

.visual-answer p {
  flex: 1 1 220px;
  color: rgba(255, 255, 255, 0.84);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
  writing-mode: horizontal-tb;
}

.visual-caption h3 {
  margin: 4px 0 12px;
}

.visual-note.kind-binary .visual-path span {
  border-color: rgba(21, 91, 132, 0.32);
}

.visual-note.kind-logic .visual-path span {
  border-radius: 999px;
}

.visual-note.kind-trace .visual-path {
  grid-template-columns: 1fr;
}

.visual-note.kind-trace .visual-path span {
  min-height: 52px;
  justify-content: start;
}

.visual-note.kind-trace .visual-path span:not(:last-child)::after {
  left: 22px;
  right: auto;
  top: auto;
  bottom: -12px;
  width: 2px;
  height: 14px;
}

.visual-note.kind-stack .visual-path {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.visual-note.kind-stack .visual-path span {
  min-height: 64px;
}

.visual-note.kind-security .visual-path span {
  border-left: 6px solid var(--bad);
}

.visual-note::after,
.result-diagnosis::after {
  content: "";
  pointer-events: none;
  position: absolute;
  right: 12px;
  top: 12px;
  width: 76px;
  height: 76px;
  background: var(--anim-sparkle) 0 0 / 800% 100% no-repeat;
  opacity: 0.46;
  animation: sprite-8 1.15s steps(8) infinite;
}

.visual-note,
.result-diagnosis {
  position: relative;
  overflow: hidden;
}

.practice-ladder,
.exam-drill-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.practice-ladder article,
.exam-drill-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.practice-ladder span {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.practice-ladder h3,
.exam-drill-grid h3 {
  margin: 10px 0 8px;
}

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

.chapter-quiz {
  display: grid;
  gap: 12px;
}

.chapter-quiz-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(240px, 0.78fr) minmax(0, 1.22fr);
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chapter-quiz-card > div:first-child {
  display: grid;
  align-content: start;
  gap: 10px;
}

.chapter-quiz-card > div:first-child span {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 30px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  font-size: 12px;
}

.chapter-quiz-card > div:first-child small {
  display: inline-block;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.chapter-quiz-card h3 {
  margin: 0;
  line-height: 1.55;
}

.chapter-quiz-choices {
  display: grid;
  gap: 8px;
}

.chapter-quiz-choices label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.chapter-quiz-choices input {
  margin-top: 4px;
}

.chapter-quiz-explanation {
  grid-column: 1 / -1;
  display: none;
  margin: 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: #edf0ec;
  color: var(--muted);
}

.chapter-quiz-card.correct {
  border-color: rgba(45, 116, 125, 0.5);
  background:
    linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.96)),
    var(--fx-correct) right top / 210px auto no-repeat,
    #fff;
}

.chapter-quiz-card.wrong {
  border-color: rgba(157, 74, 61, 0.45);
  background:
    linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.98)),
    var(--fx-wrong) right top / 210px auto no-repeat,
    #fff;
}

.chapter-quiz-card.correct .chapter-quiz-explanation,
.chapter-quiz-card.wrong .chapter-quiz-explanation {
  display: block;
}

.chapter-quiz-card.correct .chapter-quiz-choices label:has(input:checked) {
  border-color: var(--good);
  background: rgba(45, 116, 125, 0.1);
}

.chapter-quiz-card.wrong .chapter-quiz-choices label:has(input:checked) {
  border-color: var(--bad);
  background: rgba(157, 74, 61, 0.08);
}

.chapter-quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.chapter-quiz-actions button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.chapter-quiz-actions button[type="reset"] {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.chapter-quiz-result {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.example-lab {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 12px;
}

.worked-example,
.mistake-list article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.worked-example h3,
.worked-example p,
.mistake-list h3,
.mistake-list p {
  margin-top: 0;
}

.worked-example ol {
  padding-left: 22px;
  color: var(--muted);
}

.worked-example strong {
  display: block;
  margin-top: 10px;
  color: var(--accent);
}

.example-trace {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.example-trace span {
  padding: 6px 9px;
  border-radius: 6px;
  background: #edf0ec;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
}

.mistake-list {
  display: grid;
  gap: 10px;
}

.mistake-list p {
  margin-bottom: 0;
  color: var(--muted);
}

.recall-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.recall-list p {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.recall-list span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: 13px;
}

.chapter-mission-grid {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

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

.detail-node {
  grid-template-columns: 1fr;
}

.attempt-history,
.auth-panel {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.attempt-history p {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0 0;
}

.attempt-history span {
  min-width: 54px;
  color: var(--accent);
  font-weight: 800;
}

.auth-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 18px;
  align-items: end;
  width: min(720px, 100%);
  overflow: hidden;
}

.auth-companion {
  position: relative;
  min-height: 152px;
  display: grid;
  place-items: end center;
}

.companion-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 22px);
  z-index: 5;
  width: min(230px, 72vw);
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(29, 36, 48, 0.15);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.96)),
    var(--ui-bubble) center / 100% 100% no-repeat,
    rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
  transform: translateX(-50%);
}

@keyframes sprite-8 {
  to {
    background-position-x: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .visual-note::after,
  .result-diagnosis::after,
  .game-screen::after,
  .story-node.done::after,
  .scene-card.playing-voice::after {
    animation: none;
  }
}

.companion-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  border-right: 1px solid rgba(29, 36, 48, 0.15);
  border-bottom: 1px solid rgba(29, 36, 48, 0.15);
  background: rgba(255, 255, 255, 0.96);
  transform: translateX(-50%) rotate(45deg);
}

.audio-controls {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: min(340px, calc(100vw - 32px));
}

.game-sound-toggle,
.game-music-toggle,
.game-voice-toggle,
.game-settings-link,
.voice-line-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid rgba(29, 36, 48, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-md);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.game-sound-toggle[aria-pressed="true"],
.game-music-toggle[aria-pressed="true"],
.game-voice-toggle[aria-pressed="true"] {
  border-color: rgba(23, 111, 115, 0.35);
  color: var(--accent);
}

.settings-hero {
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px);
  align-items: center;
  overflow: hidden;
  min-height: 260px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.98) 0 54%, rgba(240, 252, 252, 0.88) 76%, rgba(255, 255, 255, 0.8)),
    radial-gradient(circle at 88% 38%, rgba(30, 210, 220, 0.16), transparent 34%),
    url("/static/visual/items/truth-key.png") 86% 52% / 210px auto no-repeat,
    var(--glass);
}

.summary-character {
  width: auto;
  max-width: min(180px, 30vw);
  max-height: 220px;
  justify-self: end;
  object-fit: contain;
  filter: drop-shadow(0 18px 26px rgba(29, 36, 48, 0.16));
}

.settings-panel {
  display: grid;
  gap: 14px;
  max-width: 980px;
}

.settings-panel article {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(260px, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.settings-panel h2 {
  margin: 0;
}

.settings-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.volume-control {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 56px;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  font-weight: 900;
}

.volume-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.volume-control output {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.settings-control-stack {
  display: grid;
  gap: 12px;
}

.track-control {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: var(--ink);
  font-weight: 900;
}

.track-control select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 250, 250, 0.92));
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.compact-settings {
  margin-top: 16px;
}

.settings-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-switches .game-sound-toggle,
.settings-switches .game-music-toggle,
.settings-switches .game-voice-toggle,
.settings-auto-play .dialogue-autoplay-toggle {
  box-shadow: var(--shadow-sm);
}

.settings-auto-play {
  display: grid;
  gap: 12px;
}

.dialogue-autoplay-toggle {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(23, 111, 115, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.dialogue-player-actions .dialogue-autoplay-toggle {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.dialogue-autoplay-toggle[aria-pressed="true"] {
  border-color: rgba(23, 111, 115, 0.38);
  background: linear-gradient(135deg, rgba(23, 111, 115, 0.16), rgba(30, 210, 220, 0.12));
  color: var(--accent);
}

.dialogue-player-actions .dialogue-autoplay-toggle[aria-pressed="true"] {
  border-color: rgba(30, 210, 220, 0.68);
  background: rgba(30, 210, 220, 0.16);
  color: #fff;
}

.voice-line-button {
  width: fit-content;
  min-width: 92px;
  min-height: 34px;
  margin-top: 10px;
  padding: 6px 11px;
  border-color: rgba(87, 71, 148, 0.22);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(238, 250, 250, 0.96));
  color: var(--accent-strong);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
}

.voice-line-button::before {
  content: "♪";
  margin-right: 5px;
}

.voice-line-button.compact {
  margin-top: 8px;
}

.voice-play-sequence {
  width: fit-content;
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid rgba(23, 111, 115, 0.24);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(23, 111, 115, 0.12), rgba(104, 77, 181, 0.1));
  color: var(--accent-strong);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.voice-play-sequence::before {
  content: "♪";
  margin-right: 6px;
}

@keyframes voice-pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.985);
  }

  50% {
    opacity: 0.95;
    transform: scale(1);
  }
}

.music-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid rgba(23, 111, 115, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(232, 242, 239, 0.92), rgba(255, 255, 255, 0.96)),
    var(--ui-result) right center / auto 120% no-repeat,
    #fff;
  box-shadow: var(--shadow-sm);
}

.music-panel h2,
.music-panel p {
  margin: 0;
}

.music-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.music-panel select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.episode-journal {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.episode-journal article {
  position: relative;
  min-height: 180px;
  overflow: hidden;
  padding: 18px;
  border: 1px solid rgba(29, 36, 48, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(245, 251, 252, 0.9)),
    radial-gradient(circle at top right, rgba(23, 111, 115, 0.12), transparent 44%);
  box-shadow: var(--shadow-sm);
}

.episode-journal article::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(155, 108, 255, 0.16);
  border-radius: 8px;
  pointer-events: none;
}

.episode-journal small {
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0;
}

.episode-journal h3 {
  margin: 8px 0;
}

.episode-journal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.episode-hub .list-head {
  align-items: end;
}

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

.episode-card {
  display: flex;
  min-height: 260px;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(29, 36, 48, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 251, 252, 0.98)),
    var(--panel);
  box-shadow: var(--shadow-sm);
}

.episode-card > span {
  width: fit-content;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.episode-card h3,
.episode-card p {
  margin: 0;
}

.episode-card h3 {
  font-size: 18px;
}

.episode-card p {
  color: var(--muted);
  line-height: 1.65;
}

.episode-card-story {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(104, 77, 181, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.episode-card-story summary {
  padding: 8px 10px;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.episode-card-story .study-markup {
  max-height: min(42svh, 360px);
  margin: 0 10px 10px;
  padding: 10px;
  overflow: auto;
  border-radius: 8px;
  background: rgba(248, 251, 252, 0.92);
}

.episode-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.episode-meta small {
  padding: 4px 7px;
  border: 1px solid rgba(104, 77, 181, 0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.episode-card a,
.episode-nav a {
  display: inline-flex;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid rgba(29, 36, 48, 0.14);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
}

.episode-card a {
  margin-top: 4px;
}

.asset-screen {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.76);
}

.asset-screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.episode-stage {
  position: relative;
  margin: -18px -10px 0;
  padding: 22px clamp(16px, 4vw, 44px) 36px;
  overflow: hidden;
  border: 1px solid rgba(29, 36, 48, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(248, 251, 252, 0.97) 0 42%, rgba(248, 251, 252, 0.82) 78%, rgba(248, 251, 252, 0.7)),
    var(--episode-bg) center / cover no-repeat,
    #f7faf8;
}

.episode-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.84)),
    repeating-linear-gradient(115deg, rgba(73, 182, 184, 0.06) 0 1px, transparent 1px 18px);
}

.episode-stage > * {
  position: relative;
  z-index: 1;
}

.episode-stage::after,
.episode-ambient {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.episode-stage::after {
  z-index: 0;
  opacity: 0.55;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.58), transparent),
    repeating-linear-gradient(0deg, transparent 0 20px, rgba(29, 36, 48, 0.04) 20px 21px);
  transform: translateX(-70%);
  animation: episode-sweep 11s ease-in-out infinite;
}

.episode-ambient {
  z-index: 0;
  opacity: 0.7;
  mix-blend-mode: multiply;
  background:
    linear-gradient(135deg, rgba(73, 182, 184, 0.14), transparent 42%),
    linear-gradient(315deg, rgba(246, 191, 90, 0.14), transparent 46%);
  animation: episode-ambient-shift 14s ease-in-out infinite;
}

.effect-memory .episode-ambient {
  background:
    repeating-linear-gradient(100deg, rgba(255, 255, 255, 0.22) 0 8px, transparent 8px 20px),
    linear-gradient(135deg, rgba(115, 126, 171, 0.18), transparent 46%);
}

.effect-glitch .episode-ambient,
.effect-danger .episode-ambient {
  opacity: 0.78;
  mix-blend-mode: normal;
  background:
    repeating-linear-gradient(90deg, rgba(125, 35, 55, 0.18) 0 2px, transparent 2px 12px),
    repeating-linear-gradient(0deg, rgba(29, 36, 48, 0.08) 0 1px, transparent 1px 9px);
  animation: episode-glitch 1.8s steps(2, end) infinite;
}

.effect-gate .episode-ambient,
.effect-trial .episode-ambient {
  background:
    linear-gradient(90deg, rgba(73, 182, 184, 0.18), transparent 36%, rgba(246, 191, 90, 0.18)),
    repeating-linear-gradient(45deg, rgba(29, 36, 48, 0.05) 0 2px, transparent 2px 18px);
}

.effect-victory .episode-ambient,
.effect-spark .episode-ambient {
  background:
    linear-gradient(120deg, rgba(73, 182, 184, 0.16), transparent 36%, rgba(246, 191, 90, 0.24)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.28) 0 5px, transparent 5px 22px);
}

.effect-data .episode-ambient {
  background:
    repeating-linear-gradient(90deg, rgba(73, 182, 184, 0.12) 0 1px, transparent 1px 36px),
    repeating-linear-gradient(0deg, rgba(73, 182, 184, 0.1) 0 1px, transparent 1px 30px);
  animation: episode-data-grid 12s linear infinite;
}

.scene-cue-active {
  animation: cue-flash 0.72s ease-out;
}

.episode-line,
.episode-long-block,
.episode-figure,
.episode-practice,
.episode-objectives {
  animation: episode-card-rise 0.52s ease both;
}

.episode-line.line-happy,
.episode-line.line-surprised {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(242, 250, 250, 0.98)),
    var(--ui-bubble) center / 100% 100% no-repeat;
}

.episode-line.line-serious {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 246, 252, 0.98)),
    var(--ui-bubble) center / 100% 100% no-repeat;
}

.effect-glitch .episode-character,
.effect-danger .episode-character {
  animation: episode-character-alert 2.2s ease-in-out infinite;
}

.effect-victory .episode-character,
.effect-spark .episode-character {
  animation: companion-float 4.8s ease-in-out infinite, episode-character-shine 3.8s ease-in-out infinite;
}

.episode-preview-intro {
  position: absolute;
  inset: 0;
  z-index: 42;
  display: grid;
  align-content: end;
  gap: 18px;
  min-height: min(760px, 100%);
  padding: clamp(20px, 5vw, 54px);
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(110deg, rgba(11, 20, 28, 0.98) 0 38%, rgba(25, 55, 63, 0.9) 58%, rgba(125, 35, 55, 0.78)),
    var(--episode-bg) center / cover no-repeat,
    #101820;
  opacity: 1;
  transition: opacity 0.42s ease, transform 0.42s ease;
}

.episode-preview-intro[hidden] {
  display: none;
}

.episode-stage[data-story-preview-state="pending"] .episode-play,
.episode-stage[data-story-preview-state="playing"] .episode-play {
  visibility: hidden;
  pointer-events: none;
}

.episode-preview-intro::before,
.episode-preview-intro::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.episode-preview-intro::before {
  z-index: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.09) 0 1px, transparent 1px 16px),
    repeating-linear-gradient(90deg, rgba(73, 182, 184, 0.14) 0 1px, transparent 1px 36px);
  opacity: 0.52;
}

.episode-preview-intro::after {
  z-index: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: translateX(-86%);
}

.episode-preview-intro.is-playing::after {
  animation: story-preview-sweep 2.7s ease-out 0.2s both;
}

.episode-preview-intro.is-finished {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.012);
}

.episode-preview-frame,
.episode-preview-copy,
.episode-preview-actions {
  position: relative;
  z-index: 1;
}

.episode-preview-frame {
  position: absolute;
  inset: 0;
}

.episode-preview-scene {
  position: absolute;
  inset: -3%;
  background: center / cover no-repeat;
  opacity: 0.56;
  filter: saturate(1.16) contrast(1.02);
  transform: scale(1.03);
}

.episode-preview-board,
.episode-preview-signal {
  position: absolute;
  display: grid;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(7, 14, 20, 0.74);
  color: #fff;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.3);
}

.episode-preview-board {
  top: 10%;
  left: clamp(18px, 6vw, 92px);
  width: min(330px, 34vw);
  padding: 16px 18px;
}

.episode-preview-board span,
.episode-preview-signal span {
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.episode-preview-board strong {
  font-size: 1.45rem;
  line-height: 1.15;
}

.episode-preview-board small {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
}

.episode-preview-signal {
  top: 20%;
  right: clamp(28px, 7vw, 104px);
  min-width: 190px;
  padding: 12px 16px;
  border-color: rgba(246, 191, 90, 0.54);
}

.episode-preview-signal strong {
  color: #f6bf5a;
  font-size: 2.5rem;
  line-height: 1;
}

.episode-preview-mini,
.episode-preview-poster,
.episode-preview-character {
  position: absolute;
  display: block;
  pointer-events: none;
  user-select: none;
}

.episode-preview-mini {
  top: 34%;
  left: clamp(28px, 12vw, 180px);
  width: min(210px, 22vw);
  border-radius: 8px;
  filter: drop-shadow(0 24px 28px rgba(0, 0, 0, 0.34));
}

.episode-preview-poster {
  top: 36%;
  right: clamp(52px, 15vw, 230px);
  width: min(320px, 28vw);
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  object-fit: cover;
  opacity: 0.78;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.34);
}

.episode-preview-character {
  right: clamp(-12px, 4vw, 70px);
  bottom: 84px;
  max-height: min(500px, 58%);
  width: auto;
  filter: drop-shadow(0 30px 36px rgba(0, 0, 0, 0.34));
}

.episode-preview-intro.is-playing .episode-preview-scene {
  animation: story-preview-scene-drift 7.2s ease-out both;
}

.episode-preview-intro.is-playing .episode-preview-board,
.episode-preview-intro.is-playing .episode-preview-signal,
.episode-preview-intro.is-playing .episode-preview-mini,
.episode-preview-intro.is-playing .episode-preview-poster,
.episode-preview-intro.is-playing .episode-preview-character {
  animation: story-preview-visual-rise 1.7s ease-out both;
}

.episode-preview-intro.is-playing .episode-preview-signal {
  animation-delay: 0.45s;
}

.episode-preview-intro.is-playing .episode-preview-mini {
  animation-delay: 0.8s;
}

.episode-preview-intro.is-playing .episode-preview-poster,
.episode-preview-intro.is-playing .episode-preview-character {
  animation-delay: 1.15s;
}

.episode-preview-cut {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  max-width: min(280px, 42vw);
  min-height: 54px;
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(9, 17, 24, 0.72);
  color: rgba(255, 255, 255, 0.88);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.28);
  font-weight: 900;
  letter-spacing: 0;
}

.episode-preview-cut.cut-1 {
  top: 48%;
  right: clamp(24px, 8vw, 112px);
  left: auto;
}

.episode-preview-cut.cut-2 {
  top: 58%;
  right: clamp(48px, 11vw, 152px);
}

.episode-preview-cut.cut-3 {
  top: 68%;
  right: clamp(72px, 14vw, 200px);
  left: auto;
}

.episode-preview-intro.is-playing .episode-preview-cut {
  animation: story-preview-cut 2.3s ease-out both;
}

.episode-preview-intro.is-playing .cut-2 {
  animation-delay: 1.45s;
}

.episode-preview-intro.is-playing .cut-3 {
  animation-delay: 2.9s;
}

.episode-preview-copy {
  max-width: min(760px, 62vw);
}

.episode-preview-copy .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.episode-preview-copy h2 {
  max-width: min(1040px, 100%);
  margin: 0;
  color: #fff;
  font-size: clamp(32px, 5vw, 64px);
  line-height: 1.04;
}

.episode-preview-copy > p {
  max-width: 720px;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(15px, 2vw, 20px);
  line-height: 1.8;
}

.episode-preview-copy blockquote {
  max-width: 700px;
  margin: 18px 0 0;
  padding: 13px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 900;
  line-height: 1.6;
}

.episode-preview-caption {
  display: inline-flex;
  max-width: min(680px, 100%);
  margin: 16px 0 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 900;
}

.episode-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.episode-preview-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-inline-size: 10rem;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.episode-preview-actions .episode-preview-start {
  min-inline-size: 10rem;
  border-color: rgba(246, 191, 90, 0.78);
  background: linear-gradient(135deg, #f6bf5a, #49b6b8);
  color: #162028;
}

.episode-preview-actions .episode-preview-skip {
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(7, 14, 20, 0.46);
  color: rgba(255, 255, 255, 0.92);
}

.episode-preview-actions button:disabled {
  cursor: default;
  opacity: 0.58;
}

html[data-visual-mode="simple"] .episode-preview-intro,
body[data-visual-mode="simple"] .episode-preview-intro {
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(242, 250, 250, 0.95)),
    var(--episode-bg) center / cover no-repeat,
    #f7faf8;
}

html[data-visual-mode="simple"] .episode-preview-copy h2,
body[data-visual-mode="simple"] .episode-preview-copy h2 {
  color: var(--ink);
}

html[data-visual-mode="simple"] .episode-preview-copy .eyebrow,
body[data-visual-mode="simple"] .episode-preview-copy .eyebrow,
html[data-visual-mode="simple"] .episode-preview-copy > p,
body[data-visual-mode="simple"] .episode-preview-copy > p {
  color: var(--muted);
}

html[data-visual-mode="simple"] .episode-preview-copy blockquote,
body[data-visual-mode="simple"] .episode-preview-copy blockquote,
html[data-visual-mode="simple"] .episode-preview-caption,
body[data-visual-mode="simple"] .episode-preview-caption,
html[data-visual-mode="simple"] .episode-preview-cut,
body[data-visual-mode="simple"] .episode-preview-cut,
html[data-visual-mode="simple"] .episode-preview-board,
body[data-visual-mode="simple"] .episode-preview-board,
html[data-visual-mode="simple"] .episode-preview-signal,
body[data-visual-mode="simple"] .episode-preview-signal {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

html[data-visual-mode="simple"] .episode-preview-scene,
body[data-visual-mode="simple"] .episode-preview-scene {
  opacity: 0.22;
}

html[data-visual-mode="simple"] .episode-preview-signal strong,
body[data-visual-mode="simple"] .episode-preview-signal strong {
  color: var(--accent-strong);
}

html[data-visual-mode="simple"] .episode-preview-actions button,
body[data-visual-mode="simple"] .episode-preview-actions button {
  border-color: rgba(29, 36, 48, 0.18);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

html[data-visual-mode="simple"] .episode-preview-actions .episode-preview-start,
body[data-visual-mode="simple"] .episode-preview-actions .episode-preview-start {
  background: var(--accent);
  color: #162028;
}

html[data-visual-mode="simple"] .episode-preview-actions .episode-preview-skip,
body[data-visual-mode="simple"] .episode-preview-actions .episode-preview-skip {
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
}

@media (max-width: 760px) {
  .episode-preview-intro {
    min-height: min(680px, 100%);
    padding: 18px;
  }

  .episode-preview-copy h2 {
    font-size: 2rem;
  }

  .episode-preview-copy > p,
  .episode-preview-copy blockquote {
    max-width: 100%;
  }

  .episode-preview-copy {
    max-width: 100%;
  }

  .episode-preview-board {
    top: 8%;
    left: 14px;
    width: min(260px, 66vw);
    padding: 12px 14px;
  }

  .episode-preview-board strong {
    font-size: 1.05rem;
  }

  .episode-preview-signal {
    top: 25%;
    right: 14px;
    min-width: 142px;
    padding: 10px 12px;
  }

  .episode-preview-signal strong {
    font-size: 1.7rem;
  }

  .episode-preview-mini {
    top: 40%;
    left: 18px;
    width: 94px;
  }

  .episode-preview-poster {
    display: none;
  }

  .episode-preview-character {
    display: none;
  }

  .episode-preview-actions button {
    flex: 1 1 136px;
    min-width: 0;
  }

  .episode-preview-actions .episode-preview-start {
    inline-size: 100%;
    min-inline-size: 0;
  }

  .episode-preview-actions .episode-preview-skip {
    inline-size: 100%;
    min-inline-size: 0;
  }

  .episode-preview-cut {
    min-width: 118px;
    max-width: 48vw;
    min-height: 48px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .episode-preview-cut.cut-1 {
    top: 10%;
    left: auto;
    right: 18px;
  }

  .episode-preview-cut.cut-2 {
    display: none;
  }

  .episode-preview-cut.cut-3 {
    display: none;
  }
}

@media (max-width: 430px) {
  .episode-preview-actions {
    gap: 8px;
  }

  .episode-preview-actions button {
    flex-basis: 100%;
  }
}

@keyframes episode-sweep {
  0%, 42% { transform: translateX(-72%); opacity: 0; }
  52% { opacity: 0.58; }
  64%, 100% { transform: translateX(72%); opacity: 0; }
}

@keyframes episode-ambient-shift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(1.5%, -1%, 0); }
}

@keyframes episode-glitch {
  0%, 100% { transform: translate(0, 0); opacity: 0.42; }
  24% { transform: translate(-1.4%, 0.6%); opacity: 0.7; }
  52% { transform: translate(1.2%, -0.5%); opacity: 0.56; }
  78% { transform: translate(-0.6%, -0.8%); opacity: 0.76; }
}

@keyframes episode-data-grid {
  0% { background-position: 0 0, 0 0; }
  100% { background-position: 72px 0, 0 60px; }
}

@keyframes episode-card-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cue-flash {
  0% { box-shadow: 0 0 0 rgba(73, 182, 184, 0); transform: translateY(0); }
  36% { box-shadow: 0 0 0 4px rgba(73, 182, 184, 0.18), var(--shadow-sm); transform: translateY(-2px); }
  100% { box-shadow: var(--shadow-sm); transform: translateY(0); }
}

@keyframes episode-character-alert {
  0%, 100% { transform: translate(0, 0); filter: drop-shadow(0 26px 24px rgba(29, 36, 48, 0.22)); }
  50% { transform: translate(-2px, -4px); filter: drop-shadow(0 28px 24px rgba(125, 35, 55, 0.3)); }
}

@keyframes episode-character-shine {
  0%, 100% { filter: drop-shadow(0 26px 24px rgba(29, 36, 48, 0.22)); }
  50% { filter: drop-shadow(0 30px 26px rgba(246, 191, 90, 0.36)); }
}

@keyframes story-preview-sweep {
  0% { transform: translateX(-88%); opacity: 0; }
  20% { opacity: 0.86; }
  100% { transform: translateX(88%); opacity: 0; }
}

@keyframes story-preview-cut {
  0% { opacity: 0; transform: translateY(18px) scale(0.96); }
  22%, 72% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0.32; transform: translateY(-8px) scale(0.99); }
}

@keyframes story-preview-scene-drift {
  0% { transform: scale(1.03) translate3d(0, 0, 0); }
  100% { transform: scale(1.09) translate3d(-1.4%, -1%, 0); }
}

@keyframes story-preview-visual-rise {
  0% { opacity: 0; transform: translate3d(0, 18px, 0) scale(0.97); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

.episode-topline,
.episode-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.episode-topline > span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  font-weight: 900;
}

.episode-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 260px);
  gap: 18px;
  align-items: end;
  min-height: 290px;
  padding: 20px 0 8px;
}

.episode-hero h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(34px, 5vw, 70px);
  line-height: 1.05;
}

.episode-hero p {
  max-width: 720px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
}

.episode-character {
  justify-self: center;
  max-width: min(260px, 36vw);
  max-height: 320px;
  object-fit: contain;
  filter: drop-shadow(0 26px 24px rgba(29, 36, 48, 0.22));
}

.episode-play {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  align-items: start;
  gap: 16px;
}

.episode-dialogue,
.episode-lesson,
.episode-check {
  border: 1px solid rgba(29, 36, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
}

.episode-dialogue {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.episode-dialogue[data-dialogue-click-advance] {
  cursor: pointer;
}

.episode-dialogue[data-dialogue-click-advance] button,
.episode-dialogue[data-dialogue-click-advance] a,
.episode-dialogue[data-dialogue-click-advance] .episode-media-dock button {
  cursor: pointer;
}

.episode-dialogue[data-dialogue-click-advance] input,
.episode-dialogue[data-dialogue-click-advance] select,
.episode-dialogue[data-dialogue-click-advance] textarea,
.episode-dialogue[data-dialogue-click-advance] audio,
.episode-dialogue[data-dialogue-click-advance] video,
.episode-dialogue[data-dialogue-click-advance] .episode-media-dock,
.episode-dialogue[data-dialogue-click-advance] .episode-scene-visual {
  cursor: auto;
}

.dialogue-player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(29, 36, 48, 0.96), rgba(48, 72, 86, 0.92));
  color: #fff;
}

.dialogue-player-bar p,
.dialogue-player-bar strong {
  margin: 0;
}

.dialogue-player-bar .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.dialogue-player-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.dialogue-player-actions button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 800;
}

.dialogue-player-actions button:disabled {
  opacity: 0.45;
}

.dialogue-inline-controls {
  display: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-inline-controls,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-inline-controls {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding: 0 clamp(12px, 2vw, 26px) clamp(10px, 1.4vw, 16px);
}

.dialogue-inline-controls button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(70, 240, 255, 0.32);
  border-radius: 999px;
  background: rgba(7, 11, 22, 0.74);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(7, 11, 22, 0.18);
}

.dialogue-inline-controls button:disabled {
  cursor: default;
  opacity: 0.45;
}

html[data-visual-mode="rpg"] .episode-dialogue.dialogue-enhanced .episode-line:not(.is-active),
body[data-visual-mode="rpg"] .episode-dialogue.dialogue-enhanced .episode-line:not(.is-active) {
  display: none;
}

.episode-line {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 136px;
  padding: 12px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(247, 250, 249, 0.98)),
    var(--ui-bubble) center / 100% 100% no-repeat;
}

.episode-line.is-active {
  animation: storyLineIn 260ms ease-out both;
}

.episode-narrator-card {
  grid-template-columns: minmax(68px, 88px) minmax(0, 1fr);
  min-height: 118px;
  border: 1px solid rgba(24, 132, 139, 0.2);
  background:
    linear-gradient(135deg, rgba(238, 248, 255, 0.96), rgba(255, 250, 236, 0.94)),
    var(--ui-plate) center / 100% 100% no-repeat;
}

.episode-narrator-mark {
  display: inline-grid;
  place-items: center;
  align-self: center;
  width: 68px;
  height: 68px;
  border: 1px solid rgba(24, 132, 139, 0.24);
  border-radius: 8px;
  background: rgba(24, 132, 139, 0.1);
  color: var(--accent-strong);
  font-size: 1.65rem;
  font-weight: 1000;
  line-height: 1;
}

.episode-narrator-card h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.25;
}

.episode-narrator-card p {
  margin: 0;
}

.episode-narrator-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.episode-narrator-card .eyebrow {
  margin-bottom: 0;
  color: var(--accent-strong);
}

.episode-narrator-card .narrator-voice-button {
  margin-top: 0;
}

.episode-line.is-active img {
  transform-origin: 50% 92%;
  animation: dialoguePortraitSpeak 640ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.episode-line.is-active.line-surprised img {
  animation-name: dialoguePortraitAlert;
}

.episode-line.is-active.line-serious img {
  animation-name: dialoguePortraitLean;
}

.episode-line.is-active > div {
  position: relative;
}

.episode-line.is-active[data-scene-sfx] > div::after {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  border: 1px solid rgba(73, 182, 184, 0.28);
  border-radius: inherit;
  opacity: 0;
  animation: dialogueCuePulse 880ms ease-out both;
}

.episode-line.is-active[data-scene-sfx="danger"] > div::after,
.episode-stage[data-active-scene-sfx="danger"] .episode-theme-card {
  border-color: rgba(255, 117, 117, 0.44);
  box-shadow: 0 0 0 1px rgba(255, 117, 117, 0.14), 0 18px 38px rgba(125, 35, 55, 0.16);
}

@keyframes storyLineIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dialoguePortraitSpeak {
  0% { transform: translate3d(0, 8px, 0) scale(0.98); }
  42% { transform: translate3d(0, -5px, 0) scale(1.025); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes dialoguePortraitAlert {
  0% { transform: translate3d(0, 10px, 0) rotate(0deg) scale(0.98); }
  34% { transform: translate3d(-3px, -8px, 0) rotate(-1.4deg) scale(1.035); }
  66% { transform: translate3d(3px, -2px, 0) rotate(1deg) scale(1.01); }
  100% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
}

@keyframes dialoguePortraitLean {
  0% { transform: translate3d(-5px, 5px, 0) scale(0.99); }
  50% { transform: translate3d(3px, -3px, 0) scale(1.015); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes dialogueCuePulse {
  0% { opacity: 0; transform: scale(0.985); }
  35% { opacity: 0.78; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.015); }
}

.episode-line img {
  width: 96px;
  height: 118px;
  object-fit: contain;
  filter: drop-shadow(0 12px 10px rgba(29, 36, 48, 0.16));
}

.episode-line.speaker-bit img {
  border-radius: 18px;
  object-fit: contain;
  background:
    radial-gradient(circle at 50% 42%, rgba(30, 210, 220, 0.14), transparent 58%),
    rgba(255, 255, 255, 0.62);
}

.episode-line p {
  margin: 0;
  font-size: 18px;
  line-height: 1.8;
}

.episode-lesson {
  padding: 18px;
}

.episode-lesson-close {
  margin: 0 0 12px;
}

.episode-lesson-close-bottom {
  margin: 16px 0 0;
}

.episode-lesson h2,
.episode-check h2 {
  margin: 0 0 12px;
}

.episode-lesson .lesson-summary {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.7;
}

.episode-lesson article {
  padding: 12px 0;
  border-top: 1px solid rgba(29, 36, 48, 0.1);
}

.episode-lesson article span,
.episode-check p span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 26px;
  margin-right: 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.episode-lesson h3,
.episode-lesson p {
  margin: 0;
}

.episode-lesson h3 {
  font-size: 16px;
}

.episode-lesson p,
.episode-check p {
  color: var(--muted);
  line-height: 1.7;
}

.episode-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

.episode-rich-content {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.episode-section,
.episode-objectives,
.episode-long-block,
.episode-figure,
.episode-practice {
  border: 1px solid rgba(29, 36, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow-sm);
}

.episode-section {
  padding: 18px;
}

.episode-section .list-head.compact {
  margin-bottom: 12px;
}

.episode-objectives,
.episode-long-block,
.episode-figure,
.episode-practice {
  padding: 16px;
}

.episode-objectives p,
.episode-long-block p,
.episode-figure p,
.episode-practice p {
  color: var(--muted);
  line-height: 1.8;
}

.episode-long-block p,
.episode-figure p,
.episode-practice p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.episode-long-block > p,
.episode-figure > p {
  color: var(--ink);
}

.episode-objectives p {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.episode-objectives p span,
.episode-long-block > span,
.episode-practice > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  margin-right: 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.episode-long-block + .episode-long-block {
  margin-top: 12px;
}

.episode-long-block h3,
.episode-figure h3,
.episode-practice h3 {
  margin: 8px 0;
}

.episode-long-block ul,
.episode-practice ol {
  margin: 12px 0 0;
  color: var(--ink);
  line-height: 1.8;
}

.episode-mini-lines,
.episode-example {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(73, 182, 184, 0.08);
}

.episode-mini-lines p,
.episode-example p {
  margin: 0;
}

.episode-mini-lines strong,
.episode-example strong,
.episode-practice strong {
  margin-right: 8px;
  color: var(--ink);
}

.episode-figure-grid,
.episode-practice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.episode-figure .compact-path {
  margin: 12px 0;
}

.episode-figure small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 800;
}

.episode-board .visual-note {
  margin: 0;
  grid-template-columns: minmax(120px, 160px) minmax(360px, 1fr) minmax(300px, 0.85fr);
}

.episode-check {
  padding: 18px;
}

.episode-check p {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 12px 0;
}

.episode-nav {
  margin-top: 18px;
}

.episode-nav .primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.recovery-route {
  margin-bottom: 24px;
}

.recovery-route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.recovery-route-grid article {
  position: relative;
  min-height: 176px;
  padding: 18px;
  border: 1px solid rgba(23, 111, 115, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(242, 249, 249, 0.9)),
    radial-gradient(circle at top right, rgba(72, 199, 184, 0.16), transparent 42%);
  box-shadow: var(--shadow-sm);
}

.recovery-route-grid span,
.recovery-route-grid strong {
  display: inline-grid;
  min-height: 28px;
  place-items: center;
  margin-right: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(23, 111, 115, 0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.recovery-route-grid h3 {
  margin: 12px 0 8px;
}

.recovery-route-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.readiness-meter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.bond-event-grid,
.result-dialogue-grid,
.interlude-grid,
.remediation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.bond-event-grid article,
.remediation-grid article {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(238, 250, 250, 0.94)),
    var(--panel);
  box-shadow: var(--shadow-sm);
}

.bond-event-grid article > div:last-child > span,
.remediation-grid article > div:last-child > span,
.interlude-card > span {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.bond-event-grid h3,
.bond-event-grid p,
.remediation-grid h3,
.remediation-grid p,
.interlude-card h3,
.interlude-card p {
  margin: 0;
}

.bond-event-grid h3,
.remediation-grid h3,
.interlude-card h3 {
  margin-bottom: 6px;
}

.remediation-grid p,
.interlude-card p {
  color: var(--muted);
  line-height: 1.7;
}

.remediation-grid a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.interlude-card {
  min-height: 100%;
  padding: 18px;
  border: 1px solid rgba(69, 44, 145, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(243, 240, 255, 0.9)),
    var(--panel);
  box-shadow: var(--shadow-sm);
}

.compact-scene {
  min-height: 100%;
}

.readiness-meter-grid article {
  padding: 16px;
  border: 1px solid rgba(29, 36, 48, 0.1);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.readiness-meter-grid strong {
  color: var(--ink);
  font-size: 13px;
}

.readiness-meter-grid h3 {
  margin: 10px 0 0;
}

.readiness-meter-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.auth-panel form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.auth-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.auth-panel input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  font: inherit;
}

.form-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff0ee;
  color: var(--bad);
  font-weight: 700;
}

.drill-grid,
.case-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.case-grid {
  margin-bottom: 28px;
}

.drill-card,
.case-card {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.b-mission {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid #9ac7b5;
  border-radius: 8px;
  background: #f4fbf7;
}

.b-mission article {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.b-mission-score {
  display: grid;
  place-items: center;
  min-height: 70px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.b-mission h2,
.b-mission p {
  margin: 0;
}

.b-mission p {
  color: var(--muted);
}

.b-mission-bar {
  height: 10px;
  border-radius: 999px;
  background: #dce9e4;
  overflow: hidden;
}

.b-mission-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.b-solver-kit {
  margin-bottom: 24px;
}

.solver-kit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.solver-kit-grid article {
  min-height: 168px;
  padding: 18px;
  border: 1px solid rgba(23, 111, 115, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(242, 249, 249, 0.9)),
    radial-gradient(circle at top right, rgba(72, 199, 184, 0.14), transparent 42%);
  box-shadow: var(--shadow-sm);
}

.solver-kit-grid span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.solver-kit-grid h3 {
  margin: 10px 0 8px;
}

.solver-kit-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.case-card.is-done,
.drill-card.is-done {
  border-color: #9ac7b5;
  background: #fbfffd;
}

.drill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.drill-tags span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.drill-card h2,
.case-card h2 {
  margin-top: 12px;
}

.drill-card p,
.case-card p {
  color: var(--ink);
}

.drill-card ol,
.case-card ol {
  padding-left: 22px;
  color: var(--muted);
}

.drill-card details,
.case-card details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.drill-card summary,
.case-card summary {
  cursor: pointer;
  font-weight: 800;
}

.training-done {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--accent);
  font-weight: 800;
}

.pseudo-block {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #f8fafc;
}

.pseudo-block code {
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
}

.trace-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.trace-columns span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

:root {
  --rpg-bg-deep: #070b16;
  --rpg-bg-mid: #10162a;
  --rpg-panel: rgba(12, 18, 32, 0.78);
  --rpg-panel-light: rgba(255, 255, 255, 0.92);
  --rpg-cyan: #46f0ff;
  --rpg-teal: #28d7c6;
  --rpg-purple: #8f5bff;
  --rpg-gold: #f5c76a;
  --rpg-danger: #ff5d5d;
  --rpg-warning: #ffb347;
  --rpg-radius: 18px;
  --rpg-shadow-cyan: 0 0 24px rgba(70, 240, 255, 0.35);
  --rpg-shadow-purple: 0 0 24px rgba(143, 91, 255, 0.35);
}

.rpg-label,
.rpg-mode-only {
  display: none !important;
}

[hidden],
html[data-visual-mode] [hidden],
body[data-visual-mode] [hidden] {
  display: none !important;
}

html[data-visual-mode="rpg"] .simple-label,
body[data-visual-mode="rpg"] .simple-label {
  display: none !important;
}

html[data-visual-mode="rpg"] .rpg-label,
body[data-visual-mode="rpg"] .rpg-label {
  display: inline !important;
}

html[data-visual-mode="rpg"] .rpg-mode-only,
body[data-visual-mode="rpg"] .rpg-mode-only {
  display: block !important;
}

html[data-visual-mode="rpg"] .companion-stage.rpg-mode-only,
body[data-visual-mode="rpg"] .companion-stage.rpg-mode-only {
  display: grid !important;
}

html[data-visual-mode="rpg"] .result-badges.rpg-mode-only,
body[data-visual-mode="rpg"] .result-badges.rpg-mode-only,
html[data-visual-mode="rpg"] .result-dialogue-grid.rpg-mode-only,
body[data-visual-mode="rpg"] .result-dialogue-grid.rpg-mode-only {
  display: grid !important;
}

html[data-visual-mode="rpg"] .rpg-command-deck,
body[data-visual-mode="rpg"] .rpg-command-deck {
  display: grid !important;
}

html[data-visual-mode="rpg"] .chapter-party-line,
body[data-visual-mode="rpg"] .chapter-party-line {
  display: flex !important;
}

.visual-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 42px;
  padding: 4px;
  border: 1px solid rgba(216, 182, 95, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px rgba(17, 24, 33, 0.12);
}

.visual-mode-option {
  min-height: 32px;
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.visual-mode-option[aria-pressed="true"] {
  background:
    linear-gradient(135deg, rgba(70, 240, 255, 0.2), rgba(245, 199, 106, 0.18)),
    #111821;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(70, 240, 255, 0.28), var(--rpg-shadow-cyan);
}

html[data-visual-mode="simple"] body,
body[data-visual-mode="simple"] {
  background: #f7f8fb;
  color: var(--ink);
}

html[data-visual-mode="simple"] body::before,
body[data-visual-mode="simple"]::before,
html[data-visual-mode="simple"] .topbar::before,
body[data-visual-mode="simple"] .topbar::before,
html[data-visual-mode="simple"] .topbar::after,
body[data-visual-mode="simple"] .topbar::after,
html[data-visual-mode="simple"] .topbar-corner,
body[data-visual-mode="simple"] .topbar-corner {
  display: none;
}

html[data-visual-mode="simple"] .topbar,
body[data-visual-mode="simple"] .topbar {
  overflow: visible;
  border-top: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 24px rgba(17, 24, 33, 0.08);
}

html[data-visual-mode="simple"] .brand,
body[data-visual-mode="simple"] .brand {
  border-color: var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: none;
}

html[data-visual-mode="simple"] .brand::after,
body[data-visual-mode="simple"] .brand::after {
  display: none;
}

html[data-visual-mode="simple"] .topnav a,
html[data-visual-mode="simple"] .topnav button,
body[data-visual-mode="simple"] .topnav a,
body[data-visual-mode="simple"] .topnav button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: none;
}

html[data-visual-mode="simple"] .topnav a::before,
html[data-visual-mode="simple"] .topnav button::before,
body[data-visual-mode="simple"] .topnav a::before,
body[data-visual-mode="simple"] .topnav button::before,
html[data-visual-mode="simple"] .summary::before,
body[data-visual-mode="simple"] .summary::before {
  display: none;
}

html[data-visual-mode="simple"] .summary,
body[data-visual-mode="simple"] .summary {
  border-color: var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

html[data-visual-mode="simple"] .companion-stage:not(.rpg-mode-only),
body[data-visual-mode="simple"] .companion-stage:not(.rpg-mode-only) {
  display: grid !important;
  width: min(170px, 28vw);
  min-height: 126px;
  opacity: 0.96;
}

html[data-visual-mode="simple"] .visual-bg,
body[data-visual-mode="simple"] .visual-bg {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(235, 251, 253, 0.9)),
    var(--visual-bg) center / cover no-repeat,
    #fff !important;
}

html[data-visual-mode="simple"] .chapter-hero,
body[data-visual-mode="simple"] .chapter-hero {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(238, 250, 250, 0.92)),
    var(--visual-bg) center / cover no-repeat,
    #fff !important;
  border-color: rgba(23, 111, 115, 0.18);
  box-shadow: var(--shadow-sm);
}

html[data-visual-mode="simple"] .episode-stage,
body[data-visual-mode="simple"] .episode-stage {
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.95) 0 42%, rgba(232, 250, 250, 0.82) 72%, rgba(238, 232, 252, 0.74) 100%),
    var(--episode-bg) center / cover no-repeat,
    #fff !important;
  border-color: rgba(23, 111, 115, 0.22);
  box-shadow: 0 18px 48px rgba(17, 24, 33, 0.12);
}

html[data-visual-mode="simple"] .visual-bg::before,
html[data-visual-mode="simple"] .chapter-effect,
body[data-visual-mode="simple"] .visual-bg::before,
body[data-visual-mode="simple"] .chapter-effect {
  display: none !important;
}

html[data-visual-mode="simple"] .episode-stage::before,
body[data-visual-mode="simple"] .episode-stage::before {
  display: block;
  opacity: 0.42;
  background:
    radial-gradient(circle at 16% 18%, rgba(70, 240, 255, 0.16), transparent 30%),
    radial-gradient(circle at 82% 12%, rgba(143, 91, 255, 0.14), transparent 34%),
    repeating-linear-gradient(115deg, rgba(73, 182, 184, 0.05) 0 1px, transparent 1px 18px);
}

html[data-visual-mode="simple"] .episode-stage::after,
body[data-visual-mode="simple"] .episode-stage::after {
  display: block;
  opacity: 0.18;
  transform: none;
  animation: none;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.62), transparent),
    repeating-linear-gradient(0deg, transparent 0 20px, rgba(29, 36, 48, 0.04) 20px 21px);
}

html[data-visual-mode="simple"] .episode-ambient,
body[data-visual-mode="simple"] .episode-ambient {
  display: block;
  opacity: 0.32;
  mix-blend-mode: normal;
  animation: none;
}

html[data-visual-mode="simple"] .episode-hero,
body[data-visual-mode="simple"] .episode-hero {
  min-height: 180px;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 190px);
  align-items: end;
  margin: 10px 0 18px;
  padding: clamp(16px, 2.4vw, 26px);
  border: 1px solid rgba(23, 111, 115, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(233, 250, 250, 0.78)),
    radial-gradient(circle at 86% 18%, rgba(70, 240, 255, 0.18), transparent 34%);
  box-shadow: 0 18px 44px rgba(17, 24, 33, 0.1);
}

html[data-visual-mode="simple"] .episode-hero h1,
body[data-visual-mode="simple"] .episode-hero h1 {
  color: #101827;
}

html[data-visual-mode="simple"] .episode-hero p,
body[data-visual-mode="simple"] .episode-hero p {
  color: #445065;
}

html[data-visual-mode="simple"] .episode-character,
body[data-visual-mode="simple"] .episode-character {
  display: block !important;
  max-width: min(180px, 28vw);
  max-height: 220px;
  opacity: 0.98;
  filter: drop-shadow(0 20px 28px rgba(17, 24, 33, 0.22));
}

html[data-visual-mode="simple"] .episode-dialogue,
html[data-visual-mode="simple"] .episode-line,
html[data-visual-mode="simple"] .episode-lesson,
html[data-visual-mode="simple"] .episode-section,
html[data-visual-mode="simple"] .episode-objectives,
html[data-visual-mode="simple"] .episode-long-block,
html[data-visual-mode="simple"] .episode-figure,
html[data-visual-mode="simple"] .episode-practice,
body[data-visual-mode="simple"] .episode-dialogue,
body[data-visual-mode="simple"] .episode-line,
body[data-visual-mode="simple"] .episode-lesson,
body[data-visual-mode="simple"] .episode-section,
body[data-visual-mode="simple"] .episode-objectives,
body[data-visual-mode="simple"] .episode-long-block,
body[data-visual-mode="simple"] .episode-figure,
body[data-visual-mode="simple"] .episode-practice {
  border-color: rgba(23, 111, 115, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(245, 251, 251, 0.94)),
    var(--ui-bubble) center / 100% 100% no-repeat;
  box-shadow: 0 12px 28px rgba(17, 24, 33, 0.08);
}

html[data-visual-mode="simple"] .episode-dialogue,
body[data-visual-mode="simple"] .episode-dialogue {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(239, 250, 250, 0.92)),
    radial-gradient(circle at 100% 0%, rgba(70, 240, 255, 0.12), transparent 32%);
}

html[data-visual-mode="simple"] .episode-lesson,
body[data-visual-mode="simple"] .episode-lesson {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 242, 252, 0.9)),
    radial-gradient(circle at 100% 14%, rgba(143, 91, 255, 0.1), transparent 34%);
}

html[data-visual-mode="simple"] .episode-line,
body[data-visual-mode="simple"] .episode-line {
  grid-template-columns: 76px minmax(0, 1fr);
  min-height: 108px;
  border: 1px solid rgba(23, 111, 115, 0.14);
  border-left: 5px solid rgba(40, 215, 198, 0.76);
}

html[data-visual-mode="simple"] .episode-line.line-serious,
body[data-visual-mode="simple"] .episode-line.line-serious {
  border-left-color: rgba(143, 91, 255, 0.7);
}

html[data-visual-mode="simple"] .episode-line.line-happy,
html[data-visual-mode="simple"] .episode-line.line-surprised,
body[data-visual-mode="simple"] .episode-line.line-happy,
body[data-visual-mode="simple"] .episode-line.line-surprised {
  border-left-color: rgba(245, 199, 106, 0.82);
}

html[data-visual-mode="simple"] .episode-line.is-active,
body[data-visual-mode="simple"] .episode-line.is-active {
  border-color: rgba(40, 215, 198, 0.34);
  box-shadow: 0 16px 34px rgba(23, 111, 115, 0.12);
}

html[data-visual-mode="simple"] .episode-line img,
body[data-visual-mode="simple"] .episode-line img {
  width: 76px;
  height: 92px;
  filter: drop-shadow(0 12px 16px rgba(17, 24, 33, 0.18));
}

html[data-visual-mode="simple"] .episode-line.speaker-bit img,
body[data-visual-mode="simple"] .episode-line.speaker-bit img {
  object-fit: contain;
  background: radial-gradient(circle at 50% 44%, rgba(70, 240, 255, 0.14), rgba(255, 255, 255, 0.62) 62%);
}

html[data-visual-mode="simple"] .episode-dialogue.dialogue-enhanced .episode-line:not(.is-active),
body[data-visual-mode="simple"] .episode-dialogue.dialogue-enhanced .episode-line:not(.is-active) {
  display: grid;
}

html[data-visual-mode="simple"] .roadmap-zone,
html[data-visual-mode="simple"] .story-node,
body[data-visual-mode="simple"] .roadmap-zone,
body[data-visual-mode="simple"] .story-node {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

html[data-visual-mode="simple"] .rpg-node-chain::before,
html[data-visual-mode="simple"] .map-node::after,
body[data-visual-mode="simple"] .rpg-node-chain::before,
body[data-visual-mode="simple"] .map-node::after {
  display: none !important;
}

html[data-visual-mode="simple"] body[data-endpoint="quiz"] .companion-stage,
html[data-visual-mode="simple"] body[data-endpoint="question_detail"] .side-companion,
html[data-visual-mode="simple"] body[data-endpoint="quiz_challenge"] .companion-stage,
html[data-visual-mode="simple"] body[data-endpoint="mock_start"] .companion-stage,
html[data-visual-mode="simple"] body[data-endpoint="submit_challenge"] .companion-stage,
html[data-visual-mode="simple"] body[data-endpoint="review"] .companion-stage,
body[data-visual-mode="simple"][data-endpoint="quiz"] .companion-stage,
body[data-visual-mode="simple"][data-endpoint="question_detail"] .side-companion,
body[data-visual-mode="simple"][data-endpoint="quiz_challenge"] .companion-stage,
body[data-visual-mode="simple"][data-endpoint="mock_start"] .companion-stage,
body[data-visual-mode="simple"][data-endpoint="submit_challenge"] .companion-stage,
body[data-visual-mode="simple"][data-endpoint="review"] .companion-stage {
  display: none !important;
}

html[data-visual-mode="simple"] .quiz-remediation-section .cast-avatar,
html[data-visual-mode="simple"] .quiz-remediation-section .voice-line-button,
html[data-visual-mode="simple"] .remediation-grid .cast-avatar,
html[data-visual-mode="simple"] .remediation-grid .voice-line-button,
html[data-visual-mode="simple"] .bond-event-grid .cast-avatar,
html[data-visual-mode="simple"] .panel-art,
body[data-visual-mode="simple"] .quiz-remediation-section .cast-avatar,
body[data-visual-mode="simple"] .quiz-remediation-section .voice-line-button,
body[data-visual-mode="simple"] .remediation-grid .cast-avatar,
body[data-visual-mode="simple"] .remediation-grid .voice-line-button,
body[data-visual-mode="simple"] .bond-event-grid .cast-avatar,
body[data-visual-mode="simple"] .panel-art {
  display: none !important;
}

html[data-visual-mode="simple"] .companion-stage.rpg-mode-only,
body[data-visual-mode="simple"] .companion-stage.rpg-mode-only {
  display: grid !important;
  width: min(210px, 30vw);
  min-height: 150px;
  opacity: 0.94;
  filter: saturate(0.95);
}

html[data-visual-mode="simple"] body[data-endpoint="quiz"] .companion-stage.rpg-mode-only,
html[data-visual-mode="simple"] body[data-endpoint="quiz_challenge"] .companion-stage.rpg-mode-only,
html[data-visual-mode="simple"] body[data-endpoint="mock_start"] .companion-stage.rpg-mode-only,
html[data-visual-mode="simple"] body[data-endpoint="submit_challenge"] .companion-stage.rpg-mode-only,
html[data-visual-mode="simple"] body[data-endpoint="review"] .companion-stage.rpg-mode-only,
body[data-visual-mode="simple"][data-endpoint="quiz"] .companion-stage.rpg-mode-only,
body[data-visual-mode="simple"][data-endpoint="quiz_challenge"] .companion-stage.rpg-mode-only,
body[data-visual-mode="simple"][data-endpoint="mock_start"] .companion-stage.rpg-mode-only,
body[data-visual-mode="simple"][data-endpoint="submit_challenge"] .companion-stage.rpg-mode-only,
body[data-visual-mode="simple"][data-endpoint="review"] .companion-stage.rpg-mode-only {
  display: grid !important;
}

html[data-visual-mode="simple"] .side-companion.rpg-mode-only,
body[data-visual-mode="simple"] .side-companion.rpg-mode-only {
  display: grid !important;
  opacity: 0.92;
}

html[data-visual-mode="simple"] body[data-endpoint="question_detail"] .side-companion.rpg-mode-only,
body[data-visual-mode="simple"][data-endpoint="question_detail"] .side-companion.rpg-mode-only {
  display: grid !important;
}

html[data-visual-mode="simple"] .quiz-remediation-section .cast-avatar,
html[data-visual-mode="simple"] .remediation-grid .cast-avatar,
html[data-visual-mode="simple"] .bond-event-grid .cast-avatar,
body[data-visual-mode="simple"] .quiz-remediation-section .cast-avatar,
body[data-visual-mode="simple"] .remediation-grid .cast-avatar,
body[data-visual-mode="simple"] .bond-event-grid .cast-avatar {
  display: block !important;
  filter: saturate(0.92) drop-shadow(0 10px 14px rgba(17, 24, 33, 0.14));
}

html[data-visual-mode="simple"] .panel-art,
body[data-visual-mode="simple"] .panel-art {
  display: block !important;
  opacity: 0.28;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-lesson-visual.rpg-mode-only,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-lesson-visual.rpg-mode-only {
  display: grid !important;
  grid-template-columns: minmax(180px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  margin: 14px 0 18px;
  padding: 14px;
  border: 1px solid rgba(40, 215, 198, 0.22);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(240, 255, 253, 0.92), rgba(248, 245, 255, 0.86)),
    radial-gradient(circle at 84% 16%, rgba(70, 240, 255, 0.16), transparent 34%);
  box-shadow: 0 14px 32px rgba(17, 24, 33, 0.08);
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-lesson-visual h3,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-lesson-visual h3 {
  margin: 4px 0 8px;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-lesson-visual .binary-diagram-note,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-lesson-visual .binary-diagram-note {
  grid-column: 1 / -1;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-lesson article,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-lesson article {
  display: none;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-log-fold summary,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-log-fold summary {
  background:
    linear-gradient(135deg, rgba(234, 255, 252, 0.9), rgba(250, 246, 255, 0.82)),
    radial-gradient(circle at 96% 0%, rgba(70, 240, 255, 0.12), transparent 30%);
}

html[data-visual-mode="simple"] .quiz-command-panel,
html[data-visual-mode="simple"] .question-card,
html[data-visual-mode="simple"] .challenge-card,
html[data-visual-mode="simple"] .result-diagnosis,
html[data-visual-mode="simple"] .review-coach-grid article,
body[data-visual-mode="simple"] .quiz-command-panel,
body[data-visual-mode="simple"] .question-card,
body[data-visual-mode="simple"] .challenge-card,
body[data-visual-mode="simple"] .result-diagnosis,
body[data-visual-mode="simple"] .review-coach-grid article {
  border-color: var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

html[data-visual-mode="rpg"] body,
body[data-visual-mode="rpg"] {
  background:
    radial-gradient(circle at 16% 10%, rgba(70, 240, 255, 0.22), transparent 30%),
    radial-gradient(circle at 82% 4%, rgba(143, 91, 255, 0.22), transparent 32%),
    linear-gradient(180deg, rgba(7, 11, 22, 0.94), rgba(16, 22, 42, 0.64) 370px, rgba(247, 245, 240, 0.94) 900px),
    url("/static/visual/backgrounds/story-city.jpg") top center / cover fixed no-repeat,
    var(--rpg-bg-deep);
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"],
html[data-visual-mode="rpg"] body[data-endpoint="question_detail"],
html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"],
html[data-visual-mode="rpg"] body[data-endpoint="mock_exam"],
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"],
html[data-visual-mode="rpg"] body[data-endpoint="submit_challenge"],
body[data-visual-mode="rpg"][data-endpoint="quiz"],
body[data-visual-mode="rpg"][data-endpoint="question_detail"],
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"],
body[data-visual-mode="rpg"][data-endpoint="mock_exam"],
body[data-visual-mode="rpg"][data-endpoint="mock_start"],
body[data-visual-mode="rpg"][data-endpoint="submit_challenge"] {
  background:
    radial-gradient(circle at 14% 12%, rgba(70, 240, 255, 0.28), transparent 28%),
    radial-gradient(circle at 80% 6%, rgba(143, 91, 255, 0.3), transparent 34%),
    linear-gradient(180deg, rgba(7, 11, 22, 0.9), rgba(16, 22, 42, 0.5) 410px, rgba(247, 245, 240, 0.93) 920px),
    var(--bg-quiz-battle-terminal) center top / cover fixed no-repeat,
    var(--rpg-bg-deep);
}

html[data-visual-mode="rpg"] .summary,
body[data-visual-mode="rpg"] .summary {
  animation: panelEnter 0.42s ease both;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary {
  overflow: hidden;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 240px);
  align-items: center;
  min-height: 430px;
  border-color: rgba(70, 240, 255, 0.32);
  background:
    linear-gradient(90deg, rgba(7, 11, 22, 0.92), rgba(11, 18, 34, 0.74) 58%, rgba(70, 240, 255, 0.08)),
    radial-gradient(circle at 86% 22%, rgba(70, 240, 255, 0.24), transparent 28%),
    var(--bg-quiz-battle-terminal) center / cover no-repeat;
  color: #f3fbff;
  box-shadow: 0 0 34px rgba(70, 240, 255, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary::after,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent, rgba(70, 240, 255, 0.12), transparent) 0 34% / 100% 1px no-repeat,
    linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  mix-blend-mode: screen;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary > *,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary > * {
  position: relative;
  z-index: 1;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary h1,
html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary p,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary h1,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary p {
  color: inherit;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary > div:first-child,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary > div:first-child {
  max-width: 640px;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .companion-stage,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .companion-stage {
  grid-column: 2;
  grid-row: 1 / span 3;
  width: min(100%, 240px);
  min-height: 280px;
  place-items: center;
  align-self: stretch;
  border: 1px solid rgba(70, 240, 255, 0.18);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 92%, rgba(70, 240, 255, 0.34), transparent 32%),
    rgba(255, 255, 255, 0.06);
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .companion-large,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .companion-large {
  max-width: 150px;
  max-height: 210px;
  filter: drop-shadow(0 22px 24px rgba(0, 0, 0, 0.42));
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .companion-item,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .companion-item {
  right: 18px;
  bottom: 20px;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .companion-bubble,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .companion-bubble {
  border-color: rgba(70, 240, 255, 0.28);
  background:
    linear-gradient(135deg, rgba(9, 16, 30, 0.94), rgba(18, 31, 48, 0.9)),
    var(--ui-bubble) center / 100% 100% no-repeat;
  color: #f3fbff;
  box-shadow: 0 0 18px rgba(70, 240, 255, 0.16);
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .companion-bubble::after,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .companion-bubble::after {
  border-color: rgba(70, 240, 255, 0.28);
  background: rgba(18, 31, 48, 0.94);
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .metrics,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .metrics {
  grid-column: 1;
  align-self: stretch;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .metrics > div,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .metrics > div {
  border-color: rgba(70, 240, 255, 0.24);
  background: rgba(255, 255, 255, 0.1);
  color: #f3fbff;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .metrics span,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .metrics span {
  color: var(--rpg-cyan);
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .summary-actions,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .summary-actions {
  grid-column: 1 / -1;
}

@media (max-width: 760px) {
  html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary,
  body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .companion-stage,
  body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .companion-stage {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    min-height: 156px;
    place-items: center start;
    padding-left: 18px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .companion-large,
  body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .companion-large {
    max-width: 112px;
    max-height: 142px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .summary .metrics,
  body[data-visual-mode="rpg"][data-endpoint="quiz"] .summary .metrics {
    grid-column: 1;
  }
}

html[data-visual-mode="rpg"] .quiz-command-panel,
html[data-visual-mode="rpg"] .quiz-mode-grid article,
html[data-visual-mode="rpg"] .question-card,
html[data-visual-mode="rpg"] .question-side,
html[data-visual-mode="rpg"] .challenge-card,
html[data-visual-mode="rpg"] .mock-control,
html[data-visual-mode="rpg"] .exam-rules article,
html[data-visual-mode="rpg"] .mock-plan article,
html[data-visual-mode="rpg"] .mock-profile article,
html[data-visual-mode="rpg"] .result-diagnosis,
html[data-visual-mode="rpg"] .result-badges article,
html[data-visual-mode="rpg"] .review-coach-grid article,
html[data-visual-mode="rpg"] .review-row,
body[data-visual-mode="rpg"] .quiz-command-panel,
body[data-visual-mode="rpg"] .quiz-mode-grid article,
body[data-visual-mode="rpg"] .question-card,
body[data-visual-mode="rpg"] .question-side,
body[data-visual-mode="rpg"] .challenge-card,
body[data-visual-mode="rpg"] .mock-control,
body[data-visual-mode="rpg"] .exam-rules article,
body[data-visual-mode="rpg"] .mock-plan article,
body[data-visual-mode="rpg"] .mock-profile article,
body[data-visual-mode="rpg"] .result-diagnosis,
body[data-visual-mode="rpg"] .result-badges article,
body[data-visual-mode="rpg"] .review-coach-grid article,
body[data-visual-mode="rpg"] .review-row {
  border-color: rgba(70, 240, 255, 0.24);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(240, 250, 251, 0.9)),
    radial-gradient(circle at top right, rgba(70, 240, 255, 0.16), transparent 44%);
  box-shadow: 0 16px 42px rgba(7, 11, 22, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

html[data-visual-mode="rpg"] .question-card,
html[data-visual-mode="rpg"] .challenge-card,
body[data-visual-mode="rpg"] .question-card,
body[data-visual-mode="rpg"] .challenge-card {
  position: relative;
  overflow: hidden;
}

html[data-visual-mode="rpg"] .question-card::before,
html[data-visual-mode="rpg"] .challenge-card::before,
body[data-visual-mode="rpg"] .question-card::before,
body[data-visual-mode="rpg"] .challenge-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  height: 4px;
  background: linear-gradient(90deg, var(--rpg-teal), var(--rpg-purple), var(--rpg-gold));
  opacity: 0.9;
}

html[data-visual-mode="rpg"] .question-card::after,
html[data-visual-mode="rpg"] .challenge-card::after,
body[data-visual-mode="rpg"] .question-card::after,
body[data-visual-mode="rpg"] .challenge-card::after {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: 0;
  pointer-events: none;
  background: var(--ui-question-analysis-hud) center / cover no-repeat;
  opacity: 0.065;
  mix-blend-mode: multiply;
}

html[data-visual-mode="rpg"] .question-card > *,
html[data-visual-mode="rpg"] .challenge-card > *,
body[data-visual-mode="rpg"] .question-card > *,
body[data-visual-mode="rpg"] .challenge-card > * {
  position: relative;
  z-index: 1;
}

html[data-visual-mode="rpg"] .choice,
html[data-visual-mode="rpg"] .challenge-choices label,
body[data-visual-mode="rpg"] .choice,
body[data-visual-mode="rpg"] .challenge-choices label {
  border-color: rgba(70, 240, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(238, 249, 250, 0.92)),
    var(--ui-choice) center / 100% 100% no-repeat;
}

html[data-visual-mode="rpg"] .choice:hover,
html[data-visual-mode="rpg"] .challenge-choices label:hover,
body[data-visual-mode="rpg"] .choice:hover,
body[data-visual-mode="rpg"] .challenge-choices label:hover {
  border-color: rgba(70, 240, 255, 0.58);
  box-shadow: var(--rpg-shadow-cyan);
}

html[data-visual-mode="rpg"] .mock-control,
body[data-visual-mode="rpg"] .mock-control {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(236, 250, 251, 0.84)),
    var(--ui-timer) right 18px center / 210px auto no-repeat,
    radial-gradient(circle at 88% 18%, rgba(70, 240, 255, 0.2), transparent 36%);
}

html[data-visual-mode="rpg"] .mock-control::after,
body[data-visual-mode="rpg"] .mock-control::after {
  content: "";
  position: absolute;
  inset: -18px 0 -18px auto;
  width: min(520px, 58%);
  pointer-events: none;
  background: var(--anim-mock-gate-open) right center / cover no-repeat;
  opacity: 0.075;
  mix-blend-mode: multiply;
}

html[data-visual-mode="rpg"] .mock-control > *,
body[data-visual-mode="rpg"] .mock-control > * {
  position: relative;
  z-index: 1;
}

html[data-visual-mode="rpg"] .mock-timer,
body[data-visual-mode="rpg"] .mock-timer {
  border: 1px solid rgba(70, 240, 255, 0.38);
  background:
    linear-gradient(180deg, rgba(7, 11, 22, 0.98), rgba(16, 22, 42, 0.94)),
    var(--ui-timer) center / 100% 100% no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), var(--rpg-shadow-cyan);
}

html[data-visual-mode="rpg"] .result-badges article,
body[data-visual-mode="rpg"] .result-badges article {
  position: relative;
  overflow: hidden;
}

html[data-visual-mode="rpg"] .result-badges article::before,
body[data-visual-mode="rpg"] .result-badges article::before {
  content: "";
  position: absolute;
  inset: 8px 8px auto auto;
  width: min(240px, 62%);
  height: 86px;
  pointer-events: none;
  background: var(--result-ranks) center / cover no-repeat;
  opacity: 0.07;
  mix-blend-mode: multiply;
}

html[data-visual-mode="rpg"] .result-badges article::after,
body[data-visual-mode="rpg"] .result-badges article::after {
  content: "";
  position: absolute;
  right: -16px;
  bottom: -18px;
  width: 104px;
  height: 104px;
  pointer-events: none;
  background: var(--rank-star) center / contain no-repeat;
  opacity: 0.24;
  filter: drop-shadow(0 0 18px rgba(245, 199, 106, 0.32));
}

html[data-visual-mode="rpg"] .review-row,
body[data-visual-mode="rpg"] .review-row {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(239, 250, 250, 0.9)),
    var(--ui-review-card) center / 100% 100% no-repeat;
}

html[data-visual-mode="rpg"] .review-row.due::after,
body[data-visual-mode="rpg"] .review-row.due::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 10px;
  width: 82px;
  height: 58px;
  pointer-events: none;
  background: var(--anim-review-transfer) center / contain no-repeat;
  opacity: 0.24;
}

html[data-visual-mode="rpg"] .review-coach,
body[data-visual-mode="rpg"] .review-coach {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

html[data-visual-mode="rpg"] .review-coach::before,
body[data-visual-mode="rpg"] .review-coach::before {
  content: "";
  position: absolute;
  top: -46px;
  right: -52px;
  width: min(560px, 74vw);
  height: 300px;
  pointer-events: none;
  background: var(--ui-srs-vault) center / contain no-repeat;
  opacity: 0.12;
  mix-blend-mode: multiply;
}

html[data-visual-mode="rpg"] .review-coach > *,
body[data-visual-mode="rpg"] .review-coach > * {
  position: relative;
  z-index: 1;
}

html[data-visual-mode="rpg"] .episode-dialogue,
body[data-visual-mode="rpg"] .episode-dialogue {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(238, 250, 250, 0.9)),
    var(--ui-bubble-large) center / 100% 100% no-repeat;
}

html[data-visual-mode="rpg"] .episode-line.is-active,
body[data-visual-mode="rpg"] .episode-line.is-active {
  border: 1px solid rgba(70, 240, 255, 0.26);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 251, 252, 0.98)),
    var(--ui-bubble-large) center / 100% 100% no-repeat;
  box-shadow: 0 16px 34px rgba(7, 11, 22, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

html[data-visual-mode="rpg"] .episode-line .eyebrow,
body[data-visual-mode="rpg"] .episode-line .eyebrow {
  width: fit-content;
  min-height: 28px;
  padding: 4px 12px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(7, 11, 22, 0.9), rgba(16, 22, 42, 0.76)),
    var(--ui-name-plate) center / 100% 100% no-repeat;
  color: #eef8ff;
  box-shadow: 0 0 16px rgba(70, 240, 255, 0.18);
}

html[data-visual-mode="rpg"] .episode-line.is-active div > p:not(.eyebrow),
body[data-visual-mode="rpg"] .episode-line.is-active div > p:not(.eyebrow) {
  color: var(--ink);
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

html[data-visual-mode="rpg"] .episode-line.is-active img,
body[data-visual-mode="rpg"] .episode-line.is-active img {
  filter: drop-shadow(0 14px 14px rgba(7, 11, 22, 0.2));
}

html[data-visual-mode="rpg"] .result-row.ok::before,
html[data-visual-mode="rpg"] .result-row.ng::before,
body[data-visual-mode="rpg"] .result-row.ok::before,
body[data-visual-mode="rpg"] .result-row.ng::before {
  content: "";
  align-self: stretch;
  min-width: 46px;
  border-radius: 8px;
  background: var(--fx-correct) center / contain no-repeat;
}

html[data-visual-mode="rpg"] .result-row,
body[data-visual-mode="rpg"] .result-row {
  grid-template-columns: 46px 58px minmax(0, 1fr) 86px;
}

html[data-visual-mode="rpg"] .result-row.ng::before,
body[data-visual-mode="rpg"] .result-row.ng::before {
  background-image: var(--fx-wrong);
}

html[data-visual-mode="rpg"] .result.ok,
body[data-visual-mode="rpg"] .result.ok {
  box-shadow: 0 0 28px rgba(70, 240, 255, 0.24);
}

html[data-visual-mode="rpg"] .result.ng,
body[data-visual-mode="rpg"] .result.ng {
  box-shadow: 0 0 28px rgba(255, 93, 93, 0.18);
}

.rpg-command-deck {
  grid-template-columns: minmax(260px, 1.35fr) repeat(3, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.rpg-command-deck article {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid rgba(70, 240, 255, 0.22);
  border-radius: var(--rpg-radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent),
    var(--rpg-panel);
  color: #eef8ff;
  box-shadow: var(--rpg-shadow-cyan);
}

.rpg-command-deck article::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(70, 240, 255, 0.12), transparent);
  transform: translateX(-120%);
  animation: scanLine 4.8s linear infinite;
}

.rpg-command-deck h2 {
  margin: 8px 0 10px;
  color: #fff;
}

.rpg-command-deck p {
  margin: 0;
  color: rgba(238, 248, 255, 0.82);
}

html[data-visual-mode="rpg"] .dashboard-hero,
body[data-visual-mode="rpg"] .dashboard-hero {
  border-color: rgba(70, 240, 255, 0.32);
  background:
    linear-gradient(90deg, rgba(7, 11, 22, 0.86) 0 48%, rgba(12, 18, 32, 0.72) 72%, rgba(255, 255, 255, 0.9)),
    radial-gradient(circle at 18% 24%, rgba(70, 240, 255, 0.22), transparent 36%),
    url("/static/visual/backgrounds/story-city.jpg") center / cover no-repeat;
  color: #f4fbff;
  box-shadow: var(--rpg-shadow-cyan), inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

html[data-visual-mode="rpg"] .dashboard-hero h1,
html[data-visual-mode="rpg"] .dashboard-hero p,
body[data-visual-mode="rpg"] .dashboard-hero h1,
body[data-visual-mode="rpg"] .dashboard-hero p {
  color: #f4fbff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

html[data-visual-mode="rpg"] .dashboard-hero .eyebrow,
body[data-visual-mode="rpg"] .dashboard-hero .eyebrow {
  color: var(--rpg-gold);
}

.quiz-unlock-map {
  margin: 0 0 24px;
  padding: clamp(16px, 2vw, 24px);
  border: 1px solid rgba(70, 240, 255, 0.24);
  border-radius: var(--rpg-radius);
  background:
    linear-gradient(145deg, rgba(7, 11, 22, 0.88), rgba(16, 22, 42, 0.76)),
    var(--rpg-panel);
  color: #edfaff;
  box-shadow: var(--rpg-shadow-purple);
}

.quiz-unlock-map .list-head p,
.quiz-unlock-map h2 {
  color: inherit;
}

.unlock-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.quiz-unlock-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) minmax(180px, auto);
  gap: 10px;
  align-items: stretch;
  margin: 0 0 14px;
}

.quiz-unlock-summary > div,
.quiz-unlock-summary > a {
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid rgba(70, 240, 255, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.quiz-unlock-summary span {
  display: block;
  color: #fff;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 1000;
  line-height: 1;
}

.quiz-unlock-summary small {
  display: block;
  margin-top: 8px;
  color: rgba(237, 250, 255, 0.72);
  font-size: 12px;
  font-weight: 900;
}

.quiz-unlock-summary > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #07111d;
  background: linear-gradient(135deg, var(--rpg-gold), #fff3bf);
  font-weight: 1000;
  text-align: center;
  text-decoration: none;
}

.unlock-chip {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 88px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.unlock-chip img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.unlock-icon-fallback {
  display: inline-flex !important;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(70, 240, 255, 0.28);
  border-radius: 50%;
  color: #dffcff !important;
  background: rgba(70, 240, 255, 0.1);
  font-size: 16px !important;
  font-weight: 1000 !important;
  line-height: 1 !important;
}

.unlock-chip span,
.unlock-chip small {
  display: block;
  color: rgba(237, 250, 255, 0.72);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.unlock-chip strong {
  display: block;
  overflow-wrap: break-word;
  word-break: keep-all;
  color: #fff;
  line-height: 1.32;
}

.unlock-chip.unlocked {
  border-color: rgba(70, 240, 255, 0.45);
  box-shadow: 0 0 18px rgba(70, 240, 255, 0.18);
}

.unlock-chip.available {
  border-color: rgba(245, 199, 106, 0.5);
  background: linear-gradient(135deg, rgba(245, 199, 106, 0.16), rgba(70, 240, 255, 0.08));
}

.unlock-chip.locked {
  opacity: 0.68;
  filter: grayscale(0.35);
}

.unlock-chip a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid rgba(70, 240, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #f4fbff;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.route-targets {
  margin-top: 6px !important;
  color: var(--muted) !important;
  font-size: 12px !important;
  line-height: 1.45;
}

html[data-visual-mode="rpg"] .route-targets,
body[data-visual-mode="rpg"] .route-targets {
  color: rgba(237, 250, 255, 0.72) !important;
}

html[data-visual-mode="simple"] .quiz-unlock-map,
body[data-visual-mode="simple"] .quiz-unlock-map {
  border-color: rgba(24, 132, 139, 0.16);
  background:
    radial-gradient(circle at top right, rgba(30, 210, 220, 0.1), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 247, 0.94));
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

html[data-visual-mode="simple"] .quiz-unlock-map h2,
html[data-visual-mode="simple"] .quiz-unlock-map .list-head p,
body[data-visual-mode="simple"] .quiz-unlock-map h2,
body[data-visual-mode="simple"] .quiz-unlock-map .list-head p {
  color: var(--ink);
}

html[data-visual-mode="simple"] .unlock-chip,
body[data-visual-mode="simple"] .unlock-chip {
  border-color: rgba(44, 55, 73, 0.12);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 18px rgba(14, 21, 32, 0.05);
}

html[data-visual-mode="simple"] .quiz-unlock-summary > div,
body[data-visual-mode="simple"] .quiz-unlock-summary > div {
  border-color: rgba(44, 55, 73, 0.12);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 18px rgba(14, 21, 32, 0.05);
}

html[data-visual-mode="simple"] .quiz-unlock-summary span,
body[data-visual-mode="simple"] .quiz-unlock-summary span {
  color: var(--ink);
}

html[data-visual-mode="simple"] .quiz-unlock-summary small,
body[data-visual-mode="simple"] .quiz-unlock-summary small {
  color: var(--muted);
}

html[data-visual-mode="simple"] .quiz-unlock-summary > a,
body[data-visual-mode="simple"] .quiz-unlock-summary > a {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

html[data-visual-mode="simple"] .unlock-icon-fallback,
body[data-visual-mode="simple"] .unlock-icon-fallback {
  border-color: rgba(24, 132, 139, 0.22);
  color: var(--accent) !important;
  background: rgba(24, 132, 139, 0.08);
}

html[data-visual-mode="simple"] .unlock-chip span,
html[data-visual-mode="simple"] .unlock-chip small,
body[data-visual-mode="simple"] .unlock-chip span,
body[data-visual-mode="simple"] .unlock-chip small {
  color: var(--muted);
}

html[data-visual-mode="simple"] .unlock-chip strong,
body[data-visual-mode="simple"] .unlock-chip strong {
  color: var(--ink);
}

html[data-visual-mode="simple"] .unlock-chip.unlocked,
body[data-visual-mode="simple"] .unlock-chip.unlocked {
  border-color: rgba(24, 132, 139, 0.32);
  background: linear-gradient(135deg, rgba(244, 251, 247, 0.96), #fff);
  box-shadow: 0 10px 22px rgba(24, 132, 139, 0.08);
}

html[data-visual-mode="simple"] .unlock-chip.available,
body[data-visual-mode="simple"] .unlock-chip.available {
  border-color: rgba(216, 182, 95, 0.42);
  background: linear-gradient(135deg, rgba(255, 249, 232, 0.96), #fff);
}

html[data-visual-mode="simple"] .unlock-chip a,
body[data-visual-mode="simple"] .unlock-chip a {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

@media (max-width: 680px) {
  .quiz-unlock-summary {
    grid-template-columns: repeat(3, 1fr);
  }

  .quiz-unlock-summary > a {
    grid-column: 1 / -1;
  }
}

.core-kicker {
  color: var(--rpg-gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.rpg-core-meter {
  overflow: hidden;
  height: 14px;
  margin: 12px 0;
  border: 1px solid rgba(70, 240, 255, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.rpg-core-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rpg-teal), var(--rpg-gold));
  box-shadow: var(--rpg-shadow-cyan);
}

.null-log {
  border-color: rgba(255, 93, 93, 0.34) !important;
  box-shadow: 0 0 24px rgba(255, 93, 93, 0.14) !important;
}

html[data-visual-mode="rpg"] .roadmap-hero,
html[data-visual-mode="rpg"] .story-hero,
html[data-visual-mode="rpg"] .chapter-hub,
body[data-visual-mode="rpg"] .roadmap-hero,
body[data-visual-mode="rpg"] .story-hero,
body[data-visual-mode="rpg"] .chapter-hub {
  border-color: rgba(245, 199, 106, 0.38);
  box-shadow: var(--rpg-shadow-cyan), inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

html[data-visual-mode="rpg"] .chapter-hub.visual-bg,
body[data-visual-mode="rpg"] .chapter-hub.visual-bg {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.97) 0 58%, rgba(255, 255, 255, 0.91) 78%, rgba(255, 255, 255, 0.78)),
    var(--visual-bg) center / cover no-repeat;
}

html[data-visual-mode="rpg"] .chapter-hub .chapter-head.wide p,
html[data-visual-mode="rpg"] .chapter-hub .mission,
html[data-visual-mode="rpg"] .chapter-hub .reward,
body[data-visual-mode="rpg"] .chapter-hub .chapter-head.wide p,
body[data-visual-mode="rpg"] .chapter-hub .mission,
body[data-visual-mode="rpg"] .chapter-hub .reward {
  color: #243142;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.74);
}

html[data-visual-mode="rpg"] .chapter-hub .mission strong,
html[data-visual-mode="rpg"] .chapter-hub .reward strong,
body[data-visual-mode="rpg"] .chapter-hub .mission strong,
body[data-visual-mode="rpg"] .chapter-hub .reward strong {
  color: #101722;
}

html[data-visual-mode="rpg"] .rpg-world-map,
body[data-visual-mode="rpg"] .rpg-world-map {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

html[data-visual-mode="rpg"] .roadmap-zone,
body[data-visual-mode="rpg"] .roadmap-zone {
  position: relative;
  overflow: hidden;
  border-color: rgba(70, 240, 255, 0.22);
  background:
    linear-gradient(120deg, rgba(7, 11, 22, 0.88), rgba(16, 22, 42, 0.76)),
    var(--rpg-panel);
  color: #eef8ff;
  box-shadow: var(--rpg-shadow-purple);
}

.rpg-node-chain {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

html[data-visual-mode="rpg"] .rpg-node-chain::before,
body[data-visual-mode="rpg"] .rpg-node-chain::before {
  content: "";
  position: absolute;
  inset: 22px 3% auto;
  height: 92px;
  pointer-events: none;
  background: var(--map-road) center / contain repeat-x;
  opacity: 0.28;
  filter: drop-shadow(0 0 16px rgba(70, 240, 255, 0.28));
}

.map-node {
  position: relative;
  min-height: 150px;
}

.map-node > a,
.map-node > span {
  position: relative;
  z-index: 1;
  display: grid;
  height: 100%;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--rpg-radius);
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.map-node i {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(70, 240, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(70, 240, 255, 0.28);
}

.map-node img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.map-node strong {
  color: inherit;
  line-height: 1.35;
}

.map-node small {
  color: rgba(238, 248, 255, 0.72);
}

.map-node-unlocks {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-style: normal;
}

.map-node-unlocks b {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 3px 7px;
  border: 1px solid rgba(70, 240, 255, 0.22);
  border-radius: 999px;
  background: rgba(70, 240, 255, 0.1);
  color: rgba(238, 248, 255, 0.82);
  font-size: 10px;
  font-weight: 1000;
  line-height: 1.2;
}

.map-node.available > a {
  border-color: rgba(70, 240, 255, 0.46);
  box-shadow: var(--rpg-shadow-cyan);
  animation: mapNodePulse 2.8s ease-in-out infinite;
}

.map-node.completed > a,
.map-node.completed > span {
  border-color: rgba(245, 199, 106, 0.58);
  background: linear-gradient(135deg, rgba(245, 199, 106, 0.2), rgba(255, 255, 255, 0.08));
}

.map-node.completed i {
  background: rgba(245, 199, 106, 0.18);
  box-shadow: 0 0 18px rgba(245, 199, 106, 0.26);
}

.map-node.locked > span {
  opacity: 0.58;
  filter: grayscale(0.6);
}

html[data-visual-mode="rpg"] .map-node::after,
body[data-visual-mode="rpg"] .map-node::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 52px;
  height: 52px;
  pointer-events: none;
  background: var(--map-city-node) center / contain no-repeat;
  opacity: 0.22;
  filter: drop-shadow(0 0 16px rgba(70, 240, 255, 0.28));
}

html[data-visual-mode="rpg"] .map-node.kind-gate::after,
body[data-visual-mode="rpg"] .map-node.kind-gate::after,
html[data-visual-mode="rpg"] .map-node.kind-boss::after,
body[data-visual-mode="rpg"] .map-node.kind-boss::after,
html[data-visual-mode="rpg"] .map-node.kind-security::after,
body[data-visual-mode="rpg"] .map-node.kind-security::after {
  background-image: var(--map-gate-node);
}

html[data-visual-mode="rpg"] .map-node.kind-portal::after,
body[data-visual-mode="rpg"] .map-node.kind-portal::after,
html[data-visual-mode="rpg"] .map-node.kind-memory::after,
body[data-visual-mode="rpg"] .map-node.kind-memory::after,
html[data-visual-mode="rpg"] .map-node.kind-logic::after,
body[data-visual-mode="rpg"] .map-node.kind-logic::after {
  background-image: var(--map-portal-node);
}

html[data-visual-mode="rpg"] .map-node.kind-trace::after,
body[data-visual-mode="rpg"] .map-node.kind-trace::after,
html[data-visual-mode="rpg"] .map-node.kind-stack::after,
body[data-visual-mode="rpg"] .map-node.kind-stack::after {
  background-image: var(--map-forest-node);
}

html[data-visual-mode="rpg"] .rpg-node-map,
body[data-visual-mode="rpg"] .rpg-node-map {
  position: relative;
  gap: 18px;
}

html[data-visual-mode="rpg"] .rpg-node-map .story-node.available,
body[data-visual-mode="rpg"] .rpg-node-map .story-node.available {
  border-color: rgba(70, 240, 255, 0.42);
  box-shadow: var(--rpg-shadow-cyan);
}

html[data-visual-mode="rpg"] .rpg-node-map .story-node,
body[data-visual-mode="rpg"] .rpg-node-map .story-node {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(239, 250, 250, 0.94)),
    radial-gradient(circle at top right, rgba(70, 240, 255, 0.12), transparent 38%);
  color: #17202d;
}

html[data-visual-mode="rpg"] .rpg-node-map .story-node > p,
html[data-visual-mode="rpg"] .rpg-node-map .story-node .mission,
html[data-visual-mode="rpg"] .rpg-node-map .story-node .reward,
body[data-visual-mode="rpg"] .rpg-node-map .story-node > p,
body[data-visual-mode="rpg"] .rpg-node-map .story-node .mission,
body[data-visual-mode="rpg"] .rpg-node-map .story-node .reward {
  color: #334155;
  font-weight: 700;
}

html[data-visual-mode="rpg"] .rpg-node-map .story-node .mission strong,
html[data-visual-mode="rpg"] .rpg-node-map .story-node .reward strong,
body[data-visual-mode="rpg"] .rpg-node-map .story-node .mission strong,
body[data-visual-mode="rpg"] .rpg-node-map .story-node .reward strong {
  color: #0f172a;
}

html[data-visual-mode="rpg"] .rpg-node-map .story-node.done,
body[data-visual-mode="rpg"] .rpg-node-map .story-node.done {
  border-color: rgba(245, 199, 106, 0.5);
  animation: nodeUnlock 0.6s ease both;
}

.rpg-unit-route {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(70, 240, 255, 0.26);
  border-radius: var(--rpg-radius);
  background:
    linear-gradient(135deg, rgba(7, 11, 22, 0.9), rgba(16, 22, 42, 0.78)),
    var(--rpg-panel);
  color: #edfaff;
  box-shadow: var(--rpg-shadow-cyan);
}

.rpg-unit-route::before {
  content: "";
  position: absolute;
  inset: 78px 22px auto;
  height: 76px;
  pointer-events: none;
  background: var(--map-road) center / contain repeat-x;
  opacity: 0.24;
  filter: drop-shadow(0 0 18px rgba(70, 240, 255, 0.32));
}

.rpg-unit-route .list-head {
  position: relative;
  z-index: 1;
}

.rpg-unit-route .list-head h2,
.rpg-unit-route .list-head p {
  color: inherit;
}

.unit-route-track {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.unit-route-node {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 126px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background:
    radial-gradient(circle at top right, rgba(70, 240, 255, 0.14), transparent 42%),
    rgba(255, 255, 255, 0.08);
}

.route-index {
  position: absolute;
  top: 8px;
  right: 10px;
  color: rgba(237, 250, 255, 0.58);
  font-size: 12px;
  font-weight: 1000;
}

.route-orb {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(70, 240, 255, 0.26);
  border-radius: 50%;
  background: rgba(70, 240, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.route-orb img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.unit-route-node small,
.unit-route-node p {
  margin: 0;
  color: rgba(237, 250, 255, 0.72);
  font-size: 12px;
  font-weight: 800;
}

.unit-route-node strong {
  display: block;
  margin: 3px 0;
  color: #fff;
  line-height: 1.35;
}

.route-unlock-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.route-unlock-targets span,
.route-unlock-targets b {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.2;
}

.route-unlock-targets span {
  padding: 3px 8px;
  border: 1px solid rgba(70, 240, 255, 0.24);
  color: rgba(243, 251, 255, 0.78);
  background: rgba(70, 240, 255, 0.1);
  font-weight: 900;
}

.route-unlock-targets b {
  padding: 3px 9px;
  border: 1px solid rgba(245, 199, 106, 0.28);
  color: #fff7dc;
  background: rgba(245, 199, 106, 0.12);
  font-weight: 1000;
}

.unit-route-node > a,
.unit-route-node > span:last-child {
  grid-column: 1 / -1;
  display: inline-flex;
  width: fit-content;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  border: 1px solid rgba(70, 240, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-size: 12px;
  font-weight: 1000;
  text-decoration: none;
}

.unit-route-node.done {
  border-color: rgba(245, 199, 106, 0.58);
  background:
    linear-gradient(135deg, rgba(245, 199, 106, 0.18), rgba(255, 255, 255, 0.08)),
    rgba(255, 255, 255, 0.08);
}

.unit-route-node.done .route-orb {
  border-color: rgba(245, 199, 106, 0.56);
  box-shadow: 0 0 22px rgba(245, 199, 106, 0.22);
}

.unit-route-node.available {
  border-color: rgba(70, 240, 255, 0.48);
  box-shadow: 0 0 22px rgba(70, 240, 255, 0.18);
  animation: mapNodePulse 3.2s ease-in-out infinite;
}

.unit-route-node.locked {
  opacity: 0.62;
  filter: grayscale(0.45);
}

html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .audio-controls,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .audio-controls {
  top: 92px;
  bottom: auto;
  transform: scale(0.9);
  transform-origin: right top;
  opacity: 0.76;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .audio-controls:hover,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .audio-controls:focus-within,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .audio-controls:hover,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .audio-controls:focus-within {
  transform: scale(1);
  opacity: 1;
}

html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .rpg-unit-route,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .rpg-unit-route {
  margin-bottom: 84px;
}

.chapter-section-nav {
  position: sticky;
  top: 86px;
  z-index: 7;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 20px;
  padding: 10px;
  border: 1px solid rgba(70, 240, 255, 0.18);
  border-radius: var(--rpg-radius);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.chapter-section-nav a {
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
}

html[data-visual-mode="rpg"] .chapter-section-nav,
body[data-visual-mode="rpg"] .chapter-section-nav {
  border-color: rgba(245, 199, 106, 0.3);
  background: rgba(7, 11, 22, 0.76);
  box-shadow: var(--rpg-shadow-purple);
}

html[data-visual-mode="rpg"] .chapter-section-nav a,
body[data-visual-mode="rpg"] .chapter-section-nav a {
  border-color: rgba(70, 240, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #eef8ff;
}

.chapter-clear-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1fr);
  gap: 18px;
  margin: -8px 0 22px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(245, 199, 106, 0.36);
  border-radius: var(--rpg-radius);
  background:
    radial-gradient(circle at 82% 0%, rgba(245, 199, 106, 0.22), transparent 34%),
    radial-gradient(circle at 18% 12%, rgba(70, 240, 255, 0.2), transparent 34%),
    linear-gradient(135deg, rgba(7, 11, 22, 0.96), rgba(24, 18, 44, 0.9));
  color: #eef8ff;
  box-shadow: var(--rpg-shadow-cyan);
}

.chapter-clear-panel::after {
  content: "";
  position: absolute;
  inset: auto 18px 14px auto;
  width: 140px;
  height: 140px;
  pointer-events: none;
  background: var(--fx-clear) center / contain no-repeat;
  opacity: 0.42;
  filter: drop-shadow(0 0 22px rgba(245, 199, 106, 0.3));
}

.chapter-clear-core,
.chapter-clear-lines,
.chapter-clear-unlocks,
.chapter-clear-panel .story-actions {
  position: relative;
  z-index: 1;
}

.chapter-clear-core span,
.chapter-clear-unlocks > span {
  color: var(--rpg-gold);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chapter-clear-core h2 {
  margin: 6px 0 8px;
  color: #fff;
  font-size: clamp(26px, 4vw, 46px);
}

.chapter-clear-core p,
.chapter-clear-lines p {
  margin: 0;
  color: rgba(238, 248, 255, 0.82);
  line-height: 1.75;
  font-weight: 800;
}

.chapter-clear-lines {
  display: grid;
  gap: 8px;
  align-content: center;
}

.chapter-clear-lines p {
  padding: 10px 12px;
  border: 1px solid rgba(70, 240, 255, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.chapter-clear-unlocks,
.chapter-clear-panel .story-actions {
  grid-column: 1 / -1;
}

html[data-visual-mode="simple"] .chapter-clear-panel,
body[data-visual-mode="simple"] .chapter-clear-panel {
  border-color: rgba(15, 23, 42, 0.14);
  background:
    radial-gradient(circle at 82% 0%, rgba(20, 184, 166, 0.12), transparent 34%),
    linear-gradient(135deg, #ffffff, #f4fbfb);
  color: var(--text);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

html[data-visual-mode="simple"] .chapter-clear-core span,
html[data-visual-mode="simple"] .chapter-clear-unlocks > span,
body[data-visual-mode="simple"] .chapter-clear-core span,
body[data-visual-mode="simple"] .chapter-clear-unlocks > span {
  color: var(--accent);
}

html[data-visual-mode="simple"] .chapter-clear-core h2,
body[data-visual-mode="simple"] .chapter-clear-core h2 {
  color: var(--text);
}

html[data-visual-mode="simple"] .chapter-clear-core p,
html[data-visual-mode="simple"] .chapter-clear-lines p,
body[data-visual-mode="simple"] .chapter-clear-core p,
body[data-visual-mode="simple"] .chapter-clear-lines p {
  color: var(--muted);
}

html[data-visual-mode="simple"] .chapter-clear-lines p,
body[data-visual-mode="simple"] .chapter-clear-lines p {
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.74);
}

.chapter-clear-unlocks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chapter-clear-unlocks a,
.chapter-clear-unlocks b {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid rgba(70, 240, 255, 0.28);
  border-radius: 999px;
  background: rgba(70, 240, 255, 0.12);
  color: #eef8ff;
  font-size: 13px;
  font-style: normal;
  font-weight: 1000;
  text-decoration: none;
}

@media (max-width: 760px) {
  .chapter-clear-panel {
    grid-template-columns: 1fr;
  }
}

.chapter-party-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chapter-party-line article {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  max-width: 360px;
  padding: 10px;
  border: 1px solid rgba(70, 240, 255, 0.22);
  border-radius: 16px;
  background: rgba(7, 11, 22, 0.58);
  color: #eef8ff;
}

.chapter-party-line img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.28));
  animation: characterFloat 4s ease-in-out infinite;
}

.chapter-party-line span,
.chapter-party-line small {
  display: block;
  color: rgba(238, 248, 255, 0.78);
}

.chapter-party-line strong {
  display: block;
  color: #fff;
}

html[data-visual-mode="simple"] .chapter-party-line,
body[data-visual-mode="simple"] .chapter-party-line {
  margin-top: 4px;
}

html[data-visual-mode="simple"] .chapter-party-line article,
body[data-visual-mode="simple"] .chapter-party-line article {
  border-color: rgba(23, 111, 115, 0.16);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(238, 250, 250, 0.92));
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

html[data-visual-mode="simple"] .chapter-party-line img,
body[data-visual-mode="simple"] .chapter-party-line img {
  animation: none;
}

html[data-visual-mode="simple"] .chapter-party-line span,
html[data-visual-mode="simple"] .chapter-party-line small,
body[data-visual-mode="simple"] .chapter-party-line span,
body[data-visual-mode="simple"] .chapter-party-line small {
  color: var(--muted);
}

html[data-visual-mode="simple"] .chapter-party-line strong,
body[data-visual-mode="simple"] .chapter-party-line strong {
  color: var(--ink);
}

.lesson-command-grid article,
.diagram-console,
.worked-example-console > article,
.worked-example-console .mistake-list article,
.exam-bridge-grid > article {
  animation: panelEnter 0.36s ease both;
}

.exam-bridge-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(300px, 1.1fr) minmax(260px, 1fr);
  gap: 12px;
}

.exam-bridge-grid > article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.exam-bridge-grid h3 {
  margin-top: 0;
}

.practice-ladder.compact,
.exam-drill-grid.compact {
  grid-template-columns: 1fr;
}

html[data-visual-mode="rpg"] .learning-phase,
body[data-visual-mode="rpg"] .learning-phase {
  border-color: rgba(70, 240, 255, 0.16);
  box-shadow: 0 18px 50px rgba(7, 11, 22, 0.1);
}

html[data-visual-mode="rpg"] .scene-card,
body[data-visual-mode="rpg"] .scene-card {
  border-color: rgba(70, 240, 255, 0.2);
  box-shadow: 0 12px 30px rgba(17, 24, 33, 0.08);
}

@keyframes panelEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes glowPulse {
  0%,
  100% {
    box-shadow: var(--rpg-shadow-cyan);
  }
  50% {
    box-shadow: 0 0 34px rgba(70, 240, 255, 0.5);
  }
}

@keyframes nodeUnlock {
  from {
    opacity: 0.72;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes badgeRise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes coreCommandHit {
  0% {
    transform: translateX(0) scale(1);
  }
  28% {
    transform: translateX(-5px) scale(1.08);
  }
  52% {
    transform: translateX(5px) scale(0.96);
  }
  100% {
    transform: translateX(0) scale(1);
  }
}

@keyframes battleCommandFlash {
  0% {
    opacity: 0;
    transform: scale(0.82);
  }
  28% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.12);
  }
}

@keyframes scanLine {
  to {
    transform: translateX(120%);
  }
}

@keyframes mapNodePulse {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes characterFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rpg-command-deck article,
  .map-node.available > a,
  .rpg-node-map .story-node.done,
  .chapter-party-line img,
  .lesson-command-grid article,
  .diagram-console,
  .worked-example-console > article,
  .worked-example-console .mistake-list article,
  .exam-bridge-grid > article,
  .rpg-battle-flash,
  .rpg-enemy-core {
    animation: none !important;
    transform: none !important;
  }

  .rpg-command-deck article::after {
    display: none;
  }
}

@media (max-width: 980px) {
  .rpg-command-deck,
  .exam-bridge-grid {
    grid-template-columns: 1fr;
  }

  .chapter-section-nav {
    top: 78px;
  }
}

@media (max-width: 520px) {
  .visual-mode-switch {
    grid-column: span 2;
    justify-content: center;
  }

  .visual-mode-option {
    flex: 1;
    padding-inline: 8px;
  }

  .chapter-section-nav {
    position: static;
  }

  .chapter-party-line article {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .chapter-party-line img {
    width: 56px;
    height: 56px;
  }
}

/* Mode polish: standard keeps the cast and color, RPG becomes the immersive one-screen view. */
html[data-visual-mode="simple"] body,
body[data-visual-mode="simple"] {
  background:
    radial-gradient(circle at 12% 8%, rgba(70, 240, 255, 0.11), transparent 28%),
    radial-gradient(circle at 88% 0%, rgba(245, 199, 106, 0.08), transparent 30%),
    linear-gradient(180deg, #f8fbfc 0%, #eef7f7 44%, #f7f8fb 100%);
}

html[data-visual-mode="simple"] .summary,
body[data-visual-mode="simple"] .summary {
  border-color: rgba(24, 132, 139, 0.16);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(235, 251, 253, 0.88)),
    radial-gradient(circle at 96% 0%, rgba(70, 240, 255, 0.12), transparent 34%);
}

html[data-visual-mode="simple"] .summary .eyebrow,
body[data-visual-mode="simple"] .summary .eyebrow {
  color: #176f73;
}

html[data-visual-mode="simple"] .summary h1,
body[data-visual-mode="simple"] .summary h1 {
  color: #111821;
}

html[data-visual-mode="simple"] .companion-stage,
body[data-visual-mode="simple"] .companion-stage,
html[data-visual-mode="simple"] .companion-stage.rpg-mode-only,
body[data-visual-mode="simple"] .companion-stage.rpg-mode-only {
  display: grid !important;
  border-color: rgba(24, 132, 139, 0.14);
  background:
    radial-gradient(circle at 50% 92%, rgba(70, 240, 255, 0.16), transparent 36%),
    rgba(255, 255, 255, 0.7);
}

html[data-visual-mode="simple"] .companion-bubble,
body[data-visual-mode="simple"] .companion-bubble {
  border-color: rgba(24, 132, 139, 0.16);
  color: #263348;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(237, 251, 251, 0.9)),
    var(--ui-bubble) center / 100% 100% no-repeat;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-stage,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-stage {
  overflow: visible;
  margin-inline: clamp(-18px, -1vw, -8px);
  padding: clamp(18px, 3vw, 34px);
  border-radius: 22px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.84) 0 36%, rgba(232, 250, 250, 0.7) 70%, rgba(238, 232, 252, 0.62) 100%),
    var(--episode-bg) center / cover no-repeat,
    #fff !important;
  box-shadow: 0 24px 72px rgba(17, 24, 33, 0.14);
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-play,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-play {
  align-items: start;
  gap: clamp(16px, 2.4vw, 28px);
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-topline > span,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-topline > span {
  border: 1px solid rgba(24, 132, 139, 0.16);
  background: rgba(255, 255, 255, 0.9);
  color: #176f73;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-topline a,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-topline a {
  border-color: rgba(24, 132, 139, 0.2);
  background: rgba(255, 255, 255, 0.88);
  color: #145f66;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .dialogue-player-bar {
  color: #152033;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .dialogue-player-bar .eyebrow,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .dialogue-player-bar .eyebrow {
  color: #176f73;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .dialogue-player-actions button,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .dialogue-player-actions button {
  border-color: rgba(24, 132, 139, 0.22);
  background: rgba(255, 255, 255, 0.86);
  color: #152033;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-hero,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-hero {
  position: relative;
  overflow: hidden;
  border-color: rgba(40, 215, 198, 0.26);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.84), rgba(233, 250, 250, 0.68)),
    var(--episode-bg) center / cover no-repeat,
    radial-gradient(circle at 86% 18%, rgba(70, 240, 255, 0.18), transparent 34%);
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-hero::before,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.28)),
    repeating-linear-gradient(115deg, rgba(24, 132, 139, 0.05) 0 1px, transparent 1px 18px);
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-hero > *,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-hero > * {
  position: relative;
  z-index: 1;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-dialogue.dialogue-enhanced .episode-line,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-dialogue.dialogue-enhanced .episode-line {
  display: grid;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-dialogue,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-lesson,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-dialogue,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-lesson {
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-line,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-line {
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(240, 251, 251, 0.92)),
    var(--ui-bubble-large) center / 100% 100% no-repeat;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-line p:last-child,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-line p:last-child {
  color: #172033;
  font-size: clamp(17px, 1.45vw, 22px);
  line-height: 1.75;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue {
  grid-template-rows: auto minmax(118px, auto) minmax(0, 1fr);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-scene-visual.rpg-mode-only,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-scene-visual.rpg-mode-only {
  display: grid !important;
  grid-template-columns: minmax(92px, 132px) minmax(0, 1fr);
  gap: 12px 16px;
  align-items: center;
  margin: 0 clamp(12px, 2vw, 26px);
  padding: 12px 14px;
  border: 1px solid rgba(70, 240, 255, 0.24);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(7, 11, 22, 0.72), rgba(18, 31, 48, 0.56)),
    radial-gradient(circle at 100% 0%, rgba(70, 240, 255, 0.18), transparent 36%);
  color: #f3fbff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-scene-visual > img,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-scene-visual > img {
  width: 100%;
  max-height: 104px;
  object-fit: contain;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.28));
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-scene-visual figcaption,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-scene-visual figcaption {
  display: grid;
  gap: 3px;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-scene-visual figcaption span,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-scene-visual figcaption span {
  color: var(--rpg-cyan);
  font-size: 11px;
  font-weight: 1000;
  text-transform: uppercase;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-scene-visual figcaption strong,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-scene-visual figcaption strong {
  color: #fff;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-scene-visual figcaption small,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-scene-visual figcaption small {
  color: rgba(243, 251, 255, 0.78);
  line-height: 1.55;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .scene-mini-diagram,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .scene-mini-diagram,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .scene-mini-path,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .scene-mini-path {
  grid-column: 1 / -1;
  margin: 0;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .scene-mini-diagram {
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  padding: 8px;
  background:
    linear-gradient(90deg, rgba(70, 240, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(70, 240, 255, 0.08) 1px, transparent 1px),
    rgba(255, 255, 255, 0.06);
  background-size: 18px 18px;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .scene-mini-diagram .lamp-cell {
  min-height: 58px;
  padding: 7px 5px;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .scene-diagram-note,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .scene-diagram-note {
  grid-column: 1 / -1;
  margin: 0;
  color: #f3fbff;
  background: rgba(234, 255, 252, 0.12);
  border-color: rgba(70, 240, 255, 0.22);
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .quiz-battle-preview,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .quiz-battle-preview {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(70, 240, 255, 0.26);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(7, 11, 22, 0.9), rgba(17, 28, 50, 0.78)),
    var(--bg-quiz-battle-terminal) center / cover no-repeat;
  color: #f3fbff;
  box-shadow: 0 22px 54px rgba(7, 11, 22, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .quiz-battle-system,
body[data-visual-mode="rpg"][data-endpoint="quiz"] .quiz-battle-system {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.quiz-battle-system article {
  min-height: 132px;
  padding: 15px;
  border: 1px solid rgba(70, 240, 255, 0.24);
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0%, rgba(70, 240, 255, 0.14), transparent 42%),
    linear-gradient(135deg, rgba(7, 11, 22, 0.9), rgba(19, 29, 48, 0.82));
  color: #f3fbff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.quiz-battle-system span {
  color: var(--rpg-gold);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quiz-battle-system strong {
  display: block;
  margin: 7px 0 6px;
  color: #fff;
  font-size: clamp(20px, 2.1vw, 28px);
  line-height: 1.15;
}

.quiz-battle-system p {
  margin: 0;
  color: rgba(243, 251, 255, 0.78);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.65;
}

.quiz-battle-preview .battle-side {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 126px;
  padding: 14px;
  border: 1px solid rgba(70, 240, 255, 0.22);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.quiz-battle-preview .enemy-side {
  grid-template-columns: minmax(0, 1fr);
  border-color: rgba(255, 93, 93, 0.22);
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 93, 93, 0.12), transparent 40%),
    rgba(255, 255, 255, 0.08);
}

.quiz-battle-preview .battle-side img {
  width: 84px;
  height: 108px;
  object-fit: contain;
  filter: drop-shadow(0 16px 22px rgba(0, 0, 0, 0.34));
}

.quiz-battle-preview .battle-side span,
.quiz-battle-preview .battle-side small {
  color: rgba(243, 251, 255, 0.76);
  font-weight: 800;
}

.quiz-battle-preview .battle-side strong {
  display: block;
  margin: 3px 0;
  color: #fff;
  font-size: clamp(20px, 2.2vw, 30px);
}

.quiz-battle-preview .battle-preview-core {
  display: grid;
  place-items: center;
  gap: 6px;
  color: var(--rpg-gold);
  font-weight: 1000;
}

.quiz-battle-preview .battle-preview-core img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(70, 240, 255, 0.42));
}

@media (max-width: 760px) {
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue {
    grid-template-rows: auto minmax(0, 1fr);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-scene-visual.rpg-mode-only,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-scene-visual.rpg-mode-only {
    display: none !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .quiz-battle-preview,
  body[data-visual-mode="rpg"][data-endpoint="quiz"] .quiz-battle-preview {
    grid-template-columns: 1fr;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz"] .quiz-battle-system,
  body[data-visual-mode="rpg"][data-endpoint="quiz"] .quiz-battle-system {
    grid-template-columns: 1fr;
  }

  .quiz-battle-preview .battle-preview-core {
    grid-template-columns: auto auto;
    justify-content: center;
  }
}

/* Mode bridge polish: standard stays scrollable but keeps the cast, route map, and visual cues. */
html[data-visual-mode="simple"] body[data-endpoint="adventure"] .story-route-panel,
body[data-visual-mode="simple"][data-endpoint="adventure"] .story-route-panel {
  display: block !important;
  border-color: rgba(24, 132, 139, 0.18);
  background:
    radial-gradient(circle at 92% 12%, rgba(70, 240, 255, 0.12), transparent 30%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(237, 251, 251, 0.9));
  color: var(--ink);
  box-shadow: 0 16px 34px rgba(17, 24, 33, 0.08);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .story-route-panel::before,
body[data-visual-mode="simple"][data-endpoint="adventure"] .story-route-panel::before {
  opacity: 0.12;
  filter: none;
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .story-route-panel .list-head h2,
html[data-visual-mode="simple"] body[data-endpoint="adventure"] .story-route-panel .list-head p,
body[data-visual-mode="simple"][data-endpoint="adventure"] .story-route-panel .list-head h2,
body[data-visual-mode="simple"][data-endpoint="adventure"] .story-route-panel .list-head p {
  color: var(--ink);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .story-route-panel .list-head p,
body[data-visual-mode="simple"][data-endpoint="adventure"] .story-route-panel .list-head p,
html[data-visual-mode="simple"] body[data-endpoint="adventure"] .unit-route-node small,
html[data-visual-mode="simple"] body[data-endpoint="adventure"] .unit-route-node p,
body[data-visual-mode="simple"][data-endpoint="adventure"] .unit-route-node small,
body[data-visual-mode="simple"][data-endpoint="adventure"] .unit-route-node p {
  color: #526077;
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .route-unlock-targets span,
body[data-visual-mode="simple"][data-endpoint="adventure"] .route-unlock-targets span {
  color: #0f766e;
  background: rgba(20, 184, 166, 0.1);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .route-unlock-targets b,
body[data-visual-mode="simple"][data-endpoint="adventure"] .route-unlock-targets b {
  color: #92400e;
  background: rgba(245, 158, 11, 0.12);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .unit-route-node,
body[data-visual-mode="simple"][data-endpoint="adventure"] .unit-route-node {
  border-color: rgba(24, 132, 139, 0.16);
  background:
    radial-gradient(circle at 100% 0%, rgba(70, 240, 255, 0.11), transparent 38%),
    rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(17, 24, 33, 0.06);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .unit-route-node.available,
body[data-visual-mode="simple"][data-endpoint="adventure"] .unit-route-node.available {
  border-color: rgba(40, 215, 198, 0.38);
  box-shadow: 0 0 0 1px rgba(40, 215, 198, 0.08), 0 12px 26px rgba(17, 24, 33, 0.08);
  animation: none;
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .unit-route-node.done,
body[data-visual-mode="simple"][data-endpoint="adventure"] .unit-route-node.done {
  border-color: rgba(216, 182, 95, 0.38);
  background:
    linear-gradient(135deg, rgba(255, 248, 230, 0.78), rgba(255, 255, 255, 0.92));
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .unit-route-node strong,
body[data-visual-mode="simple"][data-endpoint="adventure"] .unit-route-node strong {
  color: var(--ink);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .route-index,
body[data-visual-mode="simple"][data-endpoint="adventure"] .route-index {
  color: rgba(24, 132, 139, 0.48);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .route-orb,
body[data-visual-mode="simple"][data-endpoint="adventure"] .route-orb {
  border-color: rgba(40, 215, 198, 0.28);
  background: rgba(240, 255, 253, 0.92);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .unit-route-node > a,
html[data-visual-mode="simple"] body[data-endpoint="adventure"] .unit-route-node > span:last-child,
body[data-visual-mode="simple"][data-endpoint="adventure"] .unit-route-node > a,
body[data-visual-mode="simple"][data-endpoint="adventure"] .unit-route-node > span:last-child {
  border-color: rgba(24, 132, 139, 0.22);
  background: #fff;
  color: #145f66;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-scene-visual.rpg-mode-only,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-scene-visual.rpg-mode-only {
  display: grid !important;
  grid-template-columns: minmax(92px, 150px) minmax(0, 1fr);
  gap: 12px 16px;
  align-items: center;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid rgba(24, 132, 139, 0.18);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(238, 250, 250, 0.9)),
    radial-gradient(circle at 96% 12%, rgba(70, 240, 255, 0.14), transparent 32%);
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(17, 24, 33, 0.08);
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-scene-visual > img,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-scene-visual > img {
  width: 100%;
  max-height: 114px;
  object-fit: contain;
  filter: drop-shadow(0 12px 16px rgba(17, 24, 33, 0.16));
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-scene-visual figcaption,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-scene-visual figcaption {
  display: grid;
  gap: 4px;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-scene-visual figcaption span,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-scene-visual figcaption span {
  color: #176f73;
  font-size: 11px;
  font-weight: 1000;
  text-transform: uppercase;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-scene-visual figcaption small,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-scene-visual figcaption small {
  color: #526077;
  line-height: 1.55;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .scene-mini-diagram,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .scene-mini-diagram,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .scene-mini-path,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .scene-mini-path,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .scene-diagram-note,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .scene-diagram-note {
  grid-column: 1 / -1;
  margin: 0;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .scene-mini-diagram,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .scene-mini-diagram {
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  padding: 8px;
  background:
    linear-gradient(90deg, rgba(24, 132, 139, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 132, 139, 0.08) 1px, transparent 1px),
    rgba(255, 255, 255, 0.68);
  background-size: 18px 18px;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-dialogue,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-lesson,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-scene-visual,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-lesson-visual,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-rich-content,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-section,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-figure-grid,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-figure,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-long-block,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-practice,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-dialogue,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-lesson,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-scene-visual,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-lesson-visual,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-rich-content,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-section,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-figure-grid,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-figure,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-long-block,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-practice {
  min-width: 0;
  max-width: 100%;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .study-code code,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .visual-path span,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .study-code code,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .visual-path span {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual {
  grid-template-rows: auto minmax(92px, 168px) minmax(0, 1fr);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual .episode-line,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual .episode-line {
  min-height: 0;
}

@media (max-width: 760px) {
  html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-scene-visual.rpg-mode-only,
  body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-scene-visual.rpg-mode-only {
    grid-template-columns: 1fr;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual {
    grid-template-rows: auto minmax(0, 1fr);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    justify-content: stretch;
    overflow: hidden;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions button,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions button {
    width: 100%;
    min-width: 0;
    padding-inline: 6px;
    white-space: normal;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line > div,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line > div {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }
}

@media (max-width: 760px) {
  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-battle-rules,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-battle-rules {
    display: none !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-wave-status,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-wave-status {
    display: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-defeat-panel,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-defeat-panel {
    position: fixed;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    margin: 0;
    padding: 14px;
  }
}

.study-markup {
  display: grid;
  gap: 10px;
}

.study-markup p,
.study-markup h4,
.study-markup ol {
  margin: 0;
}

.study-markup h4 {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.45;
}

.study-markup p {
  color: var(--muted);
  line-height: 1.8;
}

.study-markup code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(20, 127, 134, 0.09);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.94em;
  font-weight: 800;
}

.study-code {
  overflow-x: auto;
  margin: 0;
  padding: 14px;
  border-radius: 10px;
  background: #111821;
  color: #edf7ff;
  box-shadow: inset 0 0 0 1px rgba(70, 240, 255, 0.16);
}

.study-code code {
  padding: 0;
  background: transparent;
  color: inherit;
  white-space: pre;
}

.study-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.study-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.study-table th,
.study-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(29, 36, 48, 0.1);
  text-align: left;
  vertical-align: top;
}

.study-table th {
  background: rgba(20, 127, 134, 0.08);
  color: var(--ink);
  font-weight: 900;
}

.study-list {
  padding-left: 24px;
  color: var(--muted);
}

.compact-markup {
  gap: 8px;
}

.compact-markup .study-table,
.compact-markup p {
  font-size: 14px;
}

.visual-path.compact-path,
.episode-figure .visual-path {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 14px;
}

.episode-figure .visual-path.compact-path span {
  min-height: 72px;
  padding: 12px 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
}

.episode-figure .visual-path.compact-path span:not(:last-child)::after {
  display: none;
}

.episode-lesson-visual .lesson-mini-path span {
  min-height: 72px;
  padding: 12px 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
}

.episode-lesson-visual .lesson-mini-path span:not(:last-child)::after {
  display: none;
}

.visual-path span {
  overflow-wrap: normal;
  word-break: keep-all;
  writing-mode: horizontal-tb;
}

.binary-lamp-diagram {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid rgba(20, 127, 134, 0.18);
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(20, 127, 134, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(20, 127, 134, 0.07) 1px, transparent 1px),
    rgba(255, 255, 255, 0.92);
  background-size: 24px 24px;
}

.binary-lamp-diagram.compact {
  margin: 10px 0;
}

.lamp-cell {
  position: relative;
  display: grid;
  min-height: 92px;
  place-items: center;
  gap: 5px;
  padding: 12px 8px;
  border: 2px solid rgba(29, 36, 48, 0.16);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 245, 244, 0.96));
  color: var(--muted);
  text-align: center;
}

.lamp-cell::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(29, 36, 48, 0.16);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.82);
}

.lamp-cell b {
  color: var(--ink);
  font-size: clamp(17px, 2vw, 24px);
  line-height: 1.1;
}

.lamp-cell small {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(29, 36, 48, 0.08);
  color: inherit;
  font-weight: 900;
}

.lamp-cell.on {
  border-color: rgba(20, 127, 134, 0.44);
  background: linear-gradient(180deg, rgba(234, 255, 252, 0.98), rgba(210, 248, 244, 0.94));
  color: var(--accent);
  box-shadow: 0 0 24px rgba(70, 240, 255, 0.2);
}

.lamp-cell.on::before {
  background: var(--rpg-teal);
  box-shadow: 0 0 16px rgba(70, 240, 255, 0.55), inset 0 0 0 3px rgba(255, 255, 255, 0.9);
}

[data-dialogue-diagram] .lamp-cell {
  opacity: 0.68;
  transform: translateY(1px) scale(0.97);
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

[data-dialogue-diagram] .lamp-cell.is-seen {
  opacity: 1;
  transform: translateY(0) scale(1);
}

[data-dialogue-diagram] .lamp-cell.is-current {
  border-color: rgba(246, 191, 90, 0.78);
  box-shadow: 0 0 0 2px rgba(246, 191, 90, 0.16), 0 12px 24px rgba(29, 36, 48, 0.12);
}

[data-dialogue-diagram] .lamp-cell.is-current b {
  color: var(--accent-strong);
}

[data-dialogue-diagram] .lamp-cell.on.is-lit {
  background:
    radial-gradient(circle at 50% 16%, rgba(246, 191, 90, 0.22), transparent 34%),
    linear-gradient(180deg, rgba(234, 255, 252, 0.98), rgba(210, 248, 244, 0.94));
}

[data-dialogue-diagram] .lamp-cell.on.is-lit::before {
  animation: dialogueLampPulse 1150ms ease-in-out infinite;
}

[data-dialogue-diagram] .lamp-cell:not(.is-seen) small {
  opacity: 0.68;
}

@keyframes dialogueLampPulse {
  0%, 100% {
    box-shadow: 0 0 14px rgba(70, 240, 255, 0.48), inset 0 0 0 3px rgba(255, 255, 255, 0.9);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 26px rgba(246, 191, 90, 0.72), 0 0 42px rgba(70, 240, 255, 0.28), inset 0 0 0 3px rgba(255, 255, 255, 0.94);
    transform: scale(1.12);
  }
}

.binary-diagram-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(20, 127, 134, 0.16);
  border-radius: 12px;
  background: rgba(234, 255, 252, 0.82);
  color: var(--accent);
  font-weight: 900;
  line-height: 1.5;
}

.episode-log-fold {
  padding: 0;
}

.episode-log-fold summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

.episode-log-fold summary::-webkit-details-marker {
  display: none;
}

.episode-log-fold summary span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.episode-log-fold summary strong {
  color: var(--ink);
}

.episode-log-fold[open] {
  padding-bottom: 16px;
}

.episode-log-fold[open] summary {
  border-bottom: 1px solid var(--line);
}

.episode-log-fold .episode-long-block {
  margin: 14px 16px 0;
}

html[data-visual-mode="rpg"] .episode-play,
body[data-visual-mode="rpg"] .episode-play {
  grid-template-columns: minmax(0, 1.12fr) minmax(280px, 0.88fr);
}

html[data-visual-mode="rpg"] .episode-dialogue,
body[data-visual-mode="rpg"] .episode-dialogue {
  min-height: 360px;
  border-color: rgba(70, 240, 255, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 249, 250, 0.96)),
    var(--ui-bubble) center / 100% 100% no-repeat;
  box-shadow: var(--rpg-shadow-cyan);
}

html[data-visual-mode="rpg"] .episode-line,
body[data-visual-mode="rpg"] .episode-line {
  grid-template-columns: minmax(112px, 150px) minmax(0, 1fr);
  min-height: 220px;
  padding: 18px;
}

html[data-visual-mode="rpg"] .episode-line img,
body[data-visual-mode="rpg"] .episode-line img {
  width: 100%;
  height: 190px;
}

html[data-visual-mode="rpg"] .episode-line p:last-child,
body[data-visual-mode="rpg"] .episode-line p:last-child {
  font-size: clamp(19px, 2vw, 24px);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"],
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] {
  overflow: hidden;
  min-height: 100svh;
  padding-bottom: 0;
  background:
    radial-gradient(circle at 18% 16%, rgba(70, 240, 255, 0.2), transparent 28%),
    radial-gradient(circle at 84% 8%, rgba(143, 91, 255, 0.24), transparent 34%),
    var(--episode-bg, url("/static/visual/backgrounds/story-city.jpg")) center / cover fixed no-repeat,
    var(--rpg-bg-deep);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .topbar,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .site-footer,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .topbar,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .site-footer {
  display: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .page,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .page {
  width: 100%;
  max-width: none;
  min-height: 100svh;
  margin: 0;
  padding: 0;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage {
  height: 100svh;
  min-height: 100svh;
  margin: 0;
  padding: clamp(10px, 1.6vw, 20px);
  border: 0;
  border-radius: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(8px, 1.2vw, 14px);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(5, 8, 18, 0.18), rgba(5, 8, 18, 0.58)),
    var(--episode-bg, url("/static/visual/backgrounds/story-city.jpg")) center / cover no-repeat;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-hero,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-hero {
  display: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage::before,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage::before {
  opacity: 0.72;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-topline,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-topline {
  min-height: 40px;
  padding: 0 min(330px, 38vw) 0 6px;
  color: rgba(255, 255, 255, 0.9);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-topline > span,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-topline > span {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #17202d;
  font-weight: 1000;
  box-shadow: 0 16px 34px rgba(7, 11, 22, 0.2);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-topline a,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-topline a {
  color: #fff;
  border-color: rgba(70, 240, 255, 0.28);
  background: rgba(7, 11, 22, 0.56);
  backdrop-filter: blur(10px);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-play,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-play {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(10px, 1.4vw, 18px);
  align-items: stretch;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-color: rgba(70, 240, 255, 0.34);
  background:
    linear-gradient(180deg, rgba(8, 13, 27, 0.7), rgba(6, 10, 22, 0.86)),
    var(--ui-bubble) center / 100% 100% no-repeat;
  box-shadow: 0 0 34px rgba(70, 240, 255, 0.26), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-bar {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  color: #fff;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions {
  max-width: min(100%, 560px);
  justify-content: flex-end;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line {
  min-height: 0;
  height: 100%;
  grid-template-columns: minmax(140px, 24vw) minmax(0, 1fr);
  align-items: end;
  gap: clamp(12px, 2vw, 28px);
  padding: clamp(14px, 2vw, 26px);
  background: transparent;
  border: 0;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line img,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line img {
  width: min(100%, 220px);
  height: min(44svh, 300px);
  max-height: 100%;
  justify-self: center;
  object-fit: contain;
  image-rendering: auto;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 28px 38px rgba(0, 0, 0, 0.44));
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line.speaker-bit img,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line.speaker-bit img {
  width: min(100%, 126px);
  height: min(28svh, 196px);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line > div,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line > div {
  align-self: end;
  padding: clamp(18px, 2.4vw, 30px);
  border: 1px solid rgba(70, 240, 255, 0.28);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(235, 251, 253, 0.96)),
    var(--ui-bubble-large) center / 100% 100% no-repeat;
  color: var(--ink);
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.34);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line p:last-child,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line p:last-child {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.58;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-lesson,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-lesson {
  display: none;
  height: 100%;
  min-height: 0;
  overflow: auto;
  border-color: rgba(245, 199, 106, 0.28);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(235, 251, 253, 0.9)),
    var(--ui-question-analysis-hud) center / cover no-repeat;
  color: #111821;
  backdrop-filter: blur(10px);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-lesson p,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-lesson p {
  color: #243044;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-lesson-close,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-lesson-close {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid rgba(70, 240, 255, 0.35);
  border-radius: 999px;
  background: rgba(7, 11, 22, 0.88);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(7, 11, 22, 0.18);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-lesson-visual,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-lesson-visual {
  display: grid !important;
  grid-template-columns: minmax(190px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  margin: 14px 0 18px;
  padding: 14px;
  border: 1px solid rgba(70, 240, 255, 0.26);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(7, 11, 22, 0.9), rgba(18, 31, 48, 0.76)),
    radial-gradient(circle at 82% 18%, rgba(70, 240, 255, 0.18), transparent 34%);
  color: #f3fbff;
  box-shadow: 0 18px 44px rgba(7, 11, 22, 0.18);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-lesson-visual h3,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-lesson-visual h3 {
  margin: 4px 0 8px;
  color: #fff;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-lesson-visual p,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-lesson-visual p {
  color: rgba(243, 251, 255, 0.82);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .lesson-mini-diagram,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .lesson-mini-diagram {
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  margin: 0;
  padding: 10px;
  border-color: rgba(70, 240, 255, 0.24);
  background:
    linear-gradient(90deg, rgba(70, 240, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(70, 240, 255, 0.08) 1px, transparent 1px),
    rgba(255, 255, 255, 0.08);
  background-size: 20px 20px;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .lesson-mini-diagram .lamp-cell,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .lesson-mini-diagram .lamp-cell {
  min-height: 76px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.9);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-lesson-visual .binary-diagram-note,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-lesson-visual .binary-diagram-note {
  grid-column: 1 / -1;
  margin: 0;
  border-color: rgba(70, 240, 255, 0.22);
  background: rgba(234, 255, 252, 0.12);
  color: #f3fbff;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .lesson-mini-path,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .lesson-mini-path {
  align-self: center;
  margin: 0;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage.lesson-focus .episode-dialogue,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage.lesson-focus .episode-dialogue {
  display: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage.lesson-focus .episode-play,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage.lesson-focus .episode-play {
  grid-template-columns: minmax(0, 1fr);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage.lesson-focus .episode-lesson,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage.lesson-focus .episode-lesson {
  display: block;
  padding: clamp(16px, 2vw, 24px);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-rich-content,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-board,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-rich-content,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-board {
  display: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-nav,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-nav {
  margin: 0;
  padding: 0 6px;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-nav a,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-nav a {
  color: #fff;
  border-color: rgba(70, 240, 255, 0.35);
  background: rgba(7, 11, 22, 0.68);
  backdrop-filter: blur(10px);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-nav a.primary,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-nav a.primary {
  color: #061116;
  border-color: rgba(245, 199, 106, 0.72);
  background: linear-gradient(135deg, var(--rpg-cyan), var(--rpg-gold));
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .audio-controls,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .audio-controls {
  top: max(12px, env(safe-area-inset-top));
  right: clamp(92px, 5vw, 132px);
  bottom: auto;
  left: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  max-width: min(300px, calc(100vw - 132px));
  padding: 6px;
  border: 1px solid rgba(70, 240, 255, 0.22);
  border-radius: 18px;
  background: rgba(7, 11, 22, 0.6);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.24);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .audio-controls .game-sound-toggle,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .audio-controls .game-music-toggle,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .audio-controls .game-voice-toggle,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .audio-controls .game-sound-toggle,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .audio-controls .game-music-toggle,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .audio-controls .game-voice-toggle {
  display: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .audio-controls .visual-mode-switch,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .audio-controls .visual-mode-switch {
  min-height: 34px;
  padding: 3px;
  box-shadow: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .audio-controls .visual-mode-option,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .audio-controls .game-settings-link,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .audio-controls .visual-mode-option,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .audio-controls .game-settings-link {
  min-width: 0;
  min-height: 28px;
  padding: 5px 10px;
  font-size: 11px;
}

@media (max-width: 760px) {
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage {
    padding: 8px;
    gap: 8px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-topline,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-topline {
    padding-right: 112px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-play,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-play {
    grid-template-columns: 1fr;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-lesson,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-lesson {
    display: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage.lesson-focus .episode-lesson,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage.lesson-focus .episode-lesson {
    display: block;
    height: 100%;
    min-height: 0;
    padding: 16px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-lesson-visual,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-lesson-visual {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .lesson-mini-diagram,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .lesson-mini-diagram {
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .lesson-mini-diagram .lamp-cell,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .lesson-mini-diagram .lamp-cell {
    min-height: 64px;
    padding: 8px 5px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage.lesson-focus .episode-play,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage.lesson-focus .episode-play {
    grid-template-columns: 1fr;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue {
    min-height: 0;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-bar {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions {
    justify-content: flex-start;
    gap: 5px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions button,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions button {
    min-height: 34px;
    padding: 5px 9px;
    font-size: 12px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line img,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line img {
    width: min(58vw, 190px);
    height: min(34svh, 250px);
    justify-self: center;
    align-self: end;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line.speaker-bit img,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line.speaker-bit img {
    width: min(42vw, 142px);
    height: min(27svh, 208px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line > div,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line > div {
    padding: 14px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line p:last-child,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line p:last-child {
    font-size: clamp(18px, 5.2vw, 23px);
    line-height: 1.55;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-nav,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-nav {
    gap: 6px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-nav a,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-nav a {
    min-height: 38px;
    padding: 6px 10px;
    font-size: 13px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .audio-controls,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .audio-controls {
    top: max(6px, env(safe-area-inset-top));
    right: 8px;
    bottom: auto;
    left: auto;
    width: auto;
    grid-template-columns: 1fr;
    gap: 0;
    padding: 5px;
    opacity: 0.92;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .game-sound-toggle,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .game-music-toggle,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .game-voice-toggle,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .game-sound-toggle,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .game-music-toggle,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .game-voice-toggle {
    display: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .game-sound-toggle,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .game-music-toggle,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .game-voice-toggle,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .game-settings-link,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .game-sound-toggle,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .game-music-toggle,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .game-voice-toggle,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .game-settings-link {
    min-height: 28px;
    padding: 5px 10px;
    font-size: 10px;
  }
}

.rpg-wave-controls {
  width: min(100%, 1120px);
  margin: 0 auto 12px;
  padding: 10px;
  border: 1px solid rgba(70, 240, 255, 0.25);
  border-radius: 999px;
  background: rgba(7, 11, 22, 0.72);
  color: #fff;
  box-shadow: var(--rpg-shadow-cyan);
  backdrop-filter: blur(14px);
  align-items: center;
  justify-content: space-between;
}

html[data-visual-mode="rpg"] .rpg-wave-controls.rpg-mode-only,
body[data-visual-mode="rpg"] .rpg-wave-controls.rpg-mode-only {
  display: flex !important;
}

.rpg-wave-controls button {
  min-height: 38px;
  min-width: 54px;
  padding: 6px 16px;
  border-color: rgba(70, 240, 255, 0.38);
  background: rgba(255, 255, 255, 0.96);
  white-space: nowrap;
}

.rpg-wave-controls strong {
  letter-spacing: 0;
  font-size: clamp(16px, 2vw, 22px);
  white-space: nowrap;
}

.rpg-wave-center {
  display: grid;
  min-width: 0;
  gap: 4px;
  justify-items: center;
}

.rpg-wave-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid rgba(70, 240, 255, 0.28);
  border-radius: 999px;
  background: rgba(70, 240, 255, 0.1);
  color: rgba(238, 248, 255, 0.9);
  font-size: 12px;
  font-weight: 1000;
  white-space: nowrap;
}

.rpg-wave-action {
  display: block;
  max-width: min(72vw, 520px);
  color: rgba(238, 248, 255, 0.72);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.4;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rpg-wave-controls[data-wave-state="correct"] .rpg-wave-action {
  color: #fff6d4;
}

.rpg-wave-controls[data-wave-state="wrong"] .rpg-wave-action {
  color: #ffd9d9;
}

.rpg-wave-vitals {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 8px;
  min-width: min(100%, 270px);
}

.rpg-wave-vitals > div {
  display: grid;
  grid-template-columns: auto auto minmax(52px, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid rgba(70, 240, 255, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 14px rgba(70, 240, 255, 0.06);
}

.rpg-wave-vitals span {
  color: rgba(238, 248, 255, 0.78);
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: 0;
}

.rpg-wave-vitals b {
  color: #fff;
  font-size: 13px;
  font-weight: 1000;
}

.rpg-wave-vitals i {
  overflow: hidden;
  display: block;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.rpg-wave-vitals em {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rpg-cyan), var(--rpg-teal), var(--rpg-gold));
  box-shadow: 0 0 12px rgba(70, 240, 255, 0.28);
  transition: width 0.24s ease, background 0.24s ease, opacity 0.24s ease;
}

.rpg-wave-vitals > div:last-child em {
  background: linear-gradient(90deg, var(--rpg-danger), var(--rpg-warning), var(--rpg-cyan));
}

.rpg-wave-controls.is-player-warning [data-rpg-top-player-hp],
.rpg-wave-controls.is-player-critical [data-rpg-top-player-hp] {
  background: linear-gradient(90deg, var(--rpg-danger), var(--rpg-warning));
}

.rpg-wave-controls.is-enemy-downed [data-rpg-top-enemy-hp] {
  opacity: 0.28;
}

.rpg-wave-timer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 5px 14px;
  border: 1px solid rgba(245, 199, 106, 0.36);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 1000;
  letter-spacing: 0;
}

html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .question-tools a,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .question-tools a {
  display: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"],
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"],
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"],
body[data-visual-mode="rpg"][data-endpoint="mock_start"] {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(70, 240, 255, 0.24), transparent 30%),
    radial-gradient(circle at 85% 10%, rgba(143, 91, 255, 0.28), transparent 34%),
    var(--bg-quiz-battle-terminal) center / cover fixed no-repeat,
    var(--rpg-bg-deep);
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .topbar,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .topbar,
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .topbar,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .topbar {
  display: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .page,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .page,
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .page,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .page {
  width: 100%;
  max-width: none;
  min-height: 100svh;
  margin: 0;
  padding: clamp(10px, 1.4vw, 20px) clamp(12px, 2.4vw, 42px) calc(74px + env(safe-area-inset-bottom));
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .site-footer,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .site-footer,
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .site-footer,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .site-footer {
  display: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .summary,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .summary,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .empty.slim,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .mock-readiness,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .mock-warnings,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .mock-control,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .exam-rules,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .mock-plan,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .mock-tactics,
html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .mock-profile,
html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .exam-rules,
html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .mock-plan,
html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .mock-tactics,
html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .mock-profile,
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .summary,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .summary,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .empty.slim,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .mock-readiness,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .mock-warnings,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .mock-control,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .exam-rules,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .mock-plan,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .mock-tactics,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .mock-profile,
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .exam-rules,
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .mock-plan,
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .mock-tactics,
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .mock-profile {
  display: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .question-palette,
body[data-visual-mode="rpg"][data-endpoint="mock_start"] .question-palette {
  display: none;
}

.rpg-battle-exit {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 75;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid rgba(70, 240, 255, 0.28);
  border-radius: 14px;
  background: rgba(7, 11, 22, 0.72);
  color: #fff;
  font-weight: 1000;
  text-decoration: none;
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 36px rgba(7, 11, 22, 0.24);
}

html[data-visual-mode="rpg"] .rpg-battle-exit.rpg-mode-only,
body[data-visual-mode="rpg"] .rpg-battle-exit.rpg-mode-only {
  display: inline-flex !important;
}

.rpg-battle-exit:hover,
.rpg-battle-exit:focus-visible {
  color: #061116;
  border-color: rgba(245, 199, 106, 0.72);
  background: linear-gradient(135deg, var(--rpg-cyan), var(--rpg-gold));
}

.rpg-battle-rules {
  width: min(100%, 1120px);
  margin: 0 auto 12px;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

html[data-visual-mode="rpg"] .rpg-battle-rules.rpg-mode-only,
body[data-visual-mode="rpg"] .rpg-battle-rules.rpg-mode-only {
  display: grid !important;
}

.rpg-battle-rules article {
  position: relative;
  overflow: hidden;
  min-height: 116px;
  padding: 14px;
  border: 1px solid rgba(70, 240, 255, 0.22);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(7, 11, 22, 0.82), rgba(16, 22, 42, 0.68)),
    radial-gradient(circle at 100% 0%, rgba(70, 240, 255, 0.16), transparent 34%);
  color: #eef8ff;
  box-shadow: 0 16px 38px rgba(7, 11, 22, 0.16);
}

.rpg-battle-rules article::after {
  content: "";
  position: absolute;
  right: -36px;
  bottom: -46px;
  width: 128px;
  height: 128px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(70, 240, 255, 0.2), transparent 62%);
  pointer-events: none;
}

.rpg-battle-rules span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(245, 199, 106, 0.16);
  color: var(--rpg-gold);
  font-size: 11px;
  font-weight: 1000;
  text-transform: uppercase;
}

.rpg-battle-rules h2 {
  margin: 8px 0 6px;
  color: #fff;
  font-size: clamp(17px, 1.8vw, 22px);
  line-height: 1.25;
}

.rpg-battle-rules p {
  margin: 0;
  color: rgba(238, 248, 255, 0.78);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.7;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active {
  display: grid;
  min-height: min(760px, calc(100svh - 170px));
  align-items: stretch;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-rpg-active,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-rpg-active {
  min-height: min(720px, calc(100svh - 185px));
  display: grid;
  grid-template-rows: auto auto auto auto auto auto;
  align-content: start;
  gap: clamp(14px, 2vw, 22px);
  border-color: rgba(70, 240, 255, 0.42);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(235, 251, 253, 0.9)),
    var(--ui-question-analysis-hud) center / cover no-repeat;
  box-shadow: 0 0 36px rgba(70, 240, 255, 0.28), 0 24px 64px rgba(5, 8, 18, 0.24);
  animation: panelEnter 0.28s ease both;
}

html[data-visual-mode="rpg"] .rpg-battle-arena.rpg-mode-only,
body[data-visual-mode="rpg"] .rpg-battle-arena.rpg-mode-only {
  display: flex !important;
}

.rpg-battle-arena {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 24px);
  min-height: 178px;
  padding: clamp(14px, 2.4vw, 24px);
  border: 1px solid rgba(70, 240, 255, 0.24);
  border-radius: 18px;
  background:
    linear-gradient(115deg, rgba(70, 240, 255, 0.12), transparent 28%, rgba(245, 199, 106, 0.1) 68%, transparent),
    radial-gradient(circle at 50% 52%, rgba(70, 240, 255, 0.22), transparent 38%),
    linear-gradient(90deg, rgba(7, 11, 22, 0.92), rgba(16, 22, 42, 0.76));
  color: #eef8ff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 18px 44px rgba(7, 11, 22, 0.16);
}

.rpg-battle-arena::before,
.rpg-battle-arena::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.rpg-battle-arena::before {
  z-index: -1;
  background:
    linear-gradient(rgba(70, 240, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 240, 255, 0.05) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at 50% 50%, #000 0%, transparent 72%);
}

.rpg-battle-arena::after {
  z-index: 0;
  background: linear-gradient(90deg, transparent, rgba(70, 240, 255, 0.16), transparent);
  opacity: 0.46;
  transform: translateX(-120%);
  animation: scanLine 3.6s ease-in-out infinite;
}

.rpg-player-status {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: clamp(64px, 9vw, 116px) minmax(170px, 1fr);
  align-items: center;
  gap: 14px;
  width: min(420px, 42%);
  min-width: min(100%, 300px);
  padding: 12px;
  border: 1px solid rgba(70, 240, 255, 0.28);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(70, 240, 255, 0.14), rgba(143, 91, 255, 0.08)),
    rgba(7, 11, 22, 0.62);
  box-shadow: inset 0 0 22px rgba(70, 240, 255, 0.08), 0 14px 32px rgba(0, 0, 0, 0.2);
}

.rpg-player-status img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(70, 240, 255, 0.32));
}

.rpg-player-status span,
.rpg-enemy-status span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--rpg-gold);
  font-size: 12px;
  font-weight: 1000;
  text-transform: uppercase;
}

.rpg-player-status strong {
  display: block;
  margin: 3px 0 2px;
  color: #fff;
  font-size: clamp(18px, 2.2vw, 26px);
  line-height: 1.18;
}

.rpg-player-status small {
  display: block;
  color: rgba(238, 248, 255, 0.78);
  font-weight: 800;
}

.rpg-hp-readout {
  display: flex !important;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 5px;
  color: rgba(238, 248, 255, 0.82);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0;
}

.rpg-enemy-status .rpg-hp-readout {
  color: rgba(255, 221, 174, 0.82);
}

.rpg-drive-bar {
  overflow: hidden;
  height: 10px;
  margin-top: 9px;
  border: 1px solid rgba(70, 240, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.rpg-drive-bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rpg-cyan), var(--rpg-teal), var(--rpg-gold));
  box-shadow: 0 0 16px rgba(70, 240, 255, 0.28);
  transition: width 0.28s ease, filter 0.28s ease;
}

.rpg-battle-versus {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(44px, 5vw, 70px);
  height: clamp(44px, 5vw, 70px);
  border: 1px solid rgba(245, 199, 106, 0.48);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(245, 199, 106, 0.22), rgba(7, 11, 22, 0.72) 66%),
    rgba(7, 11, 22, 0.72);
  color: #fff;
  font-size: clamp(17px, 2vw, 24px);
  font-weight: 1000;
  text-shadow: 0 0 16px rgba(245, 199, 106, 0.72);
  box-shadow: 0 0 24px rgba(245, 199, 106, 0.18);
}

.rpg-command-label {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(70, 240, 255, 0.22);
  border-radius: 16px;
  background:
    linear-gradient(90deg, rgba(7, 11, 22, 0.86), rgba(16, 22, 42, 0.64)),
    rgba(7, 11, 22, 0.72);
  color: #eef8ff;
  box-shadow: inset 0 0 18px rgba(70, 240, 255, 0.08);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .rpg-command-label.rpg-mode-only,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .rpg-command-label.rpg-mode-only {
  display: flex !important;
}

.rpg-command-label span {
  color: var(--rpg-gold);
  font-size: 12px;
  font-weight: 1000;
  text-transform: uppercase;
}

.rpg-command-label strong {
  font-size: clamp(16px, 2vw, 22px);
  line-height: 1.2;
}

.rpg-command-label small {
  color: rgba(238, 248, 255, 0.68);
  font-weight: 800;
}

.rpg-command-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.rpg-command-stats b {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border: 1px solid rgba(70, 240, 255, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(238, 248, 255, 0.92);
  font-size: 11px;
  font-weight: 1000;
  white-space: nowrap;
}

.rpg-hit-signal {
  position: absolute;
  right: 12px;
  top: 10px;
  z-index: 2;
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid rgba(70, 240, 255, 0.34);
  border-radius: 999px;
  background: rgba(7, 11, 22, 0.72);
  color: rgba(237, 250, 255, 0.78);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0;
  box-shadow: 0 0 14px rgba(70, 240, 255, 0.16);
  pointer-events: none;
}

.rpg-hit-signal .hit {
  display: none;
  color: var(--rpg-gold);
}

.rpg-hit-signal .miss {
  display: none;
  color: var(--rpg-danger);
}

.rpg-battle-log {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 2;
  display: inline-flex;
  max-width: calc(100% - 24px);
  min-height: 30px;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  border: 1px solid rgba(70, 240, 255, 0.28);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(7, 11, 22, 0.82), rgba(16, 22, 42, 0.7)),
    rgba(7, 11, 22, 0.76);
  color: rgba(237, 250, 255, 0.86);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0;
  text-align: center;
  box-shadow: 0 0 18px rgba(70, 240, 255, 0.14);
  transform: translateX(-50%);
  pointer-events: none;
}

.rpg-battle-log span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rpg-battle-impact {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 2;
  display: grid;
  min-width: min(100%, 230px);
  max-width: min(42%, 360px);
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid rgba(70, 240, 255, 0.24);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(7, 11, 22, 0.82), rgba(16, 22, 42, 0.68)),
    rgba(7, 11, 22, 0.72);
  box-shadow: 0 0 20px rgba(70, 240, 255, 0.12);
}

.rpg-battle-impact span {
  color: var(--rpg-gold);
  font-size: 10px;
  font-weight: 1000;
  text-transform: uppercase;
}

.rpg-battle-impact strong {
  color: #fff;
  font-size: 17px;
  line-height: 1.2;
}

.rpg-battle-impact small {
  color: rgba(238, 248, 255, 0.72);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.45;
}

.rpg-battle-impact[data-state="correct"] {
  border-color: rgba(245, 199, 106, 0.58);
  box-shadow: 0 0 24px rgba(245, 199, 106, 0.2);
}

.rpg-battle-impact[data-state="wrong"] {
  border-color: rgba(255, 93, 93, 0.6);
  box-shadow: 0 0 24px rgba(255, 93, 93, 0.18);
}

.rpg-battle-impact[data-state="selected"] {
  border-color: rgba(70, 240, 255, 0.58);
}

.rpg-battle-flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  opacity: 0;
  color: #fff;
  font-size: clamp(28px, 5vw, 58px);
  font-weight: 1000;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(70, 240, 255, 0.8), 0 0 34px rgba(245, 199, 106, 0.42);
  transform: scale(0.86);
  pointer-events: none;
}

.rpg-enemy-core {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(74px, 10vw, 124px);
  height: clamp(74px, 10vw, 124px);
}

.rpg-enemy-core img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(70, 240, 255, 0.42));
}

.rpg-enemy-core span {
  position: absolute;
  inset: -10px;
  border: 1px solid rgba(70, 240, 255, 0.32);
  border-radius: 50%;
  animation: glowPulse 2.2s ease-in-out infinite;
}

.rpg-enemy-status {
  position: relative;
  z-index: 1;
  min-width: min(360px, 42vw);
  padding: 12px;
  border: 1px solid rgba(255, 93, 93, 0.2);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 93, 93, 0.12), rgba(143, 91, 255, 0.08)),
    rgba(7, 11, 22, 0.58);
  box-shadow: inset 0 0 18px rgba(255, 93, 93, 0.06);
}

.rpg-enemy-status strong {
  display: block;
  margin: 3px 0 10px;
  color: #fff;
  font-size: clamp(18px, 2.4vw, 28px);
  line-height: 1.25;
}

.rpg-hp-bar {
  overflow: hidden;
  height: 14px;
  border: 1px solid rgba(70, 240, 255, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.rpg-hp-bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rpg-danger), var(--rpg-warning), var(--rpg-cyan));
  box-shadow: 0 0 18px rgba(70, 240, 255, 0.32);
  transition: width 0.28s ease, opacity 0.28s ease;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-hp-bar i,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-hp-bar i {
  width: 0%;
  opacity: 0.7;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-drive-bar i,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-drive-bar i {
  filter: saturate(1.2) drop-shadow(0 0 10px rgba(245, 199, 106, 0.36));
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-enemy-core,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-enemy-core {
  animation: coreCommandHit 0.62s ease both;
  filter: saturate(1.25) drop-shadow(0 0 24px rgba(245, 199, 106, 0.48));
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-battle-flash,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-battle-flash {
  animation: battleCommandFlash 0.74s ease both;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-hit-signal,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-hit-signal {
  border-color: rgba(245, 199, 106, 0.62);
  background: rgba(7, 11, 22, 0.86);
  box-shadow: 0 0 22px rgba(245, 199, 106, 0.26);
  animation: badgeRise 0.32s ease both;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-hit-signal .idle,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-hit-signal .idle {
  display: none;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-hit-signal .hit,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-hit-signal .hit {
  display: inline;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-battle-log,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared .rpg-battle-log {
  border-color: rgba(245, 199, 106, 0.58);
  color: #fff8d6;
  box-shadow: 0 0 22px rgba(245, 199, 106, 0.22);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-selected .rpg-hit-signal,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-selected .rpg-hit-signal {
  border-color: rgba(70, 240, 255, 0.62);
  box-shadow: 0 0 18px rgba(70, 240, 255, 0.2);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong {
  border-color: rgba(255, 93, 93, 0.72);
  box-shadow: 0 0 28px rgba(255, 93, 93, 0.22), 0 24px 64px rgba(5, 8, 18, 0.24);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-player-status,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-player-status {
  border-color: rgba(255, 93, 93, 0.48);
  box-shadow: inset 0 0 24px rgba(255, 93, 93, 0.12), 0 14px 32px rgba(0, 0, 0, 0.2);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-battle-flash,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-battle-flash {
  color: var(--rpg-danger);
  text-shadow: 0 0 18px rgba(255, 93, 93, 0.8), 0 0 34px rgba(255, 179, 71, 0.32);
  animation: battleCommandFlash 0.74s ease both;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-hit-signal,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-hit-signal {
  border-color: rgba(255, 93, 93, 0.62);
  box-shadow: 0 0 22px rgba(255, 93, 93, 0.24);
  animation: badgeRise 0.32s ease both;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-hit-signal .idle,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-hit-signal .idle {
  display: none;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-hit-signal .miss,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-hit-signal .miss {
  display: inline;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-battle-log,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-wrong .rpg-battle-log {
  border-color: rgba(255, 93, 93, 0.62);
  color: #ffe7e7;
  box-shadow: 0 0 22px rgba(255, 93, 93, 0.22);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared {
  border-color: rgba(245, 199, 106, 0.72);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active.is-rpg-defeated .rpg-drive-bar i,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active.is-rpg-defeated .rpg-drive-bar i {
  background: linear-gradient(90deg, var(--rpg-danger), rgba(255, 93, 93, 0.35));
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label:has(input:checked),
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label:has(input:checked) {
  border-color: rgba(245, 199, 106, 0.88);
  background:
    linear-gradient(90deg, rgba(245, 199, 106, 0.16), rgba(70, 240, 255, 0.14)),
    rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 22px rgba(245, 199, 106, 0.22), inset 0 0 0 1px rgba(255, 255, 255, 0.72);
  transform: translateX(4px);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label:has(input:checked) span,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label:has(input:checked) span {
  background: linear-gradient(135deg, var(--rpg-gold), var(--rpg-cyan));
  color: #07101e;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label.is-rpg-answer-correct,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label.is-rpg-answer-correct {
  border-color: rgba(245, 199, 106, 0.96);
  background:
    linear-gradient(90deg, rgba(245, 199, 106, 0.24), rgba(70, 240, 255, 0.18)),
    rgba(255, 255, 255, 0.98);
  box-shadow: 0 0 26px rgba(245, 199, 106, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.76);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label.is-rpg-answer-wrong,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label.is-rpg-answer-wrong {
  border-color: rgba(255, 93, 93, 0.9);
  background:
    linear-gradient(90deg, rgba(255, 93, 93, 0.18), rgba(255, 179, 71, 0.12)),
    rgba(255, 255, 255, 0.98);
  box-shadow: 0 0 26px rgba(255, 93, 93, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.76);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label.is-rpg-answer-locked,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label.is-rpg-answer-locked {
  border-color: rgba(70, 240, 255, 0.8);
  box-shadow: 0 0 22px rgba(70, 240, 255, 0.22), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active.is-rpg-hp-warning .rpg-drive-bar i,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active.is-rpg-hp-warning .rpg-drive-bar i {
  background: linear-gradient(90deg, var(--rpg-warning), var(--rpg-gold));
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active.is-rpg-hp-critical .rpg-drive-bar i,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active.is-rpg-hp-critical .rpg-drive-bar i {
  background: linear-gradient(90deg, var(--rpg-danger), var(--rpg-warning));
  animation: glowPulse 1s ease-in-out infinite;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.needs-answer,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.needs-answer {
  border-color: rgba(255, 179, 71, 0.86);
  box-shadow: 0 0 30px rgba(255, 179, 71, 0.28), 0 24px 64px rgba(5, 8, 18, 0.24);
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared::before,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-card.is-wave-cleared::before {
  height: 6px;
  background: linear-gradient(90deg, var(--rpg-gold), var(--rpg-cyan), var(--rpg-gold));
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-head,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-head {
  align-items: start;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-head h2,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-head h2 {
  font-size: clamp(22px, 3vw, 38px);
  line-height: 1.36;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices {
  display: grid;
  gap: 12px;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-choices label {
  min-height: 72px;
  border-width: 2px;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .choice-image-label,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .choice-image-label {
  border-color: rgba(70, 240, 255, 0.42);
  background:
    linear-gradient(135deg, rgba(70, 240, 255, 0.18), rgba(245, 199, 106, 0.16)),
    rgba(255, 255, 255, 0.96);
  color: #0a6670;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-submit,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-submit {
  position: static;
  bottom: auto;
  z-index: auto;
  justify-content: center;
  margin-top: 18px;
  pointer-events: auto;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-submit > *,
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .challenge-submit > * {
  pointer-events: auto;
}

.rpg-defeat-panel {
  position: sticky;
  bottom: 16px;
  z-index: 8;
  justify-self: center;
  width: min(100%, 680px);
  gap: 8px;
  margin: 12px auto 0;
  padding: 18px;
  border: 1px solid rgba(255, 93, 93, 0.42);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(7, 11, 22, 0.94), rgba(48, 16, 38, 0.9)),
    radial-gradient(circle at 100% 0%, rgba(255, 93, 93, 0.24), transparent 36%);
  color: #fff;
  box-shadow: 0 22px 58px rgba(7, 11, 22, 0.34), 0 0 32px rgba(255, 93, 93, 0.18);
}

html[data-visual-mode="rpg"] .rpg-mode-only[hidden],
body[data-visual-mode="rpg"] .rpg-mode-only[hidden],
html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .rpg-defeat-panel[hidden],
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .rpg-defeat-panel[hidden] {
  display: none !important;
}

html[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .rpg-defeat-panel:not([hidden]),
body[data-visual-mode="rpg"] .challenge-form.rpg-battle-active .rpg-defeat-panel:not([hidden]) {
  display: grid !important;
}

.rpg-defeat-panel span {
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 93, 93, 0.18);
  color: #ffd4d4;
  font-weight: 1000;
}

.rpg-defeat-panel h2,
.rpg-defeat-panel p {
  margin: 0;
}

.rpg-defeat-panel p {
  color: rgba(255, 239, 239, 0.78);
  line-height: 1.7;
}

.rpg-defeat-panel button,
.rpg-defeat-panel a {
  justify-self: start;
  min-height: 44px;
  padding: 9px 18px;
  border-color: rgba(245, 199, 106, 0.54);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--rpg-warning), var(--rpg-gold));
  color: #111821;
  font-weight: 1000;
  text-decoration: none;
}

@media (max-width: 760px) {
  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"],
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"],
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"],
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] {
    overflow: hidden;
    height: 100svh;
    padding-bottom: 0;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .topbar,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .topbar,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .topbar,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .topbar {
    display: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .page,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .page,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .page,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .page {
    width: 100%;
    max-width: none;
    height: 100svh;
    margin: 0;
    padding: 8px;
    overflow: hidden;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .empty.slim,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .empty.slim {
    display: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-wave-controls,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-wave-controls,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-wave-controls,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-wave-controls {
    margin-bottom: 8px;
    padding: 7px;
    border-radius: 18px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-wave-controls button,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-wave-controls button,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-wave-controls button,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-wave-controls button {
    min-height: 34px;
    min-width: 52px;
    padding: 4px 8px;
    font-size: 12px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-wave-center,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-wave-center,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-wave-center,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-wave-center {
    flex: 1 1 160px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-wave-vitals,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-wave-vitals,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-wave-vitals,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-wave-vitals {
    order: 3;
    flex: 1 1 100%;
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .challenge-form.rpg-battle-active,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .challenge-form.rpg-battle-active {
    height: calc(100svh - 72px);
    min-height: 0;
    overflow: hidden;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active .challenge-card.is-rpg-active,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .challenge-form.rpg-battle-active .challenge-card.is-rpg-active,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active .challenge-card.is-rpg-active,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .challenge-form.rpg-battle-active .challenge-card.is-rpg-active {
    height: 100%;
    min-height: 0;
    overflow: auto;
    padding: 14px 12px 72px;
    gap: 10px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active .challenge-head,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .challenge-form.rpg-battle-active .challenge-head,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active .challenge-head,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .challenge-form.rpg-battle-active .challenge-head {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-battle-arena,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-battle-arena,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-battle-arena,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-battle-arena {
    min-height: clamp(150px, 24svh, 220px);
    flex-wrap: wrap;
    align-content: center;
    gap: 10px;
    padding: 9px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .question-image-card img,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .question-image-card img,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .question-image-card img,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .question-image-card img {
    max-height: 150px;
    object-fit: contain;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-player-status,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-player-status,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-player-status,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-player-status {
    grid-template-columns: 48px minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    padding: 8px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-battle-versus,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-battle-versus,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-battle-versus,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-battle-versus {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-enemy-core,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-enemy-core,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-enemy-core,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-enemy-core {
    width: 58px;
    height: 58px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-enemy-status,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-enemy-status,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-enemy-status,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-enemy-status {
    flex: 1 1 180px;
    min-width: 0;
    padding: 9px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-command-label,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-command-label,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-command-label,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-command-label {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-hit-signal,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-hit-signal,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-hit-signal,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-hit-signal {
    right: 8px;
    top: 7px;
    min-height: 22px;
    padding: 2px 8px;
    font-size: 9px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-battle-impact,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-battle-impact,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-battle-impact,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-battle-impact {
    position: static;
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
    padding: 7px 9px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-battle-impact strong,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-battle-impact strong,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-battle-impact strong,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-battle-impact strong {
    font-size: 14px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-enemy-core,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-enemy-core,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-enemy-core,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-enemy-core {
    width: 66px;
    height: 66px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-enemy-status,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .rpg-enemy-status,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-enemy-status,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .rpg-enemy-status {
    min-width: 0;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active .challenge-head h2,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .challenge-form.rpg-battle-active .challenge-head h2,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active .challenge-head h2,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .challenge-form.rpg-battle-active .challenge-head h2 {
    font-size: clamp(19px, 5vw, 25px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active .challenge-choices label,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .challenge-form.rpg-battle-active .challenge-choices label,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active .challenge-choices label,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .challenge-form.rpg-battle-active .challenge-choices label {
    min-height: 58px;
    padding: 10px;
    gap: 10px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active .challenge-choices b,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .challenge-form.rpg-battle-active .challenge-choices b,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .challenge-form.rpg-battle-active .challenge-choices b,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .challenge-form.rpg-battle-active .challenge-choices b {
    font-size: 15px;
    line-height: 1.55;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .audio-controls,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .audio-controls,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .audio-controls,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .audio-controls {
    right: 10px;
    bottom: 10px;
    left: auto;
    width: auto;
    grid-template-columns: 1fr;
    padding: 5px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .game-sound-toggle,
  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .game-music-toggle,
  html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .game-voice-toggle,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .game-sound-toggle,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .game-music-toggle,
  html[data-visual-mode="rpg"] body[data-endpoint="mock_start"] .game-voice-toggle,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .game-sound-toggle,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .game-music-toggle,
  body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .game-voice-toggle,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .game-sound-toggle,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .game-music-toggle,
  body[data-visual-mode="rpg"][data-endpoint="mock_start"] .game-voice-toggle {
    display: none;
  }
}

.settings-modal[hidden] {
  display: none;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 32px);
}

.settings-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(7, 11, 22, 0.58);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.settings-modal-panel {
  position: relative;
  z-index: 1;
  overflow: auto;
  width: min(980px, 100%);
  max-height: min(86vh, 880px);
  padding: 18px;
  border: 1px solid rgba(70, 240, 255, 0.28);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 250, 250, 0.96)),
    #fff;
  box-shadow: 0 30px 90px rgba(7, 11, 22, 0.42);
}

.settings-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.settings-modal-head h2 {
  margin: 0;
  font-size: 28px;
}

.settings-modal-close {
  min-height: 38px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.settings-modal .settings-panel {
  max-width: none;
}

.settings-modal .settings-panel article {
  box-shadow: none;
}

body.settings-modal-open {
  overflow: hidden;
}

@media (max-width: 860px) {
  .music-panel {
    grid-template-columns: 1fr;
  }

  .summary,
  .dashboard-command,
  .question-page {
    grid-template-columns: 1fr;
  }

  .companion-stage,
  .companion-stage.compact-stage {
    width: 100%;
    min-height: 96px;
    justify-items: start;
  }

  .companion-large,
  .compact-stage .companion-large {
    max-width: 92px;
    max-height: 102px;
  }

  .companion-small,
  .companion-item {
    left: 78px;
    right: auto;
    bottom: 8px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drill-grid,
  .case-grid,
  .solver-kit-grid,
  .b-mission article {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid-main {
    grid-template-columns: 1fr;
  }

  .roadmap-grid,
  .recommendation-grid,
  .quest-grid,
  .quiz-mode-grid,
  .achievement-grid,
  .result-badges,
  .study-plan,
  .exam-rules,
  .mock-profile,
  .mastery-grid,
  .result-diagnosis,
  .mock-plan,
    .mock-tactics-grid,
    .mock-distribution-grid,
    .bond-event-grid,
  .result-dialogue-grid,
  .interlude-grid,
  .remediation-grid,
  .progress-detail,
	  .lesson-flow-grid,
	  .deep-dive-grid,
	  .practice-ladder,
	  .exam-drill-grid,
	  .mock-time-split,
	  .resource-grid,
	  .glossary-card-grid {
	    grid-template-columns: repeat(2, minmax(0, 1fr));
	  }

  .quality-grid,
  .quality-action-grid,
  .contact-panel,
  .challenge-choices,
  .example-lab,
  .chapter-quiz-card,
  .visual-note,
  .episode-grid,
  .episode-play,
  .episode-board,
  .trace-console,
  .log-console {
    grid-template-columns: 1fr;
  }

  .challenge-choices label.has-choice-image {
    grid-template-columns: 18px 38px minmax(0, 1fr);
    min-height: 0;
  }

  .challenge-choices label.has-choice-image .choice-image,
  .choice.has-choice-image .choice-image {
    max-height: 210px;
  }

  .episode-hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .episode-character {
    justify-self: start;
    max-width: 150px;
    max-height: 190px;
  }

  .episode-line {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .episode-line img {
    width: 72px;
    height: 92px;
  }

  .arc-grid,
  .cast-grid,
  .chapter-party,
  .game-playbook,
  .chapter-beats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .story-node {
    grid-template-columns: 1fr;
  }

  .mini-game {
    grid-template-columns: 1fr;
  }

  .game-form {
    grid-template-columns: 1fr;
  }

  .interactive-game,
  .review-row,
  .review-coach-grid {
    grid-template-columns: 1fr;
  }

  .token-console {
    grid-template-columns: 1fr;
  }

  .lesson-card-grid,
  .lesson-flow-grid,
  .deep-dive-grid,
  .practice-ladder,
  .exam-drill-grid,
  .quiz-config,
  .mock-config,
  .auth-panel,
  .mock-control,
  .mock-control article,
  .mock-plan,
	  .mock-profile,
	  .mock-official-rules,
	  .glossary-search-panel,
	  .mock-tactics-grid,
	  .mock-distribution-grid,
	  .mock-time-split,
	  .resource-grid,
	  .glossary-card-grid,
	  .exam-rules,
  .progress-detail,
  .study-plan,
  .mastery-grid,
  .achievement-grid,
  .result-badges,
  .bond-event-grid,
  .result-dialogue-grid,
  .interlude-grid,
  .remediation-grid,
  .chapter-party,
  .game-playbook,
  .chapter-mission-grid,
  .compact-beats {
    grid-template-columns: 1fr;
  }

  .visual-path,
  .visual-note.kind-stack .visual-path {
    grid-template-columns: 1fr;
  }

  .visual-path span {
    min-height: 54px;
  }

  .visual-path span:not(:last-child)::after {
    left: 22px;
    right: auto;
    top: auto;
    bottom: -12px;
    width: 2px;
    height: 14px;
  }

  .visual-answer {
    grid-template-columns: 1fr;
  }

  .story-actions {
    justify-content: flex-start;
  }

  .question-row {
    grid-template-columns: 76px 36px 50px minmax(0, 1fr);
  }

  .question-row .meta {
    grid-column: 1 / -1;
  }

  .question-side {
    position: static;
  }

  .quiz-config .quiz-start-actions,
  .mock-config .mock-start-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .float-a,
  .float-b,
  .pulse-soft,
  .topbar::before,
  .celebrate,
  .focus-breath,
  .episode-stage::after,
  .episode-ambient,
  .scene-cue-active,
  .episode-line,
  .episode-long-block,
  .episode-figure,
  .episode-practice,
  .episode-objectives,
  .episode-preview-intro::after,
  .episode-preview-scene,
  .episode-preview-board,
  .episode-preview-signal,
  .episode-preview-mini,
  .episode-preview-poster,
  .episode-preview-character,
  .episode-preview-cut,
  .episode-line.is-active img,
  .episode-line.is-active > div::after,
  [data-dialogue-diagram] .lamp-cell.on.is-lit::before,
  .effect-glitch .episode-character,
  .effect-danger .episode-character,
  .effect-victory .episode-character,
  .effect-spark .episode-character {
    animation: none;
  }

  [data-dialogue-diagram] .lamp-cell {
    transition: none;
  }
}

@media (max-width: 520px) {
  body[data-endpoint="mock_exam"] .mock-setup-hero .companion-stage,
  body[data-endpoint="b_training"] .b-summary .companion-stage {
    width: min(100%, 260px);
    justify-self: start;
    justify-items: center;
  }

  body[data-endpoint="mock_exam"] .mock-setup-hero .companion-bubble,
  body[data-endpoint="b_training"] .b-summary .companion-bubble {
    left: 0;
    width: min(230px, calc(100vw - 48px));
    transform: none;
  }

  body[data-endpoint="mock_exam"] .mock-setup-hero .companion-bubble::after,
  body[data-endpoint="b_training"] .b-summary .companion-bubble::after {
    left: 58px;
    transform: rotate(45deg);
  }

  body {
    padding-bottom: calc(132px + env(safe-area-inset-bottom));
  }

  .page {
    width: min(100% - 24px, 1180px);
    margin-top: 18px;
  }

  .audio-controls {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    border: 1px solid rgba(216, 182, 95, 0.22);
    border-radius: 16px;
    background: rgba(17, 24, 33, 0.86);
    backdrop-filter: blur(14px);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  }

  .game-sound-toggle,
  .game-music-toggle,
  .game-voice-toggle,
  .game-settings-link {
    min-width: 0;
    min-height: 36px;
    padding: 5px 6px;
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: none;
    font-size: 11px;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .settings-hero,
  .settings-panel article,
  .volume-control,
  .track-control {
    grid-template-columns: 1fr;
  }

  .summary-character {
    justify-self: start;
  }

  .topbar,
  .list-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 14px;
    min-height: 0;
    padding: 14px 14px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .brand {
    width: 100%;
    min-width: 0;
    gap: 10px;
  }

  .brand > span:last-child {
    min-width: 0;
  }

  .brand strong,
  .brand small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-mark {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
  }

  .topnav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    justify-content: stretch;
    overflow: visible;
    padding: 0;
    scrollbar-width: auto;
  }

  .topnav::-webkit-scrollbar {
    display: none;
  }

  .topnav a,
  .topnav form,
  .topnav button {
    min-width: 0;
    width: 100%;
    text-align: center;
    white-space: normal;
  }

  .topnav a,
  .topnav button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 8px 8px 20px;
    font-size: 12px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .topnav a::before,
  .topnav button::before {
    left: 8px;
  }

  .topnav span {
    grid-column: 1 / -1;
    align-self: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    white-space: nowrap;
  }

  @media (max-width: 360px) {
    .topnav {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .question-row {
    grid-template-columns: 1fr;
  }

  .question-title {
    white-space: normal;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .quiz-mode-grid {
    grid-template-columns: 1fr;
  }

  .roadmap-grid,
  .recommendation-grid,
  .result-diagnosis,
  .next-step,
  .mock-readiness,
  .mock-control,
  .mock-control article,
  .episode-grid,
  .episode-play,
  .episode-board {
    grid-template-columns: 1fr;
  }

  .episode-stage {
    margin-right: 0;
    margin-left: 0;
    padding: 16px 12px 28px;
  }

  .episode-hero h1 {
    font-size: 36px;
  }

  .episode-line {
    grid-template-columns: 1fr;
  }

  .result-row {
    grid-template-columns: 1fr;
  }

  .arc-grid,
  .cast-grid,
  .chapter-beats,
  .cast-card {
    grid-template-columns: 1fr;
  }

  .weak-list strong {
    white-space: normal;
  }
}

body[data-endpoint="quiz_challenge"] .audio-controls,
body[data-endpoint="mock_start"] .audio-controls,
body[data-endpoint="submit_challenge"] .audio-controls {
  position: static;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
  margin: 10px 16px 10px auto;
  padding: 6px;
  max-width: min(720px, calc(100vw - 32px));
  border: 1px solid rgba(216, 182, 95, 0.25);
  border-radius: 18px;
  background: rgba(17, 24, 33, 0.82);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

@media (max-width: 520px) {
  body[data-endpoint="quiz_challenge"] .audio-controls,
  body[data-endpoint="mock_start"] .audio-controls,
  body[data-endpoint="submit_challenge"] .audio-controls {
    left: auto;
    right: auto;
    bottom: auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: calc(100vw - 24px);
    margin: 8px 12px 8px auto;
  }
}

body[data-endpoint="home"] .audio-controls,
body[data-endpoint="dashboard"] .audio-controls,
body[data-endpoint="quiz"] .audio-controls,
body[data-endpoint="adventure"] .audio-controls,
body[data-endpoint="roadmap"] .audio-controls,
body[data-endpoint="b_training"] .audio-controls,
body[data-endpoint="data_quality"] .audio-controls,
body[data-endpoint="glossary"] .audio-controls,
body[data-endpoint="chapter_detail"] .audio-controls,
body[data-endpoint="question_detail"] .audio-controls,
body[data-endpoint="mock_exam"] .audio-controls,
body[data-endpoint="review"] .audio-controls {
  position: static;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  width: fit-content;
  max-width: min(720px, calc(100vw - 32px));
  margin: 10px 16px 0 auto;
  padding: 6px;
  border: 1px solid rgba(216, 182, 95, 0.22);
  border-radius: 18px;
  background: rgba(17, 24, 33, 0.82);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  transform: none;
  opacity: 1;
}

html[data-visual-mode] body[data-endpoint="home"] .audio-controls,
html[data-visual-mode] body[data-endpoint="dashboard"] .audio-controls,
html[data-visual-mode] body[data-endpoint="quiz"] .audio-controls,
html[data-visual-mode] body[data-endpoint="adventure"] .audio-controls,
html[data-visual-mode] body[data-endpoint="roadmap"] .audio-controls,
html[data-visual-mode] body[data-endpoint="b_training"] .audio-controls,
html[data-visual-mode] body[data-endpoint="data_quality"] .audio-controls,
html[data-visual-mode] body[data-endpoint="glossary"] .audio-controls,
html[data-visual-mode] body[data-endpoint="chapter_detail"] .audio-controls,
html[data-visual-mode] body[data-endpoint="question_detail"] .audio-controls,
html[data-visual-mode] body[data-endpoint="mock_exam"] .audio-controls,
html[data-visual-mode] body[data-endpoint="review"] .audio-controls {
  position: static;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  transform: none;
  opacity: 1;
}

body[data-endpoint="home"] .audio-controls:hover,
body[data-endpoint="dashboard"] .audio-controls:hover,
body[data-endpoint="quiz"] .audio-controls:hover,
body[data-endpoint="adventure"] .audio-controls:hover,
body[data-endpoint="roadmap"] .audio-controls:hover,
body[data-endpoint="b_training"] .audio-controls:hover,
body[data-endpoint="data_quality"] .audio-controls:hover,
body[data-endpoint="glossary"] .audio-controls:hover,
body[data-endpoint="chapter_detail"] .audio-controls:hover,
body[data-endpoint="question_detail"] .audio-controls:hover,
body[data-endpoint="mock_exam"] .audio-controls:hover,
body[data-endpoint="review"] .audio-controls:hover,
body[data-endpoint="home"] .audio-controls:focus-within,
body[data-endpoint="dashboard"] .audio-controls:focus-within,
body[data-endpoint="quiz"] .audio-controls:focus-within,
body[data-endpoint="adventure"] .audio-controls:focus-within,
body[data-endpoint="roadmap"] .audio-controls:focus-within,
body[data-endpoint="b_training"] .audio-controls:focus-within,
body[data-endpoint="data_quality"] .audio-controls:focus-within,
body[data-endpoint="glossary"] .audio-controls:focus-within,
body[data-endpoint="chapter_detail"] .audio-controls:focus-within,
body[data-endpoint="question_detail"] .audio-controls:focus-within,
body[data-endpoint="mock_exam"] .audio-controls:focus-within,
body[data-endpoint="review"] .audio-controls:focus-within {
  transform: none;
  opacity: 1;
}

.dashboard-unlock-route {
  overflow: hidden;
}

html[data-visual-mode="rpg"] .dashboard-unlock-route,
body[data-visual-mode="rpg"] .dashboard-unlock-route {
  border-color: rgba(70, 240, 255, 0.26);
  background:
    linear-gradient(135deg, rgba(7, 11, 22, 0.9), rgba(16, 22, 42, 0.82) 58%, rgba(10, 20, 30, 0.86)),
    url("/static/visual/backgrounds/story-city.jpg") center / cover no-repeat;
  color: #f4fbff;
  box-shadow: var(--rpg-shadow-cyan);
}

html[data-visual-mode="rpg"] .dashboard-unlock-route h2,
html[data-visual-mode="rpg"] .dashboard-unlock-route .list-head p,
body[data-visual-mode="rpg"] .dashboard-unlock-route h2,
body[data-visual-mode="rpg"] .dashboard-unlock-route .list-head p {
  color: #f4fbff;
}

.dashboard-route-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) minmax(160px, 2fr);
  gap: 10px;
  align-items: stretch;
  margin: 0 0 14px;
}

.dashboard-route-status > div {
  min-height: 68px;
  padding: 12px 14px;
  border: 1px solid rgba(70, 240, 255, 0.2);
  border-radius: 14px;
  background: rgba(7, 11, 22, 0.54);
}

.dashboard-route-status span {
  display: block;
  color: #fff;
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 1000;
  line-height: 1;
}

.dashboard-route-status small {
  display: block;
  margin-top: 8px;
  color: rgba(237, 250, 255, 0.72);
  font-weight: 900;
}

.dashboard-route-progress {
  display: flex;
  align-items: center;
}

.dashboard-route-progress span {
  position: relative;
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(70, 240, 255, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.dashboard-route-progress span::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--route-progress, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rpg-teal), var(--rpg-gold));
  box-shadow: 0 0 18px rgba(70, 240, 255, 0.32);
}

.dashboard-route-note {
  margin: 0 0 14px;
  color: rgba(237, 250, 255, 0.76);
  font-weight: 800;
}

.dashboard-route-strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.dashboard-route-strip::before {
  content: "";
  position: absolute;
  inset: 26px 8% auto 8%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(70, 240, 255, 0.38), rgba(245, 199, 106, 0.42), transparent);
  pointer-events: none;
}

.dashboard-route-strip .unit-route-node {
  z-index: 1;
  min-height: 116px;
  background:
    radial-gradient(circle at top right, rgba(70, 240, 255, 0.18), transparent 40%),
    linear-gradient(135deg, rgba(7, 11, 22, 0.76), rgba(16, 22, 42, 0.62));
}

.dashboard-route-strip .unit-route-node.compact p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

html[data-visual-mode="simple"] .dashboard-unlock-route,
body[data-visual-mode="simple"] .dashboard-unlock-route {
  border: 1px solid rgba(24, 132, 139, 0.14);
  background:
    radial-gradient(circle at top right, rgba(30, 210, 220, 0.1), transparent 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 247, 0.94));
}

html[data-visual-mode="simple"] .dashboard-route-strip::before,
body[data-visual-mode="simple"] .dashboard-route-strip::before {
  background: linear-gradient(90deg, transparent, rgba(24, 132, 139, 0.22), rgba(216, 182, 95, 0.28), transparent);
}

html[data-visual-mode="simple"] .dashboard-route-status > div,
body[data-visual-mode="simple"] .dashboard-route-status > div {
  border-color: rgba(44, 55, 73, 0.12);
  background: rgba(255, 255, 255, 0.92);
}

html[data-visual-mode="simple"] .dashboard-route-status span,
body[data-visual-mode="simple"] .dashboard-route-status span {
  color: var(--ink);
}

html[data-visual-mode="simple"] .dashboard-route-status small,
html[data-visual-mode="simple"] .dashboard-route-note,
body[data-visual-mode="simple"] .dashboard-route-status small,
body[data-visual-mode="simple"] .dashboard-route-note {
  color: var(--muted);
}

html[data-visual-mode="simple"] .dashboard-route-strip .unit-route-node,
body[data-visual-mode="simple"] .dashboard-route-strip .unit-route-node {
  border-color: rgba(44, 55, 73, 0.12);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 18px rgba(14, 21, 32, 0.05);
}

@media (max-width: 520px) {
  body[data-endpoint="home"] .audio-controls,
  body[data-endpoint="dashboard"] .audio-controls,
  body[data-endpoint="quiz"] .audio-controls,
  body[data-endpoint="adventure"] .audio-controls,
  body[data-endpoint="roadmap"] .audio-controls,
  body[data-endpoint="b_training"] .audio-controls,
  body[data-endpoint="data_quality"] .audio-controls,
  body[data-endpoint="glossary"] .audio-controls,
  body[data-endpoint="chapter_detail"] .audio-controls,
  body[data-endpoint="question_detail"] .audio-controls,
  body[data-endpoint="mock_exam"] .audio-controls,
  body[data-endpoint="review"] .audio-controls {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: auto;
    max-width: calc(100vw - 24px);
    margin: 8px 12px 0 auto;
  }

  .dashboard-route-strip {
    grid-template-columns: 1fr;
  }

  .dashboard-route-status {
    grid-template-columns: repeat(3, 1fr);
  }

  .dashboard-route-progress {
    grid-column: 1 / -1;
  }

  .dashboard-route-strip::before {
    inset: 12px auto 12px 26px;
    width: 2px;
    height: auto;
    background: linear-gradient(180deg, transparent, rgba(70, 240, 255, 0.38), rgba(245, 199, 106, 0.42), transparent);
  }
}

/* Story mode bridge: standard keeps the world and cast; RPG keeps the one-screen player. */
html[data-visual-mode="simple"] body[data-endpoint="adventure"] .story-hero,
body[data-visual-mode="simple"][data-endpoint="adventure"] .story-hero,
html[data-visual-mode="simple"] body[data-endpoint="chapter_detail"] .chapter-hero,
body[data-visual-mode="simple"][data-endpoint="chapter_detail"] .chapter-hero {
  border-color: rgba(24, 132, 139, 0.2);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(231, 250, 250, 0.78) 58%, rgba(247, 241, 255, 0.72)),
    var(--visual-bg) center / cover no-repeat,
    #fff !important;
  box-shadow: 0 18px 44px rgba(17, 24, 33, 0.1);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .guide-line,
body[data-visual-mode="simple"][data-endpoint="adventure"] .guide-line,
html[data-visual-mode="simple"] body[data-endpoint="chapter_detail"] .chapter-party-line,
body[data-visual-mode="simple"][data-endpoint="chapter_detail"] .chapter-party-line {
  display: flex !important;
  border-color: rgba(40, 215, 198, 0.2);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(237, 251, 251, 0.86)),
    var(--ui-bubble) center / 100% 100% no-repeat;
  box-shadow: 0 12px 26px rgba(17, 24, 33, 0.08);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .metrics div,
body[data-visual-mode="simple"][data-endpoint="adventure"] .metrics div,
html[data-visual-mode="simple"] body[data-endpoint="chapter_detail"] .chapter-meta span,
body[data-visual-mode="simple"][data-endpoint="chapter_detail"] .chapter-meta span {
  border-color: rgba(24, 132, 139, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 251, 250, 0.9)),
    radial-gradient(circle at 100% 0%, rgba(70, 240, 255, 0.12), transparent 36%);
  box-shadow: 0 10px 22px rgba(17, 24, 33, 0.06);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .story-node,
body[data-visual-mode="simple"][data-endpoint="adventure"] .story-node,
html[data-visual-mode="simple"] body[data-endpoint="roadmap"] .roadmap-zone,
body[data-visual-mode="simple"][data-endpoint="roadmap"] .roadmap-zone {
  border-color: rgba(24, 132, 139, 0.16);
  background:
    radial-gradient(circle at 96% 8%, rgba(70, 240, 255, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 251, 251, 0.94));
  box-shadow: 0 14px 30px rgba(17, 24, 33, 0.07);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .story-node.available,
body[data-visual-mode="simple"][data-endpoint="adventure"] .story-node.available {
  border-color: rgba(40, 215, 198, 0.36);
}

html[data-visual-mode="simple"] body[data-endpoint="adventure"] .story-node.done,
body[data-visual-mode="simple"][data-endpoint="adventure"] .story-node.done {
  border-color: rgba(216, 182, 95, 0.42);
  background:
    radial-gradient(circle at 96% 8%, rgba(245, 199, 106, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 249, 233, 0.92));
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .dialogue-player-bar {
  border: 1px solid rgba(24, 132, 139, 0.16);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(237, 251, 251, 0.9)),
    var(--ui-plate) center / 100% 100% no-repeat;
  box-shadow: 0 12px 24px rgba(17, 24, 33, 0.06);
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-line > div,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-line > div {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(240, 251, 251, 0.94)),
    var(--ui-bubble-large) center / 100% 100% no-repeat;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .audio-controls,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .audio-controls {
  position: static;
  inset: auto;
  width: fit-content;
  max-width: min(720px, calc(100vw - 32px));
  margin: 10px 16px 10px auto;
  padding: 6px;
  border: 1px solid rgba(216, 182, 95, 0.22);
  border-radius: 18px;
  background: rgba(17, 24, 33, 0.82);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  transform: none;
  opacity: 1;
}

@media (max-width: 760px) {
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"],
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] {
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    padding-bottom: 0;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .page,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .page,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-play,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-play,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-bar,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line > div,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line > div {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    overflow: hidden;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    justify-content: stretch;
    overflow: hidden;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions button,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions button {
    width: 100%;
    min-width: 0;
    padding-inline: 6px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line p,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line p {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 430px) {
  html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .audio-controls,
  body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .audio-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: auto;
    max-width: calc(100vw - 24px);
    margin: 8px 12px 10px auto;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions button,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions button {
    min-height: 32px;
    padding-inline: 5px;
    font-size: 11px;
  }
}

/* RPG immersion pass: keep standard readable, make RPG feel like a game screen. */
html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero.visual-bg,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero.visual-bg {
  position: relative;
  overflow: hidden;
  min-height: clamp(430px, 48vh, 560px);
  align-items: center;
  border-color: rgba(70, 240, 255, 0.44);
  background:
    radial-gradient(circle at 82% 24%, rgba(70, 240, 255, 0.3), transparent 32%),
    radial-gradient(circle at 18% 80%, rgba(143, 91, 255, 0.24), transparent 34%),
    linear-gradient(90deg, rgba(4, 8, 18, 0.95) 0 45%, rgba(7, 13, 26, 0.82) 66%, rgba(7, 13, 26, 0.62)),
    var(--visual-bg, url("/static/visual/backgrounds/story-city.jpg")) center / cover no-repeat !important;
  color: #f5fbff;
  box-shadow:
    0 0 34px rgba(70, 240, 255, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16),
    inset 0 -120px 140px rgba(4, 8, 18, 0.62);
}

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero::after,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero::after,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero.visual-bg::after,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero.visual-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 24%, rgba(4, 8, 18, 0.28)),
    repeating-linear-gradient(0deg, rgba(70, 240, 255, 0.07) 0 1px, transparent 1px 9px);
  opacity: 0.5;
  mix-blend-mode: screen;
}

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero > *,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero > *,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero.visual-bg > *,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero.visual-bg > * {
  position: relative;
  z-index: 1;
}

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero h1,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero h1,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero h1,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero h1 {
  color: #fff;
  font-size: clamp(40px, 6vw, 82px);
  letter-spacing: 0;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.35),
    0 0 22px rgba(70, 240, 255, 0.38);
}

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero p,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero p,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero p,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero p {
  max-width: 780px;
  color: rgba(245, 251, 255, 0.9);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.52);
}

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero .eyebrow,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero .eyebrow,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero .eyebrow,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero .eyebrow {
  color: var(--rpg-gold);
  text-shadow: 0 0 18px rgba(245, 199, 106, 0.4);
}

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero .companion-stage,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero .companion-stage,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero .guide-line,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero .guide-line {
  border: 1px solid rgba(70, 240, 255, 0.38);
  background:
    radial-gradient(circle at 50% 92%, rgba(70, 240, 255, 0.22), transparent 34%),
    linear-gradient(180deg, rgba(7, 11, 22, 0.62), rgba(7, 11, 22, 0.34));
  box-shadow:
    0 0 28px rgba(70, 240, 255, 0.22),
    inset 0 0 28px rgba(70, 240, 255, 0.08);
}

  html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero .companion-stage,
  body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero .companion-stage {
  width: min(280px, 26vw);
  min-height: 270px;
  padding: 18px;
}

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero .companion-large,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero .companion-large {
  max-width: 180px;
  max-height: 238px;
  filter:
    drop-shadow(0 18px 26px rgba(0, 0, 0, 0.48))
    drop-shadow(0 0 20px rgba(70, 240, 255, 0.38));
}

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero .metrics div,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero .metrics div,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero .metrics div,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero .metrics div {
  border-color: rgba(70, 240, 255, 0.34);
  background:
    linear-gradient(180deg, rgba(7, 11, 22, 0.82), rgba(16, 22, 42, 0.68)),
    rgba(7, 11, 22, 0.7);
  color: #f5fbff;
  box-shadow: inset 0 0 18px rgba(70, 240, 255, 0.08), 0 14px 30px rgba(0, 0, 0, 0.22);
}

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero .metrics span,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero .metrics span,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero .metrics span,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero .metrics span {
  color: #7af7ff;
  text-shadow: 0 0 16px rgba(70, 240, 255, 0.34);
}

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero .metrics small,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero .metrics small,
html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero .metrics small,
body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero .metrics small {
  color: rgba(237, 250, 255, 0.78);
}

html[data-visual-mode="simple"] body[data-endpoint="dashboard"] .dashboard-hero,
body[data-visual-mode="simple"][data-endpoint="dashboard"] .dashboard-hero,
html[data-visual-mode="simple"] body[data-endpoint="quiz"] .summary,
body[data-visual-mode="simple"][data-endpoint="quiz"] .summary {
  background:
    radial-gradient(circle at 92% 10%, rgba(40, 215, 198, 0.13), transparent 28%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(236, 250, 250, 0.9) 58%, rgba(250, 247, 255, 0.88));
}

html[data-visual-mode="simple"] body[data-endpoint="dashboard"] .companion-stage,
body[data-visual-mode="simple"][data-endpoint="dashboard"] .companion-stage,
html[data-visual-mode="simple"] body[data-endpoint="roadmap"] .companion-stage,
body[data-visual-mode="simple"][data-endpoint="roadmap"] .companion-stage,
html[data-visual-mode="simple"] body[data-endpoint="b_training"] .companion-stage,
body[data-visual-mode="simple"][data-endpoint="b_training"] .companion-stage {
  display: grid !important;
  border-color: rgba(24, 132, 139, 0.18);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 12px 28px rgba(17, 24, 33, 0.07);
}

html[data-visual-mode="rpg"] .rpg-hp-bar i,
body[data-visual-mode="rpg"] .rpg-hp-bar i,
html[data-visual-mode="rpg"] .rpg-drive-bar i,
body[data-visual-mode="rpg"] .rpg-drive-bar i {
  width: 100%;
}

@media (max-width: 860px) {
  html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero,
  body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero,
  html[data-visual-mode="rpg"] body[data-endpoint="adventure"] .story-hero.visual-bg,
  body[data-visual-mode="rpg"][data-endpoint="adventure"] .story-hero.visual-bg {
    min-height: 0;
    grid-template-columns: 1fr;
    background:
      radial-gradient(circle at 70% 12%, rgba(70, 240, 255, 0.24), transparent 34%),
      linear-gradient(180deg, rgba(4, 8, 18, 0.94), rgba(7, 13, 26, 0.76)),
      var(--visual-bg, url("/static/visual/backgrounds/story-city.jpg")) center / cover no-repeat !important;
  }

html[data-visual-mode="rpg"] body[data-endpoint="dashboard"] .dashboard-hero .companion-stage,
body[data-visual-mode="rpg"][data-endpoint="dashboard"] .dashboard-hero .companion-stage {
    width: min(100%, 320px);
    min-height: 210px;
    justify-self: center;
  }
}

/* Final UX guardrails for the RPG player surfaces. */
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-topline,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-topline {
  position: relative;
  z-index: 5;
  justify-content: flex-start;
  padding-right: 0;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-topline > span,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-topline > span {
  margin-left: 8px;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-bar {
  display: grid;
  grid-template-columns: minmax(92px, 0.18fr) minmax(0, 0.82fr);
  align-items: center;
  min-height: 48px;
  overflow: visible;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions {
  min-width: 0;
  flex-wrap: nowrap;
  justify-content: flex-end;
  overflow: hidden;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions button,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions button {
  min-width: 0;
  padding-inline: clamp(8px, 1vw, 14px);
  white-space: nowrap;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual {
  grid-template-rows: auto minmax(84px, auto) minmax(0, 1fr);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-scene-visual.rpg-mode-only,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-scene-visual.rpg-mode-only {
  margin-inline: clamp(8px, 1.4vw, 18px);
  padding: 10px 12px;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line {
  grid-template-columns: minmax(104px, 176px) minmax(0, 1fr);
  overflow: hidden;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line img,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line img {
  width: min(100%, 176px);
  height: min(38svh, 260px);
  image-rendering: auto;
  background: transparent;
  transform: translateZ(0);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line.speaker-bit img,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line.speaker-bit img {
  width: min(100%, 112px);
  height: min(28svh, 174px);
  border-radius: 0;
  background: transparent;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line > div,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line > div {
  max-height: 100%;
  overflow: auto;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line p:last-child,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line p:last-child {
  font-size: clamp(20px, 2.3vw, 30px);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card {
  border-color: rgba(216, 182, 95, 0.28);
  background:
    radial-gradient(circle at 6% 24%, rgba(216, 182, 95, 0.18), transparent 34%),
    linear-gradient(135deg, rgba(7, 11, 22, 0.9), rgba(28, 39, 55, 0.76));
  color: #f6fbff;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card.is-active,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card.is-active {
  border-color: rgba(246, 191, 90, 0.58);
  background:
    radial-gradient(circle at 6% 24%, rgba(216, 182, 95, 0.24), transparent 35%),
    linear-gradient(135deg, rgba(10, 16, 28, 0.96), rgba(32, 43, 58, 0.92));
  color: #f6fbff;
  box-shadow:
    0 16px 34px rgba(7, 11, 22, 0.22),
    inset 0 0 0 1px rgba(246, 191, 90, 0.18);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card.is-active > div,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card.is-active > div {
  border-color: rgba(70, 240, 255, 0.2);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(236, 249, 249, 0.97)),
    var(--ui-bubble-large) center / 100% 100% no-repeat;
  color: #17202a;
  box-shadow: inset 0 0 0 1px rgba(70, 240, 255, 0.14);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card h3,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card h3 {
  color: #fff;
  font-size: clamp(18px, 2vw, 24px);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card p:last-child,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card p:last-child,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card .episode-narrator-text,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card .episode-narrator-text {
  color: rgba(246, 251, 255, 0.9);
  font-size: clamp(17px, 1.9vw, 22px);
  line-height: 1.55;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card.is-active div > p:not(.eyebrow),
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card.is-active div > p:not(.eyebrow),
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card.is-active p:last-child,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card.is-active p:last-child,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card.is-active .episode-narrator-text,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card.is-active .episode-narrator-text {
  color: #17202a;
  text-shadow: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card.is-active h3,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card.is-active h3 {
  color: #17202a;
  text-shadow: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-mark,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-mark {
  border-color: rgba(216, 182, 95, 0.36);
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 248, 204, 0.24), transparent 46%),
    rgba(216, 182, 95, 0.15);
  color: #f6bf5a;
  box-shadow: inset 0 0 0 1px rgba(255, 248, 204, 0.12), 0 10px 20px rgba(7, 11, 22, 0.2);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card.is-active .episode-narrator-mark,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card.is-active .episode-narrator-mark {
  border-color: rgba(246, 191, 90, 0.72);
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 248, 204, 0.32), transparent 46%),
    rgba(216, 182, 95, 0.22);
  color: #ffd978;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-command-label span,
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-command-label span {
  text-transform: none;
}

html[data-visual-mode="rpg"] body[data-endpoint="quiz_challenge"] .rpg-command-label small,
body[data-visual-mode="rpg"][data-endpoint="quiz_challenge"] .rpg-command-label small {
  color: rgba(238, 248, 255, 0.82);
}

@media (max-width: 760px) {
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(96px, 28svh) auto;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line img,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line img {
    width: min(48vw, 160px);
    height: min(26svh, 208px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line.speaker-bit img,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line.speaker-bit img {
    width: min(34vw, 112px);
    height: min(22svh, 150px);
  }
}

/* Sprint 1 Design package: Episode 1 video slots and mobile readability. */
.episode-media-dock {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) repeat(2, minmax(170px, 0.95fr));
  gap: 10px;
  max-width: 100%;
  min-width: 0;
}

.episode-media-dock.is-lesson-only {
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.95fr);
}

.episode-media-dock > article {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(24, 132, 139, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 22px rgba(14, 21, 32, 0.08);
}

.episode-media-dock h2,
.episode-video-card strong {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.episode-video-card header {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.episode-theme-card p,
.episode-video-card p,
.episode-video-card small {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.episode-theme-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.episode-theme-summary,
.episode-theme-formula {
  margin: 0;
  overflow-wrap: anywhere;
}

.episode-theme-diagram {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 6px;
  max-width: 100%;
  min-width: 0;
}

.episode-theme-diagram .lamp-cell {
  min-height: 54px;
  gap: 2px;
  padding: 6px 4px;
  border-width: 1px;
  border-radius: 8px;
}

.episode-theme-diagram .lamp-cell::before {
  width: 10px;
  height: 10px;
}

.episode-theme-diagram .lamp-cell b {
  font-size: 14px;
}

.episode-theme-diagram .lamp-cell small {
  padding: 1px 6px;
  font-size: 10px;
}

.episode-theme-tags span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(24, 132, 139, 0.1);
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.episode-video-frame {
  overflow: hidden;
  border: 1px solid rgba(24, 132, 139, 0.16);
  border-radius: 8px;
  background: #0f172a;
}

.episode-video,
.episode-video-placeholder {
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.episode-video {
  object-fit: cover;
  background: #0f172a;
}

.episode-video-placeholder {
  place-items: center;
  gap: 4px;
  padding: 12px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(23, 111, 115, 0.72)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 12px);
  color: #eef8ff;
}

.episode-video-placeholder span {
  color: rgba(238, 248, 255, 0.68);
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.episode-video-placeholder strong {
  color: #fff;
  font-size: 16px;
}

.episode-video-placeholder small {
  max-width: 24ch;
  color: rgba(238, 248, 255, 0.78);
  font-size: 11px;
  font-weight: 800;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-media-dock,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-media-dock {
  grid-template-columns: 1fr;
  margin-bottom: 4px;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-media-dock > article,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-media-dock > article {
  border-color: rgba(24, 132, 139, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(240, 251, 251, 0.92)),
    var(--ui-plate) center / 100% 100% no-repeat;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-scene-visual.rpg-mode-only,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-scene-visual.rpg-mode-only {
  display: none !important;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line > div,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line > div {
  max-height: none;
  overflow: visible;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock {
  margin-inline: clamp(8px, 1.4vw, 18px);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock > article,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock > article {
  border-color: rgba(70, 240, 255, 0.22);
  background:
    radial-gradient(circle at 94% 10%, rgba(70, 240, 255, 0.16), transparent 34%),
    linear-gradient(135deg, rgba(7, 11, 22, 0.84), rgba(18, 31, 48, 0.7));
  color: #f3fbff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-card h2,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video-card strong,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-card h2,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video-card strong {
  color: #fff;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-card p,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video-card p,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-card p,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video-card p {
  color: rgba(243, 251, 255, 0.75);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-diagram,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-diagram {
  padding: 6px;
  border: 1px solid rgba(70, 240, 255, 0.2);
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(70, 240, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(70, 240, 255, 0.08) 1px, transparent 1px),
    rgba(255, 255, 255, 0.06);
  background-size: 16px 16px;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-formula,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-formula {
  color: rgba(243, 251, 255, 0.86);
  font-weight: 900;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-tags span,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-tags span {
  background: rgba(70, 240, 255, 0.12);
  color: var(--rpg-cyan);
}

@media (min-width: 761px) and (max-height: 980px) {
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 8px;
    padding-block: 10px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-bar {
    padding-block: 8px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock {
    gap: 8px;
    margin-inline: clamp(6px, 1vw, 12px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock > article,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock > article {
    gap: 6px;
    padding: 8px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-card p:not(.eyebrow),
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-tags,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-card p:not(.eyebrow),
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-tags {
    display: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-diagram,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-diagram {
    grid-template-columns: repeat(4, minmax(34px, 1fr));
    gap: 4px;
    padding: 4px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-diagram .lamp-cell,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-diagram .lamp-cell {
    min-height: 44px;
    padding: 4px 3px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video-frame,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video-frame {
    height: clamp(152px, 24svh, 220px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video-placeholder,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video-placeholder {
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video {
    object-fit: contain;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video-placeholder small,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video-placeholder small {
    display: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line > div,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line > div {
    max-height: 100%;
    overflow: auto;
  }
}

@media (max-width: 760px) {
  html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-hero,
  body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 20px;
  }

  html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-hero > div,
  body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-hero > div {
    min-width: 0;
  }

  html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-hero h1,
  body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-hero h1 {
    display: block;
    max-width: 100%;
    inline-size: 100%;
    font-size: clamp(30px, 7.4vw, 36px);
    line-height: 1.16;
    overflow-wrap: break-word;
    text-wrap: balance;
    word-break: keep-all;
  }

  html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-character,
  body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-character {
    width: min(34vw, 112px);
    justify-self: end;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-scene-visual.rpg-mode-only,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-scene-visual.rpg-mode-only {
    display: none !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock {
    display: grid;
    grid-auto-flow: row;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-inline: 0;
    overflow-x: visible;
    overscroll-behavior-inline: auto;
    scroll-snap-type: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock > article,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock > article {
    min-height: 0;
    padding: 10px;
    scroll-snap-align: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock .episode-video-card,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock .episode-video-card {
    order: 1;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock .episode-theme-card,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock .episode-theme-card {
    order: 2;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-card p:not(.eyebrow),
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-tags,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-card p:not(.eyebrow),
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-tags {
    display: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-diagram,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-diagram {
    grid-template-columns: repeat(4, minmax(30px, 1fr));
    gap: 4px;
    padding: 4px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-diagram .lamp-cell,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-diagram .lamp-cell {
    min-height: 42px;
    padding: 4px 2px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-diagram .lamp-cell::before,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-diagram .lamp-cell::before {
    width: 8px;
    height: 8px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video-placeholder,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video-placeholder {
    min-height: clamp(184px, 53vw, 230px);
    aspect-ratio: 16 / 9;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video-placeholder small,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video-placeholder small {
    display: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-flow: row;
    align-items: stretch;
    gap: 8px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only > article,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only > article {
    gap: 5px;
    padding: 8px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-card,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-card {
    display: flex;
    min-height: 38px;
    align-items: flex-start;
    gap: 6px;
    padding-block: 7px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-card .eyebrow,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-card .eyebrow {
    flex: 0 0 auto;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-card h2,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-video-card strong,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-card h2,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-video-card strong {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 12px;
    line-height: 1.25;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-card h2,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-card h2 {
    flex: 1 1 auto;
    display: block;
    min-width: 0;
    overflow: visible;
    -webkit-box-orient: initial;
    -webkit-line-clamp: unset;
    line-height: 1.35;
    overflow-wrap: anywhere;
    text-wrap: pretty;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-video-frame,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-video-frame {
    height: clamp(188px, 53vw, 232px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-video,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-video-placeholder,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-video,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-video-placeholder {
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
    object-fit: contain;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-diagram,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-diagram {
    display: none;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-diagram .lamp-cell,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-diagram .lamp-cell {
    min-height: 34px;
    padding: 3px 1px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-diagram .lamp-cell b,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-diagram .lamp-cell b {
    font-size: 11px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-diagram .lamp-cell small,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-theme-diagram .lamp-cell small {
    padding-inline: 3px;
    font-size: 9px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line > div,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line > div {
    padding: 9px 10px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line p:last-child,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line p:last-child {
    font-size: clamp(15px, 4vw, 17px);
    line-height: 1.48;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .voice-line-button.compact,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .voice-line-button.compact {
    min-height: 32px;
    margin-top: 6px;
    padding: 5px 10px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card {
    grid-template-columns: minmax(62px, 72px) minmax(0, 1fr);
    grid-template-rows: auto;
    min-height: 0;
    align-items: center;
    padding: 9px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-mark,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-mark {
    width: 58px;
    height: 58px;
    font-size: 1.42rem;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card h3,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card h3 {
    margin-bottom: 4px;
    font-size: clamp(15px, 4vw, 17px);
    line-height: 1.28;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card p:last-child,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card p:last-child,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card .episode-narrator-text,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card .episode-narrator-text {
    font-size: clamp(14px, 3.6vw, 16px);
    line-height: 1.5;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-width: 100%;
    overflow: visible;
    padding-bottom: 2px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions button,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions button {
    flex: 0 0 auto;
    width: auto;
    inline-size: auto;
    min-width: 44px;
    min-height: 32px;
    padding: 5px 9px;
    font-size: 11px;
    white-space: nowrap;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions .dialogue-autoplay-toggle,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions .dialogue-autoplay-toggle {
    min-width: 74px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-inline-controls,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-inline-controls {
    justify-content: stretch;
    gap: 6px;
    padding-inline: 4px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-inline-controls button,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-inline-controls button {
    flex: 1 1 104px;
    min-height: 42px;
    padding-inline: 10px;
    font-size: 12px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line {
    grid-template-columns: minmax(54px, 72px) minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 9px;
    min-height: 168px;
    padding: 9px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line img,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line img {
    width: min(18vw, 68px);
    height: min(16svh, 96px);
    align-self: start;
    justify-self: center;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line.speaker-bit img,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line.speaker-bit img {
    width: min(15vw, 58px);
    height: min(13svh, 82px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line > div,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line > div {
    max-height: none;
    min-width: 0;
    overflow: visible;
    padding: 11px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line p:last-child,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line p:last-child {
    font-size: clamp(16px, 4.25vw, 18px);
    line-height: 1.54;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 430px) {
  html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-hero h1,
  body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-hero h1 {
    font-size: clamp(26px, 7.2vw, 31px);
    line-height: 1.2;
  }
}

@media (min-width: 761px) {
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line > div,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line > div {
    padding: 12px 18px !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line p:not(.eyebrow),
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line p:not(.eyebrow) {
    font-size: clamp(19px, 2.2vw, 26px) !important;
    line-height: 1.42 !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line img,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line img {
    height: min(24svh, 190px) !important;
  }
}

/* Story Bible v2 UI foundation. */
.episode-backline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.story-previous-link {
  border-color: rgba(189, 109, 37, 0.26);
  background: rgba(255, 247, 232, 0.9);
  color: #7a4314;
}

.episode-story-foundation {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
  gap: 14px;
  align-items: stretch;
  margin: 0 0 18px;
}

.chapter-start-card,
.episode-recap-card,
.episode-figure-context {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: clamp(14px, 2vw, 20px);
  border: 1px solid rgba(44, 55, 73, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-sm);
}

.chapter-start-card h2,
.episode-recap-card h2,
.episode-figure-context h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.chapter-start-card > p:not(.eyebrow) {
  margin: 0;
  color: #263348;
  font-size: clamp(15px, 1.5vw, 17px);
  line-height: 1.72;
}

.story-recap-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: story-recap;
}

.story-recap-list li {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
  color: #1c2938;
  font-size: clamp(14px, 1.4vw, 16px);
  line-height: 1.65;
  overflow-wrap: anywhere;
  counter-increment: story-recap;
}

.story-recap-list li::before {
  content: counter(story-recap);
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(20, 127, 134, 0.12);
  color: #125f66;
  font-weight: 1000;
  line-height: 1;
}

.episode-figure-context dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.episode-figure-context dl > div {
  display: grid;
  grid-template-columns: minmax(72px, 0.28fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(234, 247, 243, 0.74);
}

.episode-figure-context dt,
.episode-figure-context dd {
  margin: 0;
}

.episode-figure-context dt {
  color: #125f66;
  font-weight: 1000;
}

.episode-figure-context dd {
  color: #1d2d3c;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.episode-narrator-card,
.episode-narrator-card > div,
.episode-narrator-text {
  min-width: 0;
}

.episode-narrator-text {
  overflow-wrap: anywhere;
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-story-foundation,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-story-foundation {
  grid-template-columns: minmax(0, 1fr);
}

html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .chapter-start-card,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-recap-card,
html[data-visual-mode="simple"] body[data-endpoint="chapter_episode"] .episode-figure-context,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .chapter-start-card,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-recap-card,
body[data-visual-mode="simple"][data-endpoint="chapter_episode"] .episode-figure-context {
  border-color: rgba(24, 132, 139, 0.16);
  background: rgba(255, 255, 255, 0.96);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-story-foundation,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-story-foundation {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.86fr);
  min-height: clamp(132px, 16svh, 144px);
  max-height: min(30svh, 240px);
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  scrollbar-gutter: stable;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .chapter-start-card,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-recap-card,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-figure-context,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .chapter-start-card,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-recap-card,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-figure-context {
  border-color: rgba(70, 240, 255, 0.22);
  background:
    linear-gradient(135deg, rgba(7, 11, 22, 0.88), rgba(23, 35, 52, 0.82)),
    rgba(7, 11, 22, 0.88);
  color: #f4fbff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 16px 34px rgba(7, 11, 22, 0.18);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .chapter-start-card h2,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-recap-card h2,
html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-figure-context h2,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .chapter-start-card h2,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-recap-card h2,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-figure-context h2 {
  color: #fff;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .chapter-start-card > p:not(.eyebrow),
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .chapter-start-card > p:not(.eyebrow) {
  color: rgba(244, 251, 255, 0.84);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .story-recap-list li,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .story-recap-list li {
  color: rgba(244, 251, 255, 0.9);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .story-recap-list li::before,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .story-recap-list li::before {
  background: rgba(70, 240, 255, 0.14);
  color: var(--rpg-cyan);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-figure-context dl > div,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-figure-context dl > div {
  background: rgba(255, 255, 255, 0.07);
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-figure-context dt,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-figure-context dt {
  color: #f6bf5a;
}

html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-figure-context dd,
body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-figure-context dd {
  color: rgba(244, 251, 255, 0.9);
}

@media (max-width: 900px) {
  .episode-story-foundation,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-story-foundation,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-story-foundation {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .episode-topline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .episode-backline {
    gap: 6px;
  }

  .episode-story-foundation {
    gap: 10px;
    margin-bottom: 12px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-story-foundation,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-story-foundation {
    max-height: 30svh;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-bar,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-bar {
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    min-height: 62px;
    overflow: visible;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .dialogue-player-actions,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .dialogue-player-actions {
    flex-wrap: nowrap;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock {
    grid-template-rows: minmax(62px, auto) auto auto minmax(116px, 1fr) auto;
    gap: 6px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock {
    max-height: 23svh;
    overflow: auto;
    overscroll-behavior: contain;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only {
    gap: 5px;
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-video-frame,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock.is-lesson-only .episode-video-frame {
    height: clamp(112px, 14svh, 116px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock > article,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock > article {
    gap: 5px;
    padding: 8px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video-frame,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video-frame {
    height: clamp(116px, 18svh, 148px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line {
    min-height: 116px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line > div,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line > div {
    max-height: 100%;
    overflow: auto;
    padding: 10px !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line p:not(.eyebrow),
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line p:not(.eyebrow) {
    font-size: 15px !important;
    line-height: 1.45 !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line img,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line img {
    height: min(14svh, 92px) !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .chapter-start-card h2,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-recap-card h2,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-figure-context h2,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .chapter-start-card h2,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-recap-card h2,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-figure-context h2 {
    font-size: clamp(18px, 5.4vw, 22px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .story-recap-list,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .story-recap-list {
    gap: 6px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .story-recap-list li,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .story-recap-list li {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 6px;
    overflow: visible;
    font-size: 12px;
    line-height: 1.25;
  }

  .chapter-start-card,
  .episode-recap-card,
  .episode-figure-context {
    padding: 13px;
  }

  .story-recap-list li,
  .episode-figure-context dl > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  .story-recap-list li::before {
    width: 24px;
    height: 24px;
  }

  .episode-narrator-card,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    align-items: start;
  }

  .episode-narrator-mark,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-mark,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-mark {
    width: 44px;
    height: 44px;
    font-size: 1.08rem;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card h3,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card h3,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card h3,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card h3 {
    font-size: clamp(17px, 4.4vw, 20px);
    line-height: 1.34;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-narrator-card .episode-narrator-text,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-narrator-card .episode-narrator-text,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card .episode-narrator-text,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-narrator-card .episode-narrator-text {
    font-size: clamp(15px, 4vw, 17px);
    line-height: 1.62;
  }
}

@media (min-width: 761px) and (max-height: 820px) {
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-story-foundation,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-story-foundation {
    max-height: min(25svh, 190px);
    min-height: clamp(132px, 16svh, 144px);
    gap: 10px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock {
    grid-template-rows: auto auto auto minmax(150px, 1fr) auto;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock {
    gap: 8px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-media-dock > article,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-media-dock > article {
    gap: 4px;
    padding: 5px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-card h2,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video-card strong,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-card h2,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video-card strong {
    max-height: 2.5em;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.25;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-card h2,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-card h2 {
    max-height: none;
    overflow: visible;
    overflow-wrap: anywhere;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-video-frame,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-video-frame {
    height: clamp(86px, 13svh, 102px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-theme-diagram .lamp-cell,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-theme-diagram .lamp-cell {
    min-height: 28px;
    padding: 3px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line {
    min-height: 150px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-line > div,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-line > div {
    max-height: 100%;
    overflow: auto;
    padding: 10px 14px !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line p:not(.eyebrow),
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line p:not(.eyebrow) {
    font-size: 16px !important;
    line-height: 1.38 !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line img,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock .episode-line img {
    height: min(16svh, 116px) !important;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .chapter-start-card,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-recap-card,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-figure-context,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .chapter-start-card,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-recap-card,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-figure-context {
    gap: 7px;
    padding: 12px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .chapter-start-card h2,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-recap-card h2,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-figure-context h2,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .chapter-start-card h2,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-recap-card h2,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-figure-context h2 {
    font-size: clamp(17px, 1.55vw, 21px);
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .chapter-start-card > p:not(.eyebrow),
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .story-recap-list li,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-figure-context dd,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .chapter-start-card > p:not(.eyebrow),
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .story-recap-list li,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-figure-context dd {
    font-size: 13px;
    line-height: 1.45;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .story-recap-list,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .story-recap-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .story-recap-list li,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .story-recap-list li {
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 6px;
    line-height: 1.28;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .story-recap-list li::before,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .story-recap-list li::before {
    width: 20px;
    height: 20px;
    border-radius: 6px;
  }

}

@media (max-height: 520px) {
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"],
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] {
    overflow-x: hidden;
    overflow-y: auto;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .page,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .page,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage {
    height: auto;
    min-height: 100svh;
    overflow: visible;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-stage,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-stage {
    grid-template-rows: auto auto auto;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-play,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-play,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue {
    height: auto;
  }

  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-media-dock,
  html[data-visual-mode="rpg"] body[data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock,
  body[data-visual-mode="rpg"][data-endpoint="chapter_episode"] .episode-dialogue.has-scene-visual.has-media-dock {
    grid-template-rows: auto minmax(132px, 156px) auto minmax(150px, 240px) auto;
  }
}

@media (max-width: 520px) {
  body[data-endpoint="data_quality"] .topnav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
  }

  body[data-endpoint="data_quality"] .topnav a,
  body[data-endpoint="data_quality"] .topnav button {
    display: inline-flex;
    justify-content: center;
    min-width: 0;
    width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 360px) {
  body[data-endpoint="data_quality"] .topnav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
