/* ============================================================================
   CYCLE 12: AGE OF DOMINION — INTERACTIVE 3D NOVEL & STRATEGY PWA STYLESHEET
   Supports Desktop, Tablet, and Mobile Portrait/Landscape App layouts
   ============================================================================ */

:root {
  --bg-deep: #040711;
  --panel-bg: rgba(9, 14, 30, 0.84);
  --panel-bg-strong: rgba(7, 11, 24, 0.94);
  --panel-border: rgba(56, 189, 248, 0.25);
  --panel-glow: 0 10px 36px rgba(0, 0, 0, 0.68), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --primary: #38bdf8;
  --primary-soft: rgba(56, 189, 248, 0.16);
  --accent: #c084fc;
  --accent-soft: rgba(192, 132, 252, 0.18);
  --gold: #fbbf24;
  --danger: #fb7185;
  --success: #34d399;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --hud-top: 62px;
  --bottom-nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-ui: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-ui);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.mobile-only { display: none !important; }
.desktop-only { display: flex; }

/* Custom subtle scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(15, 23, 42, 0.4); }
::-webkit-scrollbar-thumb { background: rgba(56, 189, 248, 0.35); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(56, 189, 248, 0.6); }

/* ============================================================================
   FULLSCREEN 3D CANVAS & FLOATING OVERLAYS
   ============================================================================ */
#canvas3d-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: radial-gradient(circle at 50% 42%, #0c1430 0%, #03050c 100%);
  touch-action: none;
}

.floating-layer {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.floating-label {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: auto;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(6, 10, 24, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.35);
  backdrop-filter: blur(8px);
  font-size: 11px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  transition: transform 0.14s ease, border-color 0.14s ease, opacity 0.18s ease;
}

.floating-label:hover {
  transform: translate(-50%, -112%) scale(1.06);
  border-color: var(--primary);
}

.floating-label.selected {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.45);
}

.floating-label .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.damage-float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 18px;
  font-weight: 900;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  animation: damageRise 0.95s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.damage-float.crit {
  font-size: 23px;
  color: var(--gold);
}

@keyframes damageRise {
  0%   { opacity: 0; transform: translate(-50%, -20%) scale(0.7); }
  20%  { opacity: 1; transform: translate(-50%, -65%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(0.92); }
}

/* ============================================================================
   TOP HUD HEADER & BUTTONS
   ============================================================================ */
.top-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--hud-top) + var(--safe-top));
  padding: var(--safe-top) 14px 0 14px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(180deg, rgba(4, 7, 17, 0.94) 0%, rgba(4, 7, 17, 0.72) 100%);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--panel-border);
}

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

.brand-orb {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--primary), var(--accent), var(--gold), var(--primary));
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.55);
  animation: orbSpin 12s linear infinite;
  flex-shrink: 0;
}

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

.brand-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.7px;
  background: linear-gradient(90deg, #fff, #7dd3fc, #e9d5ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px;
  border-radius: 999px;
}

.mode-tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.mode-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.mode-tab-btn.active {
  color: #04101f;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  box-shadow: 0 2px 14px rgba(56, 189, 248, 0.42);
}

.top-right-resources {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.res-pill {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--panel-border);
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.res-pill span { color: var(--text-muted); font-size: 11px; }
.res-pill strong { color: #f8fafc; font-weight: 700; }

/* Shared Interactive Buttons */
button {
  font-family: inherit;
  border: none;
  outline: none;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary, .btn-gold, .btn-accent, .btn-danger, .btn-glass, .btn-ghost, .btn-icon {
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-compact { padding: 6px 11px; font-size: 12px; }
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--panel-border);
  color: #fff;
  font-size: 15px;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #4f46e5);
  color: #fff;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.35);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }

.btn-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0b1120;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }

.btn-accent {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.32);
}
.btn-accent:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }

