html, body { overflow: hidden; position: fixed; inset: 0; }

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #0e0c15;
}
#canvas { display: block; touch-action: none; }

.hud {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, 560px);
  padding: 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.hud-btn {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font: inherit;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  background: rgba(0, 0, 0, .35);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.hud-btn.off { opacity: .4; text-decoration: line-through; }
.hud-score { text-align: center; text-shadow: 0 2px 6px rgba(0, 0, 0, .6); font-variant-numeric: tabular-nums; }
.hud-score b { display: block; font-size: 38px; font-weight: 900; font-style: italic; line-height: 1; }
.hud-score small { font-size: 11px; font-weight: 800; letter-spacing: .08em; opacity: .85; }

.overlay {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: flex;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(14, 11, 22, .82);
}
.sheet { margin: auto; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.game-title { margin: 0; font-size: clamp(40px, 12vw, 56px); line-height: .95; font-weight: 900; font-style: italic; color: var(--sun); }
.how { margin: 0; line-height: 1.45; }
.who { margin: 0; color: var(--muted); }
.who b { color: var(--ink); }
.who a, .target a { color: var(--sun); font-weight: 800; }
.back.center { align-self: center; }

.over-label { margin: 0; text-align: center; font-size: 20px; font-weight: 900; font-style: italic; color: var(--muted); }
.over-label.record { color: var(--sun); }
.final-score { text-align: center; font-size: 76px; line-height: 1; font-weight: 900; font-style: italic; font-variant-numeric: tabular-nums; }
.target { margin: 0; min-height: 1.4em; text-align: center; font-weight: 700; color: var(--sun); }

.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.board:empty { display: none; }
.board li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  background: var(--panel);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.board li.me { outline: 2px solid var(--sun); }
.board li b { flex: none; }

#startPanel:empty, #overPanel:empty { display: none; }
#startPanel, #overPanel { display: flex; flex-direction: column; gap: 8px; }
.trak-earned { margin: 0; text-align: center; font-size: 20px; font-weight: 900; font-style: italic; color: var(--sun); }
.trak-panel { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--panel); border-radius: 8px; }
.trak-panel .trak-preview { width: 76px; height: auto; flex: none; }
.trak-panel .text, .trak-upgrade .text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trak-panel small, .trak-upgrade small, .trak-detail small, .trak-tile small { color: var(--muted); font-size: 13px; }
.trak-garage { padding-bottom: max(72px, env(safe-area-inset-bottom)); background: var(--night); }
.trak-garage .sheet { margin: 0 auto auto; max-width: 420px; }
.trak-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.trak-coins { color: var(--sun); font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }
.trak-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.trak-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 8px; font: inherit; color: var(--ink); text-align: center; background: var(--panel); border: 2px solid var(--line); border-radius: 8px; cursor: pointer; }
.trak-tile.on { border-color: var(--sun); }
.trak-tile small.price { color: var(--sun); font-weight: 800; }
.trak-tile .trak-preview { width: 100%; max-width: 136px; height: auto; }
.trak-detail { display: flex; flex-direction: column; gap: 2px; }
.trak-detail b { font-size: 20px; font-weight: 900; font-style: italic; }
.trak-upgrade { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel); border-radius: 8px; }
.trak-upgrade .btn { flex: none; min-width: 84px; font-variant-numeric: tabular-nums; }
.pips { display: flex; gap: 4px; margin-top: 3px; }
.pips i { width: 22px; height: 6px; border-radius: 3px; background: var(--line); }
.pips i.on { background: var(--sun); }
