:root {
  --bg-color: #080b14;
  --bg-card: rgba(16, 22, 40, 0.85);
  --cyan-glow: #00f0ff;
  --magenta-glow: #ff0077;
  --gold-glow: #ffd700;
  --text-main: #f0f4f8;
  --text-muted: #8a99ad;
  --border-glass: rgba(255, 255, 255, 0.12);
  --font-display: 'Orbitron', -apple-system, sans-serif;
  --font-body: 'Rajdhani', -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 16px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button, input, select, textarea, a, .btn, .icon-btn, .btn-primary, .btn-secondary, .btn-tertiary, .btn-outline, .btn-close-modal, .btn-mini, .hud-exit-btn, .turbo-badge, .btn-touchpad-turbo {
  touch-action: manipulation !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

input[type="text"] {
  user-select: text !important;
  -webkit-user-select: text !important;
}

#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, #111a33 0%, #080b14 100%);
}

/* TOP HEADER */
#game-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  background: rgba(8, 11, 20, 0.95);
  border-bottom: 1px solid var(--border-glass);
  z-index: 50;
  height: 46px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 2px;
}

.logo-text .highlight {
  color: var(--cyan-glow);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.icon-btn:hover, .icon-btn:active {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--cyan-glow);
}

.icon-btn.active-toggle {
  background: rgba(0, 240, 255, 0.25);
  border-color: var(--cyan-glow);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
  color: #fff;
}

/* MAIN VIEWPORT */
#main-stage {
  flex: 1 1 0%;
  min-height: 0;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
}

.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  display: flex !important;
  opacity: 1;
}

/* LOBBY SCREEN */
#screen-lobby {
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.hero-box {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  padding: 22px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  margin: auto;
}

.glitch-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2.1rem;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.8), 2px 2px 0 var(--magenta-glow);
  margin-bottom: 2px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

/* OBJECTIVE & SKILLS BANNER */
.objective-banner {
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
  text-align: left;
}

.objective-header {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--gold-glow);
  letter-spacing: 1px;
  margin-bottom: 3px;
}

.objective-desc {
  font-size: 0.86rem;
  color: #fff;
  line-height: 1.3;
}

.objective-desc strong {
  color: var(--gold-glow);
}

.skills-banner {
  background: rgba(181, 23, 158, 0.12);
  border: 1px solid rgba(181, 23, 158, 0.4);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 12px;
  text-align: left;
}

.skills-header {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  color: #ff70a6;
  letter-spacing: 1px;
  margin-bottom: 3px;
}

.skills-desc {
  font-size: 0.84rem;
  color: #e0e6ed;
  line-height: 1.35;
}

.skills-desc strong {
  color: #ff70a6;
}

.player-profile-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
  text-align: left;
}

.player-profile-card label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  color: var(--cyan-glow);
  margin-bottom: 5px;
}

.name-input-wrap {
  display: flex;
  gap: 8px;
}

.name-input-wrap input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.95rem;
  outline: none;
}

.name-input-wrap input:focus {
  border-color: var(--cyan-glow);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.name-input-wrap button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 1.1rem;
  cursor: pointer;
  color: #fff;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* BUTTONS */
.btn {
  font-family: var(--font-display);
  font-weight: 700;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  outline: none;
  border: none;
  letter-spacing: 1px;
}

.btn-primary {
  background: linear-gradient(135deg, #00f0ff 0%, #0077ff 100%);
  color: #040814;
  box-shadow: 0 4px 18px rgba(0, 240, 255, 0.35);
}

.btn-primary:hover, .btn-primary:active {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0, 240, 255, 0.55);
}

.btn-large {
  padding: 13px 16px;
}

.btn-large strong {
  display: block;
  font-size: 1.05rem;
}

.btn-large small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.8rem;
  opacity: 0.85;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: #fff;
}

.btn-secondary:hover, .btn-secondary:active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-tertiary {
  background: rgba(157, 78, 221, 0.15);
  border: 1px solid rgba(157, 78, 221, 0.4);
  color: #e0aaff;
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-muted);
}

.btn-full {
  width: 100%;
}

.btn-mini {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass);
  color: #fff;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}

.guide-chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 8px;
}

.guide-chips .chip {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.guide-chips .chip span {
  color: var(--cyan-glow);
  font-weight: 600;
}

/* SCREEN 2: WAITING ROOM */
#screen-room {
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.room-box {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  margin: auto;
}

.room-header {
  margin-bottom: 18px;
}

.room-header h2 {
  font-family: var(--font-display);
  letter-spacing: 2px;
  font-size: 1.35rem;
  margin-bottom: 8px;
}

.room-code-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid var(--cyan-glow);
  padding: 5px 12px;
  border-radius: 18px;
}

.room-code-badge strong {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 3px;
  color: var(--cyan-glow);
}

.room-code-badge button {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 0.78rem;
}

.matchup-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.slot-card {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--border-glass);
}

