/* ==========================================================================
   VOID SURVIVORS: CHRONICLES OF THE ABYSS
   Authentic 16-Bit Dark Fantasy RPG / Arcade Pixel Art Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Silkscreen:wght@400;700&family=VT323&display=swap');

:root {
  /* Core Dungeon & Slate Palette */
  --bg-deep: #060910;
  --bg-surface: #0a0f1d;
  --bg-card: #0d1527;
  --bg-card-hover: #121c33;
  --bg-frame-dark: #05080e;

  /* Pixel Border Colors */
  --border-black: #000000;
  --border-slate-light: #475569;
  --border-slate-mid: #334155;
  --border-slate-dark: #090d16;

  /* Elemental / Hero Color Accents */
  --cyan-core: #38bdf8;
  --cyan-light: #7dd3fc;
  --cyan-dark: #0284c7;
  --cyan-glow: rgba(56, 189, 248, 0.55);

  --purple-core: #c084fc;
  --purple-light: #e9d5ff;
  --purple-dark: #9333ea;
  --purple-glow: rgba(192, 132, 252, 0.55);

  --crimson-core: #f43f5e;
  --crimson-light: #fda4af;
  --crimson-dark: #be123c;
  --crimson-glow: rgba(244, 63, 94, 0.55);

  --gold-core: #fbbf24;
  --gold-light: #fef08a;
  --gold-dark: #b45309;
  --gold-glow: rgba(251, 191, 36, 0.6);

  --emerald-core: #34d399;
  --emerald-light: #a7f3d0;
  --emerald-dark: #059669;
  --emerald-glow: rgba(52, 211, 153, 0.55);

  /* Pixel Typography System */
  --font-pixel-title: 'Press Start 2P', monospace;
  --font-pixel-body: 'Silkscreen', monospace;
  --font-pixel-num: 'VT323', monospace;

  /* Backward Compatibility Aliases */
  --font-title: var(--font-pixel-title);
  --font-main: var(--font-pixel-body);
  --font-mono: var(--font-pixel-body);
}

/* ==========================================================================
   GLOBAL RESET & PIXEL RENDERING
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Custom 16-Bit Pixel Cursors */
html, body, * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' shape-rendering='crispEdges'%3E%3Cpath fill='%23000' d='M0 0h2v14h2v2h2v2h2v2H0z'/%3E%3Cpath fill='%23fff' d='M2 2h2v10h2v-2h2v-2h2v-2h2V4h2V2H2z'/%3E%3Cpath fill='%2338bdf8' d='M4 4h2v6h2V8h2V6h2V4H4z'/%3E%3C/svg%3E"), auto !important;
}

button, a, .char-card, .upgrade-card, .ult-orb-wrapper, .hud-btn, .recipe-card {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' shape-rendering='crispEdges'%3E%3Cpath fill='%23000' d='M0 0h2v14h2v2h2v2h2v2H0z'/%3E%3Cpath fill='%23fbbf24' d='M2 2h2v10h2v-2h2v-2h2v-2h2V4h2V2H2z'/%3E%3Cpath fill='%23fff' d='M4 4h2v6h2V8h2V6h2V4H4z'/%3E%3C/svg%3E"), pointer !important;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  font-family: var(--font-pixel-body);
  color: #f1f5f9;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
  text-rendering: optimizeSpeed;
}

/* Subtle CRT Scanline & Retro Arcade Ambiance Layer */
body::after {
  content: " ";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(
    rgba(18, 16, 26, 0) 50%, 
    rgba(0, 0, 0, 0.28) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.02),
    rgba(0, 255, 0, 0.01),
    rgba(0, 0, 255, 0.02)
  );
  background-size: 100% 3px, 6px 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.65;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
}

/* ==========================================================================
   LOBBY & CHARACTER SELECTION (RETRO PIXEL ART RPG STYLE)
   ========================================================================== */

#lobby-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: radial-gradient(circle at 50% 25%, #10182c 0%, #060910 80%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 34px 24px;
  overflow-y: auto;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#lobby-screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.02);
}

/* Brand Header */
.lobby-brand {
  text-align: center;
}

.brand-eyebrow {
  font-family: var(--font-pixel-title);
  font-size: 0.72rem;
  letter-spacing: 2px;
  color: var(--cyan-core);
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 12px;
  display: inline-block;
  padding: 4px 12px;
  background: #080d19;
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 #334155, 0 3px 0 #000;
}

