:root {
  color-scheme: dark;
  --ink: #f5efe5;
  --muted: rgba(245, 239, 229, 0.68);
  --line: rgba(255, 255, 255, 0.14);
  --panel: rgba(16, 14, 13, 0.72);
  --panel-strong: rgba(10, 9, 8, 0.86);
  --accent: #d8a24a;
  --danger: #b95a42;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0d0d0d;
  color: var(--ink);
  font-family: ui-serif, "Songti SC", "Noto Serif CJK SC", Georgia, serif;
}

button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  height: 42px;
  min-width: 42px;
  border-radius: 6px;
  font: 600 15px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: rgba(216, 162, 74, 0.18);
  border-color: rgba(216, 162, 74, 0.5);
}

.vn-shell {
  position: relative;
  width: 100vw;
  height: 100svh;
  overflow: hidden;
  background: #070707;
}

.route-demo {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 8;
  display: grid;
  justify-items: end;
  gap: 8px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.route-demo > button {
  min-height: 36px;
  height: 36px;
  padding: 0 12px;
  color: #16100a;
  background: var(--accent);
  border-color: rgba(255, 255, 255, 0.35);
  font-size: 12px;
  font-weight: 850;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
}

.route-demo-menu {
  width: min(360px, calc(100vw - 48px));
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(216, 162, 74, 0.38);
  border-radius: 8px;
  background: rgba(10, 9, 8, 0.88);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.38);
}

.route-demo-menu[hidden] {
  display: none;
}

.route-demo-menu select {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  font: 700 12px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.route-demo-menu button {
  min-height: 34px;
  height: 34px;
  color: rgba(245, 239, 229, 0.92);
  background: rgba(216, 162, 74, 0.18);
  border-color: rgba(216, 162, 74, 0.46);
  font-size: 12px;
}

.route-demo-menu p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.stage,
.bg,
.vignette,
.grain {
  position: absolute;
  inset: 0;
}

.stage {
  z-index: 0;
}

.bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  filter: saturate(1.05) contrast(1.02);
  transform-origin: center;
  transition: opacity 520ms ease;
  will-change: opacity, transform;
}

.bg.is-active {
  opacity: 1;
  animation: cameraMove var(--camera-duration, 8s) var(--camera-easing, cubic-bezier(0.24, 0.72, 0.28, 1)) forwards;
}

.bg.is-text-scene {
  background:
    linear-gradient(135deg, rgba(36, 31, 27, 0.96), rgba(10, 10, 10, 0.96)),
    radial-gradient(circle at 62% 38%, rgba(216, 162, 74, 0.18), transparent 36%);
}

.vignette {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.66), transparent 28%, transparent 68%, rgba(0, 0, 0, 0.28)),
    linear-gradient(0deg, rgba(0, 0, 0, 0.78), transparent 43%, rgba(0, 0, 0, 0.38));
  pointer-events: none;
}

.grain {
  opacity: 0.14;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.35) 0.6px, transparent 0.6px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
}

.side-rail {
  position: absolute;
  inset: 20px auto 20px 20px;
  width: clamp(260px, 25vw, 320px);
  max-height: calc(100svh - 40px);
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) minmax(110px, 0.88fr);
  gap: 12px;
  padding: 18px 15px 15px;
  background: linear-gradient(180deg, var(--panel-strong), rgba(10, 9, 8, 0.36));
  border-left: 2px solid var(--accent);
  border-radius: 0 10px 10px 0;
  backdrop-filter: blur(18px);
  transition: transform 220ms ease, opacity 220ms ease;
  z-index: 5;
}

.side-rail > div:first-of-type {
  min-width: 0;
  overflow: hidden;
}

.rail-toggle {
  position: absolute;
  top: 12px;
  right: -17px;
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 999px;
  color: #15100b;
  background: var(--accent);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
  z-index: 2;
}