.btn-danger {
  background: linear-gradient(135deg, #e11d48, #9f1239);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { filter: brightness(1.12); }

.btn-glass {
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
  backdrop-filter: blur(10px);
}
.btn-glass:hover:not(:disabled) { border-color: var(--primary); color: #fff; }
.btn-glass.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: #7dd3fc;
}

.btn-ghost {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
  padding: 6px 11px;
  font-size: 12px;
}
.btn-ghost.active { border-color: var(--gold); color: var(--gold); background: rgba(251, 191, 36, 0.14); }

/* Form Inputs */
select, input[type="text"] {
  width: 100%;
  background: rgba(10, 16, 34, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 10px;
  padding: 9px 11px;
  color: #f8fafc;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
select:focus, input[type="text"]:focus {
  border-color: var(--primary);
}

/* ============================================================================
   MODE PANELS CONTAINER
   ============================================================================ */
.mode-panel {
  position: fixed;
  top: calc(var(--hud-top) + var(--safe-top));
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  pointer-events: none;
}

.mode-panel > * { pointer-events: auto; }

.muted {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.panel-section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.85px;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(56, 189, 248, 0.18);
  padding-bottom: 6px;
}

/* ============================================================================
   MODE 1: INTERACTIVE VISUAL NOVEL
   ============================================================================ */
.vn-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 20px 18px 20px;
  background: radial-gradient(ellipse at center 40%, transparent 35%, rgba(3, 5, 13, 0.72) 100%);
  pointer-events: none;
}

.vn-panel > * { pointer-events: auto; }

.vn-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.vn-chapter-select-wrap {
  flex: 1;
  min-width: 240px;
  max-width: 440px;
}

.vn-chapter-select-wrap select {
  background: rgba(8, 13, 28, 0.88);
  border-color: var(--panel-border);
  font-weight: 700;
}

.vn-controls {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.vn-location-pill {
  align-self: center;
  margin-top: 4px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(8, 13, 28, 0.78);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 700;
  color: #bae6fd;
  letter-spacing: 0.4px;
  pointer-events: none;
}

.vn-stage-bottom {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: none;
}

.vn-sprites-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 20px;
  min-height: 224px;
  pointer-events: none;
  gap: 14px;
}

.vn-sprite-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 215px;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), filter 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
  animation: vnSlideIn 0.32s ease-out;
}

.vn-sprite-slot img {
  width: 204px;
  height: 264px;
  object-fit: cover;
  object-position: center 12%;
  border-radius: 18px 18px 0 0;
  border: 2px solid rgba(56, 189, 248, 0.45);
  border-bottom: none;
  background: rgba(8, 13, 28, 0.9);
  box-shadow: 0 0 34px rgba(0, 0, 0, 0.8);
  -webkit-mask-image: linear-gradient(to bottom, #000 84%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 84%, transparent 100%);
}

@keyframes vnSlideIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.vn-chapter-banner {
  align-self: center;
  margin-bottom: 6px;
  padding: 7px 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.92), rgba(56, 189, 248, 0.22), rgba(168, 85, 247, 0.24), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(251, 191, 36, 0.55);
  color: #fef3c7;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  animation: vnBannerIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes vnBannerIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.vn-sprite-slot.speaking {
  transform: translateY(-8px) scale(1.04);
  filter: brightness(1.08) drop-shadow(0 0 18px rgba(56, 189, 248, 0.45));
  z-index: 3;
}

.vn-sprite-slot.speaking img {
  border-color: var(--gold);
}

.vn-sprite-slot.dim {
  transform: translateY(4px) scale(0.94);
  filter: brightness(0.62) saturate(0.75);
  opacity: 0.88;
}

.vn-sprite-meta {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 8, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 3px 9px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 11.5px;
  font-weight: 700;
}

.vn-mood-tag {
  font-size: 10px;
  color: #fde68a;
  font-weight: 600;
}

.vn-dialogue-box {
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(10, 15, 34, 0.94) 0%, rgba(5, 9, 21, 0.97) 100%);
  border: 1px solid var(--panel-border);
  border-top: 2px solid rgba(56, 189, 248, 0.55);
  border-radius: 18px;
  padding: 16px 20px 14px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.82), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  cursor: pointer;
}

