/* Survivor Arena - Layout & Menu */

/* ============================================================
   3. UTILITY CLASSES
   ============================================================ */

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.fade-in {
  animation: fadeIn var(--transition-slow) ease forwards;
}

.fade-out {
  animation: fadeOut var(--transition-slow) ease forwards;
}

/* ============================================================
   4. GLASS-MORPHISM MIXIN PATTERN
   ============================================================ */

.glass,
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px var(--glass-shadow),
              inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ============================================================
   5. MAIN MENU SCREEN
   ============================================================ */

.menu-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  contain: layout style paint;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0, 240, 255, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(255, 0, 102, 0.03) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Menu with real background image */
.menu-has-bg {
  background: #050510;
}

.menu-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}

/* Death screen red tint overlay */
#death-screen.menu-has-bg .menu-bg {
  opacity: 0.5;
  filter: saturate(1.3);
}

#death-screen.menu-has-bg::before {
  background: radial-gradient(ellipse at 50% 60%, rgba(180, 0, 0, 0.15) 0%, rgba(60, 0, 0, 0.3) 100%);
}

/* Logo image in main menu */
.menu-logo {
  display: block;
  max-width: min(90%, 500px);
  height: auto;
  margin: 0 auto 4px;
  filter: drop-shadow(0 0 30px rgba(0, 240, 255, 0.3))
          drop-shadow(0 0 60px rgba(255, 0, 102, 0.15));
  animation: titlePulse 4s ease-in-out infinite;
}

/* Inner container: centered with safe scrolling */
.menu-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 600px;
  margin: auto;
  padding: 40px 20px;
}

/* Wider container for grid-based screens */
#upgrades-screen .menu-container,
#character-select .menu-container {
  max-width: 860px;
  padding-top: 24px;
  padding-bottom: 24px;
}

/* Title glow for shop screens */
#upgrades-screen h2,
#character-select h2 {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  letter-spacing: 0.12em;
  color: var(--primary);
  text-shadow:
    0 0 12px var(--primary-glow),
    0 0 30px var(--primary-dim);
  margin-bottom: 4px;
}

/* Glass panel behind content when there's a background image */
.menu-has-bg .menu-container {
  background: rgba(6, 6, 20, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  max-width: 480px;
  padding: 36px 28px;
  margin: auto;
}

/* Animated particle-like background dots */
.menu-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 25%, rgba(0, 240, 255, 0.12) 1px, transparent 1px),
    radial-gradient(circle at 85% 15%, rgba(168, 85, 247, 0.10) 1px, transparent 1px),
    radial-gradient(circle at 45% 75%, rgba(255, 0, 102, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(0, 240, 255, 0.06) 1px, transparent 1px),
    radial-gradient(circle at 30% 50%, rgba(168, 85, 247, 0.06) 1px, transparent 1px);
  background-size: 200px 200px, 250px 250px, 300px 300px, 180px 180px, 220px 220px;
  animation: particleDrift 30s linear infinite;
  pointer-events: none;
  opacity: 0.7;
}

/* Subtle scan-line overlay */
.menu-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
}

.menu-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 40px 24px;
  max-width: 600px;
  width: 100%;
}

.menu-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px var(--glass-shadow),
              inset 0 1px 0 rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%;
}

/* ============================================================
   6. GAME TITLE
   ============================================================ */

.game-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.15;
  text-align: center;
  color: var(--primary);
  text-shadow:
    0 0 10px var(--primary-glow),
    0 0 30px var(--primary-dim),
    0 0 60px rgba(0, 240, 255, 0.15),
    0 2px 4px rgba(0, 0, 0, 0.5);
  animation: titlePulse 4s ease-in-out infinite;
  margin-bottom: 8px;
}

.game-title .title-accent,
.title-accent {
  color: var(--secondary);
  text-shadow:
    0 0 10px var(--secondary-glow),
    0 0 30px var(--secondary-dim),
    0 0 60px rgba(255, 0, 102, 0.15),
    0 2px 4px rgba(0, 0, 0, 0.5);
}

.game-subtitle {
  font-family: var(--font-main);
  font-size: clamp(0.85rem, 2vw, 1.05rem);
  font-weight: 400;
  color: var(--text-secondary);
  text-align: center;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ============================================================
   7. MENU BUTTONS
   ============================================================ */

.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 28px;
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 1.8vw, 1rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  background: rgba(16, 16, 36, 0.8);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: none;
  position: relative;
  overflow: hidden;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-base),
    border-color var(--transition-base),
    background var(--transition-base);
}

.menu-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.05), transparent 60%);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.menu-btn:hover {
  transform: scale(1.03);
  border-color: var(--primary-dim);
  box-shadow:
    0 0 16px rgba(0, 240, 255, 0.12),
    0 4px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.menu-btn:hover::before {
  opacity: 1;
}

.menu-btn:active {
  transform: scale(0.98);
  box-shadow:
    0 0 8px rgba(0, 240, 255, 0.08),
    inset 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Primary variant (cyan accent) */
.menu-btn.primary {
  border-color: var(--primary-dim);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.1), rgba(16, 16, 36, 0.9));
  color: var(--primary);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.06);
}

.menu-btn.primary:hover {
  border-color: var(--primary);
  box-shadow:
    0 0 24px rgba(0, 240, 255, 0.2),
    0 0 48px rgba(0, 240, 255, 0.08),
    0 4px 20px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.18), rgba(16, 16, 36, 0.95));
  color: #fff;
}

/* Secondary variant (pink accent) */
.menu-btn.secondary {
  border-color: var(--secondary-dim);
  color: var(--secondary);
}

