:root {
  color-scheme: dark;
  --bg-deep: #040812;
  --glass-bg: rgba(10, 18, 34, 0.64);
  --glass-bg-strong: rgba(8, 14, 28, 0.82);
  --glass-border: rgba(140, 215, 255, 0.24);
  --glass-highlight: rgba(255, 255, 255, 0.12);
  --text-main: #f0f7ff;
  --text-sub: #9cb4cf;
  --text-muted: #6c84a3;
  --cyan: #00e5ff;
  --cyan-glow: rgba(0, 229, 255, 0.45);
  --crimson: #ff2a5f;
  --crimson-glow: rgba(255, 42, 95, 0.45);
  --gold: #ffd166;
  --gold-glow: rgba(255, 209, 102, 0.45);
  --emerald: #10b981;
  --font-display: 'Orbitron', 'Rajdhani', sans-serif;
  --font-tech: 'Rajdhani', 'Orbitron', monospace;
  --font-sans: 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  --font-serif: 'Shippori Mincho', serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* ==================== 3D キャンバス背景 ==================== */
#canvas-container {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#webgl-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.vignette-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 45%, transparent 52%, rgba(2, 6, 15, 0.62) 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0px, rgba(255, 255, 255, 0.012) 1px, transparent 1px, transparent 3px);
}

.screen-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(0, 229, 255, 0.4) 60%, transparent 100%);
  transition: opacity 0.35s ease-out;
}

.screen-flash.active {
  opacity: 0.85;
  transition: none;
}

/* ==================== アプリルート＆共通画面 ==================== */
#app {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.screen[hidden],
[hidden] {
  display: none !important;
}

/* グラスモーフィズム共通パネル */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(145%);
  -webkit-backdrop-filter: blur(16px) saturate(145%);
  border: 1px solid var(--glass-border);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 var(--glass-highlight);
  border-radius: 16px;
  pointer-events: auto;
}

.glass-pill {
  background: rgba(8, 16, 32, 0.68);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  pointer-events: auto;
}

/* ==================== ボタン共通 ==================== */
button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.btn {
  min-height: 48px;
  min-width: 160px;
  padding: 0.6rem 1.4rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 229, 255, 0.5);
  background: linear-gradient(135deg, rgba(0, 180, 230, 0.32) 0%, rgba(12, 42, 82, 0.78) 100%);
  color: #ffffff;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  pointer-events: auto;
  text-align: center;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #7df9ff;
  box-shadow: 0 0 24px var(--cyan-glow), inset 0 0 12px rgba(0, 229, 255, 0.25);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  border-color: rgba(0, 229, 255, 0.72);
  box-shadow: 0 4px 20px rgba(0, 229, 255, 0.25);
}

.btn-gold {
  border-color: rgba(255, 209, 102, 0.8);
  background: linear-gradient(135deg, rgba(255, 190, 60, 0.36) 0%, rgba(70, 45, 10, 0.82) 100%);
  box-shadow: 0 4px 24px rgba(255, 209, 102, 0.32);
}

.btn-secondary {
  border-color: rgba(156, 180, 207, 0.35);
  background: rgba(20, 32, 54, 0.75);
}

.btn-main-text {
  font-family: var(--font-display);
  font-size: clamp(0.82rem, 2.2vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.btn-sub-text {
  font-size: clamp(0.68rem, 1.8vw, 0.78rem);
  color: #cbe8ff;
  font-weight: 500;
}

.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--text-main);
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.icon-btn:hover {
  border-color: var(--cyan);
  transform: scale(1.04);
}

/* ==================== 1. タイトル画面 ==================== */
.title-screen {
  align-items: center;
  justify-content: center;
}

.title-glass-panel {
  width: min(100%, 620px);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(1rem, 3.5vh, 2.2rem) clamp(1rem, 4vw, 2.5rem);
  background: linear-gradient(160deg, rgba(8, 18, 38, 0.72) 0%, rgba(4, 10, 24, 0.84) 100%);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(130, 220, 255, 0.32);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.72),
    0 0 40px rgba(0, 229, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.55rem, 1.8vh, 1.1rem);
  pointer-events: auto;
}