.vn-speaker-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.vn-speaker-badge {
  background: linear-gradient(135deg, #0284c7, #6366f1);
  color: #fff;
  padding: 4px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.vn-speaker-badge.narrator {
  background: linear-gradient(135deg, #334155, #1e293b);
  color: #cbd5e1;
}

.vn-speaker-title {
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
}

.vn-text {
  font-size: 15.5px;
  line-height: 1.68;
  color: #f8fafc;
  min-height: 68px;
  max-height: 170px;
  overflow-y: auto;
  user-select: text;
}

.vn-choices {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vn-choice-btn {
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(17, 26, 52, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #f1f5f9;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.vn-choice-btn:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--gold);
  transform: translateX(4px);
}

.vn-choice-btn.battle-choice {
  border-color: rgba(251, 113, 133, 0.65);
  background: rgba(136, 19, 55, 0.28);
}

.vn-choice-hint {
  font-size: 11.5px;
  font-weight: 500;
  color: #94a3b8;
}

.vn-tap-hint {
  margin-top: 10px;
  text-align: right;
  font-size: 11.5px;
  color: var(--primary);
  font-weight: 700;
  animation: pulseHint 1.6s ease-in-out infinite;
}

@keyframes pulseHint {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ============================================================================
   SIDEBAR LAYOUT (GALAXY, ARENA SETUP, INSPECTOR)
   ============================================================================ */
.hud-sidebar {
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 14px;
  width: 356px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--panel-glow);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 11px;
  overflow-y: auto;
  z-index: 20;
}

.hud-sidebar.wide {
  left: auto;
  right: 14px;
  width: 396px;
}

.galaxy-floating-actions {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 24;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.mobile-sheet-toggles {
  display: none;
  gap: 6px;
}

.sector-list, .roster-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.sector-card, .roster-item {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, transform 0.14s;
}

.sector-card:hover, .roster-item:hover {
  border-color: var(--primary);
  background: rgba(30, 41, 59, 0.88);
}

.sector-card.active, .roster-item.active {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.12);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.18);
}

.roster-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.roster-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  object-position: top center;
  border: 1px solid rgba(56, 189, 248, 0.4);
  flex-shrink: 0;
}

.sector-head, .roster-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  white-space: nowrap;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #e2e8f0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chip.clickable { cursor: pointer; }
.chip.clickable:hover { border-color: var(--gold); color: var(--gold); }

.planet-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
}

.body-card {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  padding: 9px 10px;
  margin-top: 7px;
  cursor: pointer;
}
.body-card:hover { border-color: var(--primary); }

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

/* ============================================================================
   MODE 3: 3D REAL-TIME ACTION ARENA & VIRTUAL JOYSTICK
   ============================================================================ */
.arena-mobile-setup-bar {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 25;
}

.arena-center-hud {
  position: absolute;
  top: 14px;
  left: 384px;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.arena-center-hud > * { pointer-events: auto; }

.versus-bars {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(8, 13, 28, 0.84);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 10px 14px;
}

.vs-side { flex: 1; min-width: 0; }
.vs-side.right { text-align: right; }

.vs-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
}
.vs-header.right { justify-content: flex-end; }

.vs-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  object-position: top center;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: #0f172a;
}

.vs-name {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vs-badge {
  font-size: 13px;
  font-weight: 900;
  color: var(--gold);
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.4);
  padding: 6px 10px;
  border-radius: 10px;
  flex-shrink: 0;
}

.hp-track {
  width: 100%;
  height: 11px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin-bottom: 4px;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, #34d399);
  transition: width 0.14s ease;
}

.hp-fill.enemy {
  background: linear-gradient(90deg, #f97316, #f43f5e);
}

.arena-bottom-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.arena-bottom-controls > * { pointer-events: auto; }

.joystick-zone {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.62);
  border: 2px solid rgba(56, 189, 248, 0.38);
  backdrop-filter: blur(8px);
  position: relative;
  touch-action: none;
  flex-shrink: 0;
  box-shadow: inset 0 0 22px rgba(56, 189, 248, 0.12);
}

.joystick-knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #7dd3fc, #0284c7);
  border: 2px solid #e0f2fe;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.5);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.arena-bottom-dock {
  flex: 1;
  min-width: 0;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skill-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.skill-btn {
  position: relative;
  min-width: 110px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(19, 31, 60, 0.94), rgba(10, 17, 36, 0.96));
  border: 1px solid rgba(56, 189, 248, 0.42);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.skill-btn:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-2px); }
.skill-btn.ult { border-color: rgba(192, 132, 252, 0.72); }
.skill-btn.dodge { border-color: rgba(52, 211, 153, 0.65); }
.skill-btn.auto { border-color: rgba(251, 191, 36, 0.65); }

.skill-btn.on-cd {
  opacity: 0.58;
  filter: grayscale(0.4);
}

.skill-cd {
  font-size: 10.5px;
  color: var(--gold);
  font-weight: 800;
  min-height: 13px;
}

