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

:root {
  --bg-dark: #0b1220;
  --panel-bg: rgba(15, 23, 42, 0.88);
  --panel-border: rgba(148, 163, 184, 0.24);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --gold: #fbbf24;
  --gold-dark: #b45309;
  --emerald: #34d399;
  --rose: #fb7185;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-lg: 0 20px 50px rgba(2, 6, 23, 0.7);
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  touch-action: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Top HUD Bar */
.hud-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  pointer-events: none;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.hud-pill,
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  font-size: 12px;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

.pill-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 10px;
}

.hud-pill strong {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.coin-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fef08a, var(--gold) 65%, var(--gold-dark));
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
  flex-shrink: 0;
}

.icon-btn {
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: rgba(30, 41, 59, 0.94);
  border-color: rgba(148, 163, 184, 0.45);
}

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

.icon-btn.active {
  border-color: rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
}

.badge-btn {
  position: relative;
}

.notify-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

/* Live In-Run Mission Progress HUD */
.run-hud {
  position: fixed;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  width: min(88vw, 340px);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  text-align: center;
}

.mission-progress-wrap {
  width: 100%;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.74);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.mission-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #e2e8f0;
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}

.mission-bar-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  overflow: hidden;
}

.mission-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #34d399, #fbbf24);
  transition: width 0.2s ease-out;
}

.run-sub-row {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.streak-badge,
.run-coins-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: rgba(15, 23, 42, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.streak-badge {
  color: #67e8f9;
  border-color: rgba(103, 232, 249, 0.5);
}

.run-coins-badge {
  color: var(--gold);
}

.powerup-timers {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.pu-chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-variant-numeric: tabular-nums;
}

/* Touch Zone Subtle Guides (Top = Climb, Bottom = Dive) */
.touch-zones-hint {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

.zone-half {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  padding: 64px 16px 18px;
  transition: background 0.12s ease, opacity 0.25s ease;
}

.zone-top {
  align-items: flex-start;
}

.zone-bottom {
  align-items: flex-end;
}

.zone-half span {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(248, 250, 252, 0.65);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.zone-half.active-up {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.12), transparent 55%);
}

.zone-half.active-down {
  background: linear-gradient(0deg, rgba(251, 146, 60, 0.12), transparent 55%);
}

.zone-divider {
  width: 100%;
  height: 1px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.14) 0px,
    rgba(255, 255, 255, 0.14) 8px,
    transparent 8px,
    transparent 18px
  );
}

/* Canvas Stage */
.stage-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Overlays */
.overlay-card {
  position: absolute;
  z-index: 30;
  width: min(92vw, 440px);
  padding: 22px 20px;
  border-radius: var(--radius-lg);
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: popIn 0.2s ease-out;
}

.overlay-card.compact {
  width: min(88vw, 340px);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.seed-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.record-banner {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.2);
  border: 1px solid rgba(52, 211, 153, 0.55);
  color: var(--emerald);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.game-title {
  font-size: clamp(28px, 5vw, 36px);
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #ffffff 20%, #7dd3fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-heading {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.modal-heading.victory {
  color: var(--emerald);
}

.modal-heading.failed {
  color: var(--rose);
}

.game-subtitle {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.quick-stats-grid,
.summary-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-box {
  padding: 10px 8px;
  border-radius: var(--radius-md);
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.16);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-box.highlight {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(14, 116, 144, 0.25);
}

.stat-k {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.stat-v {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.gold-text {
  color: var(--gold);
}

.cta-row {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.secondary-cta-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.primary-btn {
  flex: 1;
  height: 46px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(234, 88, 12, 0.45);
  transition: transform 0.12s ease, filter 0.15s ease;
}

.primary-btn:hover {
  filter: brightness(1.08);
}

.primary-btn:active {
  transform: scale(0.98);
}

.ghost-btn {
  height: 38px;
  padding: 0 13px;
  border-radius: var(--radius-md);
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ghost-btn:hover {
  background: rgba(51, 65, 85, 0.88);
  border-color: rgba(148, 163, 184, 0.45);
}

.mini-pill {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.18);
  color: var(--emerald);
  font-size: 10px;
  font-weight: 800;
}

.controls-hint {
  margin-top: 14px;
  font-size: 11px;
  color: var(--text-muted);
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.35);
  font-family: inherit;
  font-size: 10px;
  color: #e2e8f0;
}

/* Modal Drawer (Quests, Scenery & Shop) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.drawer-panel {
  width: min(95vw, 580px);
  max-height: 84dvh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: #0f172a;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(30, 41, 59, 0.65);
  border-bottom: 1px solid var(--panel-border);
  flex-wrap: wrap;
}

.drawer-tabs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tab-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.tab-btn.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
}

.drawer-bank {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.close-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.drawer-body {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pane-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.utc-inline {
  color: #7dd3fc;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Quests List */
.quests-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quest-card {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(30, 41, 59, 0.58);
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quest-info {
  flex: 1;
  min-width: 0;
}

.quest-title {
  font-size: 13px;
  font-weight: 800;
}

.quest-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.quest-bar-wrap {
  margin-top: 8px;
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  overflow: hidden;
}

.quest-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #34d399);
  transition: width 0.25s ease;
}

.quest-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.quest-progress-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.claim-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  border: none;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #0f172a;
}

.claim-btn:disabled {
  background: rgba(51, 65, 85, 0.6);
  color: var(--text-muted);
  cursor: default;
}

.claim-btn.claimed {
  background: rgba(52, 211, 153, 0.18);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: var(--emerald);
}

/* Shop Grid */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(154px, 1fr));
  gap: 10px;
}

.shop-item {
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(30, 41, 59, 0.58);
  border: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.shop-item.equipped {
  border-color: rgba(56, 189, 248, 0.7);
  background: rgba(14, 116, 144, 0.22);
}

.swatch-preview {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.scenery-preview-canvas {
  width: 72px;
  height: 84px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #0284c7;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.item-name {
  font-size: 13px;
  font-weight: 800;
}

.item-tagline {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.shop-btn {
  margin-top: auto;
  width: 100%;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.shop-btn.buy {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  border: none;
  color: #0f172a;
}

.shop-btn.buy:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.shop-btn.equipped-btn {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.5);
  color: #bae6fd;
  cursor: default;
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .hud-bar {
    padding: 8px 10px;
  }
  .hud-pill,
  .icon-btn {
    height: 30px;
    padding: 0 9px;
    font-size: 11px;
  }
  .utc-pill {
    display: none;
  }
}