.brand-title {
  font-family: var(--font-pixel-title);
  font-size: 2.5rem;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 
    4px 4px 0 #000, 
    -2px -2px 0 #000, 
    2px -2px 0 #000, 
    -2px 2px 0 #000, 
    0 0 25px var(--cyan-glow);
  margin-bottom: 8px;
}

.brand-subtitle {
  font-family: var(--font-pixel-body);
  font-size: 0.95rem;
  color: #94a3b8;
  letter-spacing: 2px;
  text-shadow: 1px 1px 0 #000;
}

/* Character Selection Area */
.character-selection-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 18px 0;
}

.selection-title {
  font-family: var(--font-pixel-title);
  font-size: 1.05rem;
  letter-spacing: 2px;
  color: #fbbf24;
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.selection-title::before, .selection-title::after {
  content: '♦';
  color: #f59e0b;
  font-size: 0.9rem;
}

.characters-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  width: 100%;
}

/* 16-Bit Character Card */
.char-card {
  position: relative;
  background: var(--bg-card);
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 2px 2px 0px #384b6b, 
    inset -2px -2px 0px #060912, 
    0 6px 0px #000;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.char-card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  box-shadow: 
    inset 2px 2px 0px #64748b, 
    inset -2px -2px 0px #060912, 
    0 10px 0px #000, 
    0 0 20px var(--char-glow);
}

.char-card.selected {
  border-color: #000;
  background: #0f1a30;
  box-shadow: 
    inset 3px 3px 0px var(--char-color), 
    inset -3px -3px 0px #060912, 
    0 8px 0px #000, 
    0 0 25px var(--char-glow);
  transform: translateY(-4px);
}

/* Top Pixel Corner Badges for Selected Card */
.char-card.selected::before {
  content: 'SELECTED';
  position: absolute;
  top: 4px;
  right: 4px;
  font-family: var(--font-pixel-title);
  font-size: 0.5rem;
  background: var(--char-color);
  color: #000;
  padding: 3px 6px;
  font-weight: 900;
  border: 1px solid #000;
  box-shadow: 0 1px 0 #000;
  z-index: 5;
}

/* Character Portrait Frame with Pixel Border */
.char-portrait-frame {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0;
  overflow: hidden;
  position: relative;
  margin-bottom: 12px;
  border: 3px solid #000;
  box-shadow: 
    inset 2px 2px 0 #475569, 
    inset -2px -2px 0 #0f172a, 
    0 3px 0 #000;
  background: #000;
}

.char-card.selected .char-portrait-frame {
  border-color: #000;
  box-shadow: 
    inset 2px 2px 0 var(--char-color), 
    inset -2px -2px 0 #0f172a, 
    0 3px 0 #000,
    0 0 15px var(--char-glow);
}

.char-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  transition: transform 0.25s ease;
}

.char-card:hover .char-portrait-img {
  transform: scale(1.05);
}

.char-portrait-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 35%;
  background: linear-gradient(180deg, transparent 0%, rgba(6, 9, 16, 0.95) 100%);
  pointer-events: none;
}

.char-name {
  font-family: var(--font-pixel-title);
  font-size: 0.95rem;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 6px;
}

.char-title {
  font-family: var(--font-pixel-body);
  font-size: 0.65rem;
  letter-spacing: 1.5px;
  color: var(--char-color, #38bdf8);
  text-shadow: 1px 1px 0 #000;
  margin-bottom: 14px;
}

/* Segmented 8-bit Block Stats */
.char-stat-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-pixel-body);
  font-size: 0.72rem;
  color: #94a3b8;
  text-shadow: 1px 1px 0 #000;
}

.stat-bar-track {
  width: 86px;
  height: 8px;
  background: #000;
  border: 1px solid #1e293b;
  border-radius: 0;
  overflow: hidden;
  box-shadow: inset 1px 1px 0 #000;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 0;
  background: repeating-linear-gradient(
    90deg,
    var(--char-color) 0px,
    var(--char-color) 6px,
    #000 6px,
    #000 8px
  ) !important;
}