.title-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: var(--font-tech);
  font-size: clamp(0.62rem, 1.8vw, 0.76rem);
  letter-spacing: 0.14em;
  color: var(--cyan);
}

.meta-divider {
  width: 16px;
  height: 1px;
  background: rgba(0, 229, 255, 0.45);
}

.title-emblem {
  position: relative;
  width: clamp(44px, 8vh, 72px);
  height: clamp(44px, 8vh, 72px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.emblem-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 229, 255, 0.6);
}

.emblem-ring.ring-outer {
  inset: 0;
  border-top-color: var(--gold);
  border-bottom-color: var(--gold);
  animation: spinSlow 12s linear infinite;
}

.emblem-ring.ring-mid {
  inset: 8px;
  border-left-color: transparent;
  border-right-color: #ffffff;
  animation: spinReverse 8s linear infinite;
}

.emblem-core {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, var(--cyan) 65%, transparent 100%);
  box-shadow: 0 0 16px var(--cyan);
}

@keyframes spinSlow {
  to { transform: rotate(360deg); }
}

@keyframes spinReverse {
  to { transform: rotate(-360deg); }
}

.title-logo {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 5.2vw, 2.65rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.15;
  background: linear-gradient(135deg, #ffffff 0%, #aeeeff 45%, #ffd166 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 32px rgba(0, 229, 255, 0.25);
}

.title-sub {
  font-family: var(--font-serif);
  font-size: clamp(0.78rem, 2.3vw, 1.05rem);
  font-weight: 600;
  letter-spacing: 0.15em;
  color: #d6e8ff;
}

.title-synopsis {
  font-size: clamp(0.74rem, 2vw, 0.9rem);
  line-height: 1.65;
  color: var(--text-sub);
  max-width: 52ch;
}

.title-synopsis strong {
  color: #ffffff;
}

.title-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 0.2rem;
}

.title-actions .btn {
  width: min(100%, 320px);
}

