/* Bunker Commando — 16-Bit Neo Geo Arcade Run-and-Gun Styling */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-dark: #101218;
  --panel-bg: rgba(18, 22, 30, 0.94);
  --panel-border: #3a4557;
  --gold: #fbbf24;
  --amber: #f97316;
  --red: #ef4444;
  --green: #22c55e;
  --cyan: #38bdf8;
  --text: #f8fafc;
  --muted: #94a3b8;
  --pixel-font: 'Courier New', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
  background: radial-gradient(circle at top, #1f2433 0%, #0d1016 70%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

#app-shell {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 10px 56px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Challenge Banner */
.challenge-banner {
  background: linear-gradient(90deg, #991b1b, #d97706, #991b1b);
  border: 2px solid #fde047;
  border-radius: 8px;
  padding: 6px 12px;
  text-align: center;
  font-family: var(--pixel-font);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.4px;
  color: #fff;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(15, 19, 28, 0.9);
  border: 1px solid #2b3444;
  border-radius: 10px;
  padding: 6px 10px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-badge {
  background: linear-gradient(135deg, #f59e0b, #dc2626);
  color: #111;
  font-family: var(--pixel-font);
  font-weight: 900;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.6px;
}

.brand-title {
  margin: 0;
  font-family: var(--pixel-font);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fde68a;
  text-shadow: 0 2px 0 #7c2d12;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #1e2636;
  color: #e2e8f0;
  border: 1px solid #3c4a63;
  border-radius: 7px;
  padding: 5px 9px;
  font-family: var(--pixel-font);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease, background 0.12s ease;
}

.hud-pill:hover {
  background: #283349;
  border-color: #64748b;
}

.hud-pill:active {
  transform: translateY(1px);
}

.hud-pill.accent-gold {
  border-color: rgba(251, 191, 36, 0.6);
  background: rgba(217, 119, 6, 0.22);
  color: #fde68a;
}

.hud-pill.accent-cyan {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(14, 116, 144, 0.28);
  color: #bae6fd;
}

.hud-pill.active-on {
  border-color: #4ade80;
  background: rgba(22, 163, 74, 0.28);
  color: #bbf7d0;
}

.hud-pill.icon-only {
  padding: 5px 8px;
}

.gold-count {
  background: #fbbf24;
  color: #111;
  border-radius: 99px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 900;
}

/* Stage & Canvas */
.stage-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.canvas-frame {
  position: relative;
  width: 100%;
  max-width: 1040px;
  aspect-ratio: 16 / 9;
  background: #0b0e14;
  border: 2px solid #3c4659;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

/* Overlays */
.overlay-screen {
  position: absolute;
  inset: 0;
  background: rgba(9, 12, 18, 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 20;
  overflow-y: auto;
}

.title-card,
.modal-card {
  width: 100%;
  max-width: 660px;
  background: var(--panel-bg);
  border: 2px solid #d97706;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.75);
  text-align: center;
  max-height: 100%;
  overflow-y: auto;
}

.modal-card.compact {
  max-width: 390px;
}

.modal-card.wide-card {
  max-width: 680px;
  text-align: left;
}

.title-eyebrow,
.modal-eyebrow {
  font-family: var(--pixel-font);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.4px;
  color: #fbbf24;
  text-transform: uppercase;
}

.hero-logo {
  margin: 4px 0 4px;
  font-family: var(--pixel-font);
  font-size: clamp(24px, 4.4vw, 40px);
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 55%, #dc2626 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.85));
}

.hero-tagline {
  margin: 0 0 12px;
  font-size: 13px;
  color: #cbd5e1;
}

.hero-tagline strong {
  color: #fde047;
}

/* Buttons */
.primary-cta-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.btn-primary,
.btn-secondary,
.btn-ghost {
  font-family: var(--pixel-font);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.6px;
  border-radius: 9px;
  padding: 10px 16px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.08s ease, filter 0.12s ease;
}

.btn-primary {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 60%, #b45309 100%);
  color: #111827;
  border-color: #fde68a;
  box-shadow: 0 4px 0 #78350f;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #78350f; }

.pulse-glow {
  animation: pulseGlow 1.9s infinite ease-in-out;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 4px 0 #78350f, 0 0 12px rgba(251, 191, 36, 0.35); }
  50% { box-shadow: 0 4px 0 #78350f, 0 0 24px rgba(251, 191, 36, 0.72); }
}

.btn-secondary {
  background: #253044;
  color: #f8fafc;
  border-color: #475569;
  box-shadow: 0 3px 0 #0f172a;
}

.btn-secondary.cyan {
  background: linear-gradient(180deg, #0284c7, #0369a1);
  border-color: #7dd3fc;
  color: #fff;
}

.btn-secondary.green {
  background: linear-gradient(180deg, #16a34a, #15803d);
  border-color: #86efac;
  color: #fff;
}

.btn-secondary:hover { filter: brightness(1.1); }
.btn-secondary:active { transform: translateY(2px); }

.btn-ghost {
  background: rgba(30, 41, 59, 0.65);
  color: #cbd5e1;
  border-color: #334155;
  padding: 7px 12px;
  font-size: 12px;
}

.btn-ghost:hover {
  background: rgba(51, 65, 85, 0.8);
  color: #fff;
}

/* Mission Strip */
.mission-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.mission-btn {
  background: #171f2e;
  border: 2px solid #334155;
  border-radius: 8px;
  padding: 6px 4px;
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: var(--pixel-font);
  transition: border-color 0.12s ease, transform 0.08s ease;
}

.mission-btn:hover:not(:disabled) {
  border-color: #fbbf24;
  transform: translateY(-1px);
}

.mission-btn.selected {
  border-color: #fbbf24;
  background: rgba(217, 119, 6, 0.22);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.3);
}

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

.mission-btn .m-num {
  font-size: 11px;
  font-weight: 900;
  color: #fbbf24;
}

.mission-btn .m-name {
  font-size: 10px;
  line-height: 1.15;
  color: #cbd5e1;
}

.mission-btn .m-stars {
  font-size: 11px;
  color: #facc15;
  letter-spacing: 1px;
}

/* Meta & Cliffhanger */
.meta-strip {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.meta-chip {
  background: #141a26;
  border: 1px solid #2e3a4e;
  border-radius: 99px;
  padding: 3px 10px;
  font-family: var(--pixel-font);
  font-size: 11px;
  color: #cbd5e1;
}

.meta-chip strong {
  color: #fde68a;
}

.cliffhanger-bar {
  background: rgba(245, 158, 11, 0.14);
  border: 1px dashed rgba(251, 191, 36, 0.55);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--pixel-font);
  font-size: 11.5px;
  color: #fde68a;
  margin-bottom: 10px;
}

.controls-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 12px;
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 10px;
}

.controls-legend kbd {
  background: #0f172a;
  border: 1px solid #475569;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 4px;
  font-family: var(--pixel-font);
  font-size: 10px;
  color: #f8fafc;
}

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

/* Modal internals */
.modal-title {
  margin: 2px 0 6px;
  font-family: var(--pixel-font);
  font-size: 24px;
  font-weight: 900;
  color: #fff;
}

.modal-sub {
  margin: 0 0 14px;
  color: #94a3b8;
  font-size: 13px;
}

.modal-btn-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid #2b3547;
  padding-bottom: 8px;
}

.armory-wallet,
.streak-pill {
  background: rgba(251, 191, 36, 0.16);
  border: 1px solid #fbbf24;
  border-radius: 99px;
  padding: 5px 12px;
  font-family: var(--pixel-font);
  font-size: 13px;
  color: #fde68a;
  white-space: nowrap;
}

.modal-foot {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.muted-note {
  font-size: 11.5px;
  color: #94a3b8;
}

/* Result Card */
.result-stars {
  font-size: 28px;
  letter-spacing: 6px;
  color: #facc15;
  text-shadow: 0 0 14px rgba(250, 204, 21, 0.5);
  margin-bottom: 10px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.stat-box {
  background: #141b27;
  border: 1px solid #2f3b52;
  border-radius: 8px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-family: var(--pixel-font);
  font-size: 10px;
  color: #94a3b8;
}

.stat-val {
  font-family: var(--pixel-font);
  font-size: 17px;
  color: #fff;
}

.stat-val.gold {
  color: #fbbf24;
}

.lb-submit-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 6px;
}

.lb-submit-row input {
  background: #0f1623;
  border: 2px solid #334155;
  border-radius: 8px;
  color: #fff;
  font-family: var(--pixel-font);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  width: 190px;
  max-width: 55%;
  text-transform: uppercase;
}

.lb-submit-row input:focus {
  outline: none;
  border-color: #38bdf8;
}

.result-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0 8px;
}

.inline-status {
  min-height: 16px;
  font-family: var(--pixel-font);
  font-size: 11.5px;
  color: #86efac;
  margin-bottom: 4px;
}

/* Armory Grid */
.armory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.perk-card {
  background: #141c29;
  border: 1px solid #314059;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.perk-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.perk-name {
  font-family: var(--pixel-font);
  font-weight: 900;
  font-size: 13px;
  color: #fde68a;
}

.perk-lvl {
  font-family: var(--pixel-font);
  font-size: 11px;
  color: #38bdf8;
}

.perk-desc {
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.3;
}

.perk-buy-btn {
  margin-top: auto;
  background: linear-gradient(180deg, #f59e0b, #d97706);
  color: #111827;
  border: 1px solid #fde68a;
  border-radius: 7px;
  padding: 6px 10px;
  font-family: var(--pixel-font);
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
}

.perk-buy-btn:disabled {
  background: #273142;
  color: #64748b;
  border-color: #334155;
  cursor: not-allowed;
}

/* Leaderboard Table */
.daily-mod-banner {
  background: rgba(14, 165, 233, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: var(--pixel-font);
  font-size: 12px;
  color: #bae6fd;
  margin-bottom: 10px;
}

.lb-table {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 8px;
  background: #141b28;
  border: 1px solid #2b384f;
  border-radius: 7px;
  padding: 6px 10px;
  font-family: var(--pixel-font);
  font-size: 12px;
}

.lb-rank { color: #fbbf24; font-weight: 900; }
.lb-name { color: #f8fafc; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-mission { color: #94a3b8; font-size: 11px; }
.lb-score { color: #4ade80; font-weight: 900; }
.lb-empty { text-align: center; padding: 18px; color: #94a3b8; font-family: var(--pixel-font); font-size: 12px; }

/* Touch Controls */
.touch-controls {
  display: none;
  width: 100%;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  padding: 6px 2px 10px;
}

.touch-left,
.touch-right {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.dpad-row,
.action-subrow {
  display: flex;
  gap: 6px;
}

.tbtn {
  font-family: var(--pixel-font);
  font-weight: 900;
  font-size: 15px;
  color: #f8fafc;
  background: rgba(30, 41, 59, 0.92);
  border: 2px solid #475569;
  border-radius: 12px;
  min-width: 54px;
  height: 50px;
  padding: 0 10px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 3px 0 #0f172a;
}

.tbtn:active,
.tbtn.pressed {
  transform: translateY(2px);
  background: #334155;
  border-color: #fbbf24;
}

.tbtn.sm {
  height: 40px;
  font-size: 12px;
  flex: 1;
}

.tbtn.tank {
  background: rgba(21, 128, 61, 0.85);
  border-color: #86efac;
}

.tbtn.fire {
  background: linear-gradient(180deg, #dc2626, #991b1b);
  border-color: #fca5a5;
  height: 52px;
  min-width: 146px;
  font-size: 16px;
}

.tbtn.jump {
  background: linear-gradient(180deg, #0284c7, #0369a1);
  border-color: #7dd3fc;
  height: 44px;
  font-size: 12px;
  flex: 1;
}

.tbtn.grenade {
  background: linear-gradient(180deg, #d97706, #92400e);
  border-color: #fde68a;
  height: 44px;
  font-size: 12px;
  flex: 1;
}

/* Mobile Responsive (390x844 and narrow screens — 0px overflow & clear of studio-bar) */
@media (max-width: 820px), (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}

@media (max-width: 640px) {
  #app-shell {
    padding: 6px 6px 64px;
    gap: 6px;
  }
  .top-bar {
    padding: 5px 7px;
    gap: 5px;
  }
  .brand-title {
    font-size: 13px;
  }
  .hud-pill {
    padding: 4px 6px;
    font-size: 11px;
  }
  .hud-pill .pill-label {
    display: none;
  }
  .canvas-frame {
    border-radius: 8px;
  }
  .overlay-screen {
    padding: 6px;
    align-items: flex-start;
  }
  .title-card,
  .modal-card {
    padding: 10px 10px;
    border-radius: 10px;
  }
  .hero-logo {
    font-size: 20px;
  }
  .hero-tagline {
    font-size: 11px;
    margin-bottom: 8px;
  }
  .primary-cta-row {
    gap: 6px;
    margin-bottom: 8px;
  }
  .btn-primary,
  .btn-secondary {
    padding: 8px 11px;
    font-size: 11.5px;
  }
  .mission-strip {
    gap: 4px;
    margin-bottom: 6px;
  }
  .mission-btn {
    padding: 4px 2px;
  }
  .mission-btn .m-name {
    display: none;
  }
  .controls-legend {
    display: none;
  }
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .tbtn {
    min-width: 48px;
    height: 46px;
    padding: 0 8px;
    font-size: 14px;
  }
  .tbtn.fire {
    min-width: 132px;
    height: 48px;
    font-size: 14px;
  }
}