/* Loadout Info Box */
.char-loadout-info {
  width: 100%;
  background: #070b15;
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 #1e293b, 0 2px 0 #000;
  border-radius: 0;
  padding: 8px 10px;
  font-size: 0.75rem;
  text-align: left;
  line-height: 1.4;
}

.loadout-label {
  font-family: var(--font-pixel-body);
  font-size: 0.65rem;
  color: #64748b;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.loadout-val {
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   TACTILE RETRO PIXEL BUTTONS
   ========================================================================== */

.lobby-actions {
  display: flex;
  gap: 18px;
  align-items: center;
}

.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px 40px;
  background: #0284c7;
  color: #fff;
  font-family: var(--font-pixel-title);
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 3px 3px 0px #7dd3fc, 
    inset -3px -3px 0px #0369a1, 
    0 6px 0px #000;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
  user-select: none;
}

.btn-primary:hover {
  background: #0ea5e9;
  box-shadow: 
    inset 3px 3px 0px #bae6fd, 
    inset -3px -3px 0px #0284c7, 
    0 6px 0px #000,
    0 0 22px rgba(56, 189, 248, 0.6);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 
    inset 3px 3px 0px #0369a1, 
    inset -3px -3px 0px #7dd3fc, 
    0 2px 0px #000;
}

.btn-secondary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  background: #1e293b;
  color: #cbd5e1;
  font-family: var(--font-pixel-title);
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 3px 3px 0px #475569, 
    inset -3px -3px 0px #0f172a, 
    0 6px 0px #000;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease, color 0.15s ease;
}

.btn-secondary:hover {
  background: #334155;
  color: #fff;
  box-shadow: 
    inset 3px 3px 0px #64748b, 
    inset -3px -3px 0px #1e293b, 
    0 6px 0px #000;
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(4px);
  box-shadow: 
    inset 3px 3px 0px #0f172a, 
    inset -3px -3px 0px #475569, 
    0 2px 0px #000;
}

/* ==========================================================================
   IN-GAME HUD (HEADS-UP DISPLAY)
   ========================================================================== */

/* Top EXP Bar */
#exp-bar-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 12px;
  background: #000;
  border-bottom: 3px solid #000;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.6);
  z-index: 30;
}

#exp-bar-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    90deg,
    #38bdf8 0px,
    #38bdf8 10px,
    #0284c7 10px,
    #0284c7 12px
  );
  box-shadow: inset 0 2px 0 #bae6fd, inset 0 -2px 0 #0369a1;
  transition: width 0.15s ease-out;
}

/* In-Game HUD Overlay */
#hud-overlay {
  position: absolute;
  top: 18px;
  left: 0;
  width: 100%;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 35;
  pointer-events: none;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

/* Pixel Stone HUD Panels */
.hud-panel {
  display: flex;
  align-items: center;
  background: #0a1122;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 2px 2px 0 #334155, 
    inset -2px -2px 0 #05080e, 
    0 4px 0 #000;
  padding: 6px 14px;
}

/* Mini Character Portrait */
.char-portrait-mini {
  width: 38px;
  height: 38px;
  border-radius: 0;
  background: #000;
  border: 2px solid var(--cyan-core);
  box-shadow: inset 1px 1px 0 #fff, 0 2px 0 #000;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  overflow: hidden;
}

.char-portrait-mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Level Badge */
#level-badge {
  font-family: var(--font-pixel-title);
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: var(--gold-core);
  text-shadow: 2px 2px 0 #000;
  margin-right: 14px;
}

/* Chunky Health Bar */
.hp-bar-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 170px;
}

.hp-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-pixel-body);
  font-size: 0.68rem;
  font-weight: 700;
  color: #94a3b8;
  text-shadow: 1px 1px 0 #000;
}

#hp-bar-track {
  width: 100%;
  height: 12px;
  background: #000;
  border: 2px solid #000;
  border-radius: 0;
  box-shadow: inset 1px 1px 0 #334155, inset -1px -1px 0 #000;
  position: relative;
  overflow: hidden;
}

#hp-bar-ghost {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: #ffffff;
  border-radius: 0;
  opacity: 0.5;
  transition: width 0.35s ease-out 0.2s;
}

