/* SKY BLOXX — Crisp 2000s Nokia Tower Bloxx Cartoon UI */
:root {
  --ink: #0f172a;
  --gold: #f59e0b;
  --blue: #2563eb;
  --red: #dc2626;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #3898e8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  touch-action: none;
}

.hidden { display: none !important; }
body:not(.embed) .embed-only { display: none !important; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ==================== HUD ==================== */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 10px) 12px calc(var(--safe-bot) + 18px);
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: auto;
}

.hud-box {
  background: rgba(255, 255, 255, 0.94);
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 6px 10px;
  box-shadow: 0 3px 0 var(--ink);
  min-width: 112px;
}

.hud-floor {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  font-weight: 900;
  color: var(--ink);
}

.hud-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 800;
  color: #334155;
}

.hud-combo {
  background: #fde047;
  color: #0f172a;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 900;
}

.hud-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.hud-lives {
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid var(--ink);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 14px;
  letter-spacing: 2px;
}

.hud-boost-btn {
  padding: 5px 10px;
  border-radius: 99px;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, #fde047, #f59e0b);
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 2px 0 var(--ink);
  cursor: pointer;
}

.hud-boost-btn.active {
  background: #86efac;
}

.hud-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 2.5px solid var(--ink);
  background: rgba(255, 255, 255, 0.94);
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
}

.hud-tap-hint {
  align-self: center;
  background: rgba(15, 23, 42, 0.84);
  color: #fde047;
  border: 2px solid #fde047;
  border-radius: 99px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.4px;
  transition: opacity 0.35s ease;
}

.hud-tap-hint.faded { opacity: 0; }

/* ==================== LOBBY & CITY ==================== */
.screen-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-top) + 12px) 14px calc(var(--safe-bot) + 16px);
  overflow-y: auto;
}

.lobby {
  background: linear-gradient(180deg, rgba(20, 62, 118, 0.38) 0%, rgba(15, 23, 42, 0.82) 100%);
}

.city-screen {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stats-pill {
  background: rgba(15, 23, 42, 0.88);
  color: #fde047;
  border: 2px solid #f59e0b;
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 900;
}

.top-btns { display: flex; gap: 6px; }

.top-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #fff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.brand-wrap {
  text-align: center;
  margin-top: 24px;
}

.brand-sub {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #fde047;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.brand-title {
  margin: 4px 0 0;
  font-size: 38px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 0 var(--ink);
}

.brand-title span { color: #fde047; }

.lobby-deck {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-big, .btn-med, .btn-sm {
  border-radius: 13px;
  border: 2.5px solid var(--ink);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
}

.btn-big:active, .btn-med:active, .btn-sm:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn-big {
  padding: 15px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 17px;
}

.btn-big small { font-size: 11.5px; font-weight: 700; opacity: 0.92; }
.btn-med { padding: 12px 12px; font-size: 13.5px; }
.btn-sm { padding: 9px 12px; font-size: 12.5px; }

.btn-gold { background: linear-gradient(180deg, #fde047, #f59e0b); color: var(--ink); }
.btn-blue { background: linear-gradient(180deg, #3b82f6, #1d4ed8); color: #fff; }
.btn-light { background: #e2e8f0; color: var(--ink); }
.btn-ghost { background: transparent; color: #475569; box-shadow: none; }
.full-w { width: 100%; }

/* City 3x3 Builder */
.city-head { text-align: center; margin: 10px 0 8px; }
.city-title { margin: 0; font-size: 22px; font-weight: 900; }
.city-hint { font-size: 12px; font-weight: 700; color: #334155; margin-top: 2px; }

.tier-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.tier-btn {
  padding: 7px 4px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #fff;
  font-size: 10.5px;
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.tier-btn.active {
  background: var(--ink);
  color: #fde047;
}

.tier-btn.locked {
  background: #cbd5e1;
  color: #475569;
  border-style: dashed;
}

/* Next tower type to unlock (city map and end screen); hidden when empty */
.unlock-goal {
  align-self: center;
  display: inline-block;
  margin-top: 5px;
  font-size: 11.5px;
  font-weight: 900;
  background: #fef9c3;
  color: var(--ink);
  border: 1.5px dashed var(--ink);
  border-radius: 99px;
  padding: 3px 10px;
}

.unlock-goal:empty { display: none; }

.tier-swatch {
  width: 18px;
  height: 10px;
  border-radius: 4px;
  border: 1.5px solid var(--ink);
}

.city-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.city-tile {
  aspect-ratio: 1 / 1.05;
  border-radius: 13px;
  border: 2.5px solid var(--ink);
  background: linear-gradient(180deg, #86efac, #4ade80);
  box-shadow: 0 4px 0 var(--ink);
  padding: 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.city-tile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.tile-tower-icon {
  width: 36px;
  border-radius: 5px 5px 2px 2px;
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.tile-pop {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 900;
  background: rgba(15, 23, 42, 0.85);
  color: #fde047;
  padding: 2px 6px;
  border-radius: 99px;
}

.tile-empty {
  font-size: 24px;
  opacity: 0.45;
}

/* Paper sprite art in city tiles (sprites.js); the old icon stays if sprites are missing */
.tile-art-wrap {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  margin: 2px 0;
}

.tile-art {
  display: block;
  width: 100%;
  height: 100%;
}

.tile-art-floors {
  position: absolute;
  right: 0;
  top: 0;
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 99px;
  padding: 1px 5px;
}

/* ==================== MODALS ==================== */
.modal {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.72);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 335px;
  background: #f8fafc;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 0 var(--ink);
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: center;
}

.modal-title { font-size: 23px; font-weight: 900; }
.modal-title.danger { color: var(--red); }
.modal-sub { font-size: 12.5px; font-weight: 800; color: #475569; }

.record-tag {
  align-self: center;
  font-size: 11px;
  font-weight: 900;
  background: var(--red);
  color: #fff;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1.5px solid var(--ink);
}

.end-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.end-box {
  background: #e2e8f0;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 7px;
}

.end-box small { display: block; font-size: 10px; font-weight: 800; color: #475569; }
.end-box b { font-family: ui-monospace, monospace; font-size: 16px; font-weight: 900; }

.subradar-pill {
  align-self: center;
  font-size: 11px;
  font-weight: 900;
  background: var(--ink);
  color: #fde047;
  border: 1.5px solid var(--gold);
  border-radius: 99px;
  padding: 4px 12px;
}

.toast {
  position: absolute;
  bottom: calc(var(--safe-bot) + 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--ink);
  color: #fff;
  border: 2px solid #fde047;
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
