/* ============================================================
   Chrono-Front: Galactic War — Main Menu Styles
   REVISED: Garden + Military + Sci-Fi identity.
   Two-column layout: menu left, coming-soon card right.
   ============================================================ */

/* ── Page Layout ─────────────────────────────────────────── */
body.menu-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(34,211,238,0.15) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 10%, rgba(124,58,237,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 40%, #060d1a 0%, #020408 100%);
}

.loading-audio-toggle {
  position: relative;
  z-index: 2;
  margin-top: 12px;
  padding: 9px 14px;
  border: 1px solid rgba(34, 211, 238, 0.55);
  border-radius: 4px;
  background: rgba(8, 145, 178, 0.12);
  color: #e8f0ff;
  font: 700 11px 'Exo 2', sans-serif;
  cursor: pointer;
}

/* ── Scanlines (subtle sci-fi texture) ───────────────────── */
.bg-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.04) 3px,
    rgba(0,0,0,0.04) 4px
  );
}

/* ── Animated Background Orbs ────────────────────────────── */
.bg-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.bg-particles::before,
.bg-particles::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  animation: floatOrb 16s ease-in-out infinite alternate;
}

.bg-particles::before {
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(34,211,238,0.15) 0%, transparent 65%);
  top: -200px; left: -200px;
}

.bg-particles::after {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(124,58,237,0.1) 0%, transparent 65%);
  bottom: -150px; right: -100px;
  animation-delay: -8s;
  animation-duration: 20s;
}

@keyframes floatOrb {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(80px, 50px) scale(1.2); }
}

/* Leaf particles (CSS anim, injected by JS) */
.leaf-particle {
  position: absolute;
  opacity: 0;
  animation: leafFloat linear infinite;
  pointer-events: none;
}
@keyframes leafFloat {
  0%   { transform: translateY(0) rotate(0deg) translateX(0);   opacity: 0; }
  8%   { opacity: 0.7; }
  88%  { opacity: 0.4; }
  100% { transform: translateY(-110vh) rotate(540deg) translateX(20px); opacity: 0; }
}

/* Plasma particles (CSS anim, injected by JS) */
.plasma-particle {
  position: absolute;
  opacity: 0;
  animation: plasmaFloat linear infinite;
  pointer-events: none;
}
@keyframes plasmaFloat {
  0%   { transform: translateY(0) scale(1);   opacity: 0; }
  10%  { opacity: 0.8; }
  80%  { opacity: 0.5; }
  100% { transform: translateY(-115vh) scale(0.5); opacity: 0; }
}

/* ── Two-Column Page Layout ──────────────────────────────── */
.page-layout {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 32px;
  width: 100%;
  max-width: 1100px;
  padding: 32px 20px 24px;
}

/* ── Main Menu Column ────────────────────────────────────── */
.menu-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
  max-width: 460px;
  flex-shrink: 0;
}

/* ── Header / Title ──────────────────────────────────────── */
.menu-header {
  position: relative;
  text-align: center;
  width: 100%;
}

.title-glow-ring {
  position: absolute;
  top: 55%; left: 50%;
  transform: translate(-50%, -50%);
  width: 340px; height: 130px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(34,211,238,0.15) 0%, transparent 70%);
  pointer-events: none;
}

/* Alert badge above title */
.title-badge {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 12px;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #fef08a;
  background: rgba(220, 38, 38, 0.25);
  border: 1px solid rgba(239,68,68,0.5);
  border-radius: 3px;
  text-transform: uppercase;
  animation: badgePulse 2.5s ease-in-out infinite;
}
@keyframes badgePulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.65; }
}

.game-title {
  font-family: var(--font-title);
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.title-top {
  font-size: clamp(1.6rem, 6vw, 2.8rem);
  color: #67e8f9;
  text-shadow:
    0 0 10px rgba(34,211,238,0.6),
    0 0 36px rgba(34,211,238,0.15);
  letter-spacing: 0.06em;
}

/* Divider between CHRONO-FRONT and REBORN */
.title-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0 16px;
}
.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(163,230,53,0.5), transparent);
}
.divider-icon {
  color: #fbbf24;
  font-size: 0.8rem;
}

.title-bottom {
  font-size: clamp(1.6rem, 5.5vw, 2.8rem);
  color: #fbbf24;
  text-shadow:
    0 0 12px rgba(251,191,36,0.7),
    0 0 32px rgba(251,191,36,0.25);
  letter-spacing: 0.18em;
}

