/* =========================================================
   CROSSGAMES - NEON SKY FLIGHT DEDICATED GAME VIEW STYLES
   Aesthetics: Deep Space Neon Violet & Supersonic Flight HUD
   ========================================================= */

:root {
  --bg-dark: #070612;
  --bg-card: rgba(22, 14, 44, 0.85);
  --bg-card-hover: rgba(36, 22, 70, 0.95);
  --border-glass: rgba(255, 255, 255, 0.12);
  --border-glass-bright: rgba(157, 78, 221, 0.4);

  --accent-primary: #9d4edd;
  --accent-secondary: #ff007f;
  --accent-gradient: linear-gradient(135deg, #9d4edd 0%, #ff007f 100%);
  --accent-glow: rgba(157, 78, 221, 0.45);

  --color-gold: #ffb703;
  --color-gold-glow: rgba(255, 183, 3, 0.5);
  --color-danger: #ff4b72;
  --color-danger-glow: rgba(255, 75, 114, 0.5);
  --color-success: #00e676;
  --color-success-glow: rgba(0, 230, 118, 0.5);

  --text-main: #f5f0ff;
  --text-muted: #bfa8e0;
  --text-dim: #7f6a9e;

  --font-display: 'Outfit', 'Noto Sans SC', sans-serif;
  --font-body: 'Noto Sans SC', sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --header-height: 68px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Ambient cosmic glow */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(130px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}
.glow-1 {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, #7b2cbf 0%, transparent 70%);
  top: -120px;
  left: -120px;
}
.glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #ff007f 0%, transparent 70%);
  bottom: -150px;
  right: -150px;
}

.app-root {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: rgba(14, 10, 28, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-back-hub {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass-bright);
  border-radius: var(--radius-full);
  color: var(--text-main);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s ease;
}
.btn-back-hub:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateX(-2px);
  color: #fff;
}

.game-brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 14px var(--accent-glow);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
}
.brand-sub {
  font-size: 11px;
  color: var(--accent-secondary);
  font-weight: 700;
  display: block;
}

/* Header Middle Quick Level Changer */
.header-middle {
  display: flex;
  align-items: center;
  gap: 12px;
}

.level-indicator-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(157, 78, 221, 0.15);
  border: 1px solid var(--accent-primary);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  color: #fff;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(157, 78, 221, 0.25);
  transition: all 0.2s ease;
}
.level-indicator-btn:hover {
  background: rgba(157, 78, 221, 0.25);
  transform: scale(1.03);
}

.btn-nav-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}
.btn-nav-arrow:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}
.btn-nav-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-glass);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
}
.stat-chip.stars { color: var(--color-gold); }
.stat-chip.coins { color: #ffd166; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.2s ease;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}

/* Main Layout */
.game-main-layout {
  flex: 1;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 16px 40px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* Top HUD */
.game-hud-top {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  box-shadow: var(--shadow-sm);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass-bright);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
}
.hud-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.05);
}

.hud-middle {
  display: flex;
  flex-direction: column;
  padding: 0 10px;
}

.hud-progress-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.hud-label-distance {
  color: var(--accent-secondary);
  font-family: var(--font-display);
}

.hud-progress-track {
  position: relative;
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width 0.1s linear;
}

.hud-player-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
  transition: left 0.1s linear;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-stat-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
}
.timer-box .hud-val { color: var(--accent-secondary); min-width: 60px; }
.coin-box .hud-val { color: #ffd166; }

/* Canvas Container */
.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 3 / 2;
  background: #090616;
  border: 2px solid var(--border-glass-bright);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.danger-warning-border {
  position: absolute;
  inset: 0;
  border: 4px solid var(--color-danger);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}
.danger-warning-border.active {
  opacity: 1;
  animation: dangerFlash 0.5s ease-in-out infinite alternate;
}
@keyframes dangerFlash {
  from { opacity: 0.2; }
  to { opacity: 0.85; }
}

.canvas-overlay-text {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 15;
}

.floating-text-item {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 18px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  animation: floatUpFade 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes floatUpFade {
  0% { opacity: 1; transform: translateY(0) scale(0.8); }
  20% { transform: translateY(-10px) scale(1.15); }
  100% { opacity: 0; transform: translateY(-40px) scale(1); }
}

/* Mobile Virtual Controls */
.virtual-controls {
  display: none;
  width: 100%;
  max-width: 800px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  gap: 24px;
}

.dpad-container {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dpad-btn {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
}
.dpad-btn:active {
  background: var(--accent-primary);
  color: #0b0d14;
  transform: scale(0.92);
}

.action-buttons-container {
  display: flex;
  align-items: center;
  gap: 16px;
}
.action-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}
.action-boost {
  background: var(--accent-gradient);
  color: #fff;
}
.action-boost:active {
  transform: scale(0.92);
  filter: brightness(1.2);
}
.action-icon { font-size: 24px; }
.action-label { font-size: 11px; font-weight: 800; font-family: var(--font-display); }

/* Desktop Controls Hint */
.desktop-controls-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  flex-wrap: wrap;
}
.hint-item kbd {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass-bright);
  border-radius: 4px;
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  margin: 0 2px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 4, 18, 0.88);
  backdrop-filter: blur(14px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.25s ease-out;
}
@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.overlay-card {
  background: rgba(22, 14, 44, 0.95);
  border: 1px solid var(--border-glass-bright);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  position: relative;
}

