:root {
  color-scheme: dark;
  --bg: #04060a;
  --panel: #0a0e17;
  --panel-2: #101624;
  --ink: #e0f2fe;
  --muted: #8ec5fc;
  --line: #1e293b;
  --gold: #00f2ff;
  --green: #10b981;
  --red: #f43f5e;
  --blue: #38bdf8;
  --purple: #c084fc;
  --shadow: rgba(0, 0, 0, 0.7);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  user-select: none;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 30%, rgba(0, 242, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(56, 189, 248, 0.05) 0%, transparent 40%),
    linear-gradient(180deg, #050814 0%, #020308 52%, #080c1a 100%);
  font-family:
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    system-ui,
    sans-serif;
  letter-spacing: 0.5px;
}

button {
  color: inherit;
  font: inherit;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  background: #000;
  color: #f8fbff;
  touch-action: manipulation;
}

.boot-screen[hidden] {
  display: none;
}

.boot-start {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 0 18px;
  text-align: center;
}

.boot-tap-button {
  border: 0;
  background: transparent;
  color: #f8fbff;
  font-family: Georgia, "Times New Roman", "Hiragino Mincho ProN", serif;
  font-size: clamp(30px, 7vw, 56px);
  font-weight: 800;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(122, 223, 255, 0.82);
  cursor: pointer;
  animation: bootTapBlink 1.25s ease-in-out infinite;
}

.boot-screen.is-loading .boot-tap-button {
  animation: none;
  opacity: 0.48;
}

.boot-audio-note {
  margin: 0;
  color: rgba(248, 251, 255, 0.82);
  font-size: clamp(12px, 3.3vw, 15px);
  line-height: 1.4;
  letter-spacing: 0;
  text-shadow: 0 0 10px rgba(122, 223, 255, 0.35);
}

.boot-status {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(34px, env(safe-area-inset-bottom));
  margin: 0;
  color: rgba(248, 251, 255, 0.78);
  text-align: center;
  font-size: 13px;
}

@keyframes bootTapBlink {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1.04);
  }
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
}

.topbar {
  min-height: 64px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(13, 17, 17, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px var(--shadow);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.crest {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #00f2ff 0 15%, transparent 20%),
    radial-gradient(circle at 50% 50%, transparent 0 45%, #005f73 50%, transparent 55%),
    conic-gradient(from 0deg, var(--gold), #0f172a, var(--gold), #0284c7, var(--gold));
  box-shadow: 0 0 10px rgba(0, 242, 255, 0.4);
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.1;
  white-space: nowrap;
}

#chapter-label {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.resources {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.resource-chip {
  min-width: 94px;
  padding: 6px 8px;
  border: 1px solid rgba(216, 161, 60, 0.45);
  border-radius: 6px;
  background: rgba(24, 24, 18, 0.92);
}

.resource-chip span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.resource-chip strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.game-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(300px, 1fr);
  gap: 10px;
}

.play-surface {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #050607;
  box-shadow: 0 12px 30px var(--shadow);
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  image-rendering: pixelated;
  background: #060707;
  cursor: pointer;
  touch-action: none;
  overscroll-behavior: contain;
}

.map-hotspots {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.map-hotspots[hidden] {
  display: none;
}

.map-pin-button {
  position: absolute;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  filter: drop-shadow(0 4px 7px rgba(0, 0, 0, 0.72));
}

.map-pin-face {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: 28px;
  height: 28px;
  border: 2px solid var(--pin-color, var(--gold));
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 242, 199, 0.95) 0 2px, transparent 3px),
    radial-gradient(circle at 50% 50%, rgba(5, 8, 12, 0.08) 0 58%, rgba(5, 8, 12, 0.4) 60% 100%);
  box-shadow:
    0 0 0 2px rgba(3, 5, 8, 0.72),
    0 0 14px rgba(122, 223, 255, 0.35);
  transform: translate(-50%, -50%);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.map-pin-face::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  width: 2px;
  height: 38px;
  border-radius: 999px;
  background: rgba(255, 226, 161, 0.72);
  transform: translateX(-50%);
}

.map-pin-face::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  width: 38px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 226, 161, 0.72);
  box-shadow: none;
  transform: translateY(-50%);
}

.map-pin-face i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff2c7;
  box-shadow: 0 0 8px rgba(255, 226, 161, 0.95);
  transform: translate(-50%, -50%);
}

.map-pin-number {
  display: none;
}

