:root {
  --bg: #05060f;
  --cyan: #3df0ff;
  --pink: #ff3d81;
  --gold: #ffd23d;
  --text: #e8ecff;
  --dim: #8088b0;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }

.hidden { display: none !important; }

/* ---------- overlay screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 14px;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(5, 6, 15, .55), rgba(5, 6, 15, .92));
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; transform: scale(1.02); } }

h1 {
  margin: 0;
  font-size: clamp(44px, 12vw, 104px);
  line-height: .95;
  letter-spacing: .12em;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 12px var(--cyan), 0 0 44px var(--cyan);
}
h1 span { display: block; color: #fff; text-shadow: 0 0 12px var(--pink), 0 0 44px var(--pink); }

h2 { margin: 0; letter-spacing: .3em; font-size: 15px; color: var(--dim); }
h2.glow { font-size: clamp(26px, 6vw, 44px); color: #fff; text-shadow: 0 0 12px var(--cyan), 0 0 36px var(--cyan); }
h2.glow.red { text-shadow: 0 0 12px var(--pink), 0 0 36px var(--pink); }

.tag { margin: 0; color: var(--dim); letter-spacing: .08em; font-size: 14px; }
.dim { color: var(--dim); font-size: 12px; line-height: 1.7; margin: 0; }

.big {
  padding: 14px 54px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .3em;
  text-indent: .3em;
  color: #fff;
  border: 2px solid var(--cyan);
  border-radius: 6px;
  background: rgba(61, 240, 255, .1);
  box-shadow: 0 0 18px rgba(61, 240, 255, .45), inset 0 0 18px rgba(61, 240, 255, .18);
  transition: transform .08s, background .12s;
}
.big:hover { background: rgba(61, 240, 255, .22); }
.big:active { transform: scale(.96); }

.ghost { color: var(--dim); font-size: 13px; letter-spacing: .15em; padding: 8px 14px; }
.ghost:hover { color: var(--text); }

/* ---------- hangar (permanent upgrades) ---------- */
.shop { width: min(680px, 100%); margin-top: 6px; }
.shop h2 span { color: var(--gold); letter-spacing: .05em; margin-left: 10px; }
#shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 8px; margin-top: 10px; }

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 10px 12px;
  text-align: left;
  border: 1px solid #252a4a;
  border-radius: 6px;
  background: rgba(16, 19, 40, .8);
  transition: border-color .12s;
}
.item b { font-size: 13px; }
.item i { font-style: normal; font-size: 11px; color: var(--dim); grid-column: 1; }
.item .cost { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--gold); font-size: 13px; }
.item .pips { grid-column: 1 / -1; font-size: 9px; letter-spacing: 2px; color: var(--cyan); }
.item:not(:disabled):hover { border-color: var(--gold); }
.item:disabled { cursor: default; opacity: .55; }
.item.maxed { opacity: 1; border-color: #2c5f66; }
.item.maxed .cost { color: var(--cyan); }

/* ---------- level-up cards ---------- */
#cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; width: min(760px, 100%); }
.card {
  position: relative;
  flex: 1 1 200px;
  max-width: 240px;
  min-height: 190px;
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px solid #2c335e;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(24, 28, 60, .95), rgba(10, 12, 28, .95));
  transition: transform .1s, border-color .1s, box-shadow .1s;
}
.card:hover { transform: translateY(-4px); border-color: var(--cyan); box-shadow: 0 0 22px rgba(61, 240, 255, .35); }
.card .ico { font-size: 38px; line-height: 1; text-shadow: 0 0 14px currentColor; }
.card b { font-size: 15px; letter-spacing: .05em; }
.card em { font-style: normal; font-size: 11px; letter-spacing: .15em; color: var(--gold); min-height: 14px; }
.card p { margin: 0; font-size: 12px; line-height: 1.5; color: #aab1d6; }
.card kbd { position: absolute; top: 8px; left: 10px; font: inherit; font-size: 11px; color: var(--dim); }

/* ---------- pause / game over ---------- */
#build { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 560px; }
#build span { padding: 5px 9px; border: 1px solid #252a4a; border-radius: 4px; font-size: 12px; background: rgba(16, 19, 40, .8); }

#stats { display: grid; grid-template-columns: auto auto; gap: 6px 26px; font-size: 15px; text-align: left; }
#stats span:nth-child(odd) { color: var(--dim); }
#stats span:nth-child(even) { text-align: right; font-weight: 700; }
#stats .gold { color: var(--gold); }
#stats .new { color: var(--cyan); }

/* ---------- in-game buttons ---------- */
.corner {
  position: fixed;
  top: calc(34px + env(safe-area-inset-top));
  right: 12px;
  width: 38px;
  height: 38px;
  font-size: 13px;
  color: var(--dim);
  border: 1px solid #252a4a;
  border-radius: 6px;
  background: rgba(10, 12, 28, .6);
  z-index: 2;
}
#muteBtn { right: 58px; font-size: 17px; }
#muteBtn.off { text-decoration: line-through; opacity: .5; }

#dashBtn {
  position: fixed;
  right: 22px;
  bottom: calc(34px + env(safe-area-inset-bottom));
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  background: rgba(61, 240, 255, .1);
  color: var(--cyan);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .15em;
  touch-action: none;
  display: none;
}
#dashBtn:active { background: rgba(61, 240, 255, .3); }

body:not([data-state="play"]) #pauseBtn { display: none; }
body[data-state="play"] { cursor: crosshair; }

.touch { display: none; }
@media (pointer: coarse) {
  body[data-state="play"] #dashBtn { display: block; }
  .desk { display: none; }
  .touch { display: inline; }
}
