@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Bebas+Neue&family=Nunito:wght@400;700;900&display=swap");

/* ══════════════════════════════════════════
   ROOT & RESET
══════════════════════════════════════════ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --px: "Press Start 2P", monospace;
  --mod: "Nunito", sans-serif;
  --title: "Bebas Neue", sans-serif;

  /* Pixel palette */
  --dark: #06060f;
  --dark2: #0d0d1e;
  --panel: #0a0a1c;
  --border: #1e1e3a;
  --gold: #ffd700;
  --green: #4ab04a;
  --red: #e8331a;
  --blue: #44aaff;
  --muted: #6060a0;
  --white: #f0f0ff;

  /* Modern palette */
  --m-bg1: #0f0c29;
  --m-bg2: #1a1040;
  --m-accent: #ff6b35;
  --m-gold: #ffd23f;
  --m-green: #06d6a0;
  --m-red: #ef233c;
  --m-blue: #4cc9f0;
  --m-purple: #7209b7;
  --m-card: rgba(255, 255, 255, 0.06);
  --m-card-border: rgba(255, 255, 255, 0.12);
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--dark);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ══════════════════════════════════════════
   SCREENS
══════════════════════════════════════════ */
.screen {
  display: none;
  width: 100vw;
  height: 100vh;
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════════
   MODERN SCREEN BASE
══════════════════════════════════════════ */
.modern-screen {
  font-family: var(--mod);
  color: #fff;
  overflow-y: auto;
}
.modern-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(135deg, #0f0c29 0%, #1a0a3a 40%, #0d1b2a 100%);
  pointer-events: none;
}
.modern-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      ellipse 60% 40% at 20% 20%,
      rgba(114, 9, 183, 0.25) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 50% 50% at 80% 80%,
      rgba(76, 201, 240, 0.15) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 40% 60% at 60% 10%,
      rgba(255, 107, 53, 0.12) 0%,
      transparent 50%
    );
}

/* ══════════════════════════════════════════
   PIXEL LOGIN
══════════════════════════════════════════ */
#loginScreen {
  font-family: var(--px);
  align-items: center;
  justify-content: center;
  background: var(--dark);
}
.login-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(68, 170, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(68, 170, 255, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  animation: gridScroll 24s linear infinite;
}
.login-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
}
@keyframes gridScroll {
  to {
    background-position: 32px 32px;
  }
}