.vn-shell.rail-collapsed .side-rail {
  transform: translateX(calc(-100% - 18px));
  opacity: 0.92;
}

.vn-shell.rail-collapsed .rail-toggle {
  right: -52px;
  transform: rotate(180deg);
}

.vn-shell.rail-collapsed .dialogue-panel {
  left: 32px;
}

.kicker,
.meta-row,
.shot-list button,
.controls button {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(20px, 1.65vw, 28px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.story-select {
  width: 100%;
  max-width: 100%;
  margin-top: 12px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  font: 650 13px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-overflow: ellipsis;
}

.macro-links a,
.story-map-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
  font: 750 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.story-map-link:hover,
.macro-links a:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 162, 74, 0.5);
  background: rgba(216, 162, 74, 0.14);
}

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

.macro-links a {
  margin-top: 0;
  font-size: 12px;
}

.shot-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 6px;
}

.shot-list button {
  width: 100%;
  min-height: 34px;
  height: auto;
  padding: 7px 9px;
  text-align: left;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.shot-list button strong,
.shot-list button span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shot-list button strong {
  font-size: 11px;
  color: rgba(216, 162, 74, 0.84);
}

.shot-list button span {
  margin-top: 2px;
  font-size: 12px;
}

.shot-markers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
  min-width: 0;
}

.shot-marker {
  display: inline-flex;
  align-items: center;
  min-height: 17px;
  padding: 1px 5px;
  border: 1px solid rgba(216, 162, 74, 0.28);
  border-radius: 999px;
  color: rgba(255, 226, 180, 0.9);
  background: rgba(216, 162, 74, 0.12);
  font-size: 10px;
  font-style: normal;
  line-height: 1.1;
  white-space: nowrap;
}

.shot-marker.major {
  color: rgba(255, 244, 219, 0.96);
  border-color: rgba(235, 88, 102, 0.7);
  background: rgba(235, 88, 102, 0.18);
}

.shot-marker.gate {
  color: rgba(231, 244, 255, 0.95);
  border-color: rgba(106, 190, 255, 0.58);
  background: rgba(106, 190, 255, 0.16);
}

.shot-marker.final {
  color: rgba(249, 235, 255, 0.96);
  border-color: rgba(185, 120, 255, 0.68);
  background: rgba(185, 120, 255, 0.17);
}

.shot-marker.relation {
  color: rgba(255, 240, 247, 0.95);
  border-color: rgba(255, 142, 176, 0.54);
  background: rgba(255, 142, 176, 0.14);
}

.shot-marker.war {
  color: rgba(241, 255, 228, 0.95);
  border-color: rgba(165, 214, 110, 0.55);
  background: rgba(165, 214, 110, 0.14);
}

.shot-list button.is-current {
  color: var(--ink);
  background: rgba(216, 162, 74, 0.16);
  border-color: rgba(216, 162, 74, 0.34);
}

.branch-tools {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  min-height: 0;
  overflow: hidden;
}

.branch-tools-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--accent);
  font: 700 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-transform: uppercase;
}

.branch-jump-list {
  display: grid;
  gap: 5px;
  max-height: 118px;
  overflow: auto;
}

.branch-actions {
  display: grid;
  gap: 6px;
  margin-bottom: 7px;
}

.branch-actions button {
  width: 100%;
  min-height: 30px;
  height: auto;
  padding: 6px 8px;
  color: rgba(245, 239, 229, 0.86);
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(216, 162, 74, 0.28);
  font-size: 11px;
  line-height: 1.2;
}