.menu-btn.secondary:hover {
  border-color: var(--secondary);
  box-shadow:
    0 0 24px rgba(255, 0, 102, 0.2),
    0 0 48px rgba(255, 0, 102, 0.08),
    0 4px 20px rgba(0, 0, 0, 0.3);
  color: #fff;
}

/* Disabled state */
.menu-btn:disabled,
.menu-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.tagline {
  font-family: var(--font-main);
  font-size: clamp(0.8rem, 2vw, 1rem);
  color: rgba(200, 200, 220, 0.6);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 8px;
}

.player-stats-preview {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: rgba(255, 215, 0, 0.7);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
  padding: 8px 24px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 20px;
  border: 1px solid rgba(255, 215, 0, 0.15);
}

/* Branding label */
.branding-label {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: clamp(0.65rem, 1.5vw, 0.8rem);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  color: rgba(200, 200, 220, 0.5);
  text-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

.branding-original {
  color: rgba(168, 85, 247, 0.65);
  font-weight: 400;
}

.branding-name {
  font-weight: 900;
  color: rgba(0, 240, 255, 0.7);
  text-shadow:
    0 0 8px rgba(0, 240, 255, 0.3),
    0 0 20px rgba(0, 240, 255, 0.1);
  letter-spacing: 0.2em;
}

/* Language selector dropdown */
.lang-select {
  width: 100%;
  padding: 10px 16px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(16, 16, 36, 0.9);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2300f0ff' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.lang-select:hover,
.lang-select:focus {
  border-color: var(--primary-dim);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.1);
}

.lang-select option {
  background: #0a0a1e;
  color: #e0e0e8;
  padding: 8px;
}

.gold-display {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
  padding: 6px 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.menu-btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

/* ============================================================
   8. CHARACTER SELECT GRID
   ============================================================ */

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 700px;
  padding: 8px 0;
}

.character-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition:
    transform var(--transition-fast),
    border-color var(--transition-base),
    box-shadow var(--transition-base);
  position: relative;
  overflow: hidden;
}

.character-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary-dim);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.4),
    0 0 16px rgba(0, 240, 255, 0.08);
}

.character-card.selected {
  border-color: var(--primary);
  box-shadow:
    0 0 20px rgba(0, 240, 255, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.4);
}

.character-card.selected::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), transparent 50%);
  pointer-events: none;
}

/* Locked character */
.character-card.locked {
  opacity: 0.45;
  filter: grayscale(0.8) brightness(0.7);
}

.character-card.locked:hover {
  opacity: 0.6;
  filter: grayscale(0.5) brightness(0.8);
  transform: translateY(-2px);
  border-color: rgba(255, 215, 0, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Price label for locked characters */
.character-price {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  color: #999;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  margin-top: 4px;
}

.character-price.affordable {
  color: #ffd700;
  border-color: rgba(255, 215, 0, 0.35);
  background: rgba(255, 215, 0, 0.08);
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.3);
}

.character-portrait {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  border: 2.5px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.character-card.selected .character-portrait {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.25), 0 4px 16px rgba(0, 0, 0, 0.5);
}

.character-card:hover .character-portrait {
  border-color: var(--primary-dim);
}

.character-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.character-card:hover .character-portrait img {
  transform: scale(1.08);
}

.character-name {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  text-align: center;
}

.character-passive {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}
.character-passive .passive-value {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================================
   9. UPGRADES (PERMANENT) GRID
   ============================================================ */

/* ---- Upgrades Grid ---- */
.upgrades-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  width: 100%;
  padding: 8px 0;
}

/* ---- Upgrade Card (Premium Shop Style) ---- */
.upgrade-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 14px 18px;
  background:
    linear-gradient(165deg, rgba(30, 30, 55, 0.95) 0%, rgba(14, 14, 28, 0.95) 100%);
  border: 1.5px solid rgba(100, 80, 200, 0.2);
  border-radius: var(--radius-lg);
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 0.18s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

/* Subtle top highlight line */
.upgrade-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(168, 85, 247, 0.4), transparent);
}

.upgrade-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: rgba(168, 85, 247, 0.45);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(168, 85, 247, 0.12);
}

.upgrade-card:active {
  transform: scale(0.97);
  transition-duration: 0.08s;
}

.upgrade-card.maxed {
  border-color: rgba(255, 215, 0, 0.3);
}

.upgrade-card.maxed::before {
  background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.5), transparent);
}

.upgrade-card.maxed .upgrade-level {
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold-dim);
}

.upgrade-card.maxed .upgrade-icon {
  border-color: rgba(255, 215, 0, 0.3);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.1);
}

/* ---- Icon ---- */
.upgrade-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 30% 30%, rgba(80, 60, 160, 0.3) 0%, rgba(0, 0, 0, 0.5) 100%);
  border: 1.5px solid rgba(168, 85, 247, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ---- Name ---- */
.upgrade-name {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.2;
}

/* ---- Description (passive text) ---- */
.upgrade-card .character-passive {
  font-size: 0.62rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.3;
  min-height: 1.6em;
}

/* ---- Level display ---- */
.upgrade-level {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

/* ---- Level Progress Bar ---- */
.upgrade-level-bar {
  display: flex;
  gap: 3px;
  justify-content: center;
  width: 90%;
  padding: 3px 0;
}

.upgrade-level-pip {
  flex: 1;
  height: 6px;
  max-width: 18px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.upgrade-level-pip.filled {
  background: linear-gradient(180deg, #c084fc, #7c3aed);
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.35);
}

/* ---- Cost ---- */
.upgrade-cost {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255, 200, 0, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(255, 200, 0, 0.15);
  margin-top: 2px;
  text-shadow: 0 0 6px rgba(255, 200, 0, 0.3);
}

.upgrade-cost::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold-dim);
}