:root {
  --bg-void: #050508;
  --bg-panel: rgba(11, 12, 18, 0.92);
  --bg-card: rgba(18, 20, 29, 0.88);
  --border-dim: #26293a;
  --border-gold: #8a6d3b;
  --amber-glow: #f59e0b;
  --amber-bright: #fbbf24;
  --cyan-cold: #38bdf8;
  --crimson-alert: #ef4444;
  --crimson-dark: #7f1d1d;
  --violet-corrupt: #a855f7;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --font-display: 'Cinzel Decorative', serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-tech: 'Share Tech Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-void);
  color: var(--text-main);
  font-family: var(--font-mono);
}

#app-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #11131f 0%, #040407 100%);
  gap: 20px;
  padding: 12px;
}

/* Desktop Side Panels */
.desktop-panel {
  width: 310px;
  height: min(860px, 94vh);
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  border-top: 2px solid var(--border-gold);
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

@media (max-width: 1080px) {
  .desktop-panel {
    display: none;
  }
  #app-wrapper {
    padding: 0;
  }
}

.panel-header .tag {
  font-size: 0.7rem;
  color: var(--amber-glow);
  letter-spacing: 2px;
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--text-main);
  letter-spacing: 1px;
  margin-top: 2px;
}

.panel-section {
  border-top: 1px solid var(--border-dim);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-section h3 {
  font-size: 0.75rem;
  color: var(--amber-bright);
  letter-spacing: 1.5px;
}

.control-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-list li {
  background: var(--bg-card);
  border: 1px solid #1f2333;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ctrl-badge {
  align-self: flex-start;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--amber-glow);
  color: var(--amber-bright);
}

.control-list strong {
  font-size: 0.8rem;
  color: #fff;
}

.control-list p {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

kbd {
  background: #1e293b;
  border: 1px solid #475569;
  padding: 1px 4px;
  font-size: 0.68rem;
  border-radius: 2px;
}

.lore-box {
  background: var(--bg-card);
  border-left: 2px solid var(--border-gold);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.73rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.hl-amber { color: var(--amber-bright); font-weight: 600; }
.hl-cyan { color: var(--cyan-cold); font-weight: 600; }
.hl-dim { color: #94a3b8; font-weight: 600; }

.panel-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-dim);
}

.sys-btn {
  display: block;
  text-align: center;
  padding: 8px;
  font-size: 0.72rem;
  background: #131622;
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.sys-btn:hover {
  border-color: var(--amber-glow);
  color: #fff;
}

/* Telemetry & Guide Cards */
.telemetry-log {
  height: 195px;
  overflow-y: auto;
  background: #06070b;
  border: 1px solid #1c2030;
  padding: 8px;
  font-family: var(--font-tech);
  font-size: 0.74rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.log-entry {
  color: #94a3b8;
  line-height: 1.3;
}

.log-entry.sys { color: var(--amber-bright); }
.log-entry.warn { color: var(--crimson-alert); }
.log-entry.cyan { color: var(--cyan-cold); }

.enemy-guide-card {
  background: var(--bg-card);
  border: 1px solid #1e2230;
  padding: 9px;
}

.enemy-guide-card h4 {
  font-size: 0.78rem;
  color: #fff;
  margin-bottom: 3px;
}

.enemy-guide-card p {
  font-size: 0.71rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Mobile Portrait Viewport */
#phone-frame {
  position: relative;
  width: min(460px, 100vw);
  height: min(880px, 100vh);
  background: #040406;
  border: 2px solid #282c3e;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.95), 0 0 25px rgba(245, 158, 11, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  touch-action: none;
}

@media (max-width: 500px) {
  #phone-frame {
    width: 100vw;
    height: 100vh;
    border: none;
  }
}

#webgl-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#webgl-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hud-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: crosshair;
}

/* Atmospheric Overlays */
#crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.28) 50%);
  background-size: 100% 4px;
  opacity: 0.45;
}

#vignette-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.85);
}

#glitch-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(239, 68, 68, 0.18) 0px,
    rgba(56, 189, 248, 0.18) 3px,
    transparent 6px
  );
  mix-blend-mode: screen;
  transition: opacity 0.1s;
}

#glitch-overlay.active {
  opacity: 1;
  animation: glitchPulse 0.18s infinite;
}

@keyframes glitchPulse {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-2px, -1px); }
  100% { transform: translate(0, 0); }
}