.p1-card { border-color: rgba(0, 240, 255, 0.4); }
.p2-card { border-color: rgba(255, 0, 119, 0.4); }

.slot-badge {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 1px;
  margin-bottom: 4px;
  opacity: 0.8;
}

.player-avatar {
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.slot-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.slot-status {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 1px;
}

.slot-status.ready {
  background: rgba(0, 240, 255, 0.2);
  color: var(--cyan-glow);
}

.slot-status.waiting {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.vs-divider {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.05rem;
  color: var(--gold-glow);
}

.room-footer-notice {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
}

.room-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* SCREEN 3: IN-GAME BATTLEGROUND */
#screen-game {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#screen-game.active {
  display: flex !important;
}

/* RESPONSIVE HUD BAR */
#game-hud {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px;
  background: rgba(8, 11, 20, 0.95);
  border-bottom: 1px solid var(--border-glass);
  min-height: 52px;
  z-index: 20;
}

.hud-player {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-width: 0;
}

.p1-hud { align-items: flex-start; }
.p2-hud { align-items: flex-end; text-align: right; }

.hud-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  overflow: hidden;
}

.hud-name {
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cyan-dot { background: var(--cyan-glow); box-shadow: 0 0 6px var(--cyan-glow); }
.magenta-dot { background: var(--magenta-glow); box-shadow: 0 0 6px var(--magenta-glow); }

/* BIG BOLD SCORE DISPLAY */
.hud-score-display {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.5px;
  margin: 1px 0;
}

.highlight-cyan {
  color: var(--cyan-glow);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

.highlight-magenta {
  color: var(--magenta-glow);
  text-shadow: 0 0 10px rgba(255, 0, 119, 0.6);
}

.hud-cores-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
}

.cores-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
}

.cores-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.74rem;
}

.hud-combo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.68rem;
  color: var(--gold-glow);
}

.hud-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 0 4px;
}

.match-timer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-glass);
  padding: 2px 8px;
  border-radius: 8px;
}

.timer-label {
  font-size: 0.52rem;
  letter-spacing: 1px;
  color: var(--text-muted);
}

#hud-timer {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-main);
}

/* TURBO BADGE IN HUD (VISIBLE ON DESKTOP) */
.turbo-badge {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 4px 10px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.turbo-badge.ready {
  background: rgba(255, 215, 0, 0.2);
  border-color: var(--gold-glow);
  color: #fff;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
}

.turbo-badge.active {
  background: rgba(255, 69, 0, 0.35);
  border-color: #ff4500;
  color: #fff;
  box-shadow: 0 0 16px rgba(255, 69, 0, 0.7);
}

.hud-exit-btn {
  background: rgba(255, 60, 60, 0.15);
  border: 1px solid rgba(255, 60, 60, 0.4);
  color: #ff9999;
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hud-exit-btn:hover, .hud-exit-btn:active {
  background: rgba(255, 60, 60, 0.35);
  border-color: #ff4d6d;
  color: #fff;
}

/* CANVAS WRAPPER */
#canvas-wrapper {
  flex: 1 1 0%;
  min-height: 0;
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #040711;
  touch-action: none;
  cursor: crosshair;
  contain: strict;
  transform: translateZ(0);
  will-change: transform;
}

#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1200 / 700;
  object-fit: contain;
  contain: size layout paint;
  transform: translateZ(0);
}

/* DEDICATED BOTTOM TOUCHPAD ZONE (FULL-WIDTH & CENTERED) */
#touchpad-zone {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  background: rgba(8, 11, 20, 0.98);
  border-top: 1px solid var(--border-glass);
  z-index: 30;
  height: 64px;
  width: 100%;
  touch-action: none;
}

.touchpad-slider {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  position: relative;
  touch-action: none;
}

.touchpad-track {
  width: 100%;
  height: 44px;
  background: rgba(0, 240, 255, 0.06);
  border: 1.5px solid rgba(0, 240, 255, 0.35);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 14px rgba(0, 240, 255, 0.15);
}

.track-hint {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  color: var(--cyan-glow);
  opacity: 0.85;
  pointer-events: none;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
  white-space: nowrap;
}

.thumb-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 50%;
  width: 42px;
  transform: translateX(-50%);
  background: rgba(0, 240, 255, 0.45);
  border: 1.5px solid var(--cyan-glow);
  border-radius: 18px;
  pointer-events: none;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.7);
  transition: left 0.05s ease-out;
}

/* COUNTDOWN OVERLAY */
#countdown-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  z-index: 30;
}

#countdown-number {
  font-family: var(--font-display);
  font-size: 5.5rem;
  font-weight: 900;
  color: var(--gold-glow);
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
}

.countdown-subtext {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none !important;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
  margin: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 1px;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-body {
  margin-bottom: 16px;
}

.modal-body p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
  line-height: 1.4;
}

#input-join-code {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--border-glass);
  border-radius: 10px;
  padding: 10px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 6px;
  text-align: center;
  color: var(--cyan-glow);
  outline: none;
  text-transform: uppercase;
}

