:root {
  --bg: #090A10;
  --surface: #131622;
  --surface-card: #1A1E30;
  --surface-border: #262B42;
  --text: #F0F4FC;
  --text-muted: #8E99B8;
  --accent: #00F0FF;
  --accent-purple: #7B2CBF;
  --accent-pink: #FF007F;
  --accent-glow: rgba(0, 240, 255, 0.4);
  --success: #00FFB2;
  --error: #FF1744;
  --warning: #FFB300;
  --font-stack: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-stack);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  -webkit-tap-highlight-color: transparent;
}

/* Ambient dynamic cyber background */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(0, 240, 255, 0.12) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(123, 44, 191, 0.10) 0%, transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 36px 36px, 36px 36px;
  pointer-events: none;
  z-index: 0;
}

/* Fixed Top Header */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(15, 18, 28, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

.header-branding {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: #090A10;
  border: 1px solid #00F0FF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px var(--accent-glow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.logo-icon:hover {
  transform: scale(1.08) rotate(3deg);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.7);
}

.brand-name {
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: 1.2px;
  background: linear-gradient(90deg, #FFFFFF 0%, #00F0FF 50%, #FF007F 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(0, 240, 255, 0.35);
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--surface);
  padding: 6px 14px;
  border-radius: 24px;
  border: 1px solid var(--surface-border);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-divider {
  color: var(--surface-border);
}

.stat-val {
  color: var(--accent);
  font-weight: 700;
}

/* Rank Badge & Flame */
.rank-pill {
  background: rgba(0, 240, 255, 0.12) !important;
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 12px;
  padding: 2px 8px;
}

.rank-badge {
  color: #00F0FF;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}

.streak-pill {
  transition: all 0.3s ease;
}

.streak-flame {
  display: inline-block;
  opacity: 0.3;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.streak-flame.active {
  opacity: 1;
  animation: flameFlicker 0.8s infinite alternate;
}

@keyframes flameFlicker {
  0% { transform: scale(1) rotate(-4deg); filter: drop-shadow(0 0 4px #FF9100); }
  100% { transform: scale(1.3) rotate(6deg); filter: drop-shadow(0 0 12px #FF3D00); }
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.icon-btn:hover {
  background: var(--surface-card);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 0 12px var(--accent-glow);
}

.icon-btn:active {
  transform: scale(0.92);
}

/* Stage Progression Roadmap Tracker */
.stage-roadmap {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  height: 38px;
  background: rgba(14, 17, 26, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 95;
  padding: 0 16px;
}

.roadmap-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 600px;
  width: 100%;
}

.roadmap-step {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.4;
  transition: all 0.3s ease;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.roadmap-step.active {
  opacity: 1;
  color: #00F0FF;
  transform: scale(1.04);
}

.roadmap-step.boss-step.active {
  color: var(--error);
  animation: pulseSiren 1s infinite alternate;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-border);
  transition: all 0.3s ease;
}

.roadmap-step.active .step-dot {
  background: #00F0FF;
  box-shadow: 0 0 10px #00F0FF, 0 0 18px rgba(0, 240, 255, 0.6);
}

.roadmap-step.boss-step.active .step-dot {
  background: var(--error);
  box-shadow: 0 0 12px var(--error);
}

.roadmap-line {
  flex: 1;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  max-width: 32px;
}

/* Main Container */
main {
  flex: 1;
  margin-top: 102px;
  margin-bottom: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 768px;
  margin-left: auto;
  margin-right: auto;
}

/* Boss Fight Banner / Timer */
.boss-banner {
  width: 100%;
  background: linear-gradient(135deg, rgba(255, 23, 68, 0.22), rgba(123, 44, 191, 0.25));
  border: 1px solid var(--error);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: none;
  flex-direction: column;
  gap: 8px;
  animation: pulseGlow 2s infinite alternate;
  position: relative;
  overflow: hidden;
}

.boss-banner::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: repeating-linear-gradient(90deg, #FF1744 0, #FF1744 12px, #000 12px, #000 24px);
  animation: hazardStripes 1s linear infinite;
}

@keyframes hazardStripes {
  from { transform: translateX(0); }
  to { transform: translateX(24px); }
}

@keyframes pulseGlow {
  from { box-shadow: 0 0 10px rgba(255, 23, 68, 0.2); }
  to { box-shadow: 0 0 28px rgba(255, 23, 68, 0.6); }
}

.boss-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.boss-tag {
  color: var(--error);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 800;
}

.boss-timer {
  font-size: 1.3rem;
  font-family: monospace;
  font-weight: 800;
  color: #FFF;
  text-shadow: 0 0 8px rgba(255, 23, 68, 0.8);
}

.timer-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00F0FF, #FF007F, #FF1744);
  transition: width 0.1s linear;
}

/* Game Stage Card */
.stage-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  padding: 24px 20px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: border-color 0.4s ease, box-shadow 0.4s ease, transform 0.3s ease;
}

.stage-card:hover {
  border-color: rgba(0, 240, 255, 0.4);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7), 0 0 24px rgba(0, 240, 255, 0.12);
}

.stage-card.stage-enter {
  animation: stageEnter 0.42s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes stageEnter {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    filter: blur(3px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

.game-title-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--surface-border);
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.game-domain-badge {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 800;
  color: var(--accent);
  background: rgba(0, 240, 255, 0.12);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.game-objective {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Common Button Styles */
.btn {
  min-height: 48px;
  min-width: 48px;
  padding: 12px 24px;
  border-radius: 24px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.5px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.btn:active {
  transform: scale(0.95) translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, #00F0FF 0%, #7B2CBF 100%);
  color: #FFFFFF;
  font-weight: 800;
  border: 1px solid rgba(0, 240, 255, 0.4);
  box-shadow: 0 4px 18px rgba(0, 240, 255, 0.3);
}

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

.btn-secondary {
  background: var(--surface-card);
  color: var(--text);
  border: 1px solid var(--surface-border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 14px var(--accent-glow);
}

.btn-success {
  background: linear-gradient(135deg, #00FFB2, #00BFA5);
  color: #0A1914;
  font-weight: 800;
}

.btn-danger {
  background: linear-gradient(135deg, #FF1744, #C51162);
  color: #FFFFFF;
}

/* Floating Combo Badge */
.combo-popup {
  position: fixed;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #FF007F, #7B2CBF);
  color: #FFF;
  font-size: 1.5rem;
  font-weight: 900;
  padding: 12px 28px;
  border-radius: 30px;
  box-shadow: 0 0 32px rgba(255, 0, 127, 0.85);
  pointer-events: none;
  z-index: 200;
  animation: comboPop 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  letter-spacing: 1px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

@keyframes comboPop {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.6); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  75% { opacity: 1; transform: translate(-50%, -55%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -85%) scale(0.9); }
}

/* Bottom Feedback Bar */
.feedback-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: rgba(15, 18, 28, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  z-index: 90;
  transition: all 0.3s ease;
  padding: 0 16px;
  text-align: center;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.flash-green {
  background: rgba(0, 255, 178, 0.2) !important;
  color: #00FFB2 !important;
  border-top-color: #00FFB2 !important;
  box-shadow: 0 -4px 24px rgba(0, 255, 178, 0.3) !important;
}

.flash-red {
  background: rgba(255, 23, 68, 0.22) !important;
  color: #FF1744 !important;
  border-top-color: #FF1744 !important;
  box-shadow: 0 -4px 24px rgba(255, 23, 68, 0.35) !important;
}

.flash-purple {
  background: rgba(0, 240, 255, 0.2) !important;
  color: #00F0FF !important;
  border-top-color: #00F0FF !important;
  box-shadow: 0 -4px 24px rgba(0, 240, 255, 0.35) !important;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-backdrop.show {
  display: flex;
  opacity: 1;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 240, 255, 0.15);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.show .modal-box {
  transform: scale(1);
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #FFF;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--surface-border);
  padding-bottom: 12px;
  letter-spacing: 0.6px;
}

.modal-content {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-content ul {
  list-style-position: inside;
  padding-left: 6px;
}

.modal-content li {
  margin-bottom: 6px;
}

/* Operative Dossier Card */
.dossier-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), rgba(123, 44, 191, 0.14));
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 8px;
}

.dossier-avatar {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #090A10;
  border: 1px solid #00F0FF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.35);
}

.dossier-rank-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: #00F0FF;
  letter-spacing: 0.8px;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.dossier-level-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 6px 0;
}

.stat-card {
  background: var(--surface-card);
  padding: 12px 10px;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.stat-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card-rate {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--accent);
}

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

/* Cloud Account Box */
.cloud-account-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cloud-id-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-card);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--surface-border);
}

.cloud-id-text {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--accent);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-transfer-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.cloud-transfer-input {
  flex: 1;
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 6px 10px;
  color: #FFF;
  font-family: monospace;
  font-size: 0.8rem;
  outline: none;
}

.cloud-transfer-input:focus {
  border-color: var(--accent);
}

.cloud-status {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cloud-status.offline {
  background: rgba(142, 153, 184, 0.15);
  color: var(--text-muted);
}

.cloud-status.synced {
  background: rgba(0, 255, 178, 0.15);
  color: var(--success);
}

.cloud-status.syncing {
  background: rgba(255, 179, 0, 0.15);
  color: var(--warning);
}

/* Fullscreen Particle FX Canvas */
#fx-canvas {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 150;
}

/* Mobile Responsive Layout */
@media (max-width: 768px) {
  header {
    height: auto;
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
    background: rgba(14, 17, 26, 0.96);
  }

  .header-branding {
    order: 1;
  }

  .header-actions {
    order: 2;
    margin-left: auto;
  }

  .status-bar {
    order: 3;
    width: 100%;
    justify-content: space-around;
    padding: 6px 10px;
    font-size: 0.82rem;
    background: rgba(0, 0, 0, 0.4);
  }

  .stage-roadmap {
    top: auto;
    bottom: 52px;
    height: 32px;
  }

  main {
    margin-top: 116px;
    padding: 12px 10px;
    margin-bottom: 88px;
  }

  .stage-card {
    padding: 16px 12px;
    border-radius: 18px;
  }

  .game-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 14px;
  }

  .game-objective {
    font-size: 0.82rem;
  }

  .feedback-bar {
    height: 52px;
    font-size: 0.88rem;
    padding: 0 10px;
  }
}

@media (max-width: 440px) {
  .brand-name {
    font-size: 1.1rem;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1rem;
  }

  .status-bar {
    font-size: 0.78rem;
    padding: 4px 6px;
    gap: 4px;
  }

  .cloud-status {
    padding: 2px 6px;
    font-size: 0.72rem;
  }

  .cloud-text {
    display: none;
  }

  .modal-box {
    padding: 18px 14px;
    border-radius: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