/* HUD Top */
#hud-top {
  position: relative;
  z-index: 5;
  padding: 12px 14px 8px;
  background: linear-gradient(180deg, rgba(5, 6, 10, 0.92) 0%, rgba(5, 6, 10, 0.55) 80%, transparent 100%);
  pointer-events: none;
}

#hud-top button {
  pointer-events: auto;
}

.hud-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.shell-badge {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--amber-bright);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 3px 8px;
  letter-spacing: 1px;
}

.zone-badge {
  font-family: var(--font-tech);
  font-size: 0.78rem;
  color: var(--text-main);
  letter-spacing: 1.5px;
}

.icon-btn {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-dim);
  color: var(--amber-bright);
  width: 26px;
  height: 26px;
  font-family: var(--font-mono);
  font-weight: 800;
  cursor: pointer;
}

.bars-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.bar-track {
  position: relative;
  height: 8px;
  background: rgba(15, 17, 26, 0.95);
  border: 1px solid #2d3248;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  transition: width 0.12s ease-out;
}

.hp-fill {
  background: linear-gradient(90deg, #991b1b, #ef4444);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.energy-fill {
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

.overload-fill {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  background: repeating-linear-gradient(
    45deg,
    #f59e0b,
    #f59e0b 4px,
    #dc2626 4px,
    #dc2626 8px
  );
}

.perks-mini-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.perk-pill {
  font-size: 0.6rem;
  padding: 2px 6px;
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid #374151;
  color: #cbd5e1;
  pointer-events: auto;
}

.perk-pill.disabled-perk {
  border-color: var(--crimson-alert);
  color: var(--crimson-alert);
  text-decoration: line-through;
}

/* Boss HUD */
#boss-hud {
  margin-top: 8px;
  padding: 7px 10px;
  background: rgba(20, 8, 14, 0.9);
  border: 1px solid rgba(239, 68, 68, 0.6);
}

.boss-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 0.76rem;
  color: #fca5a5;
  margin-bottom: 4px;
}

.boss-bar-track {
  height: 9px;
  background: #1a090d;
  border: 1px solid #7f1d1d;
}

.boss-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #7f1d1d, #ef4444, #f59e0b);
  transition: width 0.15s;
}

.boss-sub {
  font-size: 0.6rem;
  color: #f87171;
  margin-top: 3px;
  letter-spacing: 1px;
}

/* Center Banner */
#center-banner {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 88%;
  z-index: 6;
  text-align: center;
  pointer-events: none;
  background: rgba(8, 9, 14, 0.88);
  padding: 10px 14px;
  border-left: 3px solid var(--amber-glow);
  border-right: 3px solid var(--amber-glow);
  animation: bannerIn 0.25s ease-out;
}

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

.banner-line {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber-glow), transparent);
  margin: 4px 0;
}

#banner-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--amber-bright);
  letter-spacing: 2px;
}