#input-join-code:focus {
  border-color: var(--cyan-glow);
}

.error-text {
  color: #ff4d6d;
  font-size: 0.82rem;
  margin-top: 6px;
  text-align: center;
}

/* QR CODE MODAL */
.qr-container {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #0a0d1a;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  min-height: 180px;
}

#lan-qr-img {
  max-width: 170px;
  max-height: 170px;
  border-radius: 8px;
}

.lan-url-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
}

.lan-url-box .url-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.lan-url-box code {
  color: var(--cyan-glow);
  font-family: monospace;
  font-size: 0.9rem;
  word-break: break-all;
}

/* VICTORY MODAL */
.victory-card {
  max-width: 480px;
  text-align: center;
  border-color: rgba(255, 215, 0, 0.4);
  box-shadow: 0 0 35px rgba(255, 215, 0, 0.2);
}

.victory-crown {
  font-size: 2.5rem;
  margin-bottom: 2px;
}

.winner-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--gold-glow);
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
  margin-bottom: 2px;
}

.winner-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.endgame-stats-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--border-glass);
  margin-bottom: 16px;
}

.stat-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-col h4 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.5rem;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.vs-col {
  justify-content: flex-end;
  padding-bottom: 2px;
}

.stat-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.4);
}

.gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* TOAST NOTIFICATIONS */
#toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: rgba(16, 22, 40, 0.95);
  border: 1px solid var(--cyan-glow);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

.hidden { display: none !important; }

/* RADAR BADGE (QUICK PLAY WAITING ALERT) */
.radar-badge {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.7);
  animation: radarPulse 1.4s ease-in-out infinite;
}

@keyframes radarPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; box-shadow: 0 0 16px rgba(16, 185, 129, 0.9); }
}

/* LEADERBOARD CARD */
.leaderboard-card {
  width: 100%;
  background: rgba(16, 22, 40, 0.75);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 10px;
  backdrop-filter: blur(8px);
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}

.leaderboard-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 800;
  color: #ffd700;
  letter-spacing: 0.8px;
}

.career-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
}

.career-label {
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
}

#career-record {
  color: var(--cyan-glow);
  font-family: var(--font-display);
  font-weight: 800;
}

.leaderboard-table-wrap {
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  text-align: left;
}

.leaderboard-table th {
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.leaderboard-table td {
  padding: 6px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.leaderboard-table tr:last-child td {
  border-bottom: none;
}

.leaderboard-table .rank-cell {
  font-family: var(--font-display);
  font-weight: 800;
}

.leaderboard-table .name-cell {
  font-weight: 700;
  color: #ffffff;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-table .wins-cell {
  font-family: var(--font-display);
  color: var(--cyan-glow);
  font-weight: 800;
}

.leaderboard-table .winrate-cell {
  font-family: var(--font-display);
  color: #10b981;
}

.leaderboard-table .streak-cell {
  color: #f59e0b;
  font-weight: 700;
}

.empty-leaderboard {
  text-align: center;
  color: var(--text-muted);
  padding: 12px 0;
  font-style: italic;
}

/* HEAD-TO-HEAD RIVALRY BANNERS */
.h2h-banner, .gameover-h2h-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.12), rgba(255, 0, 119, 0.12));
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 8px;
  padding: 6px 14px;
  margin: 10px 0;
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 800;
  color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.15);
}

.h2h-icon {
  font-size: 0.95rem;
}

/* MOBILE RESPONSIVE MEDIA QUERIES */
@media (max-width: 600px) {
  #game-header { padding: 4px 8px; height: 42px; }
  .logo-text { font-size: 0.88rem; }
  .icon-btn { padding: 4px 8px; font-size: 0.78rem; }
  .glitch-title { font-size: 1.6rem; }
  .hero-box, .room-box, .modal-card { padding: 14px; }
  .action-row { grid-template-columns: 1fr; }
  
  /* On mobile: hide redundant HUD turbo button so scores fit with ample space! */
  #btn-turbo { display: none; }
  
  #game-hud { padding: 3px 8px; min-height: 48px; }
  .hud-name { font-size: 0.7rem; max-width: 80px; }
  .hud-score-display { font-size: 1.22rem; }
  .cores-value { font-size: 0.68rem; }
  .match-timer-box { padding: 1px 6px; }
  #hud-timer { font-size: 0.92rem; }
  .hud-exit-btn { padding: 3px 6px; font-size: 0.68rem; }
  
  #touchpad-zone { height: 64px; padding: 6px 8px; }
  .btn-touchpad-turbo { height: 40px; padding: 0 12px; font-size: 0.76rem; }
  .touchpad-track { height: 40px; }
  .track-hint { font-size: 0.58rem; letter-spacing: 0.8px; }

  .leaderboard-card { padding: 10px; }
  .leaderboard-table { font-size: 0.68rem; }
}