#hp-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: repeating-linear-gradient(
    90deg,
    #ef4444 0px,
    #ef4444 10px,
    #b91c1c 10px,
    #b91c1c 12px
  );
  border-radius: 0;
  box-shadow: inset 0 2px 0 #fca5a5, inset 0 -2px 0 #7f1d1d;
  transition: width 0.12s ease-out;
}

/* Center HUD Timer, Kills, Gold */
.hud-center {
  gap: 20px;
}

.hud-stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-pixel-title);
  font-size: 0.8rem;
  text-shadow: 2px 2px 0 #000;
}

.hud-icon {
  display: flex;
  align-items: center;
  color: var(--cyan-core);
}

.skull-icon { color: var(--crimson-core); }
.gold-icon { color: var(--gold-core); }

/* Right HUD Buttons */
.hud-btn {
  width: 38px;
  height: 38px;
  border-radius: 0;
  background: #0a1122;
  border: 3px solid #000;
  box-shadow: 
    inset 2px 2px 0 #334155, 
    inset -2px -2px 0 #05080e, 
    0 4px 0 #000;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.hud-btn:hover {
  transform: translateY(-2px);
  color: #fff;
  box-shadow: 
    inset 2px 2px 0 #64748b, 
    inset -2px -2px 0 #05080e, 
    0 6px 0 #000;
}

.hud-btn:active {
  transform: translateY(2px);
  box-shadow: 
    inset 2px 2px 0 #05080e, 
    0 2px 0 #000;
}

/* Bottom Left: Inventory Loadout Dock */
#inventory-dock {
  position: absolute;
  bottom: 22px;
  left: 22px;
  display: flex;
  gap: 8px;
  z-index: 35;
  pointer-events: none;
}

.inventory-slot {
  width: 46px;
  height: 46px;
  background: #0a1122;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 2px 2px 0 #334155, 
    inset -2px -2px 0 #05080e, 
    0 4px 0 #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.inventory-slot.evolved {
  border-color: #000;
  box-shadow: 
    inset 2px 2px 0 #fef08a, 
    inset -2px -2px 0 #854d0e, 
    0 4px 0 #000, 
    0 0 16px var(--gold-glow);
}

.slot-level-pips {
  position: absolute;
  bottom: 3px;
  display: flex;
  gap: 2px;
}

.pip {
  width: 5px;
  height: 5px;
  border-radius: 0;
  background: #1e293b;
  border: 1px solid #000;
}

.pip.filled {
  background: var(--cyan-core);
  box-shadow: 0 0 4px var(--cyan-core);
}

/* Bottom Right: Ultimate Ability Meter */
#ultimate-container {
  position: absolute;
  bottom: 22px;
  right: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 35;
  pointer-events: auto;
}

.ult-orb-wrapper {
  position: relative;
  width: 62px;
  height: 62px;
  cursor: pointer;
}

.ult-orb {
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: #080d19;
  border: 3px solid #000;
  box-shadow: 
    inset 2px 2px 0 #334155, 
    inset -2px -2px 0 #05080e, 
    0 4px 0 #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  clip-path: polygon(
    0 8px, 8px 0,
    calc(100% - 8px) 0, 100% 8px,
    100% calc(100% - 8px), calc(100% - 8px) 100%,
    8px 100%, 0 calc(100% - 8px)
  );
  transition: all 0.2s ease;
}

.ult-fill-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg, #38bdf8 0%, #0369a1 100%);
  opacity: 0.7;
  transition: height 0.2s ease;
}

.ult-orb.ready {
  border-color: #000;
  box-shadow: 
    inset 3px 3px 0 #fef08a, 
    inset -3px -3px 0 #854d0e, 
    0 4px 0 #000, 
    0 0 25px var(--gold-glow);
  animation: pixel-pulse 0.8s steps(2, start) infinite alternate;
}