.game-subtitle {
  margin-top: 8px;
  font-size: clamp(0.7rem, 2vw, 0.88rem);
  color: #7a9e7a;
  letter-spacing: 0.07em;
  font-style: italic;
}

/* Threat level bar */
.threat-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 14px;
  background: rgba(220,38,38,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 4px;
}
.threat-label {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: #f87171;
  font-weight: 700;
}
.threat-pips {
  display: flex;
  gap: 4px;
}
.pip {
  width: 10px; height: 10px;
  border-radius: 2px;
  background: rgba(239,68,68,0.2);
  border: 1px solid rgba(239,68,68,0.3);
}
.pip--active {
  background: #ef4444;
  box-shadow: 0 0 5px rgba(239,68,68,0.8);
  animation: pipBlink 1.8s ease-in-out infinite;
}
.pip--active:nth-child(2) { animation-delay: 0.2s; }
.pip--active:nth-child(3) { animation-delay: 0.4s; }
.pip--active:nth-child(4) { animation-delay: 0.6s; }
@keyframes pipBlink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}
.threat-value {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #fca5a5;
}

/* ── Navigation ──────────────────────────────────────────── */
.menu-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.menu-btn-row {
  display: flex;
  gap: 12px;
  width: 100%;
}
.menu-btn-row .menu-btn { flex: 1; }

/* ── Buttons ─────────────────────────────────────────────── */
.menu-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: 0.1em;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.menu-btn:active { transform: scale(0.96); }

