/* style.css — Fort Blast */
:root {
  --bg: #0d0d1a;
  --panel: rgba(18, 18, 32, 0.82);
  --panel-border: rgba(255, 255, 255, 0.1);
  --panel-glow: rgba(255, 107, 53, 0.15);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.55);
  --accent: #ff6b35;
  --accent-light: #ff8855;
  --accent2: #ffd23f;
  --danger: #ef4444;
  --success: #4ade80;
  --font-display: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #e8e8f0;
    --panel: rgba(255, 255, 255, 0.88);
    --panel-border: rgba(0, 0, 0, 0.12);
    --panel-glow: rgba(255, 107, 53, 0.1);
    --text: #1a1a2e;
    --text-dim: rgba(0, 0, 0, 0.5);
    color-scheme: light;
  }
}

html[data-theme="dark"] {
  --bg: #0d0d1a;
  --panel: rgba(18, 18, 32, 0.82);
  --panel-border: rgba(255, 255, 255, 0.1);
  --panel-glow: rgba(255, 107, 53, 0.15);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.55);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #e8e8f0;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(0, 0, 0, 0.12);
  --panel-glow: rgba(255, 107, 53, 0.1);
  --text: #1a1a2e;
  --text-dim: rgba(0, 0, 0, 0.5);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font-body);
  color: var(--text);
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  touch-action: none;
  display: block;
}

/* Vignette overlay for depth */
#vignette {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.35) 100%);
}

/* Damage flash overlay */
#damageFlash {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 6;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(239,68,68,0.5) 100%);
  opacity: 0;
  transition: opacity 0.08s ease-out;
}

#hud {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 14px;
  z-index: 10;
}

/* Top bar */
#topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}

.stat-block {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 8px 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  min-width: 84px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.stat-block.center { text-align: center; }
.stat-block.right { text-align: right; }

.stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-value.big {
  font-size: 26px;
  font-weight: 900;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  color: var(--accent2);
  text-shadow: 0 2px 8px rgba(255, 210, 63, 0.3);
}

.health-bar {
  position: relative;
  width: 130px; height: 20px;
  background: rgba(0,0,0,0.4);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.health-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #fbbf24 40%, #4ade80 100%);
  border-radius: 9px;
  transition: width 0.3s cubic-bezier(0.2, 0.8, 0.3, 1);
  width: 100%;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.3);
}

.health-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px; font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* Ammo bar */
#ammoBar {
  display: flex; justify-content: center; gap: 8px;
  pointer-events: auto;
  flex-wrap: wrap;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.ammo-btn {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 16px;
  padding: 8px 14px 6px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  min-width: 66px;
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.3, 1.2), border-color 0.2s, background 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  position: relative;
}

.ammo-btn:hover { transform: translateY(-3px); }
.ammo-btn:active { transform: translateY(0) scale(0.95); }

.ammo-btn.active {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.18);
  box-shadow: 0 0 24px rgba(255, 107, 53, 0.35), 0 4px 16px rgba(0,0,0,0.2);
  transform: translateY(-2px);
}

.ammo-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 3px;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent);
}

.ammo-btn.shake { animation: shake 0.35s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); border-color: var(--danger); }
  40% { transform: translateX(6px); border-color: var(--danger); }
  60% { transform: translateX(-4px); border-color: var(--danger); }
  80% { transform: translateX(4px); border-color: var(--danger); }
}

.ammo-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.ammo-icon svg { width: 100%; height: 100%; }

.ammo-name {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.ammo-btn.active .ammo-name { color: var(--accent); }

.ammo-count {
  font-size: 15px; font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin-top: 1px;
}

.ammo-key {
  position: absolute;
  top: 4px; right: 6px;
  font-size: 8px;
  font-weight: 700;
  color: var(--text-dim);
  opacity: 0.5;
  letter-spacing: 0.05em;
}

.ammo-btn.active .ammo-key { color: var(--accent); opacity: 0.8; }

/* Mute button */
#muteBtn {
  position: fixed;
  top: 14px; right: 14px;
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 10px; font-weight: 800;
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
  pointer-events: auto;
  transition: opacity 0.2s, transform 0.15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

#muteBtn:hover { transform: scale(1.05); }
#muteBtn:active { transform: scale(0.92); }
#muteBtn.muted { opacity: 0.45; }

/* Modals */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.35s ease;
}