.map-pin-label {
  position: absolute;
  left: 50%;
  top: 39px;
  min-width: 64px;
  padding: 4px 6px;
  border: 1px solid rgba(216, 161, 60, 0.75);
  border-radius: 6px;
  background: rgba(6, 8, 8, 0.92);
  color: #ffe2a1;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
}

.map-pin-button.is-selected .map-pin-face {
  border-color: #ffe2a1;
  box-shadow:
    0 0 0 4px rgba(255, 226, 161, 0.24),
    0 0 20px rgba(216, 161, 60, 0.86);
  transform: translate(-50%, -50%) scale(1.18);
}

.map-pin-button.is-cleared .map-pin-face {
  border-color: #b6f28a;
}

.map-pin-button.is-locked .map-pin-face {
  filter: grayscale(0.95);
  opacity: 0.28;
}

.map-pin-button:focus-visible .map-pin-face {
  outline: 2px solid #ffe2a1;
  outline-offset: 3px;
}

.canvas-hud {
  position: absolute;
  inset: 8px 8px auto 8px;
  z-index: 3;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.battle-overlay-controls {
  position: absolute;
  right: 12px;
  bottom: 14px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(2, 58px);
  gap: 8px;
  pointer-events: auto;
  touch-action: none;
}

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

.battle-map-button {
  position: relative;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 1px solid rgba(255, 226, 161, 0.85);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.28), transparent 28%),
    linear-gradient(180deg, rgba(44, 34, 18, 0.98), rgba(12, 16, 16, 0.96));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.48);
  color: #ffe2a1;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.battle-map-button.skill {
  border-color: rgba(122, 223, 255, 0.82);
  color: #d9f4ff;
}

.battle-map-button.is-ready {
  box-shadow:
    0 0 0 2px rgba(122, 223, 255, 0.22),
    0 0 18px rgba(85, 175, 215, 0.72);
}

.battle-map-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.65);
  opacity: 0.56;
}

.battle-map-button span {
  display: block;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.battle-map-button i {
  display: block;
  margin-top: 4px;
  font-style: normal;
  font-size: 9px;
  line-height: 1;
}

.title-screen {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #020308;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.title-screen[hidden] {
  display: none;
}

.title-screen-art {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
  object-position: center;
  background: #020308;
  pointer-events: none;
}

.title-menu {
  position: absolute;
  left: 50%;
  top: 54%;
  z-index: 1;
  display: grid;
  width: min(250px, 52vw);
  gap: clamp(5px, 1dvh, 10px);
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.title-menu-button {
  position: relative;
  width: 100%;
  aspect-ratio: 424 / 144;
  padding: 0 18%;
  border: 0;
  border-radius: 999px;
  background: url("../titlebotton.png") center / 100% 100% no-repeat;
  color: #f8fbff;
  text-align: center;
  font-family: Georgia, "Times New Roman", "Hiragino Mincho ProN", serif;
  font-size: clamp(18px, 3.5vw, 30px);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.85),
    0 0 14px rgba(122, 223, 255, 0.72);
  cursor: pointer;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.54));
  touch-action: manipulation;
}

.title-menu-button span {
  position: relative;
  top: -1px;
}

.title-menu-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.9) brightness(0.62) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
  opacity: 0.62;
}

.title-menu-button:not(:disabled):active {
  transform: translateY(2px) scale(0.985);
}