@keyframes pixel-pulse {
  0% { filter: drop-shadow(0 0 6px #fbbf24); }
  100% { filter: drop-shadow(0 0 20px #f59e0b) brightness(1.25); }
}

.ult-key-badge {
  font-family: var(--font-pixel-title);
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  z-index: 2;
}

.ult-name-tag {
  font-family: var(--font-pixel-title);
  font-size: 0.65rem;
  letter-spacing: 1px;
  color: #94a3b8;
  text-shadow: 1px 1px 0 #000;
}

/* Bottom Controls Hint */
#controls-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  background: #080d19;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 2px 2px 0 #334155, 
    inset -2px -2px 0 #05080e, 
    0 4px 0 #000;
  font-family: var(--font-pixel-body);
  font-size: 0.72rem;
  color: #94a3b8;
  z-index: 25;
  pointer-events: none;
}

.key-badge {
  background: #1e293b;
  color: #fff;
  padding: 3px 6px;
  border-radius: 0;
  font-family: var(--font-pixel-title);
  font-size: 0.62rem;
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 #475569, 0 2px 0 #000;
}

/* ==========================================================================
   MODALS: 16-BIT RPG DIALOG BOX SYSTEM
   ========================================================================== */

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 7, 14, 0.92);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 200;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

#codex-modal {
  z-index: 250;
}

/* The Core 16-Bit Pixel Dialog Window */
.pixel-dialog {
  background: #0b1222;
  border: 4px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 3px 3px 0 #475569, 
    inset -3px -3px 0 #070b14, 
    0 10px 0 #000, 
    0 0 50px rgba(0, 0, 0, 0.9);
  padding: 30px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 92vw;
}

.pixel-modal-large {
  max-width: 1140px;
}

/* Modal Header & Pixel Badge */
.modal-header {
  text-align: center;
  margin-bottom: 26px;
}

.pixel-tag-badge {
  display: inline-block;
  font-family: var(--font-pixel-title);
  font-size: 0.65rem;
  letter-spacing: 1px;
  color: var(--cyan-core);
  background: #060a14;
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 #334155, 0 2px 0 #000;
  padding: 4px 10px;
  margin-bottom: 8px;
}

.pixel-tag-badge.theme-gold {
  color: var(--gold-core);
  box-shadow: inset 1px 1px 0 #854d0e, 0 2px 0 #000;
}

.pixel-tag-badge.theme-blood {
  color: var(--crimson-core);
  box-shadow: inset 1px 1px 0 #991b1b, 0 2px 0 #000;
}

.modal-title {
  font-family: var(--font-pixel-title);
  font-size: 1.45rem;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 6px;
}

.modal-subtitle {
  font-family: var(--font-pixel-body);
  font-size: 0.85rem;
  color: #94a3b8;
  letter-spacing: 1px;
}

/* ==========================================================================
   LEVEL UP & BLESSING CARDS
   ========================================================================== */

#upgrade-cards {
  display: flex;
  gap: 20px;
  width: 100%;
  justify-content: center;
}

.upgrade-card {
  position: relative;
  flex: 1;
  min-width: 270px;
  max-width: 320px;
  background: #090e1b;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 3px 3px 0 #334155, 
    inset -3px -3px 0 #05080e, 
    0 8px 0 #000;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.upgrade-card:hover {
  transform: translateY(-6px);
  box-shadow: 
    inset 3px 3px 0 #64748b, 
    inset -3px -3px 0 #05080e, 
    0 14px 0 #000, 
    0 0 25px rgba(56, 189, 248, 0.4);
}

.upgrade-card.rarity-evolution {
  border-color: #000;
  box-shadow: 
    inset 3px 3px 0 #fef08a, 
    inset -3px -3px 0 #854d0e, 
    0 8px 0 #000, 
    0 0 30px var(--gold-glow);
}

.card-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.rarity-badge {
  font-family: var(--font-pixel-title);
  font-size: 0.62rem;
  letter-spacing: 1px;
  padding: 4px 8px;
  border-radius: 0;
  border: 2px solid #000;
  box-shadow: 0 2px 0 #000;
}

.level-indicator {
  font-family: var(--font-pixel-title);
  font-size: 0.65rem;
  color: #94a3b8;
}

