/* Elementa — night observatory / mineral cabinet.
   Fonts: drop SpaceGrotesk-Bold.woff2 + IBMPlexSans-{Regular,Medium}.woff2 into
   /fonts and uncomment the @font-face blocks. Never hotlink a font CDN. */

/*
@font-face { font-family:'Space Grotesk'; src:url('../fonts/SpaceGrotesk-Bold.woff2') format('woff2');
  font-weight:700; font-display:swap; }
@font-face { font-family:'IBM Plex Sans'; src:url('../fonts/IBMPlexSans-Regular.woff2') format('woff2');
  font-weight:400; font-display:swap; }
@font-face { font-family:'IBM Plex Sans'; src:url('../fonts/IBMPlexSans-Medium.woff2') format('woff2');
  font-weight:500; font-display:swap; }
*/

:root {
  --bg-deep: #101724;
  --panel: #2B3A44;
  --panel-stroke: #16202A;
  --gold: #F5C63C;
  --gold-deep: #6E4A0B;
  --ink: #F2F4FF;
  --muted: #8592A0;
  --font-display: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-ui: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* no double-tap zoom on any control */
button, .overlay, .panel { touch-action: manipulation; }

/* class selectors outrank the UA [hidden] rule, so make it explicit —
   without this, .btn and .overlay.is-open both defeat the hidden attribute */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-ui);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage { position: fixed; inset: 0; }

#game {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- HUD ---- */
.hud {
  position: absolute;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat--end { align-items: flex-end; text-align: right; }

/* §6 score capsule */
.capsule {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--panel);
  border: 2px solid var(--panel-stroke);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.08);
}
.label {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  line-height: 1;
  color: var(--gold);
  -webkit-text-stroke: 2px var(--gold-deep);
  paint-order: stroke fill;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.combo {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: .04em;
  opacity: 0;
  transition: opacity 160ms ease;
  min-height: 16px;
}

.powerbar { position: absolute; pointer-events: none; }

/* ---- overlays ---- */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(16, 23, 36, 0.80);
  backdrop-filter: blur(2px);
}
.overlay.is-open { display: flex; }

.panel {
  min-width: 260px;
  max-width: 86vw;
  padding: 28px 24px;
  text-align: center;
  border: 2px solid var(--panel-stroke);
  border-radius: 16px;
  background: #2B3A44;
}
.panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  color: var(--ink);
}
.panel .sub { margin: 0 0 20px; font-size: 16px; color: var(--muted); }

.btn {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 16px;
  padding: 12px 26px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.btn--primary { border-color: var(--gold); color: var(--gold); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---- Phase 3: stars, power-up bar, shop ---- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
  display: block;
}
.icon--star { width: 18px; height: 18px; color: var(--gold); }
.icon--tiny { width: 11px; height: 11px; color: var(--gold); }

.topbar {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.capsule--star {
  gap: 7px;
  min-width: 0;
  height: 34px;
  padding: 0 14px;
}
.value--sm {
  font-size: 19px;
  -webkit-text-stroke: 1.5px var(--gold-deep);
}

.powerbar {
  position: absolute;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
}
.pu {
  flex: 1 1 0;
  max-width: 118px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 12px;
  background: var(--panel);
  border: 2px solid var(--panel-stroke);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.07);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}
.pu:active { transform: translateY(1px); }
.pu:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.pu.is-armed {
  border-color: var(--gold);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.10), 0 0 0 2px rgba(245, 198, 60, 0.25);
}
.pu.is-poor { opacity: 0.5; }
.pu-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.armhint {
  position: absolute;
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 140ms ease;
}
.armhint.is-on { opacity: 1; }

.shoplist {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  text-align: left;
}
.shoplist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 15px;
}
.shoplist li:last-child { border-bottom: 0; }
.shoplist .name { flex: 1; }
.shoplist .cost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* ---- Phase 4: shell ---- */
.overlay--solid { background: var(--bg-deep); }

.iconbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  background: var(--panel);
  border: 2px solid var(--panel-stroke);
  color: var(--muted);
  cursor: pointer;
  pointer-events: auto;
}
.iconbtn:hover { color: var(--ink); }
.iconbtn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.topbar { justify-content: space-between; }
.topbar__right { display: flex; gap: 8px; pointer-events: auto; }

.logo {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 44px;
  letter-spacing: .10em;
  color: var(--gold);
  -webkit-text-stroke: 2px var(--gold-deep);
  paint-order: stroke fill;
}
.tagline { margin: 0 0 22px; font-size: 15px; color: var(--muted); }

.panel--home { min-width: 280px; }
.panel .btn { display: block; width: 100%; margin: 8px 0 0; }
.homestats {
  display: flex;
  justify-content: center;
  gap: 34px;
  margin-bottom: 20px;
}
.homestats .stat { align-items: center; gap: 2px; }
.btn--danger { border-color: rgba(232, 84, 63, 0.55); color: #F09A8C; }

#resume-wrap { margin-bottom: 6px; }
#resume-wrap .sub { margin: 0 0 8px; }

.panel--howto { max-width: 340px; }
.steps {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  line-height: 1.35;
}
.steps canvas {
  flex: 0 0 auto;
  width: 88px;
  height: 88px;
  border-radius: 10px;
}
.btn .cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--gold);
  margin-left: 6px;
}

.preload-wrap { text-align: center; }
.preload-rail {
  width: 190px;
  height: 2px;
  margin: 18px auto 0;
  background: rgba(255, 255, 255, 0.10);
  overflow: hidden;
}
.preload-bar {
  width: 0;
  height: 100%;
  background: var(--gold);
  transition: width 140ms linear;
}