.login-center {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.game-logo {
  text-align: center;
}
.logo-top {
  display: flex;
  align-items: baseline;
  gap: 6px;
  justify-content: center;
}
.logo-pixel {
  font-size: clamp(18px, 4vw, 32px);
  color: var(--gold);
  text-shadow:
    3px 3px 0 #7a5000,
    0 0 24px #ffd70055;
}
.logo-run {
  font-size: clamp(18px, 4vw, 32px);
  color: var(--blue);
  text-shadow:
    3px 3px 0 #003366,
    0 0 24px #44aaff55;
}
.logo-z {
  font-size: clamp(36px, 8vw, 64px);
  color: var(--red);
  text-shadow:
    4px 4px 0 #800,
    0 0 30px #ff0000aa;
  line-height: 1;
  animation: zPulse 2s ease-in-out infinite;
}
@keyframes zPulse {
  0%,
  100% {
    text-shadow:
      4px 4px 0 #800,
      0 0 30px #ff0000aa;
  }
  50% {
    text-shadow:
      4px 4px 0 #800,
      0 0 50px #ff4444ff;
  }
}
.logo-tag {
  font-size: 7px;
  color: var(--muted);
  margin-top: 6px;
  letter-spacing: 1px;
}

.login-box {
  background: var(--panel);
  border: 2px solid var(--border);
  padding: 28px 24px;
  width: min(360px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 0 40px rgba(232, 51, 26, 0.1);
}
.login-box-header {
  font-size: 11px;
  color: var(--green);
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: 3px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 7px;
  color: var(--muted);
  letter-spacing: 2px;
}
.field input {
  background: var(--dark);
  border: 2px solid var(--border);
  color: var(--white);
  padding: 11px 10px;
  font-family: var(--px);
  font-size: 9px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus {
  border-color: var(--gold);
}

/* Login buttons — full width matching input fields */
.px-btn {
  font-family: var(--px);
  font-size: 9px;
  padding: 14px 18px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 1px;
  margin: 0 auto;
  width: 100%;
  text-align: center;
  display: block;
}
.px-btn:active {
  transform: translateY(1px);
}
.px-btn-primary {
  background: var(--green);
  color: #fff;
  border-color: #2d7d2d;
  box-shadow: 0 4px 16px rgba(74, 176, 74, 0.4);
}
.px-btn-primary:hover {
  background: #5ccc5c;
  box-shadow: 0 6px 22px rgba(74, 176, 74, 0.6);
}
.px-btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.px-btn-ghost:hover {
  color: var(--white);
  border-color: #555;
}

.login-msg {
  font-size: 7px;
  color: var(--red);
  text-align: center;
  min-height: 12px;
}
.login-note {
  font-size: 7px;
  color: var(--muted);
  text-align: center;
}
.px-btn-forgot {
  font-family: var(--px);
  font-size: 7px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  width: 100%;
  letter-spacing: 1px;
  padding: 2px;
  transition: color 0.15s;
}
.px-btn-forgot:hover {
  color: var(--gold);
}

/* ══════════════════════════════════════════
   MODERN BUTTONS
══════════════════════════════════════════ */
.modern-btn {
  font-family: var(--mod);
  font-weight: 900;
  font-size: 15px;
  padding: 14px 28px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}
.modern-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background 0.2s;
}
.modern-btn:hover::after {
  background: rgba(255, 255, 255, 0.1);
}
.modern-btn:active {
  transform: scale(0.97);
}
.modern-btn-primary {
  background: linear-gradient(135deg, var(--m-accent), #ff3870);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4);
}
.modern-btn-primary:hover {
  box-shadow: 0 6px 28px rgba(255, 107, 53, 0.6);
}
.modern-btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.full-btn {
  width: 100%;
  margin-top: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

/* ══════════════════════════════════════════
   CHARACTER SELECT
══════════════════════════════════════════ */
#charScreen {
  align-items: center;
  padding: 20px 16px 32px;
  gap: 20px;
  overflow-y: auto;
}
.char-header {
  position: relative;
  z-index: 1;
  text-align: center;
}
.char-title {
  font-family: var(--title);
  font-size: clamp(32px, 6vw, 56px);
  color: #fff;
  letter-spacing: 4px;
  text-shadow: 0 0 30px rgba(255, 107, 53, 0.5);
}
.char-sub {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
}
.char-coins {
  font-family: var(--mod);
  font-weight: 900;
  font-size: 14px;
  color: var(--m-gold);
  background: rgba(255, 210, 63, 0.12);
  border: 1px solid rgba(255, 210, 63, 0.3);
  padding: 5px 16px;
  border-radius: 50px;
  margin-top: 8px;
  display: inline-block;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: min(680px, 96vw);
  position: relative;
  z-index: 1;
}
@media (max-width: 500px) {
  .char-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.char-card {
  background: var(--m-card);
  border: 2px solid var(--m-card-border);
  border-radius: 16px;
  padding: 16px 10px;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: visible;
}
.char-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    var(--char-color, #ff6b35) 0%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.25s;
}
.char-card:hover {
  border-color: var(--char-color, #ff6b35);
  transform: translateY(-4px);
}
.char-card:hover::before {
  opacity: 0.15;
}
.char-card.selected {
  border-color: var(--char-color, #ff6b35);
  box-shadow:
    0 0 20px var(--char-color, #ff6b35),
    0 8px 32px rgba(0, 0, 0, 0.4);
  transform: translateY(-4px);
}
.char-card.selected::before {
  opacity: 0.2;
}

.char-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.char-canvas {
  display: block;
  image-rendering: pixelated;
}
.char-name {
  font-family: var(--title);
  font-size: 18px;
  color: #fff;
  letter-spacing: 2px;
  text-align: center;
}
.char-class {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
}
.char-stats {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.stat-pip {
  font-size: 8px;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}
.char-locked {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.char-locked:hover {
  background: rgba(0, 0, 0, 0.55);
}
.char-locked-btn {
  background: linear-gradient(135deg, #ff6b35, #ff3870);
  color: #fff;
  font-family: var(--mod);
  font-weight: 900;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: 0 4px 16px rgba(255, 107, 53, 0.5);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.char-locked-label {
  font-size: 10px;
  font-family: var(--mod);
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════
   WEAPON SELECT
══════════════════════════════════════════ */
.weapon-section {
  width: min(680px, 96vw);
  position: relative;
  z-index: 1;
}
.section-label {
  font-family: var(--title);
  font-size: 22px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 3px;
  margin-bottom: 10px;
}
.weapon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 500px) {
  .weapon-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.weapon-card {
  background: var(--m-card);
  border: 2px solid var(--m-card-border);
  border-radius: 12px;
  padding: 12px 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}
.weapon-card:hover {
  border-color: var(--m-gold);
  transform: translateY(-2px);
}
.weapon-card.selected {
  border-color: var(--m-gold);
  box-shadow: 0 0 16px rgba(255, 210, 63, 0.4);
  background: rgba(255, 210, 63, 0.08);
}
.weapon-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
}
.weapon-icon {
  font-size: 28px;
}
.weapon-name {
  font-family: var(--title);
  font-size: 16px;
  color: #fff;
  letter-spacing: 1px;
}
.weapon-desc {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  line-height: 1.4;
}
.weapon-lock {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
}

/* ══════════════════════════════════════════
   WORLD MAP
══════════════════════════════════════════ */
#mapScreen {
  overflow-y: auto;
}
.map-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(15, 12, 41, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
.map-player-info {
  flex: 1;
}
.map-username {
  font-family: var(--title);
  font-size: 22px;
  color: #fff;
  letter-spacing: 2px;
}
.map-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  align-items: center;
}
.lives-tag {
  font-size: 14px;
  letter-spacing: 1px;
}
.map-timer {
  font-size: 11px;
  color: #ff6b6b;
  font-family: var(--mod);
  font-weight: 700;
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

.map-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  position: relative;
  z-index: 1;
}
.worlds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  max-width: 800px;
  margin: 0 auto;
}

.world-card {
  background: var(--m-card);
  border: 2px solid var(--m-card-border);
  border-radius: 18px;
  padding: 18px 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.world-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--card-color, #ff6b35);
  border-radius: 18px 18px 0 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s;
}
.world-card:hover:not(.locked) {
  border-color: var(--card-color, #ff6b35);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.world-card:hover:not(.locked)::after {
  transform: scaleX(1);
}
.world-card.locked {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.6);
}
.wc-icon {
  font-size: 28px;
  margin-bottom: 8px;
}
.wc-chapter {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 2px;
  font-family: var(--mod);
}
.wc-name {
  font-family: var(--title);
  font-size: 20px;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.wc-progress {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 6px;
  font-family: var(--mod);
}
.wc-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}
.wc-bar-fill {
  height: 100%;
  background: var(--card-color, #ff6b35);
  border-radius: 4px;
  transition: width 0.5s;
}
.wc-lock {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 16px;
}

/* ══════════════════════════════════════════
   LEVEL SELECT
══════════════════════════════════════════ */
#levelScreen {
  overflow-y: auto;
}
.level-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(15, 12, 41, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.level-world-title {
  font-family: var(--title);
  font-size: clamp(18px, 4vw, 28px);
  color: #fff;
  letter-spacing: 2px;
  flex: 1;
}
.level-lives {
  font-size: 14px;
  letter-spacing: 1px;
}
.level-subtitle {
  font-size: 12px;
  font-family: var(--mod);
  color: rgba(255, 255, 255, 0.4);
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 1;
}
.level-grid-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  position: relative;
  z-index: 1;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  max-width: 700px;
  margin: 0 auto;
}
@media (max-width: 500px) {
  .level-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.level-btn {
  background: var(--m-card);
  border: 2px solid var(--m-card-border);
  border-radius: 10px;
  color: #fff;
  font-family: var(--mod);
  font-weight: 700;
  font-size: 12px;
  padding: 10px 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.level-btn:hover:not(.locked) {
  border-color: var(--m-gold);
  transform: scale(1.1);
  z-index: 2;
  box-shadow: 0 4px 16px rgba(255, 210, 63, 0.3);
}
.level-btn.locked {
  opacity: 0.25;
  cursor: not-allowed;
}
.level-btn.completed {
  border-color: var(--m-green);
  background: rgba(6, 214, 160, 0.08);
}
.level-btn.completed::after {
  content: "★";
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 8px;
  color: var(--m-gold);
}

/* ══════════════════════════════════════════
   ROTATE PROMPT (portrait mobile only)
══════════════════════════════════════════ */
#rotatePrompt {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #06060f;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.rotate-inner {
  text-align: center;
}
.rotate-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: spin 2s linear infinite;
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(90deg);
  }
  100% {
    transform: rotate(90deg);
  }
}
.rotate-text {
  font-family: "Press Start 2P", monospace;
  font-size: 14px;
  color: #ffd700;
  margin-bottom: 8px;
}
.rotate-sub {
  font-family: "Nunito", sans-serif;
  font-size: 14px;
  color: #6060a0;
}

/* Show rotate prompt on portrait mobile */
@media (pointer: coarse) and (orientation: portrait) {
  #rotatePrompt {
    display: flex;
  }
  .screen {
    display: none !important;
  }
  .screen.active {
    display: none !important;
  }
}

/* ══════════════════════════════════════════
   PASSWORD TOGGLE
══════════════════════════════════════════ */
.pass-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pass-wrap input {
  width: 100%;
  padding-right: 36px;
}
.pass-toggle {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.pass-toggle:hover {
  opacity: 1;
}

/* ══════════════════════════════════════════
   FIXED-WIDTH BUTTONS
══════════════════════════════════════════ */
.px-btn {
  width: 280px !important;
  max-width: 100%;
  text-align: center;
}
.modern-btn {
  width: 220px !important;
  max-width: 90%;
  text-align: center;
}
.full-btn {
  width: 100% !important;
  max-width: 400px;
}

/* ══════════════════════════════════════════
   GAME SCREEN — TRUE FULLSCREEN
══════════════════════════════════════════ */
#gameScreen {
  background: #000;
  align-items: stretch;
  justify-content: flex-start;
  flex-direction: column;
  isolation: isolate;
}

/* When gameScreen is not active, ensure canvas is fully hidden */
#gameScreen:not(.active) {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

#gameWrapper {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100vw;
  height: 100vh;
  flex: 1;
}

#hud {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: rgba(6, 6, 15, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: none;
  gap: 8px;
  flex-shrink: 0;
  width: 100%;
}
.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-center {
  flex: 1;
  display: flex;
  justify-content: center;
}
.hud-left span,
.hud-right span {
  font-family: var(--mod);
  font-weight: 900;
  font-size: 11px;
  color: #fff;
}
.hud-chapter {
  color: rgba(255, 255, 255, 0.45) !important;
}
.hud-sep {
  color: rgba(255, 255, 255, 0.2) !important;
}
.hud-level {
  color: var(--m-gold) !important;
}
.hud-lives {
  font-size: 14px !important;
  letter-spacing: 2px;
}
.hud-weapon {
  font-size: 18px !important;
}

#c {
  display: block;
  flex: 1;
  width: 100% !important;
}

/* Desktop: fill full viewport */
@media (pointer: fine) {
  #gameScreen {
    background: #000;
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
  }
  #gameWrapper {
    width: 100vw !important;
    height: 100vh !important;
    display: flex;
    flex-direction: column;
  }
  #gameWrapper #hud {
    width: 100%;
    flex-shrink: 0;
  }
  #c {
    width: 100vw !important;
    height: calc(100vh - 36px) !important;
    flex: 1;
    display: block;
  }
}