.branch-actions button:disabled {
  cursor: default;
  opacity: 0.45;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.branch-jump-list button {
  width: 100%;
  min-height: 30px;
  height: auto;
  padding: 6px 8px;
  text-align: left;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  font-size: 11px;
  line-height: 1.25;
}

.branch-jump-list button strong,
.branch-jump-list button span {
  display: block;
}

.branch-jump-list button span {
  margin-top: 3px;
  color: rgba(245, 239, 229, 0.62);
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.branch-jump-list .branch-script-button {
  margin-left: 10px;
  width: calc(100% - 10px);
  border-color: rgba(216, 162, 74, 0.28);
  background: rgba(216, 162, 74, 0.1);
}

.branch-empty {
  margin: 0;
  color: var(--muted);
  font: 600 12px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.branch-review-panel {
  display: grid;
  gap: 6px;
  max-height: 150px;
  overflow: auto;
  margin-bottom: 10px;
  padding-right: 4px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.branch-review-panel > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.branch-focus-line {
  color: rgba(216, 162, 74, 0.82) !important;
  font-size: 11px !important;
  font-weight: 800;
}

.branch-review-card {
  border: 1px solid rgba(216, 162, 74, 0.28);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
}

.branch-review-card summary {
  display: grid;
  gap: 3px;
  padding: 7px 8px;
  cursor: pointer;
}

.branch-review-card summary strong,
.branch-review-card summary span {
  display: block;
}

.branch-review-card summary strong {
  color: var(--ink);
  font-size: 12px;
}

.branch-review-card summary span {
  color: rgba(245, 239, 229, 0.62);
  font-size: 11px;
  font-weight: 750;
}

.branch-review-grid {
  display: none;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 5px 8px;
  padding: 0 9px 8px;
  font-size: 11px;
  line-height: 1.35;
}

.branch-review-grid span {
  color: rgba(216, 162, 74, 0.78);
  font-weight: 800;
}

.branch-review-grid b {
  color: var(--muted);
  font-weight: 650;
}

.branch-review-card pre {
  margin: 0 8px 7px;
  max-height: 74px;
  overflow: auto;
  white-space: pre-wrap;
  color: rgba(245, 239, 229, 0.76);
  font: 600 11px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.branch-review-card button {
  width: calc(100% - 16px);
  min-height: 32px;
  height: auto;
  margin: 0 8px 8px;
  color: rgba(245, 239, 229, 0.88);
  background: rgba(216, 162, 74, 0.14);
  border-color: rgba(216, 162, 74, 0.32);
  font-size: 11px;
}

.route-plan-panel {
  display: none;
  max-height: 120px;
  overflow: auto;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.route-plan-panel summary {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  color: var(--ink);
  cursor: pointer;
}

.route-plan-panel summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.route-plan-block {
  padding: 0 9px 8px;
}

.route-plan-block b {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 11px;
}

.route-plan-block p {
  margin: 0 0 6px;
  color: rgba(245, 239, 229, 0.72);
  font-size: 11px;
  line-height: 1.35;
}

.dialogue-panel {
  position: absolute;
  left: clamp(332px, 30vw, 372px);
  right: 32px;
  bottom: 28px;
  min-height: 176px;
  padding: 22px 24px 20px;
  background: linear-gradient(180deg, var(--panel), rgba(9, 9, 9, 0.88));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
  transition: left 220ms ease;
  z-index: 4;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 13px;
}

h2 {
  margin: 12px 0 8px;
  font-size: 22px;
  line-height: 1.15;
  color: var(--accent);
  letter-spacing: 0;
}

#lineText {
  margin: 0;
  max-width: 980px;
  min-height: 58px;
  font-size: clamp(22px, 2.2vw, 34px);
  line-height: 1.42;
  text-wrap: pretty;
}

.gesture {
  margin: 8px 0 0;
  min-height: 20px;
  color: var(--muted);
  font-size: 15px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.choice-panel {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  max-width: 720px;
}

.dice-panel {
  margin-top: 14px;
  max-width: 760px;
  padding: 14px;
  border: 1px solid rgba(216, 162, 74, 0.52);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(216, 162, 74, 0.14), rgba(0, 0, 0, 0.32)),
    rgba(8, 8, 8, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.dice-panel[hidden] {
  display: none;
}

.dice-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.dice-head strong {
  color: var(--ink);
  font-size: 15px;
}

.dice-body {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.die-box {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  color: #17100a;
  background: var(--accent);
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
  font: 900 44px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.dice-detail {
  display: grid;
  gap: 6px;
}

.dice-detail strong {
  color: var(--ink);
  font-size: 18px;
}

.dice-detail span,
.dice-detail em {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  font-style: normal;
}

.dice-detail .dice-pass {
  color: #95d48a;
}

.dice-detail .dice-fail {
  color: #e18b76;
}

.dice-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.dice-actions button {
  min-width: 132px;
  color: #17100a;
  background: var(--accent);
  border-color: rgba(255, 255, 255, 0.28);
}

.choice-panel[hidden] {
  display: none;
}

.choice-prompt {
  margin: 0 0 2px;
  color: var(--accent);
  font: 700 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.choice-bridge-line {
  margin: 0;
  padding: 8px 10px;
  display: grid;
  gap: 3px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  border-left: 3px solid rgba(216, 162, 74, 0.72);
  border-radius: 6px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.choice-bridge-line strong,
.choice-bridge-line span {
  display: block;
}

.choice-bridge-line strong {
  color: rgba(216, 162, 74, 0.92);
  font-size: 12px;
}

.choice-bridge-line span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.choice-panel button {
  width: 100%;
  height: auto;
  min-height: 52px;
  padding: 10px 12px;
  display: grid;
  gap: 5px;
  text-align: left;
  background: rgba(8, 8, 8, 0.62);
  border-color: rgba(216, 162, 74, 0.38);
}

.choice-panel button strong,
.choice-panel button span,
.choice-panel button small {
  display: block;
}

.choice-panel button span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 500;
}

.choice-panel button span:empty {
  display: none;
}

.choice-panel button small {
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  color: rgba(216, 162, 74, 0.86);
  font: 650 12px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.choice-panel button em {
  display: inline-block;
  width: fit-content;
  margin-top: 2px;
  padding: 3px 7px;
  color: #15100b;
  background: var(--accent);
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  font-style: normal;
  font-weight: 800;
}

.variable-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
  min-height: 27px;
}

.variable-status[hidden] {
  display: none;
}

.variable-status-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.variable-status span {
  display: inline-block;
  padding: 4px 8px;
  color: rgba(245, 239, 229, 0.86);
  border: 1px solid rgba(216, 162, 74, 0.34);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  font-size: 12px;
  font-weight: 800;
}

.variable-status .variable-axis {
  color: #15100b;
  background: rgba(216, 162, 74, 0.92);
  border-color: rgba(255, 255, 255, 0.42);
}

.variable-status .variable-heroine_relation {
  border-color: rgba(127, 178, 214, 0.38);
  background: rgba(127, 178, 214, 0.14);
}

.ending-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at center, rgba(84, 14, 10, 0.28), transparent 34%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.72), #000 72%);
  animation: endingFade 900ms ease forwards;
}

.ending-overlay[hidden] {
  display: none;
}

.ending-content {
  width: min(720px, 92vw);
  text-align: center;
}

.ending-kicker {
  margin: 0 0 14px;
  color: var(--danger);
  font: 800 13px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ending-debug {
  margin: 18px auto 16px;
  padding: 12px 14px;
  max-width: 640px;
  text-align: left;
  border: 1px solid rgba(216, 162, 74, 0.42);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.42);
  color: rgba(245, 239, 229, 0.84);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ending-debug strong {
  display: block;
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 12px;
}

.ending-debug p {
  margin: 5px 0;
  font-size: 12px;
  line-height: 1.45;
}

.ending-debug ol {
  margin: 8px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 12px;
  line-height: 1.38;
}

.ending-content h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(38px, 7vw, 82px);
  line-height: 0.96;
}

.ending-content p {
  margin: 18px auto 0;
  max-width: 520px;
  color: rgba(245, 239, 229, 0.78);
  font: 500 17px/1.65 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ending-content button {
  margin-top: 28px;
  min-width: 144px;
  color: #130d0b;
  background: var(--danger);
  border-color: rgba(255, 255, 255, 0.22);
}

.controls {
  position: absolute;
  top: -54px;
  right: 0;
  display: flex;
  gap: 8px;
}

.controls button.is-on {
  color: #15100a;
  background: var(--accent);
  border-color: var(--accent);
}

@keyframes cameraMove {
  from {
    transform: var(--camera-from, scale(1.04));
  }
  to {
    transform: var(--camera-to, scale(1.1));
  }
}

@keyframes endingFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 920px) {
  .side-rail {
    inset: 12px 12px auto 12px;
    width: auto;
    height: auto;
    max-height: 218px;
    grid-template-columns: minmax(170px, 0.9fr) minmax(0, 1.1fr);
    grid-template-rows: minmax(86px, auto) minmax(64px, 1fr);
    gap: 10px 12px;
    padding: 12px;
    overflow: hidden;
  }

  .rail-toggle {
    right: 10px;
    top: auto;
    bottom: -17px;
  }

  .vn-shell.rail-collapsed .side-rail {
    transform: translateY(calc(-100% - 18px));
  }

  .vn-shell.rail-collapsed .rail-toggle {
    right: 10px;
    bottom: -52px;
    transform: rotate(90deg);
  }

  .branch-tools {
    display: none;
  }

  h1 {
    font-size: 24px;
    line-height: 1.05;
  }

  .kicker {
    margin-bottom: 6px;
    font-size: 10px;
  }

  .story-select {
    margin-top: 8px;
    min-height: 32px;
    padding: 7px 8px;
    font-size: 12px;
  }

  .macro-links {
    gap: 6px;
    margin-top: 6px;
  }

  .macro-links a {
    min-height: 30px;
    font-size: 11px;
  }

  .shot-list {
    grid-row: 1 / span 2;
    grid-column: 2;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: stretch;
    padding: 0 0 5px;
    gap: 5px;
  }

  .shot-list button {
    width: 104px;
    flex: 0 0 104px;
    min-height: 70px;
    padding: 7px 8px;
  }

  .shot-list button span {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .dialogue-panel {
    left: 14px;
    right: 14px;
    bottom: 14px;
    min-height: 204px;
    padding: 18px 16px;
  }

  .controls {
    top: -50px;
  }

  #lineText {
    font-size: 22px;
  }

  .dice-body {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .die-box {
    width: 72px;
    height: 72px;
    font-size: 34px;
  }
}

@media (min-width: 921px) and (max-width: 1180px) {
  .side-rail {
    width: 272px;
    inset: 18px auto 18px 18px;
    padding: 16px 13px 13px;
    grid-template-rows: auto minmax(92px, 1fr) minmax(104px, 0.86fr);
    gap: 10px;
  }

  .dialogue-panel {
    left: 308px;
    right: 24px;
  }

  h1 {
    font-size: 20px;
    line-height: 1.1;
  }

  .kicker {
    margin-bottom: 6px;
    font-size: 10px;
  }

  .story-select {
    margin-top: 8px;
    min-height: 32px;
    padding: 7px 8px;
    font-size: 11px;
  }

  .macro-links {
    gap: 6px;
    margin-top: 6px;
  }

  .macro-links a,
  .story-map-link {
    min-height: 30px;
    font-size: 11px;
  }

  .shot-list button {
    padding: 8px 9px;
  }

  .shot-list button strong {
    font-size: 10px;
  }

  .shot-list button span {
    font-size: 11px;
    line-height: 1.15;
  }

  .shot-marker {
    font-size: 9px;
    padding-inline: 4px;
  }

  .branch-review-panel {
    max-height: 120px;
  }

  .branch-jump-list {
    max-height: 96px;
  }
}
