/* ============================================================
   ui.css — HUD, buttons, overlays, toasts
   ============================================================ */

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
}

/* ---------- HUD ---------- */

#hud {
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hud-card {
  border-radius: 14px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  overflow: hidden;
}

.hud-card .hc-icon { font-size: 15px; line-height: 1; }
.hud-card .hc-label {
  font-size: 8.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-faint);
  font-family: var(--font-ui);
}
.hud-card .hc-value {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-ui);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.hud-card.score .hc-value { color: var(--accent-gold); }
.hud-card.level .hc-value { color: var(--accent-cyan); }
.hud-card.combo .hc-value { color: var(--accent-pink); }
.hud-card.combo.hot { animation: comboPulse 0.5s ease; }

/* quota / mission progress bar spans full width */
#missionCard {
  grid-column: 1 / -1;
  border-radius: 14px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#missionCard .mc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  letter-spacing: 0.5px;
}
#missionCard .mc-top b { color: var(--text-primary); font-weight: 700; }
.progress-track {
  height: 9px;
  border-radius: 6px;
  background: rgba(255,255,255,0.10);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.6);
  transition: width 0.35s cubic-bezier(.2,.8,.3,1);
  position: relative;
}
.progress-fill::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.45) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmerSweep 2.2s linear infinite;
}

/* ---------- controls row ---------- */

#controlsRow {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.pill-btn {
  border: none;
  border-radius: 30px;
  padding: 10px 18px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.3px;
  color: #1b0f30;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.pill-btn:active { transform: scale(0.94); }
.pill-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.pill-btn.primary {
  background: linear-gradient(135deg, var(--accent-pink), #ff9bd0);
  box-shadow: 0 4px 16px rgba(255, 110, 196, 0.45);
}
.pill-btn.swap {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.4);
}
.pill-btn.ghost {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  box-shadow: none;
}

#swapBtn .charge-count {
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10.5px;
}

/* ---------- instructions / legend ---------- */

.legend {
  width: 100%;
  max-width: 480px;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: var(--font-ui);
}
.legend span { display: flex; align-items: center; gap: 4px; }

#instructions {
  font-size: 11px;
  color: var(--text-faint);
  max-width: 480px;
  text-align: center;
  line-height: 1.55;
  padding: 0 6px;
}

/* ---------- overlay screens ---------- */

#overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: rgba(6, 3, 20, 0.88);
  backdrop-filter: blur(6px);
  text-align: center;
  padding: 20px;
  z-index: 5;
}
#overlay.show { display: flex; }

.overlay-card {
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 28px 26px 22px;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), var(--shadow-glow);
  animation: overlayPop 0.4s cubic-bezier(.2,.9,.25,1.2);
}

#overlayTitle {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 6px;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#overlaySub {
  margin: 4px 0 18px;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
}
#overlayStats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 18px;
}
#overlayStats .stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
#overlayStats .stat-chip .sc-val { font-weight: 800; font-size: 17px; color: var(--accent-cyan); font-family: var(--font-ui); }
#overlayStats .stat-chip .sc-label { font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); }

/* ---------- floating combat text (score/combo) ---------- */

.float-pop {
  position: absolute;
  font-family: var(--font-ui);
  font-weight: 800;
  color: var(--accent-gold);
  text-shadow: 0 0 10px rgba(255, 209, 102, 0.7), 0 2px 4px rgba(0,0,0,0.5);
  pointer-events: none;
  animation: floatUp 0.9s ease-out forwards;
  white-space: nowrap;
}
.float-pop.combo-text {
  color: var(--accent-pink);
  font-size: 20px;
  text-shadow: 0 0 14px rgba(255, 110, 196, 0.8), 0 2px 4px rgba(0,0,0,0.5);
}

/* ---------- achievement toast ---------- */

#toastStack {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: 100%;
  padding: 0 12px;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 10px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 24px rgba(255, 209, 102, 0.25);
  animation: toastIn 0.5s cubic-bezier(.2,.9,.25,1.2), toastOut 0.5s ease-in 3.2s forwards;
  max-width: 340px;
}
.toast .toast-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 6px rgba(255,209,102,0.6));
}
.toast .toast-text { text-align: left; }
.toast .toast-title {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent-gold);
  font-family: var(--font-ui);
  font-weight: 700;
}
.toast .toast-body {
  font-size: 12.5px;
  color: var(--text-primary);
  font-weight: 600;
}

/* ---------- audio settings popover ---------- */

#audioPanel {
  position: absolute;
  top: 46px;
  right: 0;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 12px 14px;
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 190px;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#audioPanel.show { display: flex; }
#audioPanel label {
  font-size: 10.5px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-ui);
}
#audioPanel input[type="range"] {
  width: 100%;
  accent-color: var(--accent-cyan);
}
.audio-btn-wrap { position: relative; }

/* ---------- achievements drawer ---------- */

#achDrawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
#achDrawer.show { display: flex; }
.drawer-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 78vh;
  overflow-y: auto;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 18px 16px 26px;
  animation: sheetUp 0.35s cubic-bezier(.2,.9,.25,1.05);
}
.drawer-sheet h3 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-sheet h3 .close-x {
  cursor: pointer;
  opacity: 0.6;
  font-size: 20px;
}
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.ach-item {
  border-radius: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0.4;
  filter: grayscale(0.6);
}
.ach-item.unlocked {
  opacity: 1;
  filter: none;
  background: rgba(255, 209, 102, 0.08);
  border-color: rgba(255, 209, 102, 0.35);
}
.ach-item .ai-icon { font-size: 20px; }
.ach-item .ai-name { font-size: 11.5px; font-weight: 700; }
.ach-item .ai-desc { font-size: 9.5px; color: var(--text-faint); line-height: 1.3; }

@media (max-width: 380px) {
  .hud-card .hc-value { font-size: 13px; }
  .pill-btn { padding: 9px 14px; font-size: 11.5px; }
}

@media (max-width: 480px) {
  #controlsRow { gap: 6px; }
  .pill-btn { padding: 9px 13px; font-size: 11.5px; }
}