/* ══════════════════════════════════════════
   MOBILE CONTROLS — landscape layout
   Left: ▲ on top, ◀ ▶ below
   Right: weapon button (big, dynamic icon)
══════════════════════════════════════════ */
.mobile-controls {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 110px;
  padding: 10px 16px;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 10;
}
@media (pointer: coarse) {
  .mobile-controls {
    display: flex;
  }
}

.mc-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: all;
}
.mc-lr {
  display: flex;
  gap: 8px;
}
.mc-right {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

.mc-btn {
  width: 54px;
  height: 54px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.mc-btn:active {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(0.93);
}

.mc-up {
  width: 50px;
  height: 50px;
  font-size: 18px;
}

/* Weapon button — big, shows current weapon icon */
.mc-atk {
  width: 72px;
  height: 72px;
  background: rgba(255, 107, 53, 0.3);
  border: 3px solid var(--m-accent);
  border-radius: 50%;
  font-size: 30px;
  box-shadow: 0 0 16px rgba(255, 107, 53, 0.4);
}
.mc-atk:active {
  background: rgba(255, 107, 53, 0.55);
}

/* ══════════════════════════════════════════
   CHARACTER SELECT LAYOUT WITH PREVIEW
══════════════════════════════════════════ */
.char-select-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
  position: relative;
  z-index: 1;
}

.char-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  align-content: start;
}

