/* ===== CSS Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #00f0ff;
  --secondary: #b000ff;
  --accent: #ffd700;
  --danger: #ff3366;
  --success: #00ff88;
  --bg-dark: #0a0a12;
  --bg-medium: #12121a;
  --bg-light: #1a1a25;
  --text-primary: #ffffff;
  --text-secondary: #aabbcc;
  --rarity-ur: #b000ff;
  --rarity-ssr: #ffd700;
  --rarity-sr: #00f0ff;
  --rarity-r: #00ff88;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Sans SC', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: 
    radial-gradient(ellipse at 20% 80%, rgba(176, 0, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 240, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 215, 0, 0.05) 0%, transparent 70%),
    var(--bg-dark);
  background-attachment: fixed;
}

/* ===== Game Canvas ===== */
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
}

/* ===== Overlays ===== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: rgba(10, 10, 18, 0.95);
  backdrop-filter: blur(10px);
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ===== Start Screen ===== */
.start-container {
  width: 100%;
  max-width: 900px;
  height: 100%;
  max-height: 100vh;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

#logo-canvas {
  margin-top: 20px;
  filter: drop-shadow(0 0 20px var(--primary));
}

.game-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 900;
  text-align: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(0, 240, 255, 0.5);
  letter-spacing: 4px;
}

.game-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: -10px;
}

/* ===== Setup Sections ===== */
.setup-section {
  width: 100%;
  max-width: 700px;
  background: var(--bg-medium);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 16px;
  padding: 20px;
}

.setup-section h3 {
  font-size: 1rem;
  margin-bottom: 15px;
  color: var(--primary);
  text-align: center;
}

/* ===== Player Count Buttons ===== */
.player-count-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.count-btn {
  flex: 1;
  max-width: 120px;
  padding: 12px 20px;
  font-size: 1rem;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-dark);
  border: 2px solid rgba(0, 240, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.count-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
}

.count-btn.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(176, 0, 255, 0.2));
  border-color: var(--primary);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.5);
}

/* ===== Hero Grid ===== */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  padding: 5px;
}

.hero-card {
  background: var(--bg-dark);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--rarity-r);
  opacity: 0.5;
}

.hero-card.SR::before { background: var(--rarity-sr); }
.hero-card.SSR::before { background: var(--rarity-ssr); }
.hero-card.UR::before { background: var(--rarity-ur); }

.hero-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 8px 25px rgba(0, 240, 255, 0.3);
}

.hero-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
  transform: translateY(-5px);
}

.hero-card.selected::after {
  content: '✓';
  position: absolute;
  top: 5px;
  right: 8px;
  font-size: 1rem;
  color: var(--accent);
}

.hero-emoji {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 5px;
}

.hero-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-title {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.hero-rarity {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: 'Orbitron', sans-serif;
}

.hero-rarity.R { background: rgba(0, 255, 136, 0.2); color: var(--rarity-r); }
.hero-rarity.SR { background: rgba(0, 240, 255, 0.2); color: var(--rarity-sr); }
.hero-rarity.SSR { background: rgba(255, 215, 0, 0.2); color: var(--rarity-ssr); }
.hero-rarity.UR { background: rgba(176, 0, 255, 0.2); color: var(--rarity-ur); }

.hero-hp {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 5px;
}

/* ===== Neon Button ===== */
.neon-button {
  position: relative;
  padding: 15px 50px;
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.3), rgba(176, 0, 255, 0.3));
  border: 2px solid var(--primary);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s ease;
}

.neon-button:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.6), 0 0 60px rgba(176, 0, 255, 0.4);
}

.neon-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.neon-button:hover .btn-glow {
  opacity: 1;
}

/* ===== Global Modifier Hint ===== */
.global-modifier-hint {
  padding: 10px 20px;
  background: rgba(176, 0, 255, 0.1);
  border: 1px solid rgba(176, 0, 255, 0.3);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== Identity Reveal ===== */
.identity-reveal {
  text-align: center;
  animation: fadeInUp 0.5s ease;
}

#identity-canvas {
  margin-bottom: 20px;
  filter: drop-shadow(0 0 30px var(--primary));
}

.identity-reveal h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 2rem;
  margin-bottom: 10px;
}

.identity-reveal p {
  color: var(--text-secondary);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Modal Overlay ===== */
.modal-overlay {
  z-index: 200;
  background: rgba(10, 10, 18, 0.9);
  backdrop-filter: blur(5px);
}

.modal-content {
  background: var(--bg-medium);
  border: 2px solid var(--primary);
  border-radius: 16px;
  padding: 30px;
  max-width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(0, 240, 255, 0.3);
}

.modal-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 20px;
  color: var(--primary);
}

.choice-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice-btn {
  padding: 15px 20px;
  background: var(--bg-dark);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
}

.choice-btn:hover {
  border-color: var(--accent);
  transform: translateX(10px);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.choice-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 5px;
}

.choice-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== Result Screen ===== */
.result-container {
  text-align: center;
  padding: 30px;
  max-width: 500px;
}

.result-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 3rem;
  margin-bottom: 20px;
}

.result-title.victory {
  color: var(--accent);
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.result-title.defeat {
  color: var(--danger);
  text-shadow: 0 0 30px rgba(255, 51, 102, 0.5);
}

.result-message {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.result-details {
  background: var(--bg-dark);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 30px;
  max-height: 300px;
  overflow-y: auto;
}

.result-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.result-detail:last-child {
  border-bottom: none;
}

.result-detail .name {
  font-weight: 500;
}

.result-detail .identity {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.identity-master { background: rgba(255, 215, 0, 0.2); color: var(--rarity-ssr); }
.identity-loyalist { background: rgba(0, 240, 255, 0.2); color: var(--rarity-sr); }
.identity-rebel { background: rgba(255, 51, 102, 0.2); color: var(--danger); }
.identity-traitor { background: rgba(176, 0, 255, 0.2); color: var(--rarity-ur); }

/* ===== Footer ===== */
.footer {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.4);
  z-index: 50;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer a:hover {
  color: var(--accent);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .hero-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
  }
  
  .hero-card {
    padding: 8px;
  }
  
  .hero-emoji {
    font-size: 2rem;
  }
  
  .hero-name {
    font-size: 0.75rem;
  }
  
  .hero-title {
    font-size: 0.65rem;
  }
  
  .count-btn {
    padding: 10px 15px;
    font-size: 0.9rem;
  }
  
  .modal-content {
    padding: 20px;
  }
  
  .result-title {
    font-size: 2rem;
  }
}

/* ===== Animations ===== */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 20px rgba(0, 240, 255, 0.3); }
  50% { box-shadow: 0 0 40px rgba(0, 240, 255, 0.6); }
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}
