/* =========================================================
   CROSSGAMES - MAIN DESIGN SYSTEM & STYLESHEET
   Aesthetics: Deep Space Cyber Neon / Glassmorphism Arcade
   ========================================================= */

:root {
  /* Color Palette */
  --bg-dark: #0b0d14;
  --bg-card: rgba(22, 27, 46, 0.75);
  --bg-card-hover: rgba(30, 38, 64, 0.9);
  --bg-glass: rgba(18, 22, 38, 0.65);
  --border-glass: rgba(255, 255, 255, 0.1);
  --border-glass-bright: rgba(255, 255, 255, 0.22);
  
  /* Primary Neon Accents */
  --accent-primary: #00f2fe;
  --accent-secondary: #4facfe;
  --accent-gradient: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  --accent-glow: rgba(0, 242, 254, 0.4);
  
  --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);
  --color-purple: #9d4edd;
  --color-purple-glow: rgba(157, 78, 221, 0.4);

  /* Typography Colors */
  --text-main: #f0f4fc;
  --text-muted: #8e9bb4;
  --text-dim: #5c6882;

  /* Game Specific Theme Tints */
  --theme-road: #ff7b00;
  --theme-river: #00b4d8;
  --theme-sky: #7209b7;
  --theme-dungeon: #e63946;

  /* Font Families */
  --font-display: 'Outfit', 'Noto Sans SC', sans-serif;
  --font-body: 'Noto Sans SC', sans-serif;
  --font-arcade: 'Press Start 2P', monospace;

  /* Radius & Shadows */
  --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.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px var(--accent-glow);

  --header-height: 72px;
}

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

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;
  -moz-osx-font-smoothing: grayscale;
}

/* Ambient Animated Glow Spheres in Background */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
  animation: floatGlow 18s ease-in-out infinite alternate;
}
.glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #7928ca 0%, transparent 70%);
  top: -100px;
  left: -100px;
}
.glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #0070f3 0%, transparent 70%);
  bottom: -150px;
  right: -150px;
  animation-duration: 22s;
}
.glow-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #ff0080 0%, transparent 70%);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.25;
  animation-duration: 26s;
}

@keyframes floatGlow {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.15); }
  100% { transform: translate(-40px, 80px) scale(0.9); }
}

/* Main App Shell Layout */
.app-root {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* =========================================================
   HEADER STYLING
   ========================================================= */
.app-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: rgba(11, 13, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 100;
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.brand-logo:hover {
  transform: scale(1.03);
}

.logo-icon-wrap {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #ff007f 0%, #7928ca 50%, #00f2fe 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(121, 40, 202, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.logo-emoji {
  font-size: 24px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.1;
}

.brand-accent {
  background: linear-gradient(135deg, #00f2fe, #4facfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tagline {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Nav Tabs */
.header-nav {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-glass);
}

.nav-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.nav-tab.active {
  background: var(--accent-gradient);
  color: #0b0d14;
  box-shadow: 0 2px 14px var(--accent-glow);
  font-weight: 800;
}

.badge-dot {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff3366;
  box-shadow: 0 0 8px #ff3366;
}

/* Header Right: Controls & User Capsule */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  border-color: var(--border-glass-bright);
}
.icon-btn:active {
  transform: translateY(0);
}

/* User Capsule (Guest Identity) */
.user-capsule {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px 6px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.25s ease;
}
.user-capsule:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-primary);
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.25);
  transform: translateY(-1px);
}

.avatar-ring {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffe259, #ffa751);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name-line {
  display: flex;
  align-items: center;
  gap: 4px;
}
.user-nickname {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-main);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-id-tag {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-display);
}

.user-stats-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
}
.stat-pill.stars {
  color: var(--color-gold);
}
.stat-pill.coins {
  color: #ffd166;
}

/* =========================================================
   COMMON UI BUTTONS & ELEMENTS
   ========================================================= */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-gradient);
  color: #0b0d14;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px var(--accent-glow);
}
.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}

.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;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}
.btn-secondary:active {
  transform: translateY(0);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.btn-accent {
  background: linear-gradient(135deg, #ff007f, #7928ca);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(255, 0, 127, 0.4);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}
.btn-small:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-large {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-glow {
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-glow-danger {
  background: linear-gradient(135deg, #ff4b72, #e63946);
  color: #fff;
  box-shadow: 0 0 20px var(--color-danger-glow);
}
.btn-glow-danger:hover {
  box-shadow: 0 0 25px var(--color-danger-glow);
  transform: translateY(-2px);
}

/* Router Screen Container */
.app-main {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}

.screen-view {
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  width: 100%;
}

.screen-view.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
}

.toast-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(18, 22, 38, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass-bright);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: auto;
}

.toast-item.toast-success {
  border-left: 4px solid var(--color-success);
}
.toast-item.toast-danger {
  border-left: 4px solid var(--color-danger);
}
.toast-item.toast-gold {
  border-left: 4px solid var(--color-gold);
}

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

/* Responsive adjustments */
@media (max-width: 900px) {
  .app-header {
    padding: 0 16px;
    height: 64px;
  }
  .header-nav {
    display: none; /* Mobile menu or bottom nav */
  }
  .brand-tagline {
    display: none;
  }
  .user-stats-line {
    display: none;
  }
}