.victory-card { border-color: rgba(255, 0, 127, 0.4); box-shadow: 0 20px 60px rgba(255, 0, 127, 0.15); }
.defeat-card { border-color: rgba(255, 75, 114, 0.4); box-shadow: 0 20px 60px rgba(255, 75, 114, 0.15); }

.victory-ribbon {
  position: absolute;
  top: 14px;
  background: var(--accent-gradient);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 4px 18px;
  border-radius: var(--radius-full);
}

.overlay-icon { font-size: 54px; margin-bottom: 8px; }
.overlay-title { font-family: var(--font-display); font-size: 28px; font-weight: 900; color: #fff; margin-bottom: 4px; }
.overlay-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }

/* Stars Animation */
.victory-stars-box {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
  width: 100%;
}
.star-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  flex: 1;
}
.star-slot.earned {
  background: rgba(255, 183, 3, 0.12);
  border-color: var(--color-gold);
  box-shadow: 0 0 16px var(--color-gold-glow);
}
.star-badge {
  font-size: 30px;
  filter: grayscale(1) opacity(0.3);
}
.star-slot.earned .star-badge {
  filter: grayscale(0) opacity(1);
  transform: scale(1.15);
  animation: starPop 0.5s ease;
}
@keyframes starPop {
  0% { transform: scale(0); }
  70% { transform: scale(1.3); }
  100% { transform: scale(1.15); }
}
.star-cond { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.star-slot.earned .star-cond { color: #fff; }

.victory-stats-table {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.vstat-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.vstat-name { color: var(--text-muted); font-weight: 600; }
.vstat-value { font-family: var(--font-display); font-weight: 800; color: #fff; }

.defeat-tip-box {
  width: 100%;
  background: rgba(255, 75, 114, 0.08);
  border: 1px solid rgba(255, 75, 114, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 24px;
  text-align: left;
}
.tip-icon { font-size: 16px; }
.tip-text { font-size: 12px; color: #ffccd5; line-height: 1.5; }

.overlay-buttons { display: flex; flex-direction: column; width: 100%; gap: 12px; }
.button-row { display: flex; gap: 10px; width: 100%; }
.button-row > * { flex: 1; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-gradient);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  box-shadow: 0 0 16px var(--accent-glow);
  transition: all 0.2s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass-bright);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
}
.btn-large { padding: 14px 28px; font-size: 16px; }
.btn-glow-danger {
  background: linear-gradient(135deg, #ff4b72, #e63946);
  color: #fff;
  box-shadow: 0 0 20px var(--color-danger-glow);
}

/* 100-Level Selector Drawer Modal */
.level-drawer-box {
  background: #150d2c;
  border: 1px solid var(--border-glass-bright);
  border-radius: var(--radius-xl);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-family: var(--font-display); font-size: 18px; font-weight: 800; color: #fff; }
.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chapter-nav-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.ch-btn {
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.ch-btn.active {
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 800;
}

.drawer-levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px;
}
.drawer-level-tile {
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
.drawer-level-tile:hover:not(.locked) {
  transform: scale(1.06);
  background: rgba(157, 78, 221, 0.2);
  border-color: var(--accent-primary);
}
.drawer-level-tile.current {
  border-color: var(--accent-secondary);
  background: rgba(157, 78, 221, 0.25);
  box-shadow: 0 0 12px var(--accent-glow);
}
.drawer-level-tile.boss-tile {
  background: linear-gradient(135deg, rgba(255, 75, 114, 0.25) 0%, rgba(255, 183, 3, 0.25) 100%);
  border: 1.5px solid #ffb703;
  box-shadow: 0 0 10px rgba(255, 183, 3, 0.4);
}
.drawer-level-tile.boss-tile .dtile-num {
  color: #ffb703;
  text-shadow: 0 0 8px rgba(255, 183, 3, 0.6);
}
.drawer-level-tile.locked {
  opacity: 0.35;
  cursor: not-allowed;
}
.dtile-num { font-family: var(--font-display); font-size: 16px; font-weight: 800; color: #fff; }
.dtile-stars { font-size: 9px; color: var(--color-gold); margin-top: 2px; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
}
.toast-item {
  padding: 12px 20px;
  background: rgba(22, 14, 44, 0.95);
  border: 1px solid var(--border-glass-bright);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.toast-success { border-left: 4px solid var(--color-success); }
.toast-danger { border-left: 4px solid var(--color-danger); }
.toast-gold { border-left: 4px solid var(--color-gold); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (pointer: coarse), (max-width: 768px) {
  .virtual-controls { display: flex; }
  .desktop-controls-hint { display: none; }
  .app-header { padding: 0 16px; }
  .brand-sub { display: none; }
}

@media (max-width: 600px) {
  .game-hud-top { grid-template-columns: 1fr 1fr; gap: 8px; }
  .hud-middle { grid-column: 1 / -1; order: 3; padding: 0; }
  .dpad-btn { width: 50px; height: 50px; }
  .action-btn { width: 62px; height: 62px; }
}