.modal-overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: linear-gradient(160deg, rgba(32, 28, 56, 0.97), rgba(18, 16, 36, 0.97));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  padding: 40px 36px 36px;
  max-width: 420px; width: 100%;
  text-align: center;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: modalIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  position: relative;
  overflow: hidden;
}

.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 120px;
  background: radial-gradient(ellipse at top, rgba(255, 107, 53, 0.12), transparent 70%);
  pointer-events: none;
}

@keyframes modalIn {
  from { transform: scale(0.88) translateY(24px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.title-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(255, 107, 53, 0.12);
  border: 1px solid rgba(255, 107, 53, 0.25);
  border-radius: 20px;
  padding: 4px 14px;
  margin-bottom: 14px;
  position: relative;
}

.title-badge.success { color: var(--success); background: rgba(74, 222, 128, 0.12); border-color: rgba(74, 222, 128, 0.25); }
.title-badge.danger { color: var(--danger); background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.25); }

.game-title {
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 900;
  margin: 0 0 4px;
  background: linear-gradient(135deg, #ff6b35, #ffd23f);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.03em;
  line-height: 1.05;
  position: relative;
}

.game-subtitle {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent2);
  margin: 0 0 22px;
  position: relative;
}

.game-desc {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-dim);
  margin: 0 0 22px;
  position: relative;
}

.how-to {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 14px 18px;
  margin: 0 0 26px;
  display: flex; flex-direction: column; gap: 9px;
  position: relative;
}

.how-row {
  display: flex; align-items: center; gap: 14px;
  font-size: 13px;
  color: var(--text-dim);
}

.how-key {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 7px;
  padding: 4px 12px;
  font-size: 11px; font-weight: 700;
  color: var(--text);
  min-width: 60px; text-align: center;
  letter-spacing: 0.04em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.02em;
  margin: 0 0 22px;
  color: var(--accent2);
  position: relative;
}

.modal-title.danger { color: var(--danger); }

.wave-stats {
  display: flex; flex-direction: column; gap: 10px;
  margin: 0 0 18px;
  position: relative;
}

.wave-stat {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 12px 18px;
}

.ws-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.ws-value {
  font-size: 22px; font-weight: 800;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
}

.ammo-refill {
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
  margin: 0 0 26px;
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

.ammo-refill::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 15px 40px;
  font-size: 16px;
  font-weight: 800;
  font-family: inherit;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.3, 1.2), box-shadow 0.2s, filter 0.15s;
  box-shadow: 0 8px 24px rgba(255, 107, 53, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(255, 107, 53, 0.5), inset 0 1px 0 rgba(255,255,255,0.2);
  filter: brightness(1.05);
}

.btn-primary:hover::before { left: 100%; }

.btn-primary:active { transform: translateY(0) scale(0.96); }

/* Responsive */
@media (max-width: 380px) {
  #hud { padding: 10px; }
  .stat-block { padding: 6px 12px; min-width: 68px; }
  .stat-value.big { font-size: 22px; }
  .health-bar { width: 95px; height: 18px; }
  .ammo-btn { min-width: 58px; padding: 6px 10px 4px; }
  .ammo-icon { width: 28px; height: 28px; }
  .game-title { font-size: 36px; }
  .modal { padding: 32px 24px 28px; border-radius: 24px; }
  .modal-title { font-size: 26px; }
  .btn-primary { padding: 13px 32px; font-size: 15px; }
}

@media (min-width: 768px) {
  #hud { padding: 22px; }
  .stat-block { padding: 10px 20px; min-width: 96px; }
  .stat-value.big { font-size: 30px; }
  .health-bar { width: 160px; height: 24px; }
  .health-text { font-size: 13px; }
  .ammo-btn { min-width: 84px; padding: 10px 18px 8px; }
  .ammo-icon { width: 38px; height: 38px; }
  .game-title { font-size: 56px; }
  .modal { max-width: 460px; padding: 48px 44px 40px; }
  .modal-title { font-size: 32px; }
  .btn-primary { padding: 16px 44px; font-size: 17px; }
}