.title-footer-info {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  font-family: var(--font-tech);
  font-size: clamp(0.62rem, 1.6vw, 0.74rem);
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* ==================== 2. プレイ画面 上部 HUD ==================== */
.play-screen {
  justify-content: space-between;
}

.top-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  width: 100%;
  z-index: 5;
  flex: none;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.area-indicator {
  padding: 0.35rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
}

.area-code {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.area-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-badges {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.module-pill {
  min-height: 36px;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-family: var(--font-tech);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(10, 20, 38, 0.75);
  border: 1px solid rgba(140, 215, 255, 0.3);
  color: var(--text-main);
  pointer-events: auto;
  white-space: nowrap;
}

.module-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.module-pill.crimson-active {
  border-color: rgba(255, 42, 95, 0.75);
  color: #ffd6e0;
}

.module-pill.crimson-active .dot {
  background: var(--crimson);
  box-shadow: 0 0 10px var(--crimson);
}

.module-pill.gold-active {
  border-color: rgba(255, 209, 102, 0.8);
  color: #fff0c2;
}

.module-pill.gold-active .dot {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}

.module-pill.locked {
  opacity: 0.55;
}

/* ==================== 演出バナー ==================== */
.tactical-banner {
  position: absolute;
  top: 7.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  padding: 0.5rem 1.4rem;
  background: rgba(6, 14, 30, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--cyan);
  border-bottom: 1px solid var(--cyan);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65), 0 0 24px rgba(0, 229, 255, 0.25);
  text-align: center;
  pointer-events: none;
  width: min(92%, 460px);
  animation: bannerIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes bannerIn {
  from {
    opacity: 0;
    transform: translate(-50%, -10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.banner-code {
  font-family: var(--font-tech);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  color: var(--cyan);
}

.banner-title {
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.8vw, 1.25rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #ffffff;
}

/* ==================== 2A. 探索パート UI ==================== */
.explore-layer {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  pointer-events: none;
}

.crystal-screen-marker {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  background: rgba(4, 16, 34, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 229, 255, 0.75);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: #ffffff;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
  pointer-events: auto;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.crystal-screen-marker:hover {
  transform: translate(-50%, -50%) scale(1.06);
  box-shadow: 0 0 28px rgba(0, 229, 255, 0.75);
}

.marker-reticle {
  width: 12px;
  height: 12px;
  border: 2px solid var(--cyan);
  transform: rotate(45deg);
  box-shadow: 0 0 8px var(--cyan);
  flex: none;
}

.marker-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.explore-bottom-dock {
  width: min(100%, 680px);
  padding: clamp(0.75rem, 2vh, 1.15rem) clamp(0.85rem, 2.5vw, 1.4rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.explore-info {
  flex: 1;
  min-width: 0;
}

.objective-tag {
  font-family: var(--font-tech);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--cyan);
  margin-bottom: 0.2rem;
}

.objective-desc {
  font-size: clamp(0.78rem, 2vw, 0.92rem);
  line-height: 1.45;
  color: var(--text-main);
}

.btn-explore {
  flex: none;
  min-width: 210px;
}

/* ==================== 2B. アーカイブ記録 / シナリオ対話パネル ==================== */
.narrative-layer {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 0.5rem;
  pointer-events: none;
}

.narrative-card {
  width: min(100%, 720px);
  max-height: calc(100dvh - 5.5rem);
  overflow-y: auto;
  padding: clamp(1rem, 2.5vh, 1.6rem) clamp(1rem, 3vw, 1.8rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-color: rgba(0, 229, 255, 0.45);
}

.narrative-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(140, 215, 255, 0.2);
  padding-bottom: 0.45rem;
}

.narrative-tag {
  font-family: var(--font-tech);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--cyan);
}

.narrative-page {
  font-family: var(--font-tech);
  font-size: 0.76rem;
  color: var(--text-sub);
}

.narrative-title {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.8vw, 1.35rem);
  font-weight: 800;
  color: #ffffff;
}

.narrative-body {
  font-size: clamp(0.84rem, 2.2vw, 1rem);
  line-height: 1.75;
  color: #dcebff;
  min-height: 3.4em;
}

.narrative-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.25rem;
}

/* ==================== 2C. バトル画面 UI ==================== */
.battle-layer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
  padding-top: 0.3rem;
  pointer-events: none;
}

.enemy-hud {
  width: min(100%, 680px);
  padding: 0.55rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: none;
}

.enemy-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.enemy-identity {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.enemy-code {
  font-family: var(--font-tech);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--crimson);
}

.enemy-name {
  font-size: clamp(0.9rem, 2.4vw, 1.15rem);
  font-weight: 900;
  color: #ffffff;
}

.enemy-badges {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.status-chip {
  font-family: var(--font-tech);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  white-space: nowrap;
}

.chip-scan {
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid #10b981;
  color: #6ee7b7;
}

.chip-intent {
  background: rgba(255, 42, 95, 0.2);
  border: 1px solid rgba(255, 42, 95, 0.65);
  color: #ffb3c6;
}

.gauge-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.gauge-track {
  position: relative;
  flex: 1;
  height: 10px;
  background: rgba(4, 10, 22, 0.85);
  border: 1px solid rgba(140, 215, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}

.enemy-hp-track {
  height: 11px;
}

.gauge-delay {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(255, 255, 255, 0.65);
  transition: width 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.gauge-fill {
  position: relative;
  height: 100%;
  border-radius: 999px;
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.enemy-hp-fill {
  background: linear-gradient(90deg, #ff2a5f 0%, #ff7b54 100%);
  box-shadow: 0 0 12px rgba(255, 42, 95, 0.6);
}

.hp-fill {
  background: linear-gradient(90deg, #00c6ff 0%, #2af598 100%);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.sp-fill {
  background: linear-gradient(90deg, #6366f1 0%, #00e5ff 60%, #ffd166 100%);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.gauge-num {
  font-family: var(--font-tech);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  min-width: 5.2em;
  text-align: right;
}

/* バトルログ */
.battle-log-box {
  width: min(100%, 680px);
  padding: 0.35rem 0.9rem;
  text-align: center;
  font-size: clamp(0.74rem, 1.9vw, 0.88rem);
  color: #e2f1ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: none;
}

/* 下部デッキ（プレイヤーステータス＋4コマンド） */
.battle-bottom-deck {
  width: min(100%, 860px);
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 0.55rem;
  align-items: stretch;
  flex: none;
}

.player-status-card {
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.45rem;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.unit-title-group {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.unit-name {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--cyan);
}

.unit-atk-label {
  font-family: var(--font-tech);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--gold);
}

.buff-chip {
  font-family: var(--font-tech);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 5px;
  background: rgba(16, 185, 129, 0.25);
  border: 1px solid #10b981;
  color: #6ee7b7;
}

.player-gauges {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stat-meter {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.meter-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-tech);
  font-size: 0.74rem;
  font-weight: 700;
}

.meter-label small {
  font-size: 0.62rem;
  color: var(--text-sub);
  margin-left: 0.2rem;
}

.meter-val {
  font-variant-numeric: tabular-nums;
  color: #ffffff;
}

/* 4コマンドグリッド */
.command-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
}

.cmd-btn {
  min-height: 54px;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.18rem;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cmd-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--cyan);
  background: rgba(14, 34, 68, 0.78);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.25);
}

.cmd-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.cmd-ultimate {
  border-color: rgba(255, 209, 102, 0.55);
  background: linear-gradient(135deg, rgba(45, 25, 10, 0.75) 0%, rgba(75, 20, 40, 0.75) 100%);
}

.cmd-ultimate.ready:not(:disabled) {
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(255, 209, 102, 0.42);
}

.cmd-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
}

.cmd-name {
  font-family: var(--font-display);
  font-size: clamp(0.72rem, 1.8vw, 0.86rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #ffffff;
}

.cmd-cost {
  font-family: var(--font-tech);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.08rem 0.4rem;
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.16);
  color: var(--cyan);
  white-space: nowrap;
}

.cmd-cost.cost-gain {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.cmd-cost.cost-ult {
  background: rgba(255, 209, 102, 0.22);
  color: var(--gold);
}

.cmd-desc {
  font-size: clamp(0.66rem, 1.6vw, 0.75rem);
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== ダメージ＆回復ポップアップ ==================== */
.popup-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  overflow: hidden;
}

.dmg-popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.25rem, 3.5vw, 2rem);
  letter-spacing: 0.04em;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  white-space: nowrap;
  animation: popupFloat 1.05s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dmg-popup.type-damage {
  color: #ff4d6d;
  text-shadow: 0 0 18px rgba(255, 42, 95, 0.8), 0 4px 12px #000;
}

.dmg-popup.type-crit {
  color: #ffd166;
  font-size: clamp(1.5rem, 4.2vw, 2.4rem);
  text-shadow: 0 0 24px rgba(255, 209, 102, 0.95), 0 4px 14px #000;
}

.dmg-popup.type-heal {
  color: #34d399;
  text-shadow: 0 0 18px rgba(16, 185, 129, 0.85), 0 4px 12px #000;
}

.dmg-popup.type-buff {
  color: #00e5ff;
  font-size: clamp(1rem, 2.6vw, 1.35rem);
  text-shadow: 0 0 18px rgba(0, 229, 255, 0.85), 0 4px 12px #000;
}

@keyframes popupFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.7);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -65%) scale(1.08);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -110%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -140%) scale(0.92);
  }
}

/* ==================== 3. ゲームオーバー ＆ 4. エンディング ==================== */
.center-screen,
.ending-screen {
  align-items: center;
  justify-content: center;
}

.result-card,
.ending-card {
  width: min(100%, 620px);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(1rem, 3vh, 2rem) clamp(1rem, 3.5vw, 2.2rem);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.6rem, 1.8vh, 1.1rem);
}

.danger-panel {
  border-color: rgba(255, 42, 95, 0.6);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 36px rgba(255, 42, 95, 0.2);
}

.gold-panel {
  border-color: rgba(255, 209, 102, 0.65);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.72), 0 0 44px rgba(255, 209, 102, 0.22);
}