.rarity-common .rarity-badge { background: #334155; color: #f1f5f9; }
.rarity-rare .rarity-badge { background: #0284c7; color: #fff; }
.rarity-epic .rarity-badge { background: #9333ea; color: #fff; }
.rarity-evolution .rarity-badge { background: #f59e0b; color: #000; }

.card-icon {
  margin: 10px 0 16px 0;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050811;
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 #334155, 0 3px 0 #000;
  border-radius: 0;
}

.card-icon img {
  width: 52px;
  height: 52px;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  filter: drop-shadow(2px 2px 0 #000);
}

.card-title {
  font-family: var(--font-pixel-title);
  font-size: 0.95rem;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 6px;
}

.card-type {
  font-family: var(--font-pixel-body);
  font-size: 0.65rem;
  letter-spacing: 1.5px;
  color: #94a3b8;
  margin-bottom: 14px;
}

.card-description {
  font-family: var(--font-pixel-body);
  font-size: 0.78rem;
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 20px;
  flex-grow: 1;
}

.card-choose-btn {
  width: 100%;
  padding: 12px 0;
  background: #1e293b;
  border: 3px solid #000;
  border-radius: 0;
  color: #fff;
  font-family: var(--font-pixel-title);
  font-size: 0.72rem;
  letter-spacing: 1px;
  box-shadow: 
    inset 2px 2px 0 #475569, 
    inset -2px -2px 0 #0f172a, 
    0 4px 0 #000;
  cursor: pointer;
  transition: all 0.1s ease;
}

.upgrade-card:hover .card-choose-btn {
  background: var(--cyan-core);
  color: #000;
  box-shadow: 
    inset 2px 2px 0 #7dd3fc, 
    inset -2px -2px 0 #0369a1, 
    0 4px 0 #000, 
    0 0 15px rgba(56, 189, 248, 0.6);
}

.card-choose-btn:active {
  transform: translateY(2px);
  box-shadow: 
    inset 2px 2px 0 #0369a1, 
    0 2px 0 #000;
}

/* ==========================================================================
   CODEX & EVOLUTIONS MODAL
   ========================================================================== */

#codex-modal .codex-content {
  width: 90%;
  max-width: 900px;
  max-height: 80vh;
  overflow-y: auto;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  margin-top: 14px;
}

.recipe-card {
  background: #070b15;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 2px 2px 0 #334155, 
    inset -2px -2px 0 #000, 
    0 4px 0 #000;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-pixel-body);
  font-size: 0.75rem;
}

.recipe-operator {
  font-family: var(--font-pixel-title);
  font-size: 0.8rem;
  color: #94a3b8;
}

.recipe-result {
  font-family: var(--font-pixel-title);
  font-size: 0.75rem;
  color: #fbbf24;
  text-shadow: 1px 1px 0 #000;
}

/* ==========================================================================
   GAME OVER MODAL & STAT CARDS
   ========================================================================== */

.stats-summary {
  display: flex;
  gap: 18px;
  margin: 22px 0;
}

.gameover-stat-card {
  background: #070b15;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 2px 2px 0 #334155, 
    inset -2px -2px 0 #000, 
    0 4px 0 #000;
  padding: 14px 22px;
  text-align: center;
  min-width: 130px;
}

.stat-card-label {
  font-family: var(--font-pixel-title);
  font-size: 0.62rem;
  color: #94a3b8;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.stat-card-val {
  font-family: var(--font-pixel-title);
  font-size: 1.25rem;
  color: #fbbf24;
  text-shadow: 2px 2px 0 #000;
}

/* ==========================================================================
   SANCTUARY SHOP & META-UPGRADES STYLES
   ========================================================================== */

.lobby-header-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  max-width: 1200px;
}

.lobby-treasury-badge {
  position: absolute;
  right: 0;
  top: 10px;
  background: #080d19;
  border: 3px solid #000;
  box-shadow: 
    inset 2px 2px 0 #334155, 
    inset -2px -2px 0 #000, 
    0 4px 0 #000;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.treasury-icon {
  font-size: 1.1rem;
}

.treasury-label {
  font-family: var(--font-pixel-title);
  font-size: 0.65rem;
  color: #94a3b8;
}

.treasury-val {
  font-family: var(--font-pixel-title);
  font-size: 0.85rem;
  color: #fbbf24;
  text-shadow: 1px 1px 0 #000;
}

/* Shop Button in Lobby */
.btn-shop {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px 30px;
  background: #b45309;
  color: #fef08a;
  font-family: var(--font-pixel-title);
  font-size: 0.78rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 
    inset 3px 3px 0px #fbbf24, 
    inset -3px -3px 0px #78350f, 
    0 6px 0px #000;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
  user-select: none;
}

.btn-shop:hover {
  background: #d97706;
  box-shadow: 
    inset 3px 3px 0px #fef08a, 
    inset -3px -3px 0px #b45309, 
    0 6px 0px #000, 
    0 0 20px rgba(251, 191, 36, 0.5);
  transform: translateY(-2px);
}

.btn-shop:active {
  transform: translateY(4px);
  box-shadow: 
    inset 3px 3px 0px #78350f, 
    inset -3px -3px 0px #fbbf24, 
    0 2px 0px #000;
}

/* Shop Modal */
#shop-modal {
  z-index: 250;
}

#shop-modal .shop-content {
  width: 92%;
  max-width: 980px;
  max-height: 85vh;
  overflow-y: auto;
}

.shop-top-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
  gap: 16px;
}