/* Preview panel */
.char-preview-panel {
  width: 200px;
  min-width: 180px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  gap: 8px;
  overflow-y: auto;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .char-select-layout {
    flex-direction: column;
  }
  .char-preview-panel {
    width: 100%;
    min-width: unset;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  .char-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.preview-title {
  font-family: var(--mod);
  font-weight: 900;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 2px;
  text-transform: uppercase;
}
#charPreviewCanvas {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  image-rendering: auto;
}
.preview-name {
  font-family: var(--title);
  font-size: 22px;
  color: #fff;
  letter-spacing: 2px;
}
.preview-stats {
  font-family: var(--mod);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  line-height: 1.6;
}

.preview-weapon-label {
  font-family: var(--mod);
  font-weight: 900;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 2px;
  margin-top: 4px;
  align-self: flex-start;
}
.weapon-grid-small {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.weapon-card-small {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}
.weapon-card-small:hover {
  border-color: var(--m-gold);
  background: rgba(255, 255, 255, 0.1);
}
.weapon-card-small.selected {
  border-color: var(--m-accent);
  background: rgba(255, 107, 53, 0.15);
}
.weapon-card-small .wcs-icon {
  font-size: 20px;
}
.weapon-card-small .wcs-info {
  flex: 1;
}
.weapon-card-small .wcs-name {
  font-family: var(--mod);
  font-weight: 900;
  font-size: 11px;
  color: #fff;
}
.weapon-card-small .wcs-dmg {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
}

/* ══════════════════════════════════════════
   OVERLAYS
══════════════════════════════════════════ */
.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.game-overlay.active {
  display: flex;
}
.overlay-box {
  background: rgba(15, 12, 41, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  min-width: min(300px, 88vw);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.overlay-die {
  border-color: rgba(239, 35, 60, 0.4);
}
.overlay-win {
  border-color: rgba(255, 210, 63, 0.4);
}
.overlay-icon {
  font-size: 48px;
}
.overlay-title {
  font-family: var(--title);
  font-size: 32px;
  color: #fff;
  letter-spacing: 3px;
}
.overlay-die .overlay-title {
  color: #ff4466;
}
.overlay-win .overlay-title {
  color: var(--m-gold);
}
.overlay-msg {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--mod);
}
.overlay-score {
  font-family: var(--title);
  font-size: 22px;
  color: var(--m-gold);
}
.overlay-lives-wait {
  text-align: center;
}
.wait-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  font-family: var(--mod);
  margin-bottom: 4px;
}
.wait-timer {
  font-size: 28px;
  font-family: var(--title);
  color: #ff4466;
  animation: blink 1s step-end infinite;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* ══════════════════════════════════════════════════════════
   STEP 1: CHAR SELECT — SOLO GRID (no preview panel)
══════════════════════════════════════════════════════════ */
.char-grid-solo {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 20px 20px;
  overflow-y: auto;
  flex: 1;
  align-content: start;
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 600px) {
  .char-grid-solo {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ══════════════════════════════════════════════════════════
   STEP 2: WEAPON SCREEN
══════════════════════════════════════════════════════════ */
#weaponScreen {
  align-items: center;
  padding: 0 0 16px;
  gap: 0;
  overflow-y: auto;
}

.weapon-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(15, 12, 41, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.weapon-topbar-title {
  font-family: var(--title);
  font-size: 28px;
  color: #fff;
  letter-spacing: 3px;
  flex: 1;
  text-align: center;
}

.ws-coins {
  font-family: var(--mod);
  font-weight: 900;
  font-size: 14px;
  color: var(--m-gold);
  background: rgba(255, 210, 63, 0.12);
  border: 1px solid rgba(255, 210, 63, 0.3);
  padding: 5px 14px;
  border-radius: 50px;
}

/* Selected char info strip */
.ws-char-info {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

#wsCharCanvas {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.ws-char-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ws-char-name {
  font-family: var(--title);
  font-size: 36px;
  color: #fff;
  letter-spacing: 3px;
}

.ws-char-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Weapon label */
.ws-weapon-label {
  font-family: var(--title);
  font-size: 20px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 3px;
  padding: 12px 20px 8px;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* Big weapon grid */
.weapon-grid-big {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 0 20px 16px;
  width: 100%;
  max-width: 900px;
  position: relative;
  z-index: 1;
}

@media (max-width: 700px) {
  .weapon-grid-big {
    grid-template-columns: repeat(3, 1fr);
  }
}

.weapon-card-big {
  background: var(--m-card);
  border: 2px solid var(--m-card-border);
  border-radius: 14px;
  padding: 14px 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.weapon-card-big:hover:not(.locked) {
  border-color: var(--m-gold);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(255, 210, 63, 0.25);
}

.weapon-card-big.selected {
  border-color: var(--m-accent);
  background: rgba(255, 107, 53, 0.12);
  box-shadow: 0 0 18px rgba(255, 107, 53, 0.4);
}

.weapon-card-big.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.wcb-icon {
  font-size: 32px;
}

.wcb-name {
  font-family: var(--title);
  font-size: 16px;
  color: #fff;
  letter-spacing: 1px;
  text-align: center;
}

.wcb-stats {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
}

.wcb-lock {
  font-size: 10px;
  color: var(--m-gold);
  font-family: var(--mod);
  font-weight: 900;
  text-align: center;
}

/* ══════════════════════════════════════════
   STEP 1: CHAR SCREEN — grid only, no panel
══════════════════════════════════════════ */
#charScreen {
  align-items: center;
  padding: 16px 16px 0;
  gap: 12px;
  overflow: hidden;
  justify-content: flex-start;
}

.char-grid-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  position: relative;
  z-index: 1;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 4px 16px;
}

@media (max-width: 700px) {
  .char-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

#charNextBtn {
  flex-shrink: 0;
  width: calc(100% - 32px) !important;
  max-width: 500px !important;
  margin: 8px 16px 16px !important;
  position: relative;
  z-index: 2;
}

/* ══════════════════════════════════════════
   STEP 2: WEAPON SCREEN
══════════════════════════════════════════ */
#weaponScreen {
  align-items: stretch;
  padding: 0 0 12px;
  gap: 0;
  overflow-y: auto;
  justify-content: flex-start;
}

.weapon-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(15, 12, 41, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.weapon-topbar-title {
  font-family: var(--title);
  font-size: 28px;
  color: #fff;
  letter-spacing: 3px;
  flex: 1;
  text-align: center;
}

.ws-coins {
  font-family: var(--mod);
  font-weight: 900;
  font-size: 13px;
  color: var(--m-gold);
  background: rgba(255, 210, 63, 0.12);
  border: 1px solid rgba(255, 210, 63, 0.3);
  padding: 5px 14px;
  border-radius: 50px;
  white-space: nowrap;
}

.ws-char-info {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

#wsCharCanvas {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  image-rendering: auto;
}

.ws-char-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ws-char-name {
  font-family: var(--title);
  font-size: 40px;
  color: #fff;
  letter-spacing: 3px;
}

.ws-char-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ws-weapon-label {
  font-family: var(--title);
  font-size: 20px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 3px;
  padding: 14px 24px 8px;
  flex-shrink: 0;
}

.weapon-grid-big {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 0 24px 16px;
  flex-shrink: 0;
}

@media (max-width: 800px) {
  .weapon-grid-big {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 500px) {
  .weapon-grid-big {
    grid-template-columns: repeat(2, 1fr);
  }
}

.weapon-card-big {
  background: var(--m-card);
  border: 2px solid var(--m-card-border);
  border-radius: 14px;
  padding: 16px 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.weapon-card-big:hover:not(.locked) {
  border-color: var(--m-gold);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(255, 210, 63, 0.25);
}

.weapon-card-big.selected {
  border-color: var(--m-accent);
  background: rgba(255, 107, 53, 0.12);
  box-shadow: 0 0 18px rgba(255, 107, 53, 0.4);
}

.weapon-card-big.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.wcb-icon {
  font-size: 32px;
}
.wcb-name {
  font-family: var(--title);
  font-size: 16px;
  color: #fff;
  letter-spacing: 1px;
  text-align: center;
}
.wcb-stats {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
}
.wcb-lock {
  font-size: 10px;
  color: var(--m-gold);
  font-family: var(--mod);
  font-weight: 900;
  text-align: center;
}

#letsGoBtn {
  flex-shrink: 0;
  width: calc(100% - 48px) !important;
  max-width: 500px !important;
  margin: 8px auto 16px !important;
  display: block !important;
}

/* ── Hide NEXT and LET'S GO buttons (auto-nav now) ─── */
#charNextBtn,
#letsGoBtn {
  display: none !important;
}