#banner-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* HUD Bottom */
#hud-bottom {
  position: relative;
  z-index: 5;
  margin-top: auto;
  padding: 10px 14px 14px;
  background: linear-gradient(0deg, rgba(5, 6, 10, 0.95) 0%, rgba(5, 6, 10, 0.65) 80%, transparent 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.ammo-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ammo-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.ammo-pips {
  display: flex;
  gap: 5px;
  height: 12px;
}

.ammo-pip {
  flex: 1;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid #334155;
  transform: skewX(-12deg);
}

.ammo-pip.loaded {
  background: linear-gradient(180deg, #fde68a, #f59e0b);
  border-color: #fbbf24;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.45);
}

.ammo-pip.unstable {
  background: linear-gradient(180deg, #f0abfc, #a855f7);
  border-color: #c084fc;
}

.reload-hint {
  font-size: 0.68rem;
  color: var(--amber-bright);
  text-align: center;
  background: rgba(245, 158, 11, 0.14);
  border: 1px dashed var(--amber-glow);
  padding: 3px;
  animation: pulseOpacity 1s infinite alternate;
}

@keyframes pulseOpacity {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

.tactical-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  pointer-events: auto;
}

.tac-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(15, 18, 28, 0.92);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  font-family: var(--font-mono);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.tac-btn:active {
  transform: scale(0.97);
}

.tac-btn.light-high {
  border-color: var(--amber-glow);
  box-shadow: inset 0 0 12px rgba(245, 158, 11, 0.18);
}

.tac-btn.light-low {
  border-color: #475569;
  opacity: 0.85;
}

.tac-btn.light-cold {
  border-color: var(--cyan-cold);
  box-shadow: inset 0 0 12px rgba(56, 189, 248, 0.2);
}

.tac-btn.lure-btn {
  border-color: #6366f1;
}

.btn-icon {
  font-size: 1.15rem;
}

.btn-meta {
  display: flex;
  flex-direction: column;
}

.btn-title {
  font-size: 0.72rem;
  font-weight: 800;
}

.btn-sub {
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* Overlay Screens */
.overlay-screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(5, 6, 10, 0.92);
  backdrop-filter: blur(5px);
  display: none;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 18px;
  overflow-y: auto;
}

.overlay-screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

.title-header {
  text-align: center;
  margin-top: 8px;
}

.sys-boot {
  font-family: var(--font-tech);
  font-size: 0.68rem;
  color: var(--amber-glow);
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.game-logo {
  font-family: var(--font-display);
  font-size: 2.6rem;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 0 22px rgba(245, 158, 11, 0.45);
}

.game-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 2.5px;
  margin-top: 4px;
}

.section-title {
  font-size: 0.72rem;
  color: var(--amber-bright);
  letter-spacing: 1.5px;
  margin-bottom: 8px;
  text-align: center;
}

.shell-cards-container {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 410px;
  overflow-y: auto;
  padding-right: 4px;
}

.shell-card {
  background: rgba(16, 19, 28, 0.9);
  border: 1px solid #262b3d;
  padding: 9px 11px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shell-card:hover {
  border-color: #64748b;
}

.shell-card.selected {
  border-color: var(--amber-bright);
  background: rgba(245, 158, 11, 0.09);
  box-shadow: inset 0 0 15px rgba(245, 158, 11, 0.12);
}

.shell-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shell-name {
  font-weight: 800;
  font-size: 0.82rem;
  color: #fff;
}

.shell-tag {
  font-size: 0.62rem;
  padding: 1px 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--amber-bright);
}

.shell-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.shell-stats {
  display: flex;
  gap: 10px;
  font-size: 0.64rem;
  color: #cbd5e1;
  font-family: var(--font-tech);
}

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

.primary-btn {
  width: 100%;
  padding: 13px;
  background: linear-gradient(90deg, #b45309, #d97706, #b45309);
  border: 1px solid var(--amber-bright);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 1.5px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
  transition: all 0.15s;
}

.primary-btn:hover {
  filter: brightness(1.15);
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sec-btn {
  padding: 9px;
  background: #111522;
  border: 1px solid #2e364f;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
}

.sec-btn:hover {
  border-color: var(--amber-glow);
}

.full-width {
  width: 100%;
}

/* Modals (Rewards, Codex, Game Over) */
.modal-box {
  background: #0b0d14;
  border: 1px solid var(--border-gold);
  padding: 16px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 92%;
}

.scrollable-modal {
  height: 92%;
}

.modal-box h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: #fff;
}

.modal-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.reward-cards-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
}

.perk-card {
  background: #121624;
  border: 1px solid #2b3248;
  padding: 11px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.perk-card:hover {
  border-color: var(--amber-bright);
  background: #171c2e;
}

.perk-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.perk-card-title {
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--amber-bright);
}

.perk-card-cat {
  font-size: 0.62rem;
  padding: 2px 6px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--cyan-cold);
}

.perk-effect {
  font-size: 0.72rem;
  color: #e2e8f0;
}

.perk-risk {
  font-size: 0.68rem;
  color: #f87171;
}

/* Codex Tabs & Content */
.modal-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-btn {
  background: transparent;
  border: 1px solid var(--border-dim);
  color: #fff;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.codex-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.codex-tab {
  padding: 7px;
  background: #121521;
  border: 1px solid #262b3d;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}

.codex-tab.active {
  border-color: var(--amber-glow);
  color: var(--amber-bright);
  background: rgba(245, 158, 11, 0.1);
}

.codex-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.codex-entry {
  background: #111420;
  border-left: 3px solid var(--amber-glow);
  padding: 10px;
}

.codex-entry h4 {
  font-size: 0.82rem;
  color: #fff;
  margin-bottom: 4px;
}

.codex-entry p {
  font-size: 0.71rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* End Screen Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-box {
  background: #121623;
  border: 1px solid #252b3d;
  padding: 8px;
  text-align: center;
}

.stat-box .val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--amber-bright);
}

.stat-box .lbl {
  font-size: 0.62rem;
  color: var(--text-muted);
}