.shop-treasury-box {
  background: #070b15;
  border: 3px solid #000;
  box-shadow: 
    inset 2px 2px 0 #334155, 
    inset -2px -2px 0 #000, 
    0 4px 0 #000;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-pixel-title);
  font-size: 0.72rem;
  color: #94a3b8;
}

.shop-gold-val {
  color: #fbbf24;
  font-size: 0.95rem;
  text-shadow: 1px 1px 0 #000;
}

.btn-refund {
  background: #334155;
  color: #f87171 !important;
  font-size: 0.68rem;
  padding: 10px 16px;
}

.btn-refund:hover {
  background: #475569;
  color: #fca5a5 !important;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
}

.shop-card {
  background: #080d19;
  border: 3px solid #000;
  box-shadow: 
    inset 2px 2px 0 #334155, 
    inset -2px -2px 0 #000, 
    0 4px 0 #000;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

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

.shop-card-name {
  font-family: var(--font-pixel-title);
  font-size: 0.85rem;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}

.shop-card-rank {
  font-family: var(--font-pixel-title);
  font-size: 0.65rem;
  color: #fbbf24;
}

.shop-card-pips {
  display: flex;
  gap: 5px;
  margin: 2px 0;
}

.shop-pip {
  flex: 1;
  height: 9px;
  background: #1e293b;
  border: 1.5px solid #000;
  box-shadow: inset 1px 1px 0 #334155;
}

.shop-pip.filled {
  background: #fbbf24;
  border-color: #000;
  box-shadow: inset 0 2px 0 #fef08a, 0 0 6px rgba(251, 191, 36, 0.7);
}

.shop-card-desc {
  font-family: var(--font-pixel-body);
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.4;
  min-height: 32px;
}

.shop-buy-btn {
  width: 100%;
  padding: 10px 0;
  background: #0284c7;
  color: #fff;
  border: 2px solid #000;
  border-radius: 0;
  font-family: var(--font-pixel-title);
  font-size: 0.72rem;
  box-shadow: 
    inset 2px 2px 0 #7dd3fc, 
    inset -2px -2px 0 #0369a1, 
    0 3px 0 #000;
  cursor: pointer;
  transition: all 0.1s ease;
}

.shop-buy-btn:hover:not(:disabled) {
  background: #0ea5e9;
  transform: translateY(-2px);
  box-shadow: 
    inset 2px 2px 0 #bae6fd, 
    inset -2px -2px 0 #0284c7, 
    0 5px 0 #000;
}

.shop-buy-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 
    inset 2px 2px 0 #0369a1, 
    0 1px 0 #000;
}

.shop-buy-btn:disabled {
  background: #1e293b;
  color: #64748b;
  cursor: not-allowed;
  box-shadow: inset 1px 1px 0 #334155, 0 2px 0 #000;
  border-color: #000;
}

.shop-buy-btn.maxed {
  background: #78350f;
  color: #fde047;
  box-shadow: inset 2px 2px 0 #f59e0b, 0 2px 0 #000;
  cursor: default;
}

/* ==========================================================================
   SETTINGS & SYSTEM CONFIG MODAL STYLES
   ========================================================================== */
.settings-dialog {
  max-width: 820px;
  width: 94%;
  max-height: 88vh;
  overflow-y: auto;
}

.settings-content-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
}

.settings-section {
  background: rgba(13, 18, 32, 0.75);
  border: 2px solid #1e293b;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.65);
  padding: 16px 20px;
}