.combat-log-box {
  background: rgba(6, 10, 22, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 8px 11px;
  max-height: 82px;
  overflow-y: auto;
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.combat-log-line.player { color: #7dd3fc; }
.combat-log-line.enemy { color: #fda4af; }
.combat-log-line.system { color: #fde68a; font-weight: 700; }

/* ============================================================================
   INSPECTOR & CODEX / DIPLOMACY WORKSPACE
   ============================================================================ */
.inspector-portrait-hero {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 14px;
  padding: 10px;
}

.inspector-portrait-hero img {
  width: 82px;
  height: 98px;
  border-radius: 12px;
  object-fit: cover;
  object-position: top center;
  border: 2px solid var(--primary);
  flex-shrink: 0;
}

.affinity-bar-wrap {
  margin-top: 6px;
  height: 7px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.9);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.affinity-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #f472b6);
}

.codex-workspace {
  position: absolute;
  inset: 14px;
  background: var(--panel-bg-strong);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: var(--panel-glow);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.codex-tabs-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.18);
  overflow-x: auto;
  flex-shrink: 0;
}

.codex-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}

.codex-card {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diplo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}

.save-slot-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ============================================================================
   MODALS, BACKLOG & TOAST NOTIFICATIONS
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(2, 5, 14, 0.78);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 82dvh;
  background: var(--panel-bg-strong);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card.small { max-width: 460px; text-align: center; }

.vn-history-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-right: 4px;
}

.vn-history-item {
  background: rgba(15, 23, 42, 0.75);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.5;
}

.lore-toast {
  position: fixed;
  top: calc(var(--hud-top) + var(--safe-top) + 12px);
  right: 16px;
  z-index: 90;
  max-width: 340px;
  background: rgba(9, 15, 34, 0.95);
  border: 1px solid var(--gold);
  border-left: 4px solid var(--gold);
  border-radius: 12px;
  padding: 11px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
}
.lore-toast h4 { color: var(--gold); font-size: 13px; margin-bottom: 3px; }
.lore-toast p { color: #e2e8f0; font-size: 12px; line-height: 1.45; }

/* ============================================================================
   MOBILE & TABLET APP EXPERIENCE (<= 960px)
   ============================================================================ */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  z-index: 45;
  background: rgba(5, 9, 22, 0.96);
  border-top: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.bottom-nav-btn {
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 17px;
  padding: 4px 2px;
}

.bottom-nav-btn small { font-size: 10px; font-weight: 700; }
.bottom-nav-btn.active { color: var(--primary); }
.bottom-nav-btn.active span { transform: translateY(-2px); text-shadow: 0 0 12px rgba(56, 189, 248, 0.8); }

/* v4 BGM Active Toggle, Overdrive Strip, & Achievements */
.btn-icon.active {
  background: rgba(56, 189, 248, 0.24);
  border-color: rgba(56, 189, 248, 0.65);
  color: #bae6fd;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.arena-overdrive-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding: 5px 12px;
  border-radius: 10px;
  background: rgba(8, 13, 28, 0.8);
  border: 1px solid rgba(251, 191, 36, 0.28);
  font-size: 11px;
}

.overdrive-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.overdrive-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #a855f7, #fbbf24);
  transition: width 0.16s ease;
}

.overdrive-fill.ready {
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.9);
  animation: odPulse 1s infinite alternate;
}

@keyframes odPulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.45); }
}

.ach-card {
  background: rgba(15, 23, 42, 0.76);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0.72;
  transition: border-color 0.2s ease, opacity 0.2s ease;
}

.ach-card.unlocked {
  opacity: 1;
  border-color: rgba(251, 191, 36, 0.65);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(251, 191, 36, 0.12));
  box-shadow: 0 4px 20px rgba(251, 191, 36, 0.15);
}

@media (max-width: 960px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .bottom-nav.mobile-only { display: grid !important; }

  .mode-panel {
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  }

  .mobile-sheet-toggles {
    display: flex;
  }

  .galaxy-floating-actions, .floating-insp-toggle {
    position: absolute;
    top: 8px;
    left: 10px;
    right: 10px;
    transform: none;
    justify-content: space-between;
  }

  .hud-sidebar, .hud-sidebar.wide {
    display: none;
    left: 8px;
    right: 8px;
    width: auto;
    top: 52px;
    bottom: 8px;
    max-height: none;
  }

  .hud-sidebar.mobile-sheet-active {
    display: flex;
  }

  .arena-setup-drawer {
    display: none;
    z-index: 30;
  }
  .arena-setup-drawer.open {
    display: flex;
  }

  .arena-center-hud {
    top: 48px;
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .versus-bars { padding: 8px 10px; gap: 8px; }
  .vs-avatar { width: 32px; height: 32px; }
  .vs-name { font-size: 12px; }
  .joystick-zone { width: 96px; height: 96px; }
  .joystick-knob { width: 40px; height: 40px; }
  .skill-btn { min-width: 72px; padding: 8px 6px; font-size: 11px; }
  .combat-log-box { max-height: 54px; font-size: 10.5px; }

  .vn-panel { padding: 8px 10px 10px 10px; }
  .vn-chapter-banner { font-size: 10.5px; padding: 5px 12px; margin-bottom: 4px; }
  .vn-sprites-row { min-height: 140px; padding: 0 4px; }
  .vn-sprite-slot { width: 128px; }
  .vn-sprite-slot img { width: 120px; height: 142px; }
  .vn-dialogue-box { padding: 12px 14px; border-radius: 14px; }
  .vn-text { font-size: 14px; max-height: 140px; }

  .codex-workspace { inset: 8px; border-radius: 14px; }
  .hide-sm { display: none; }
}

@media (max-width: 560px) {
  .brand-text { display: none; }
  .hide-xs { display: none; }
  .top-hud { padding: var(--safe-top) 8px 0 8px; }
  .res-pill { padding: 4px 7px; font-size: 11px; }
}