.title-save-slot-panel {
  position: relative;
  z-index: 2;
  width: min(520px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  overflow-y: auto;
  padding: 14px;
  border: 2px solid rgba(85, 175, 215, 0.72);
  border-radius: 12px;
  background: rgba(8, 12, 16, 0.96);
  box-shadow: 0 0 35px rgba(0, 242, 255, 0.38);
  pointer-events: auto;
}

.start-op-screen {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.start-op-screen[hidden] {
  display: none;
}

.start-op-video {
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
  object-position: center;
  background: #000;
}

.clear-result-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: #020308;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

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

.clear-result-overlay img {
  display: block;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
  object-position: center;
  background: #020308;
}

body.is-battle-view .game-layout {
  grid-template-columns: minmax(320px, min(540px, calc((100dvh - 104px) * 0.75), 100%));
  justify-content: center;
}

body.is-battle-view .side-panel,
body.is-battle-view .quick-actions,
body.is-battle-view .tab-button:not([data-view="map"]) {
  display: none;
}

body.is-battle-view .tabbar {
  position: absolute;
  left: 12px;
  right: auto;
  bottom: 174px;
  z-index: 5;
  display: grid;
  grid-template-columns: 52px;
  overflow: visible;
  pointer-events: auto;
}

body.is-battle-view .tab-button[data-view="map"] {
  position: relative;
  min-width: 52px;
  width: 52px;
  min-height: 52px;
  padding: 0;
  border-color: rgba(122, 223, 255, 0.88);
  border-radius: 10px;
  background: rgba(9, 17, 22, 0.94);
  box-shadow:
    0 0 0 2px rgba(0, 242, 255, 0.22),
    0 8px 18px rgba(0, 0, 0, 0.52);
  font-size: 0;
  touch-action: manipulation;
}

body.is-battle-view .tab-button[data-view="map"]::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 11px;
  width: 23px;
  height: 21px;
  border: 2px solid #ffe2a1;
  border-radius: 2px;
  background:
    linear-gradient(90deg, transparent 0 30%, rgba(255, 226, 161, 0.75) 31% 35%, transparent 36% 64%, rgba(255, 226, 161, 0.75) 65% 69%, transparent 70%),
    linear-gradient(135deg, rgba(85, 175, 215, 0.22), rgba(216, 161, 60, 0.22));
  transform: skewY(-8deg);
}

body.is-battle-view .roster-rail {
  position: absolute;
  left: 12px;
  bottom: 14px;
  z-index: 5;
  width: min(calc(100vw - 24px), 640px);
  pointer-events: auto;
}

body.is-clear-result-view .canvas-hud,
body.is-clear-result-view .command-area,
body.is-clear-result-view .battle-overlay-controls {
  display: none;
}

#view-title,
#battle-clock {
  max-width: 48%;
  padding: 5px 7px;
  border: 1px solid rgba(216, 161, 60, 0.55);
  border-radius: 6px;
  background: rgba(7, 9, 9, 0.78);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.25;
}

body.is-battle-view .canvas-hud {
  justify-content: flex-start;
}

body.is-battle-view #battle-clock {
  position: absolute;
  top: 0;
  left: 50%;
  min-width: 54px;
  max-width: none;
  text-align: center;
  transform: translateX(-50%);
}

.side-panel {
  min-height: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 19, 18, 0.94);
  box-shadow: 0 12px 30px var(--shadow);
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(216, 161, 60, 0.32);
}

.panel-title h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.panel-title p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.badge {
  flex: 0 0 auto;
  min-width: 52px;
  padding: 5px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--gold);
  text-align: center;
  font-size: 11px;
}

.stat-grid,
.logistics-grid,
.skill-grid {
  display: grid;
  gap: 8px;
}

.stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 10px 0;
}