.settings-section-title {
  font-family: var(--font-pixel-title);
  font-size: 0.78rem;
  color: #38bdf8;
  letter-spacing: 1px;
  text-shadow: 1px 1px 0 #000;
  margin-bottom: 14px;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 8px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(51, 65, 85, 0.35);
  gap: 16px;
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-name {
  font-family: var(--font-pixel-body);
  font-size: 0.88rem;
  color: #f8fafc;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 0 #000;
}

.setting-desc {
  font-family: var(--font-pixel-condensed);
  font-size: 1.05rem;
  color: #94a3b8;
}

.setting-ctrl {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Custom Pixel Sliders */
.pixel-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 12px;
  background: #090d16;
  border: 2px solid #334155;
  box-shadow: inset 1px 1px 0 #000;
  outline: none;
  cursor: pointer;
}

.pixel-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 20px;
  background: #f59e0b;
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 #fef08a, 0 2px 0 #78350f;
  cursor: pointer;
}

.pixel-slider::-webkit-slider-thumb:hover {
  background: #fbbf24;
}

.slider-badge {
  font-family: var(--font-pixel-title);
  font-size: 0.72rem;
  color: #facc15;
  min-width: 50px;
  text-align: right;
  text-shadow: 1px 1px 0 #000;
}

/* Interactive Toggles & Choice Buttons */
.btn-toggle {
  font-family: var(--font-pixel-title);
  font-size: 0.68rem;
  padding: 7px 14px;
  background: #1e293b;
  color: #64748b;
  border: 2px solid #334155;
  box-shadow: 0 2px 0 #000;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-toggle.active {
  background: #0284c7;
  color: #fff;
  border-color: #38bdf8;
  box-shadow: inset 1px 1px 0 #7dd3fc, 0 3px 0 #0369a1, 0 0 10px rgba(56, 189, 248, 0.4);
}

.btn-segmented {
  font-family: var(--font-pixel-title);
  font-size: 0.7rem;
  padding: 8px 16px;
  background: #1e293b;
  color: #94a3b8;
  border: 2px solid #334155;
  box-shadow: 0 3px 0 #000;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-segmented.active {
  background: #0f766e;
  color: #ccfbf1;
  border-color: #2dd4bf;
  box-shadow: inset 1px 1px 0 #5eead4, 0 3px 0 #115e59, 0 0 12px rgba(45, 212, 191, 0.35);
}

.choice-group {
  display: flex;
  gap: 6px;
}

.btn-choice {
  font-family: var(--font-pixel-title);
  font-size: 0.65rem;
  padding: 7px 12px;
  background: #0f172a;
  color: #64748b;
  border: 2px solid #1e293b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-choice.active {
  background: #0284c7;
  color: #fff;
  border-color: #38bdf8;
  box-shadow: inset 1px 1px 0 #7dd3fc, 0 2px 0 #0369a1;
}

/* Keybinds Reference Cards */
.keybind-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.keybind-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #070b14;
  border: 1px solid #1e293b;
  padding: 8px 12px;
  box-shadow: inset 1px 1px 0 #000;
}

.key-pill {
  font-family: var(--font-pixel-title);
  font-size: 0.62rem;
  background: #1e293b;
  color: #38bdf8;
  padding: 4px 8px;
  border: 1px solid #334155;
  box-shadow: 0 2px 0 #000;
  white-space: nowrap;
}

.key-desc {
  font-family: var(--font-pixel-condensed);
  font-size: 1.05rem;
  color: #cbd5e1;
}

/* Danger Button for Data Reset */
.btn-danger {
  font-family: var(--font-pixel-title);
  font-size: 0.68rem;
  padding: 8px 16px;
  background: #7f1d1d;
  color: #fecaca;
  border: 2px solid #ef4444;
  box-shadow: inset 1px 1px 0 #f87171, 0 3px 0 #450a0a;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger:hover {
  background: #991b1b;
  color: #fff;
  box-shadow: inset 1px 1px 0 #fca5a5, 0 3px 0 #450a0a, 0 0 12px rgba(239, 68, 68, 0.5);
}

.btn-danger:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #450a0a;
}

.hidden {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .characters-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .brand-title {
    font-size: 1.8rem;
  }
  #upgrade-cards {
    flex-direction: column;
    align-items: center;
  }
  .codex-grid, .shop-grid {
    grid-template-columns: 1fr;
  }
  .lobby-header-bar {
    flex-direction: column;
    gap: 12px;
  }
  .lobby-treasury-badge {
    position: static;
  }
}
