/* Skyline Crane Drop — 16-Bit Industrial Arcade UI Stylesheet */
:root {
  --bg-deep: #0b1120;
  --panel: rgba(15, 23, 42, 0.94);
  --panel-soft: rgba(30, 41, 59, 0.84);
  --border: rgba(148, 163, 184, 0.25);
  --text: #f8fafc;
  --muted: #94a3b8;
  --gold: #fbbf24;
  --amber: #f59e0b;
  --cyan: #22d3ee;
  --emerald: #34d399;
  --rose: #fb7185;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: 100%;
  height: 100dvh;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #0b1120 72%);
}

/* Top HUD */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(11, 17, 32, 0.92);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
  min-height: 48px;
}

.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.hud-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.hud-val {
  font-size: 16px;
  font-weight: 900;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hud-val small {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  margin-left: 2px;
}

.timer-stat .hud-val {
  color: var(--gold);
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.28), rgba(251, 191, 36, 0.14));
  border: 1px solid rgba(251, 191, 36, 0.65);
  color: #fde68a;
  white-space: nowrap;
}

.streak-dots {
  display: inline-flex;
  gap: 2px;
  font-size: 9px;
  letter-spacing: 1px;
}

.zone-badge, .wind-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(30, 41, 59, 0.82);
}

.wind-badge.calm {
  color: #94a3b8;
}

.wind-badge.gust-left, .wind-badge.gust-right {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(14, 116, 144, 0.34);
}

.wind-badge.gust-strong {
  color: #fde047;
  border-color: rgba(250, 204, 21, 0.68);
  background: rgba(161, 98, 7, 0.4);
}

.hud-lives {
  font-size: 15px;
  letter-spacing: 1px;
  white-space: nowrap;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.85);
  color: var(--text);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.icon-btn:hover {
  border-color: var(--gold);
  background: #334155;
  transform: translateY(-1px);
}

.challenge-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.24), rgba(14, 165, 233, 0.24));
  border-bottom: 1px solid rgba(251, 191, 36, 0.45);
  padding: 5px 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #fef08a;
  flex-shrink: 0;
}

/* Main Stage */
.stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #090d1a;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}

.stage-micro-hud {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
  gap: 8px;
}

.micro-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(11, 17, 32, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.22);
  backdrop-filter: blur(4px);
}

.micro-label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #cbd5e1;
}

.stab-bar {
  width: 68px;
  height: 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
  overflow: hidden;
}

.stab-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width 0.18s ease, background 0.18s ease;
}

.micro-landmark {
  font-size: 11px;
  font-weight: 800;
  color: #fde68a;
  white-space: nowrap;
}

/* Bottom Controls Bar */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  background: rgba(11, 17, 32, 0.96);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 15;
}

.drop-btn {
  width: min(360px, 100%);
  height: 48px;
  border-radius: 12px;
  border: 2px solid #fde047;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #0b1120;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 0 #92400e, 0 8px 20px rgba(245, 158, 11, 0.34);
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.1s ease;
}

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

.drop-btn:active, .drop-btn.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #92400e, 0 3px 8px rgba(245, 158, 11, 0.24);
}

.drop-icon {
  font-size: 18px;
}

.drop-kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(11, 17, 32, 0.22);
  border: 1px solid rgba(11, 17, 32, 0.32);
}

/* Studio Bar Dock Footer */
.footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  background: #070b14;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  font-size: 11.5px;
  color: var(--muted);
  flex-shrink: 0;
  z-index: 20;
}

.footer-brand {
  font-weight: 800;
  color: #e2e8f0;
  white-space: nowrap;
}

.footer-credits {
  font-weight: 800;
  color: #fbbf24;
  white-space: nowrap;
}

.footer-streak {
  font-weight: 700;
  color: #7dd3fc;
  white-space: nowrap;
}

/* Modals (position: fixed for mobile stability) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(4, 8, 18, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

.card {
  width: 100%;
  max-width: 480px;
  max-height: min(90dvh, 760px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(9, 14, 28, 0.98) 100%);
  border: 1px solid rgba(251, 191, 36, 0.32);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.68);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.ov-header {
  text-align: center;
}

.ov-badge-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.ov-badge {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
}

.district-chip {
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.42);
  color: #bae6fd;
}

.ov-title {
  margin: 0;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}

.ov-subtitle {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: #cbd5e1;
}

/* Stats Grid */
.ov-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-box {
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}

.stat-lbl {
  display: block;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-num {
  display: block;
  margin-top: 2px;
  font-size: 16px;
  font-weight: 900;
  color: #ffffff;
}

.accent-gold {
  color: var(--gold) !important;
}

.cliffhanger-box {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.36);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #fde68a;
  text-align: center;
}

/* Mode Grid */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 6px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: rgba(30, 41, 59, 0.72);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.12s ease;
}

.mode-btn:hover {
  border-color: #7dd3fc;
  transform: translateY(-1px);
}

.mode-btn.active {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.24), rgba(30, 41, 59, 0.92));
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.35);
}

.mode-ico {
  font-size: 18px;
}

