:root {
  --primary-accent: #ffcb05;
  --primary-hover: #ffd83b;
  --secondary-accent: #00e5ff;
  --danger-accent: #ff3366;
  --success-accent: #00e676;
  --dark-glass: rgba(8, 28, 54, 0.78);
  --glass-border: rgba(255, 255, 255, 0.22);
  --text-light: #f0faff;
  --font-family: -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;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #031525;
  font-family: var(--font-family);
  color: var(--text-light);
}

#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

/* ===============================
   UI Screens & Glass Panels
   =============================== */
.ui-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(3, 30, 60, 0.55), rgba(1, 10, 20, 0.88));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.ui-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.glass-card {
  background: var(--dark-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  padding: clamp(16px, 2vw, 36px) clamp(16px, 2vw, 44px);
  text-align: center;
  max-width: 520px;
  width: 90%;
}

.game-logo {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(180deg, #ffffff 0%, #ffde59 50%, #ff9100 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 12px rgba(255, 170, 0, 0.45));
  margin-bottom: 8px;
}

.panel-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 1.5px;
  margin-bottom: 24px;
  color: #fff;
}

.panel-title.danger {
  color: var(--danger-accent);
  text-shadow: 0 0 16px rgba(255, 51, 102, 0.5);
}

.subtitle, .tagline {
  font-size: 16px;
  color: #a8d5f2;
  margin-bottom: 28px;
}

/* ===============================
   Buttons
   =============================== */
.btn {
  border: none;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 14px 34px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.btn:active {
  transform: translateY(2px) scale(0.98);
}

.btn-primary {
  background: linear-gradient(180deg, #ffe066 0%, #f5a623 100%);
  color: #2c1a00;
  border: 2px solid #fff59d;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #ffea85 0%, #ffb733 100%);
  box-shadow: 0 8px 24px rgba(255, 193, 7, 0.5);
}

.btn-secondary {
  background: linear-gradient(180deg, #29b6f6 0%, #0288d1 100%);
  color: #ffffff;
  border: 2px solid #81d4fa;
}

.btn-secondary:hover {
  background: linear-gradient(180deg, #4fc3f7 0%, #039be5 100%);
  box-shadow: 0 8px 20px rgba(3, 169, 244, 0.4);
}

.btn-tertiary {
  background: rgba(255, 255, 255, 0.14);
  color: #d1ecf1;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.menu-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.menu-actions.vertical {
  flex-direction: column;
}

/* ===============================
   Loader Progress
   =============================== */
.loader-bar-bg {
  width: 100%;
  height: 14px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 12px;
}

.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00e5ff, #00e676);
  border-radius: 12px;
  transition: width 0.15s ease-out;
}

.status-text {
  font-size: 13px;
  color: #8bcbe8;
}

/* ===============================
   In-Game HUD
   =============================== */
.ui-hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: auto;
  z-index: 7;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px;
}

.hud-top-left, .hud-top-right, .hud-top-center {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud-stat-badge {
  background: var(--dark-glass);
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--glass-border);
  border-radius: 999px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.35);
}

.hud-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.hud-label {
  font-size: 11px;
  font-weight: 700;
  color: #7bc7ea;
  letter-spacing: 0.5px;
}

.hud-value {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
}

.coin-counter-bar {
  background: var(--dark-glass);
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--glass-border);
  border-radius: 999px;
  padding: 6px 16px;
  display: flex;
  gap: 18px;
}

.coin-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 800;
}

.hud-coin-img {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.shield-badge {
  background: var(--dark-glass);
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--glass-border);
  border-radius: 18px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.shield-badge.ready {
  border-color: #00e5ff;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.45);
}

.shield-badge.active {
  border-color: #00e676;
  box-shadow: 0 0 18px rgba(0, 230, 118, 0.6);
  animation: shieldPulse 1.2s infinite alternate;
}

.shield-badge.cooldown {
  opacity: 0.7;
}

@keyframes shieldPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.04); }
}

.shield-meta {
  display: flex;
  flex-direction: column;
}

.shield-title {
  font-size: 10px;
  font-weight: 800;
  color: #7dd3fc;
}

.shield-time {
  font-size: 14px;
  font-weight: 900;
}

.shield-radial-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.1);
}

.shield-radial-progress {
  height: 100%;
  width: 100%;
  background: var(--secondary-accent);
}

.btn-icon {
  background: var(--dark-glass);
  border: 1.5px solid var(--glass-border);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}

/* ===============================
   Score Summary & Game Over Grid
   =============================== */
.score-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.summary-item {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.summary-label {
  font-size: 12px;
  color: #90caf9;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.summary-num {
  font-size: 28px;
  font-weight: 900;
  color: #ffffff;
}

.coins-recap-bar {
  display: flex;
  justify-content: space-around;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 28px;
}

.recap-col {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 18px;
}

.recap-coin-img {
  width: 32px;
  height: 32px;
}

.key-pill {
  display: inline-block;
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  margin: 4px;
}

.key-pill span {
  font-weight: 900;
  color: var(--primary-accent);
}

/* ===============================
   Mobile Controls
   =============================== */
.mobile-ui {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: auto;
  padding: 0;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 16px;
  pointer-events: none;
  z-index: 6;
}

@media (pointer: coarse), (max-width: 900px) {
  .mobile-ui {
    left: 0;
    right: auto;
    width: 100vw;
    padding: 0 24px;
    justify-content: space-between;
    gap: 0;
  }
}

@media (max-width: 600px) {
  .ui-hud {
    padding: 10px 12px;
    gap: 6px;
  }

  .hud-top-left, .hud-top-right, .hud-top-center {
    gap: 6px;
  }

  .hud-stat-badge {
    gap: 5px;
    padding: 6px 9px;
  }

  .hud-icon {
    width: 16px;
    height: 16px;
  }

  .hud-label {
    font-size: 8px;
  }

  .hud-value {
    font-size: 14px;
  }

  .coin-counter-bar {
    gap: 7px;
    padding: 5px 8px;
  }

  .coin-pill {
    gap: 3px;
    font-size: 13px;
  }

  .hud-coin-img {
    width: 18px;
    height: 18px;
  }

  .shield-badge {
    gap: 6px;
    padding: 5px 8px;
  }

  .shield-title {
    font-size: 8px;
  }

  .shield-time {
    font-size: 11px;
  }
}

.touch-joystick-zone, .touch-action-zone {
  pointer-events: auto;
}

.touch-joystick-zone {
  width: 140px;
  height: 140px;
  position: relative;
}

.dpad-btn {
  position: absolute;
  width: 44px;
  height: 44px;
  background: rgba(14, 40, 70, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  user-select: none;
}

.dpad-btn:active {
  background: rgba(0, 229, 255, 0.5);
}

.dpad-btn.up { top: 0; left: 48px; }
.dpad-btn.down { bottom: 0; left: 48px; }
.dpad-btn.left { top: 48px; left: 0; }
.dpad-btn.right { top: 48px; right: 0; }

.touch-round-btn {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle, #00e5ff 0%, #00838f 100%);
  border: 3px solid #b2ebf2;
  box-shadow: 0 4px 18px rgba(0, 229, 255, 0.5);
  color: #00363a;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.5px;
  cursor: pointer;
}

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