.stat {
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

body.is-battle-view .command-area {
  position: absolute;
  inset: 0;
  z-index: 6;
  min-height: 0;
  pointer-events: none;
}

body.is-battle-view .app-shell {
  grid-template-rows: auto minmax(0, 1fr);
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.command-area {
  position: relative;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.tabbar,
.quick-actions {
  display: flex;
  gap: 6px;
}

.tabbar {
  overflow-x: auto;
  padding-bottom: 1px;
}

.tab-button,
.action-button,
.skill-button,
.logistics-button,
.stage-button,
.small-button {
  position: relative;
  min-height: 38px;
  border: 1px solid rgba(216, 161, 60, 0.5);
  border-radius: 6px;
  background: rgba(19, 23, 22, 0.96);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}

.tab-button {
  min-width: 74px;
  padding: 0 12px;
}

.tab-button.is-active,
.action-button.primary,
.stage-button.is-selected {
  border-color: var(--gold);
  background: #2a2113;
  color: #ffe2a1;
}

.action-button,
.small-button {
  padding: 0 10px;
}

.action-button:disabled,
.skill-button:disabled,
.logistics-button:disabled,
.stage-button:disabled,
.small-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.action-button:not(:disabled):active,
.skill-button:not(:disabled):active,
.logistics-button:not(:disabled):active,
.stage-button:not(:disabled):active,
.small-button:not(:disabled):active,
.save-slot-action:not(:disabled):active {
  transform: translateY(1px) scale(0.985);
  filter: brightness(1.18);
}

.quick-actions {
  min-height: 38px;
  overflow-x: auto;
}

.map-panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.map-panel-actions .action-button {
  flex: 1 1 0;
}

.save-slot-list {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.save-slot-card {
  width: 100%;
  min-height: 72px;
  padding: 9px;
  border: 1px solid rgba(216, 161, 60, 0.5);
  border-radius: 6px;
  background: rgba(15, 27, 27, 0.96);
  color: var(--ink);
  text-align: left;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.save-slot-card.is-auto {
  cursor: default;
  border-color: rgba(85, 175, 215, 0.55);
  background: rgba(8, 15, 18, 0.78);
}

.save-slot-card.is-empty {
  cursor: default;
  opacity: 0.68;
}

.save-slot-card strong {
  display: block;
  color: #ffe2a1;
  font-size: 13px;
  line-height: 1.25;
}

.save-slot-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.save-slot-card small {
  display: block;
  margin-top: 5px;
  color: #e9dfc7;
  font-size: 10px;
  line-height: 1.3;
}

.save-slot-card em {
  color: #79d7ff;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.save-slot-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.save-slot-action {
  position: relative;
  z-index: 2;
  min-width: 54px;
  min-height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  color: #f8fbff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}

.save-slot-action.save {
  border: 1px solid rgba(85, 175, 215, 0.92);
  background: rgba(22, 95, 145, 0.92);
  box-shadow: 0 0 12px rgba(85, 175, 215, 0.28);
}

.save-slot-action.load {
  border: 1px solid rgba(244, 63, 94, 0.95);
  background: rgba(130, 34, 46, 0.95);
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.25);
}

.save-slot-title-close {
  min-width: 72px;
}

.save-slot-bottom-close {
  width: 100%;
  margin-top: 8px;
}

.roster-rail {
  display: grid;
  grid-template-columns: repeat(10, minmax(84px, 1fr));
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-behavior: auto;
  touch-action: none;
  padding-bottom: 2px;
}

.ally-card {
  position: relative;
  min-width: 92px;
  height: 88px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(17, 22, 21, 0.96);
  text-align: left;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.ally-card.is-selected {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(85, 175, 215, 0.5);
}

.ally-card.is-skill-ready {
  border-color: #7adfff;
  box-shadow: 0 0 10px rgba(85, 175, 215, 0.45);
}

.ally-card.is-down {
  filter: grayscale(0.8);
  opacity: 0.62;
}

.ally-card img {
  position: absolute;
  right: 3px;
  bottom: 14px;
  width: 42px;
  height: 48px;
  object-fit: contain;
  image-rendering: pixelated;
}

.ally-card strong {
  display: block;
  width: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.ally-card span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.bar {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #311817;
}

.bar i {
  display: block;
  height: 100%;
  width: var(--value, 100%);
  background: var(--green);
}

.skill-charge {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 14px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #142736;
}

.skill-charge i {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: var(--blue);
}

.section {
  margin-top: 12px;
}

.section h3 {
  margin: 0 0 7px;
  color: #f2cc7a;
  font-size: 13px;
  line-height: 1.2;
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.stage-button {
  padding: 7px;
  text-align: left;
}

.stage-button strong {
  display: block;
  font-size: 12px;
  line-height: 1.25;
}

.stage-button span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

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

.skill-button {
  min-height: 72px;
  padding: 7px;
  text-align: left;
  background: rgba(26, 21, 28, 0.96);
}

.skill-button strong,
.logistics-button strong {
  display: block;
  font-size: 12px;
}

.skill-button span,
.logistics-button span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.logistics-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
}

.logistics-button {
  min-height: 88px;
  padding: 8px;
  text-align: left;
  background: rgba(15, 27, 27, 0.96);
}

.message-log {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  margin-top: 8px;
  padding-right: 2px;
}

.message-log p {
  padding: 6px 8px;
  border-left: 3px solid rgba(216, 161, 60, 0.75);
  background: rgba(255, 255, 255, 0.035);
  color: #e9dfc7;
  font-size: 12px;
  line-height: 1.45;
}

.meter-line {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.meter-line i {
  display: block;
  height: 100%;
  width: var(--value, 50%);
  background: var(--gold);
}

.meter-line.tech i {
  background: var(--blue);
}

.meter-caption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 7px 0 5px;
  color: var(--muted);
  font-size: 10px;
}

.meter-caption strong {
  color: #d9efff;
}

.result-banner {
  margin-top: 10px;
  padding: 9px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: rgba(44, 32, 17, 0.8);
}

.result-banner strong {
  display: block;
  margin-bottom: 4px;
}

.result-banner.is-clear-result {
  background: rgba(12, 20, 22, 0.88);
}

.result-banner.is-clear-result.is-true-clear {
  background: rgba(2, 3, 8, 0.94);
}

.clear-result-art {
  display: grid;
  place-items: center;
  min-height: 158px;
  margin-bottom: 10px;
  border: 1px solid rgba(216, 161, 60, 0.72);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(85, 175, 215, 0.22), rgba(216, 161, 60, 0.18), rgba(5, 7, 7, 0.82)),
    var(--clear-image, none);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover, contain;
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.42);
}

.clear-result-art.is-true-clear {
  min-height: min(72dvh, 760px);
  background-color: #020308;
  background-repeat: no-repeat;
  background-size: contain;
}

.clear-result-art span {
  color: #ffe2a1;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.join-card {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 9px;
  margin: 8px 0 10px;
  padding: 8px;
  border: 1px solid rgba(85, 175, 215, 0.55);
  border-radius: 6px;
  background: rgba(8, 15, 18, 0.74);
}

.join-card img {
  width: 62px;
  height: 62px;
  object-fit: cover;
  border: 1px solid var(--blue);
  background: #0b1214;
}

.join-card span,
.join-card small,
.join-card em {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.join-card p {
  margin: 5px 0;
  color: var(--text);
  line-height: 1.45;
}

.join-card em {
  color: #d9efff;
  font-style: normal;
}

.dialogue-event {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: rgba(12, 28, 36, 0.82);
}

.dialogue-event strong {
  display: block;
  margin-bottom: 5px;
  color: #d9efff;
}

.dialogue-event p {
  margin: 0 0 9px;
  color: var(--text);
  line-height: 1.55;
}

@media (max-width: 860px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  .app-shell,
  .play-surface,
  .command-area {
    touch-action: none;
  }

  .app-shell {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding: 6px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 6px;
  }

  .topbar {
    min-height: 0;
    align-items: center;
    flex-direction: row;
    gap: 6px;
    padding: 5px 6px;
  }

  .brand {
    flex: 0 0 104px;
    gap: 6px;
  }

  .crest {
    width: 28px;
    height: 28px;
  }

  h1 {
    font-size: 18px;
  }

  #chapter-label {
    margin-top: 1px;
    font-size: 12px;
  }

  .resources {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    min-width: 0;
  }

  .resource-chip {
    min-width: 0;
    padding: 4px 5px;
  }

  .resource-chip span {
    font-size: 10px;
  }

  .resource-chip strong {
    margin-top: 2px;
    font-size: 14px;
  }

  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(70px, 13dvh);
    gap: 5px;
    min-height: 0;
    overflow: hidden;
  }

  body.is-battle-view .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .play-surface {
    width: min(100%, 540px, max(250px, calc((100dvh - 350px) * 0.75)));
    margin: 0 auto;
  }

  body.is-battle-view .play-surface {
    width: min(100%, 540px, max(300px, calc((100dvh - 98px) * 0.75)));
  }

  .side-panel {
    height: min(112px, 14dvh);
    min-height: 70px;
    max-height: none;
    padding: 6px;
    overscroll-behavior: contain;
  }

  .panel-title {
    align-items: center;
    gap: 6px;
    padding-bottom: 5px;
  }

  .panel-title h2 {
    font-size: 17px;
  }

  .panel-title p {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.25;
  }

  .badge {
    min-width: 42px;
    padding: 4px 5px;
    font-size: 12px;
  }

  .stat-grid {
    gap: 5px;
    margin: 6px 0;
  }

  .stat {
    padding: 5px;
  }

  .stat strong {
    margin-top: 2px;
    font-size: 14px;
  }

  .section {
    margin-top: 7px;
  }

  .section h3 {
    margin-bottom: 5px;
    font-size: 13px;
  }

  .message-log {
    max-height: 74px;
    gap: 4px;
    margin-top: 5px;
  }

  .message-log p {
    padding: 4px 6px;
    font-size: 12px;
    line-height: 1.25;
  }

  .command-area {
    gap: 4px;
    min-height: 0;
  }

  .tabbar,
  .quick-actions {
    display: grid;
    gap: 4px;
    overflow: hidden;
  }

  .tabbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding-bottom: 0;
  }

  .quick-actions {
    grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
    min-height: 30px;
  }

  body.is-battle-view .tabbar {
    left: 9px;
    right: auto;
    bottom: 90px;
    grid-template-columns: 52px;
  }

  body.is-battle-view .roster-rail {
    left: 9px;
    bottom: 10px;
    width: min(calc(100vw - 18px), 420px);
  }

  .battle-overlay-controls {
    right: 9px;
    bottom: 116px;
    grid-template-columns: 64px;
    grid-auto-rows: 64px;
    gap: 12px;
  }

  .battle-map-button {
    width: 64px;
    height: 64px;
  }

  .battle-map-button span {
    font-size: 13px;
  }

  .tab-button,
  .action-button,
  .small-button {
    min-width: 0;
    min-height: 38px;
    padding: 0 5px;
    font-size: 14px;
  }

  .roster-rail {
    grid-template-columns: repeat(10, 54px);
    gap: 4px;
    padding-bottom: 0;
  }

  .ally-card {
    min-width: 54px;
    height: 50px;
    padding: 4px;
  }

  .ally-card img {
    right: 1px;
    bottom: 8px;
    width: 28px;
    height: 32px;
  }

  .ally-card strong {
    width: 42px;
    font-size: 11px;
  }

  .ally-card > span:not(.bar):not(.skill-charge) {
    display: none;
  }

  .bar {
    left: 4px;
    right: 4px;
    bottom: 4px;
    height: 4px;
  }

  .skill-charge {
    left: 4px;
    right: 4px;
    bottom: 10px;
    height: 3px;
  }

  #view-title,
  #battle-clock {
    padding: 4px 6px;
    font-size: 13px;
  }

  .map-pin-button {
    width: 38px;
    height: 38px;
  }

  .map-pin-face {
    width: 28px;
    height: 28px;
  }

  .map-pin-face::before {
    left: 4px;
    right: 4px;
    top: 4px;
    height: 9px;
  }

  .map-pin-face::after {
    left: 8px;
    top: 14px;
    width: 3px;
    height: 3px;
    box-shadow: 9px 0 0 #101313;
  }

  .map-pin-face i {
    left: 12px;
    top: 20px;
    width: 6px;
  }

  .map-pin-number {
    top: -6px;
    min-width: 16px;
    height: 14px;
    font-size: 9px;
    line-height: 11px;
  }

  .map-pin-label {
    top: 33px;
    min-width: 56px;
    padding: 3px 5px;
    font-size: 9px;
  }

  .logistics-grid,
  .skill-grid,
  .stage-list {
    grid-template-columns: 1fr;
  }
}

/* キャラクター詳細モーダル */
body.roster-detail-active .side-panel {
  position: fixed;
  inset: 10px;
  z-index: 1000;
  width: calc(100% - 20px) !important;
  max-width: 440px;
  height: calc(100dvh - 20px) !important;
  max-height: 580px;
  margin: auto;
  background: rgba(8, 12, 22, 0.98);
  border: 2px solid var(--gold);
  border-radius: 12px;
  box-shadow: 0 0 35px rgba(0, 242, 255, 0.45);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 14px;
}

body.roster-detail-active::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(4, 6, 10, 0.85);
  backdrop-filter: blur(2px);
}

body.save-slot-active .side-panel {
  position: fixed;
  inset: 10px;
  z-index: 1100;
  width: calc(100% - 20px) !important;
  max-width: 520px;
  height: auto !important;
  max-height: calc(100dvh - 20px);
  margin: auto;
  background: rgba(8, 12, 16, 0.98);
  border: 2px solid rgba(85, 175, 215, 0.7);
  border-radius: 12px;
  box-shadow: 0 0 35px rgba(0, 242, 255, 0.35);
  overflow-y: auto;
  padding: 14px;
}

body.save-slot-active::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1099;
  background: rgba(4, 6, 10, 0.78);
  backdrop-filter: blur(2px);
}

body.roster-detail-active .command-area,
body.map-detail-active .command-area {
  position: relative;
  z-index: 1002;
}

body.save-slot-active .command-area {
  pointer-events: none;
}

@media (max-width: 860px) {
  body.roster-detail-active .side-panel {
    inset: 8px 8px calc(148px + env(safe-area-inset-bottom)) 8px;
    width: calc(100% - 16px) !important;
    height: auto !important;
    max-height: none;
    margin: 0 auto;
    padding: 12px 12px 22px;
  }

  body.roster-detail-active .side-panel .skill-grid {
    margin-bottom: 10px;
  }
}

/* 地図モーダル */
body.map-detail-active .play-surface {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0;
  background: #000;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

body.map-detail-active #game-canvas {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  aspect-ratio: 3 / 4;
}

body.map-detail-active::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(4, 6, 10, 0.85);
  backdrop-filter: blur(2px);
}

.map-close-button {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 10;
  display: none;
  min-height: 28px;
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--red);
  background: rgba(244, 63, 94, 0.1);
  color: var(--ink);
}

body.map-detail-active .map-close-button {
  display: block;
}