.mode-name {
  font-size: 11.5px;
  font-weight: 800;
  text-align: center;
  line-height: 1.15;
}

.mode-meta {
  font-size: 9.5px;
  color: var(--muted);
  text-align: center;
}

/* Buttons */
.ov-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ov-sub-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.btn-primary, .btn-secondary, .btn-accent, .btn-share {
  font-family: inherit;
  border-radius: 11px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, border-color 0.12s ease;
}

.btn-primary {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  letter-spacing: 0.04em;
  border: 2px solid #fde047;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #0b1120;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.32);
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-secondary {
  padding: 9px 12px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.88);
  color: #f1f5f9;
}

.btn-secondary:hover {
  border-color: var(--cyan);
  background: #334155;
}

.btn-accent {
  padding: 8px 12px;
  font-size: 12px;
  border: 1px solid rgba(56, 189, 248, 0.65);
  background: #0284c7;
  color: #ffffff;
  white-space: nowrap;
}

.btn-share {
  flex: 1;
  padding: 9px 12px;
  font-size: 12.5px;
  border: 1px solid rgba(52, 211, 153, 0.55);
  background: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
}

.btn-share:hover {
  background: rgba(16, 185, 129, 0.32);
}

/* Post-Run Extras */
.post-run-extras {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.lb-submit-row {
  display: flex;
  gap: 6px;
}

.lb-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.share-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-status {
  font-size: 11px;
  font-weight: 700;
  color: #6ee7b7;
}

.share-preview {
  margin: 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(2, 6, 23, 0.78);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  line-height: 1.38;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Mini Skyline */
.mini-skyline-box {
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 11px;
  padding: 8px 10px;
}

.mini-skyline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 800;
  color: #cbd5e1;
  margin-bottom: 5px;
}

.mini-best {
  color: var(--gold);
}

#mini-city-title, #mini-city-hq {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 7px;
  image-rendering: pixelated;
  background: #0b1024;
}

/* HQ & Leaderboard Modals */
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  color: #fde68a;
}

.hq-wallet {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 12px;
  color: #cbd5e1;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.9);
  color: #e2e8f0;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}

.hq-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.hq-tab {
  padding: 8px 6px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.72);
  color: #cbd5e1;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
}

.hq-tab.active {
  background: rgba(245, 158, 11, 0.24);
  border-color: var(--gold);
  color: #fef08a;
}

.hq-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hq-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 11px;
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid var(--border);
}

.hq-item.equipped {
  border-color: var(--gold);
  background: rgba(245, 158, 11, 0.14);
}

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

.hq-item-name {
  font-size: 13px;
  font-weight: 800;
  color: #f8fafc;
}

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

.hq-action-btn {
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid rgba(251, 191, 36, 0.55);
  background: rgba(245, 158, 11, 0.22);
  color: #fde68a;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.hq-action-btn.owned {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(14, 165, 233, 0.2);
  color: #bae6fd;
}

.hq-action-btn.active-btn {
  border-color: rgba(52, 211, 153, 0.65);
  background: rgba(16, 185, 129, 0.22);
  color: #a7f3d0;
  cursor: default;
}

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

.hq-hint {
  margin: 0;
  font-size: 12px;
  color: #cbd5e1;
}

.towers-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tower-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

/* Leaderboard */
.lb-subtitle {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.lb-meta-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lb-pill {
  font-size: 11.5px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border);
  color: #e2e8f0;
}

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

.lb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.16);
  font-size: 12.5px;
}

.lb-row.top3 {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(245, 158, 11, 0.12);
}

.lb-rank {
  font-weight: 900;
  color: var(--gold);
  width: 26px;
}

.lb-name {
  flex: 1;
  font-weight: 800;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-weight: 900;
  color: #7dd3fc;
  font-variant-numeric: tabular-nums;
}

.lb-loading {
  text-align: center;
  padding: 18px;
  font-size: 12.5px;
  color: var(--muted);
}

/* Mobile Responsive (390x844 — 0px horizontal overflow!) */
@media (max-width: 640px) {
  .hud-bar {
    padding: 5px 8px;
    gap: 5px;
    min-height: 44px;
  }
  .hud-left, .hud-center, .hud-right {
    gap: 5px;
  }
  .hud-val {
    font-size: 14px;
  }
  .hud-val small {
    display: none;
  }
  .zone-badge {
    display: none;
  }
  .wind-badge {
    font-size: 10px;
    padding: 3px 7px;
  }
  .hud-lives {
    font-size: 13px;
  }
  .icon-btn {
    width: 30px;
    height: 30px;
    font-size: 13px;
  }
  .drop-btn {
    height: 46px;
    font-size: 15px;
  }
  .drop-kbd {
    display: none;
  }
  .footer-bar {
    padding: 5px 8px;
    font-size: 10.5px;
    gap: 5px;
  }
  .footer-streak {
    display: none;
  }
  .card {
    padding: 13px;
    gap: 9px;
  }
  .ov-title {
    font-size: 21px;
  }
  .mode-name {
    font-size: 10.5px;
  }
}
