@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800;900&family=Space+Grotesk:wght@500;700&display=swap');

:root {
  --bg-dark: #070913;
  --panel-bg: rgba(15, 23, 42, 0.78);
  --panel-border: rgba(99, 102, 241, 0.3);
  --panel-glow: rgba(99, 102, 241, 0.2);
  --neon-cyan: #06b6d4;
  --neon-purple: #a855f7;
  --neon-magenta: #ec4899;
  --neon-gold: #facc15;
  --neon-green: #10b981;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Grotesk', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
}

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

/* start.ng Profile Card */
.startng-card {
  position: fixed;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: 9999px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(6, 182, 212, 0.2);
  color: var(--text-primary);
  z-index: 100;
  transition: all 0.2s ease;
}

.startng-card:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 6px 24px rgba(6, 182, 212, 0.35);
}

.startng-card img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-cyan));
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.player-info {
  display: flex;
  flex-direction: column;
}

.player-info b {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #ffffff;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-info span {
  font-size: 11px;
  color: var(--neon-cyan);
  font-family: var(--font-mono);
}

.startng-card button {
  margin-left: 6px;
  border: none;
  border-radius: 9999px;
  padding: 5px 12px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: #032b21;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.startng-card button:hover {
  transform: scale(1.05);
  filter: brightness(1.15);
}

/* Top Right Menu */
.top-menu {
  position: fixed;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 100;
}

.glass-btn {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 9999px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.glass-btn:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
  transform: translateY(-1px);
}

/* HUD Layer */
.hud-layer {
  position: fixed;
  top: 70px;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 50;
  padding: 0 20px;
}

.hud-top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  max-width: 600px;
  margin: 0 auto;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 8px 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.hud-val {
  font-size: 18px;
  font-weight: 900;
  font-family: var(--font-mono);
  color: #ffffff;
}

.hud-val.highlight {
  color: var(--neon-gold);
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.5);
}

/* Surge Drive Bar */
.surge-container {
  max-width: 380px;
  margin: 10px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.surge-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(6, 182, 212, 0.6);
}

.surge-track {
  width: 100%;
  height: 10px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: 9999px;
  overflow: hidden;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.2);
  padding: 1px;
}

.surge-fill {
  height: 100%;
  background: linear-gradient(90deg, #06b6d4, #a855f7, #ec4899);
  border-radius: 9999px;
  transition: width 0.15s ease;
  box-shadow: 0 0 12px #06b6d4;
}

.surge-ready {
  animation: pulse-ready 0.8s infinite alternate;
}

@keyframes pulse-ready {
  from { box-shadow: 0 0 10px #ec4899, 0 0 20px #06b6d4; }
  to { box-shadow: 0 0 25px #ec4899, 0 0 40px #facc15; }
}

/* Buffs */
.hud-buffs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.buff-badge {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--neon-purple);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
  animation: fade-in 0.3s ease;
}

/* Screen Overlays & Modals */
.screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 80;
  padding: 20px;
}

.modal-backdrop {
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(12px);
  z-index: 95;
}

.glass-modal {
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 24px;
  padding: 36px 32px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(99, 102, 241, 0.25);
  position: relative;
  animation: modal-enter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-wide {
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.game-badge {
  display: inline-block;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.5);
  color: var(--neon-cyan);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 9999px;
  margin-bottom: 12px;
}

.game-title {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.1;
  color: #ffffff;
  margin-bottom: 8px;
  text-shadow: 0 0 25px rgba(99, 102, 241, 0.6);
}

.surge-text {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  margin-left: 6px;
}

.game-tagline {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

/* Character Preview */
.character-preview-box {
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
}

#preview-canvas {
  width: 100px;
  height: 100px;
  filter: drop-shadow(0 0 12px rgba(6, 182, 212, 0.5));
}

.char-meta {
  text-align: left;
}

.char-name {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
}

.char-role {
  display: block;
  font-size: 12px;
  color: var(--neon-cyan);
  font-family: var(--font-mono);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.btn-primary {
  background: linear-gradient(135deg, #06b6d4, #6366f1, #a855f7);
  border: none;
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 14px 28px;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 25px rgba(99, 102, 241, 0.5);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 35px rgba(99, 102, 241, 0.7);
  filter: brightness(1.1);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: var(--neon-cyan);
}

.controls-hint {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.controls-hint b {
  color: var(--neon-cyan);
}

/* Game Over Overlay */
.gameover-title {
  font-size: 30px;
  font-weight: 900;
  color: #ef4444;
  letter-spacing: 1px;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
  margin-bottom: 6px;
}

.gameover-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.run-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.run-stat-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 6px;
}

.stat-num {
  display: block;
  font-size: 22px;
  font-weight: 900;
  font-family: var(--font-mono);
  color: var(--neon-gold);
}

.stat-name {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: 4px;
}

.score-status {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--neon-cyan);
  padding: 10px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 10px;
  margin-bottom: 20px;
}

/* Leaderboard Modal */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.modal-header h2 {
  font-size: 22px;
  font-weight: 900;
  color: #ffffff;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: #ffffff;
}

.modal-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-align: left;
}

.board-table-container {
  overflow-y: auto;
  max-height: 340px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 15, 30, 0.7);
  margin-bottom: 16px;
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.board-table th {
  background: rgba(30, 41, 59, 0.9);
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 800;
  color: var(--neon-cyan);
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
}

.board-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}

.board-table tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.board-table tr.my-rank {
  background: rgba(99, 102, 241, 0.25);
  border-left: 3px solid var(--neon-cyan);
  font-weight: 700;
}

.board-footer-tip {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Mobile Controls */
.mobile-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  pointer-events: auto;
}

.mobile-surge-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-magenta), var(--neon-purple));
  border: 3px solid #ffffff;
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 0 25px rgba(236, 72, 153, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .startng-card {
    top: 10px;
    left: 10px;
    padding: 4px 10px 4px 4px;
  }
  .startng-card img {
    width: 32px;
    height: 32px;
  }
  .player-info b {
    max-width: 90px;
    font-size: 12px;
  }
  .hud-top {
    gap: 12px;
    padding: 6px 14px;
  }
  .hud-val {
    font-size: 15px;
  }
  .game-title {
    font-size: 32px;
  }
  .glass-modal {
    padding: 24px 20px;
  }
}