.result-badge {
  font-family: var(--font-tech);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 0.25rem 0.85rem;
  border-radius: 999px;
}

.danger-badge {
  background: rgba(255, 42, 95, 0.2);
  border: 1px solid var(--crimson);
  color: #ff9ebb;
}

.gold-badge {
  background: rgba(255, 209, 102, 0.2);
  border: 1px solid var(--gold);
  color: var(--gold);
}

.result-title,
.ending-title {
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 4.2vw, 2.1rem);
  font-weight: 800;
  color: #ffffff;
}

.ending-sub {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  color: var(--gold);
}

.result-desc,
.ending-epilogue {
  font-size: clamp(0.78rem, 2vw, 0.92rem);
  line-height: 1.7;
  color: #dbeafe;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ending-stats {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.stat-pill {
  background: rgba(6, 14, 28, 0.65);
  border: 1px solid rgba(255, 209, 102, 0.3);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.stat-label {
  font-family: var(--font-tech);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  color: var(--text-sub);
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(0.66rem, 1.6vw, 0.78rem);
  font-weight: 700;
  color: var(--gold);
}

.result-actions {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.result-actions .btn {
  flex: 1 1 200px;
  max-width: 280px;
}

/* ==================== 確認・一時停止モーダル ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 1rem;
  background: rgba(3, 7, 16, 0.76);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-dialog {
  width: min(100%, 380px);
  max-height: 100%;
  overflow-y: auto;
  padding: 1.4rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-tag {
  font-family: var(--font-tech);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--cyan);
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #ffffff;
}

.modal-desc {
  font-size: 0.86rem;
  color: var(--text-sub);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.modal-actions .btn {
  width: 100%;
}

/* ==================== レスポンシブ調整（スマホ縦・小画面・スマホ横） ==================== */
@media (max-width: 720px) {
  .battle-bottom-deck {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .player-gauges {
    flex-direction: row;
    gap: 0.65rem;
  }

  .stat-meter {
    flex: 1;
  }

  .explore-bottom-dock {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .btn-explore {
    width: 100%;
  }

  .ending-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .area-name {
    display: none;
  }

  #badge-gold-gyro {
    display: none;
  }

  .area-indicator {
    padding: 0.3rem 0.65rem;
  }

  .module-pill {
    padding: 0.2rem 0.5rem;
    font-size: 0.66rem;
  }
}

@media (max-width: 420px) {
  .cmd-btn {
    min-height: 48px;
    padding: 0.4rem 0.55rem;
  }

  .cmd-desc {
    font-size: 0.62rem;
  }
}

/* スマホ横画面（高さが低い画面）で見切れを防ぐコンパクトモード */
@media (max-height: 460px) {
  .title-glass-panel {
    padding: 0.65rem 1.2rem;
    gap: 0.35rem;
  }

  .title-emblem {
    display: none;
  }

  .title-synopsis {
    font-size: 0.72rem;
    line-height: 1.35;
  }

  .btn {
    min-height: 40px;
    padding: 0.35rem 1rem;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .enemy-hud {
    padding: 0.35rem 0.75rem;
    gap: 0.2rem;
  }

  .battle-log-box {
    padding: 0.2rem 0.75rem;
    font-size: 0.72rem;
  }

  .battle-bottom-deck {
    grid-template-columns: 220px 1fr;
    gap: 0.4rem;
  }

  .player-status-card {
    padding: 0.4rem 0.65rem;
    gap: 0.25rem;
  }

  .command-grid {
    gap: 0.3rem;
  }

  .cmd-btn {
    min-height: 40px;
    padding: 0.28rem 0.55rem;
    gap: 0.08rem;
  }

  .crystal-screen-marker {
    top: 34%;
    min-height: 36px;
    padding: 0.25rem 0.7rem;
  }

  .explore-bottom-dock {
    padding: 0.45rem 0.85rem;
  }

  .ending-card,
  .result-card {
    padding: 0.65rem 1.1rem;
    gap: 0.35rem;
  }

  .ending-epilogue {
    font-size: 0.72rem;
    line-height: 1.35;
    gap: 0.2rem;
  }
}
