* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: #06141c;
  color: #e8f7ff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
#wrap {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #0d3a4e 0%, #06141c 70%);
}
#stage {
  position: relative;
  width: min(100vw, calc(100vh * 420 / 720));
  height: min(100vh, calc(100vw * 720 / 420));
  max-width: 480px;
  max-height: 820px;
  background: #0a2430;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(40, 180, 220, 0.25);
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* HUD */
#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  display: flex; flex-direction: column;
}
#hud.hidden { display: none; }
.top-bar {
  pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 6px;
  background: linear-gradient(180deg, rgba(6,20,28,0.85), transparent);
  z-index: 2;
}
.stat-block {
  flex: 1;
  background: rgba(10, 40, 55, 0.85);
  border: 1px solid rgba(80, 200, 255, 0.25);
  border-radius: 12px;
  padding: 6px 10px;
}
.stat-block .label { font-size: 10px; opacity: 0.7; letter-spacing: 0.04em; text-transform: uppercase; }
.stat-block .value { font-size: 18px; font-weight: 700; color: #7ef9ff; }
.stat-block.rate .value { color: #9bffb0; font-size: 15px; }
.icon-btn {
  pointer-events: auto;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(80, 200, 255, 0.3);
  background: rgba(10, 40, 55, 0.9);
  color: #e8f7ff;
  font-size: 18px;
  cursor: pointer;
}
.hud-spacer { flex: 1; min-height: 8px; pointer-events: none; }


/* Short goal (A2) — slim line above quick buy strip */
.short-goal {
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px 5px;
  padding: 5px 10px;
  border-radius: 10px;
  background: rgba(8, 28, 40, 0.94);
  border: 1px solid rgba(80, 200, 255, 0.28);
  box-shadow: 0 2px 10px rgba(0,0,0,0.28);
  z-index: 2;
  min-height: 0;
}
.short-goal.hidden { display: none; }
.short-goal .kicker {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #e8c46a;
}
.short-goal .body {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: #f2fbff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.short-goal .body em {
  font-style: normal;
  color: #7ef9ff;
  font-weight: 700;
}

/* Always-visible quick buy strip */
.quick-modules {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 10px 6px;
  z-index: 2;
}
.qmod {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(8, 32, 44, 0.92);
  border: 1px solid rgba(80, 200, 255, 0.22);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.qmod.affordable {
  border-color: rgba(80, 255, 200, 0.65);
  box-shadow: 0 0 14px rgba(60, 230, 180, 0.35);
  background: rgba(12, 48, 52, 0.95);
  animation: afford-glow 1.6s ease-in-out infinite;
}
@keyframes afford-glow {
  50% { box-shadow: 0 0 20px rgba(80, 255, 200, 0.55); }
}
.qmod .qi {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: #0a3040;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.qmod .qinfo { flex: 1; min-width: 0; }
.qmod .qname { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qmod .qmeta { font-size: 10px; opacity: 0.7; margin-top: 1px; }
.qmod .qbuy {
  padding: 7px 11px;
  border-radius: 10px;
  border: none;
  background: #2a4050;
  color: #89a;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.qmod.affordable .qbuy {
  background: linear-gradient(180deg, #3dd6a0, #1fa87a);
  color: #042018;
}
.qmod .qbuy:disabled { opacity: 0.7; cursor: default; }

.boost-row {
  pointer-events: auto;
  display: flex; gap: 6px;
  padding: 0 10px 10px;
  z-index: 2;
}
.boost-btn {
  flex: 1;
  min-width: 0;
  padding: 8px 4px 7px;
  border-radius: 12px;
  border: 1px solid rgba(80, 200, 255, 0.35);
  background: rgba(12, 48, 64, 0.92);
  color: #c8f0ff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-family: inherit;
}
.boost-btn .bico { font-size: 14px; line-height: 1; }
.boost-btn .blabel { font-size: 11px; font-weight: 700; line-height: 1.15; }
.boost-btn .bsub { font-size: 9px; opacity: 0.75; line-height: 1.1; font-weight: 600; }
.boost-btn.primary {
  background: linear-gradient(180deg, #2ec4e0, #1890b0);
  color: #042028;
  border-color: #7ef9ff;
}
.boost-btn.primary .bsub { opacity: 0.85; }
.boost-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.boost-btn.on-cd {
  border-color: rgba(255, 200, 80, 0.45);
}
.boost-btn.active-boost {
  border-color: #ffe66b;
  box-shadow: 0 0 12px rgba(255, 230, 107, 0.35);
}
#prestige-hint {
  pointer-events: none;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #ffe66b;
  padding: 2px 4px 6px;
  animation: pulse 1.2s ease-in-out infinite;
}
#prestige-hint.hidden { display: none; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* Modules sheet */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 58%;
  background: rgba(8, 28, 40, 0.97);
  border-top: 2px solid rgba(80, 220, 255, 0.4);
  border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column;
  z-index: 20;
  pointer-events: auto;
}
.sheet.hidden { display: none; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
}
.sheet-head h2 { font-size: 16px; color: #7ef9ff; }
.sheet-body {
  overflow-y: auto;
  padding: 4px 10px 12px;
  -webkit-overflow-scrolling: touch;
}
.sheet-foot { padding: 8px 10px 14px; }
.mod-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(20, 55, 72, 0.7);
  border: 1px solid rgba(80, 200, 255, 0.2);
  border-radius: 14px;
}
.mod-row.locked { opacity: 0.45; }
.mod-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: #0a3040;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.mod-info { flex: 1; min-width: 0; }
.mod-info .name { font-weight: 700; font-size: 13px; }
.mod-info .meta { font-size: 11px; opacity: 0.75; margin-top: 2px; }
.mod-buy {
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(180deg, #3dd6a0, #1fa87a);
  color: #042018;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.mod-buy:disabled {
  background: #2a4050;
  color: #89a;
  cursor: default;
}

.mod-info .meta .hint { color: #9bffb0; }
.mod-row.milestoned {
  border-color: rgba(80, 255, 200, 0.8);
  box-shadow: 0 0 18px rgba(60, 230, 180, 0.5), inset 0 0 12px rgba(60, 230, 180, 0.12);
  transition: box-shadow 0.35s, border-color 0.35s;
}
.qmod.milestoned {
  border-color: rgba(80, 255, 200, 0.8);
  box-shadow: 0 0 18px rgba(60, 230, 180, 0.5);
}

/* Long SoftWare Version teaser (A2) — Modules panel, never Near chip */
.long-teaser {
  margin: 4px 10px 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(12, 28, 40, 0.95);
  border: 1px dashed rgba(255, 230, 107, 0.38);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-shrink: 0;
}
.long-teaser.hidden { display: none; }
.long-teaser .lock {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: rgba(40, 35, 20, 0.8);
  border: 1px solid rgba(255, 230, 107, 0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.long-teaser .lt-body { flex: 1; min-width: 0; }
.long-teaser .lt-kicker {
  font-size: 9px;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: #c8a84a;
  margin-bottom: 2px;
}
.long-teaser .lt-title {
  font-size: 13px;
  font-weight: 700;
  color: #e8d9a0;
}
.long-teaser .lt-sub {
  font-size: 11px;
  color: #9aa8b4;
  margin-top: 2px;
  line-height: 1.35;
}


/* Overlays */
.overlay {
  position: absolute; inset: 0;
  background: rgba(4, 16, 24, 0.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 30;
  padding: 20px;
}
.overlay:not(.visible) { display: none; }

/* Full-bleed title — canvas draws map+Bit behind; UI floats on top */
.overlay.title-full {
  background: transparent;
  padding: 0;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}
.overlay.title-full.visible { display: flex; }
.title-ui {
  pointer-events: auto;
  width: 100%;
  padding: 0 24px 28px;
  text-align: center;
  background: linear-gradient(180deg, transparent 0%, rgba(4, 16, 24, 0.4) 15%, rgba(4, 16, 24, 0.92) 100%);
}
.title-ui .logo {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #7ef9ff, #4ce0ff, #ffe66b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 10px rgba(80, 220, 255, 0.45));
  margin-bottom: 4px;
}
.title-ui .tagline {
  opacity: 0.9;
  font-size: 14px;
  margin: 0 0 72px; /* ~60–80px gap to Play at phone sizes */
  color: #c8f0ff;
}
.title-ui .primary.big {
  margin-top: 0;
}
.card {
  width: min(100%, 320px);
  background: linear-gradient(160deg, #123848 0%, #0a2430 100%);
  border: 1px solid rgba(100, 220, 255, 0.35);
  border-radius: 20px;
  padding: 22px 18px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.card h1 { font-size: 22px; margin-bottom: 8px; color: #7ef9ff; }
.card p { font-size: 14px; opacity: 0.85; line-height: 1.4; margin-bottom: 14px; }
.stats { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
.stat {
  flex: 1;
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  padding: 10px 6px;
}
.stat b { display: block; font-size: 18px; color: #ffe66b; }
.stat span { font-size: 11px; opacity: 0.7; }
.btn-row, .btn-col { display: flex; gap: 8px; justify-content: center; }
.btn-col { flex-direction: column; }
button.primary, button.secondary, button.ghost, button.danger, button.rewarded, button.big {
  border: none; border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
button.primary {
  background: linear-gradient(180deg, #4ce0ff, #1aa0c4);
  color: #042028;
}
button.big { font-size: 18px; padding: 14px 36px; }
button.secondary {
  background: rgba(80, 160, 200, 0.25);
  color: #e8f7ff;
  border: 1px solid rgba(100, 200, 255, 0.35);
}
button.ghost {
  background: transparent;
  color: #a8d0e0;
  border: 1px solid rgba(100, 200, 255, 0.25);
}
button.danger {
  background: linear-gradient(180deg, #e07070, #b04040);
  color: #fff;
}
button.rewarded {
  background: linear-gradient(180deg, #ffe66b, #e0b020);
  color: #302000;
}
button.wide { width: 100%; }
button.wide.hidden { display: none; }
.tiny { font-size: 11px; opacity: 0.55; margin-top: 12px; }

#ad-stub-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.88);
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 100;
  gap: 12px;
  color: #ccc;
}
#ad-stub-overlay.visible { display: flex; }
#ad-stub-track {
  width: 70%; height: 8px;
  background: #333; border-radius: 4px; overflow: hidden;
}
#ad-stub-bar {
  height: 100%; width: 0%;
  background: #4ce0ff;
}
#ad-stub-overlay .label { font-weight: 700; }
#ad-stub-overlay .hint { font-size: 12px; opacity: 0.6; }

#toast {
  position: absolute; left: 50%; bottom: 28%;
  transform: translateX(-50%);
  background: rgba(8, 30, 42, 0.95);
  border: 1px solid rgba(100, 220, 255, 0.4);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 40;
  pointer-events: none;
}
#toast.hidden { display: none; }

#toast .hi { color: #9bffb0; font-weight: 800; }
#toast .mod { color: #7ef9ff; }
#toast.milestone {
  text-align: center;
  line-height: 1.4;
  padding: 10px 16px;
  border-color: rgba(100, 220, 255, 0.5);
  box-shadow: 0 6px 22px rgba(0,0,0,0.45), 0 0 16px rgba(80, 220, 255, 0.18);
  bottom: 42%;
  max-width: 86%;
}

@media (min-width: 900px) {
  #stage { border-radius: 12px; }
}