/* Primary — PLAY (military olive-to-green) */
.menu-btn--primary {
  height: 62px;
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  background: linear-gradient(135deg, #0e7490 0%, #0891b2 50%, #0369a1 100%);
  color: #fff;
  border: 1.5px solid rgba(34,211,238,0.45);
  box-shadow: 0 4px 20px rgba(22,163,74,0.45), inset 0 1px 0 rgba(255,255,255,0.08);
}
.menu-btn--primary:hover {
  background: linear-gradient(135deg, #0891b2 0%, #06b6d4 50%, #0284c7 100%);
  box-shadow: 0 6px 26px rgba(34,211,238,0.35);
  transform: translateY(-2px);
}
.btn-shine {
  position: absolute;
  top: 0; left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: skewX(-20deg);
  animation: shineSweep 4s ease-in-out infinite;
}
@keyframes shineSweep {
  0%, 100% { left: -75%; }
  50%       { left: 120%; }
}

/* Military variant (LEVELS button) */
.menu-btn--military {
  background: rgba(30, 50, 14, 0.85) !important;
  border-color: rgba(163,230,53,0.3) !important;
  color: #a3e635 !important;
}
.menu-btn--military:hover {
  background: rgba(40, 68, 18, 0.95) !important;
  border-color: rgba(163,230,53,0.6) !important;
  box-shadow: 0 4px 16px rgba(163,230,53,0.18) !important;
}

/* Secondary */
.menu-btn--secondary {
  height: 52px;
  font-size: clamp(0.72rem, 2.4vw, 0.88rem);
  background: rgba(10, 20, 8, 0.82);
  color: #67e8f9;
  border: 1.5px solid rgba(34,211,238,0.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.menu-btn--secondary:hover {
  background: rgba(14, 30, 10, 0.92);
  border-color: rgba(34,211,238,0.4);
  color: #d9f99d;
  transform: translateY(-1px);
}

/* Tertiary (CREDITS) */
.menu-btn--tertiary {
  height: 40px;
  font-size: clamp(0.68rem, 2vw, 0.8rem);
  background: transparent;
  color: #7a9e7a;
  border: 1px solid rgba(122,158,122,0.2);
}
.menu-btn--tertiary:hover {
  color: #22d3ee;
  border-color: rgba(163,230,53,0.35);
  background: rgba(255,255,255,0.03);
}

.btn-icon { font-size: 1em; line-height: 1; }
.btn-label { pointer-events: none; }

/* ── Footer ──────────────────────────────────────────────── */
.menu-footer { margin-top: -4px; }
.version-tag {
  font-size: 0.68rem;
  color: #7a9e7a;
  opacity: 0.5;
  letter-spacing: 0.06em;
}

/* ── Coming Soon Card ────────────────────────────────────── */
.coming-soon-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 280px;
  min-height: 380px;
  background:
    linear-gradient(160deg, rgba(124,58,237,0.08) 0%, rgba(10,20,8,0.92) 60%),
    rgba(10,14,22,0.9);
  border: 1.5px solid rgba(124,58,237,0.3);
  border-radius: 18px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(124,58,237,0.15), 0 0 0 1px rgba(124,58,237,0.08);
  overflow: hidden;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 10px;
  animation: cardFloat 6s ease-in-out infinite;
}
@keyframes cardFloat {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* Alien corner accent */
.coming-soon-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle at top right, rgba(124,58,237,0.25), transparent 70%);
  pointer-events: none;
}

.cs-badge {
  padding: 3px 12px;
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #c4b5fd;
  background: rgba(124,58,237,0.2);
  border: 1px solid rgba(124,58,237,0.45);
  border-radius: 3px;
  text-transform: uppercase;
}

.cs-logo-area {
  position: relative;
  width: 80px; height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cs-logo-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(124,58,237,0.4);
  animation: ringPulse 2.5s ease-in-out infinite;
}
@keyframes ringPulse {
  0%,100% { transform: scale(1);   opacity: 0.6; }
  50%      { transform: scale(1.1); opacity: 1; }
}
.cs-logo-icon { font-size: 2.4rem; filter: drop-shadow(0 0 8px #7c3aed); }

.cs-title {
  font-family: var(--font-title);
  font-size: clamp(0.9rem, 3vw, 1.15rem);
  color: #c4b5fd;
  text-shadow: 0 0 10px rgba(124,58,237,0.6);
  letter-spacing: 0.06em;
  margin: 0;
}
.cs-subtitle {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #fbbf24;
  margin: 0;
}
.cs-description {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: #9ca3af;
  line-height: 1.55;
  margin: 0;
}
.cs-hint {
  color: #7a9e7a;
  font-style: italic;
  font-size: 0.72rem;
}
.cs-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.cs-tag {
  padding: 2px 9px;
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #a78bfa;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 20px;
}
.cs-notify-btn {
  width: 100%;
  padding: 10px 0;
  background: linear-gradient(135deg, #5b21b6, #7c3aed);
  color: #fff;
  border: 1px solid rgba(196,181,253,0.4);
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  margin-top: auto;
}
.cs-notify-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(124,58,237,0.5);
}
.cs-notify-btn:active { transform: scale(0.97); }

/* ── Overlays ────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(5px);
  animation: fadeIn 0.18s ease;
}
.overlay[hidden] { display: none !important; }
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay-box {
  background: linear-gradient(160deg, rgba(10,24,10,0.98), rgba(4,9,10,0.98));
  border: 1.5px solid rgba(34,211,238,0.2);
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  max-width: 440px;
  width: 100%;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7), 0 0 20px rgba(34,211,238,0.15);
  animation: slideUp 0.2s ease;
}
.overlay-box--wide {
  max-width: 640px;
  /* Prevent the box from overflowing the viewport — keeps Back button visible */
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
@keyframes slideUp {
  from { transform: translateY(18px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.overlay-title {
  font-family: var(--font-title);
  font-size: 1.45rem;
  color: #86efac;
  margin-bottom: 6px;
  text-shadow: 0 0 12px rgba(34,211,238,0.4);
}
.overlay-subtitle {
  font-size: 0.8rem;
  color: #7a9e7a;
  margin-bottom: 18px;
  letter-spacing: 0.06em;
}
.overlay-body {
  color: #9ca3af;
  line-height: 1.65;
  margin-bottom: 24px;
  font-size: 0.92rem;
}
.overlay-close-btn { max-width: 200px; margin: 16px auto 0; }

/* ── Levels Grid ─────────────────────────────────────────── */
.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 10px 12px;
  border-radius: 10px;
  min-height: 110px;
  text-align: center;
  transition: transform 0.12s, box-shadow 0.15s;
}

/* Unlocked / current */
.level-card--unlocked {
  background: linear-gradient(145deg, rgba(22,101,52,0.6), rgba(10,30,10,0.9));
  border: 1.5px solid rgba(34,211,238,0.4);
  cursor: pointer;
  font-family: var(--font-ui);
  color: #e2f5e2;
}
.level-card--unlocked:hover { transform: scale(1.04); box-shadow: 0 4px 16px rgba(34,211,238,0.25); }

.level-card--current { border-color: #86efac; box-shadow: 0 0 12px rgba(34,211,238,0.3); }

/* Locked */
.level-card--locked {
  background: rgba(15,15,15,0.5);
  border: 1px solid rgba(255,255,255,0.06);
  cursor: not-allowed;
  opacity: 0.6;
  font-family: var(--font-ui);
  color: #4b5563;
}
.level-lock { font-size: 1.2rem; position: absolute; top: 8px; right: 8px; }

/* Future placeholder */
.level-card--future {
  background: transparent;
  border: 1px dashed rgba(34,211,238,0.15);
  color: #4b5563;
  font-size: 0.72rem;
  font-family: var(--font-ui);
  font-style: italic;
  cursor: default;
}
.level-more { font-size: 0.7rem; }

.level-num  { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.level-name { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; }
.level-diff { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.1em; padding: 2px 8px; border-radius: 20px; }
.level-diff--easy   { background: rgba(22,163,74,0.25);  color: #86efac; border: 1px solid rgba(22,163,74,0.3); }
.level-diff--moderate { background: rgba(14,165,233,0.2); color: #bae6fd; border: 1px solid rgba(14,165,233,0.35); }
.level-diff--medium { background: rgba(234,179,8,0.2);   color: #fde68a; border: 1px solid rgba(234,179,8,0.3); }
.level-diff--hard   { background: rgba(239,68,68,0.2);   color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.level-diff--expert { background: rgba(126,34,206,0.25); color: #e9d5ff; border: 1px solid rgba(192,132,252,0.5); }
.level-diff--impossible { background: rgba(127,29,29,0.45); color: #fecaca; border: 1px solid rgba(248,113,113,0.75); }
.level-stars { display: flex; gap: 2px; margin-top: 2px; }
.star { color: #fbbf24; font-size: 0.85rem; }

/* ── Credits body ────────────────────────────────────────── */
.credits-body {
  text-align: left;
  color: #9ca3af;
  line-height: 1.8;
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.credits-body p { margin-bottom: 12px; }
.credits-body strong { color: #fbbf24; display: block; }
.credits-note { text-align: center; color: #7a9e7a; font-style: italic; font-size: 0.78rem; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 720px) {
  .page-layout { flex-direction: column; align-items: center; gap: 24px; }
  .coming-soon-card { max-width: 420px; min-height: auto; align-self: center; margin-top: 0; }
  .menu-wrapper { max-width: 420px; }
}
@media (max-width: 400px) {
  .menu-wrapper { padding: 16px; gap: 16px; }
  .menu-btn--primary { height: 54px; }
  .menu-btn--secondary { height: 46px; }
}

/* ── Signal Row (replaces alien invasion event badge) ─── */
.signal-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.signal-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(239,68,68,0.3);
  border: 1px solid rgba(239,68,68,0.3);
}
.signal-dot--active {
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239,68,68,0.8);
  animation: pipBlink 2s ease-in-out infinite;
}
.signal-text {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: #f87171;
  font-weight: 700;
}

/* ── Dust particles ─────────────────────────────────────── */
.dust-particle {
  position: absolute;
  animation: leafFloat linear infinite;
  pointer-events: none;
}

/* ── Adventure Options ──────────────────────────────────── */
.adventure-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.adv-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: rgba(22,101,52,0.3);
  border: 1.5px solid rgba(34,211,238,0.3);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-ui);
  color: #e8f5e9;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: left;
  width: 100%;
}
.adv-btn:hover {
  background: rgba(22,101,52,0.5);
  border-color: rgba(34,211,238,0.6);
  transform: translateX(4px);
}
.adv-btn--secondary { background: rgba(10,24,10,0.5); border-color: rgba(34,211,238,0.15); }
.adv-icon { font-size: 1.6rem; flex-shrink: 0; }
.adv-text { display: flex; flex-direction: column; gap: 3px; }
.adv-name { font-weight: 700; font-size: 0.9rem; letter-spacing: 0.08em; }
.adv-desc { font-size: 0.75rem; color: #7a9e7a; }

/* ── Phase Tabs (Levels overlay) ────────────────────────── */
.overlay-box--fullscreen { max-width: 860px; }
.levels-phase-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.phase-tab {
  padding: 6px 14px;
  background: rgba(10,24,10,0.7);
  border: 1px solid rgba(34,211,238,0.15);
  border-radius: 20px;
  color: #7a9e7a;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.phase-tab:hover { color: #86efac; border-color: rgba(34,211,238,0.4); }
.phase-tab--active {
  background: rgba(22,101,52,0.4);
  border-color: #86efac;
  color: #86efac;
  box-shadow: 0 0 8px rgba(34,211,238,0.2);
}
.level-req {
  font-size: 0.6rem;
  color: #6b7280;
  font-style: italic;
  margin-top: 2px;
}
.level-complete { color: #fbbf24; font-size: 0.9rem; }
.level-card--completed { border-color: rgba(251,191,36,0.4) !important; }

/* ── Characters overlay ─────────────────────────────────── */
.chars-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.char-tab {
  flex: 1;
  padding: 8px;
  background: rgba(10,24,10,0.7);
  border: 1.5px solid rgba(34,211,238,0.15);
  border-radius: 8px;
  color: #7a9e7a;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.12s;
}
.char-tab:hover { color: #86efac; border-color: rgba(34,211,238,0.4); }
.char-tab--active {
  background: rgba(22,101,52,0.4);
  border-color: #86efac;
  color: #86efac;
}
/* Panels are block by default; [hidden] must win over display:block */
.chars-panel { display: block; }
.chars-panel[hidden] { display: none !important; }
.chars-panel--active { display: block; }
.chars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  max-height: 280px;
  min-height: 80px;
  overflow-y: auto;
  flex-shrink: 1;   /* allow grid to compress when box is height-constrained */
  margin-bottom: 14px;
  padding: 4px;
}
.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px 10px;
  border-radius: 8px;
  text-align: center;
  font-family: var(--font-ui);
  transition: transform 0.1s;
}
.char-card--unlocked {
  background: rgba(22,101,52,0.25);
  border: 1px solid rgba(34,211,238,0.3);
  color: #e8f5e9;
}
.char-card--unlocked:hover { transform: scale(1.04); }
.char-card--alien {
  background: rgba(124,58,237,0.2);
  border: 1px solid rgba(124,58,237,0.35);
  color: #e8f5e9;
}
.char-card--locked {
  background: rgba(10,10,10,0.4);
  border: 1px solid rgba(255,255,255,0.06);
  color: #4b5563;
  opacity: 0.7;
}
.char-icon { font-size: 1.4rem; }
.char-silhouette {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #374151;
}
.char-name { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; }
.char-name--locked { color: #6b7280; }
.char-role {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 1px 6px;
  border-radius: 10px;
}
.char-role--offense  { background: rgba(239,68,68,0.2);  color: #fca5a5; }
.char-role--energy   { background: rgba(251,191,36,0.2);  color: #fde68a; }
.char-role--medic    { background: rgba(34,211,238,0.2); color: #86efac; }
.char-role--engineer { background: rgba(251,191,36,0.2);  color: #fde68a; }
.char-role--defense  { background: rgba(96,165,250,0.2);  color: #93c5fd; }
.char-role--alien    { background: rgba(124,58,237,0.2);  color: #c4b5fd; }
.char-cost { font-size: 0.72rem; color: #a78bfa; font-weight: 700; }
.char-lock { font-size: 0.62rem; color: #6b7280; }
.extras-count {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  padding: 8px 12px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.65);
}
.extras-count strong { color: #86efac; font-size: 1.05rem; }
.extras-count span { color: #9ca3af; font-size: 0.7rem; }
.extras-catalog-content { min-height: 0; }
.extras-detail {
  color: #cbd5e1;
  font-size: 0.64rem;
  line-height: 1.4;
  max-width: 220px;
}

/* ── Mode Grid (mini-games, puzzle, survival) ───────────── */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
  padding: 4px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 8px;
  text-align: center;
  font-family: var(--font-ui);
  position: relative;
  transition: transform 0.1s, box-shadow 0.1s;
}
.mode-card--unlocked {
  background: rgba(22,101,52,0.25);
  border: 1px solid rgba(34,211,238,0.3);
  color: #e8f5e9;
  cursor: pointer;
}
.mode-card--unlocked:hover { transform: scale(1.04); box-shadow: 0 2px 12px rgba(34,211,238,0.18); }
.mode-card--locked {
  background: rgba(10,10,10,0.35);
  border: 1px solid rgba(255,255,255,0.06);
  color: #4b5563;
  opacity: 0.7;
  cursor: default;
}
.mode-icon { font-size: 1.5rem; }
.mode-name { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; }
.mode-lock { position: absolute; top: 6px; right: 8px; font-size: 0.8rem; }
.mode-desc { font-size: 0.62rem; color: #6b7280; line-height: 1.3; }

/* ── Survival section layout ────────────────────────────── */
.survival-modes-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.survival-section { flex: 1; min-width: 200px; }
.survival-section-title {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #7a9e7a;
  margin-bottom: 10px;
}

/* ── Endless Card ───────────────────────────────────────── */
.endless-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: rgba(124,58,237,0.15);
  border: 1.5px solid rgba(124,58,237,0.4);
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-ui);
  color: #e8f5e9;
  width: 100%;
  transition: transform 0.1s, box-shadow 0.12s;
}
.endless-card:hover { transform: scale(1.03); box-shadow: 0 4px 20px rgba(124,58,237,0.3); }
.endless-icon { font-size: 2.5rem; color: #a78bfa; }
.endless-name { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.08em; color: #c4b5fd; }
.endless-desc { font-size: 0.72rem; color: #9ca3af; text-align: center; line-height: 1.4; }
.endless-score { font-size: 0.7rem; color: #fbbf24; font-weight: 600; }

/* ── Extras Grid ────────────────────────────────────────── */
.extras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.extras-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  border-radius: 10px;
  font-family: var(--font-ui);
  text-align: center;
}
.extras-card--locked {
  background: rgba(10,10,10,0.4);
  border: 1px solid rgba(255,255,255,0.07);
  color: #4b5563;
  opacity: 0.75;
}
.extras-icon { font-size: 1.6rem; }
.extras-name { font-size: 0.72rem; font-weight: 600; color: #6b7280; }
.extras-lock { position: absolute; top: 6px; right: 8px; font-size: 0.8rem; }

/* ── Settings ───────────────────────────────────────────── */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.setting-label {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: #9ca3af;
  flex: 1;
}
.setting-slider {
  width: 140px;
  accent-color: #86efac;
}
.setting-checkbox {
  width: 18px;
  height: 18px;
  accent-color: #86efac;
  cursor: pointer;
}
.setting-select {
  min-width: 150px;
  padding: 7px 9px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 4px;
  background: #07130f;
  color: #e8f0ff;
  font: 600 0.76rem var(--font-ui);
}
.setting-select:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }

/* ── Story Intro Panels ─────────────────────────────────── */
.intro-panels {
  min-height: 160px;
  margin-bottom: 16px;
  position: relative;
}
.intro-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 16px 8px;
  animation: slideUp 0.2s ease;
}
.intro-panel--active { display: flex; }
.intro-icon { font-size: 2.5rem; }
.intro-panel-title {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #86efac;
}
.intro-panel-text {
  font-size: 0.85rem;
  color: #9ca3af;
  line-height: 1.6;
  max-width: 420px;
}
.intro-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}
.intro-page {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: #7a9e7a;
  min-width: 50px;
  text-align: center;
}

/* ── Responsive additions ───────────────────────────────── */
@media (max-width: 720px) {
  .overlay-box--fullscreen { max-width: 98vw; }
  .survival-modes-row { flex-direction: column; }
  .mode-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* Short viewports: shrink chars grid further so Back button stays visible */
@media (max-height: 700px) {
  .chars-grid { max-height: 180px; }
}

/* ── Locked menu buttons ─────────────────────────────────── */
.menu-btn--lockable {
  position: relative;
}
.menu-btn--locked {
  opacity: 0.55;
  cursor: default;
}
.menu-btn--locked:hover {
  transform: none !important;
  box-shadow: none !important;
}
.btn-lock-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  opacity: 0.7;
  pointer-events: none;
}

/* ── Player greeting ─────────────────────────────────────── */
.player-greeting {
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: #7a9e6a;
  letter-spacing: 0.06em;
  opacity: 0.8;
}

/* ── Quit button variant ─────────────────────────────────── */
.menu-btn--quit {
  color: #9ca3af !important;
  border-color: rgba(156,163,175,0.2) !important;
}
.menu-btn--quit:hover {
  color: #ef4444 !important;
  border-color: rgba(239,68,68,0.3) !important;
}

/* ── New player overlay ──────────────────────────────────── */
.overlay-box--new-player {
  max-width: 420px;
  text-align: center;
}
.np-logo {
  font-size: 3rem;
  margin-bottom: 12px;
}
.np-input-row {
  margin: 16px 0 8px;
}
.np-input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(10, 30, 10, 0.8);
  border: 1.5px solid rgba(34,211,238,0.35);
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 1rem;
  color: #e8f5e9;
  letter-spacing: 0.06em;
  outline: none;
  text-align: center;
  transition: border-color 0.15s;
}
.np-input:focus {
  border-color: rgba(34,211,238,0.7);
  box-shadow: 0 0 12px rgba(34,211,238,0.2);
}
.np-input::placeholder { color: #4b5563; }
.np-error {
  min-height: 20px;
  font-size: 0.78rem;
  color: #ef4444;
  margin-bottom: 8px;
}

/* ── Locked overlay ──────────────────────────────────────── */
.locked-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

/* ── Character Portrait System ───────────────────────────── */
/* Replaces emoji icons with detailed SVG pixel-art portraits */

.char-card {
  /* Override to accommodate taller portrait */
  padding: 8px 6px 8px;
}

.char-portrait {
  width: 56px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
  margin-bottom: 2px;
  flex-shrink: 0;
  position: relative;
}

.char-portrait--svg {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.char-portrait--svg svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  /* Pixel-art style rendering */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.char-portrait--svg img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: crisp-edges;
}

/* Military portrait tint (green border) */
.char-card--unlocked .char-portrait--svg {
  border-color: rgba(34, 211, 238, 0.28);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.12) inset;
}

/* Alien portrait tint (purple border) */
.char-portrait--alien {
  background: rgba(74, 26, 120, 0.35);
  border-color: rgba(168, 85, 247, 0.35) !important;
  box-shadow: 0 0 8px rgba(232, 121, 249, 0.12) inset !important;
}

.char-portrait--canvas img {
  width: 56px;
  height: 72px;
  image-rendering: pixelated;
}

/* Locked portrait slot */
.char-portrait--locked {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
}

.char-silhouette-q {
  font-size: 1.8rem;
  color: #374151;
  font-weight: 900;
  line-height: 1;
}

/* Rarity badge for aliens */
.char-rarity {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border-radius: 8px;
  margin-top: 1px;
}
.char-rarity--common    { background: rgba(148,163,184,0.2); color: #cbd5e1; }
.char-rarity--uncommon  { background: rgba(34,197,94,0.2);   color: #86efac; }
.char-rarity--rare      { background: rgba(99,102,241,0.2);  color: #a5b4fc; }
.char-rarity--very_rare { background: rgba(232,121,249,0.2); color: #f0abfc; }
.char-rarity--legendary { background: rgba(251,191,36,0.25); color: #fde68a; }

/* ── Rarity variants for military cards ─────────────────── */
.char-role--common   { background: rgba(148,163,184,0.18); color: #cbd5e1; }
.char-role--uncommon { background: rgba(34,197,94,0.18);   color: #86efac; }
.char-role--rare     { background: rgba(99,102,241,0.18);  color: #a5b4fc; }

/* Hover glow on unlocked cards */
.char-card--unlocked:hover .char-portrait--svg,
.char-card--alien:hover    .char-portrait--svg {
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.25) inset;
}
.char-card--alien:hover .char-portrait--alien {
  box-shadow: 0 0 14px rgba(232, 121, 249, 0.28) inset !important;
}

@media (max-width: 900px) {
  body.menu-page {
    align-items: stretch;
    justify-content: flex-start;
    min-height: 100dvh;
  }
  .page-layout {
    flex-direction: column;
    align-items: center;
    gap: 22px;
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }
  .menu-wrapper { max-width: 480px; flex-shrink: 1; }
  .coming-soon-card { max-width: 480px; min-height: auto; align-self: center; margin: 0; }
}

@media (max-width: 520px) {
  body.menu-page { min-height: 100svh; min-height: 100dvh; }
  .page-layout {
    gap: 18px;
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  .menu-wrapper { gap: 16px; }
  .menu-nav, .menu-btn-row { width: 100%; }
  .coming-soon-card { padding: 22px 18px 18px; }
  .overlay {
    align-items: flex-start;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .overlay-box { padding: 24px 18px 20px; max-height: calc(100dvh - 24px); }
  .overlay-title { font-size: 1.2rem; }
  .levels-grid { grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 8px; }
  .phase-tabs { flex-wrap: wrap; }
  .phase-tab { flex: 1 1 30%; min-height: 42px; }
}

@media (max-height: 760px) {
  body.menu-page { align-items: flex-start; }
  .page-layout { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
}
