* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #05060f;
  color-scheme: dark; /* tell the browser this page is dark, so it never paints light chrome or form controls */
  --panel: #0b0f1f;
  --line: #26304a;
  --text: #cfe3ff;
  --dim: #6b7a99;
  --accent: #ffb14d;
  --good: #7df9ff;
  --edge: 12px; /* the gap between the game and the window, on all four sides */
}

html { background: var(--bg); } /* the root element owns the page background; body alone lets white show through during load */
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Trebuchet MS", system-ui, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh; /* see #wrap: on iOS 100vh is taller than the window really is */
  padding: var(--edge);
}

/* ⚠️ No width here on purpose. How big the game is on the screen is
   Screens.fit(#wrap), called once at boot: it works the size out from the
   canvas's own 960×600 and writes it inline, over anything this file says.
   A width rule here would be dead on arrival — and a width rule *without*
   fit is how the game came off the bottom of a sideways phone. */
#wrap { position: relative; }

canvas {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

/* ---------- overlays ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(5, 6, 15, 0.84);
  border-radius: 10px;
  text-align: center;
  padding: 24px;
  overflow: auto;
}

/* Flex centering clips whatever overflows both ends of the box; on a phone
   the panel is taller than the game. Auto margins centre it when there is
   room and give way to the scroll when there is not. */
.screen > :first-child { margin-top: auto; }
.screen > :last-child { margin-bottom: auto; }

.hidden { display: none !important; }

h2 { font-size: clamp(18px, 5vw, 28px); letter-spacing: clamp(1px, 0.8vw, 4px); color: var(--accent); }

.tagline { color: var(--dim); }
.msg { color: var(--good); font-size: 15px; }

/* ---------- the studio's screens ---------- */

/* The title and game-over screens come from studio/screens.js. Their colours
   are the four in config/look.js, so they are already this game's — these are
   the two things a stylesheet has to say. Nothing here needs !important: the
   library keeps its own rules in @layer screens, so this file outranks them
   by being unlayered. */
:root {
  /* the game's typeface, in place of the studio's Space Grotesk. Its Space
     Mono stays, because the scores were never in a tabular face before. */
  --screens-font: "Trebuchet MS", system-ui, sans-serif;
}

/* The HUD steps aside under the upgrade chooser, the way it already does
   under the studio's own screens: the panel is not quite opaque, and a score
   showing through it reads as a mistake. The library's own rule for this
   weighs 0-0-1, so this one — two classes and an element — wins without
   !important and without borrowing screens-open, which belongs to the
   library's screens rather than to this one. */
body.upgrading .screens-chips { display: none; }

/* ---------- buttons ---------- */

/* :not(.screens-start) keeps this off the Start button on the studio's
   screens. That button is a pill with the game's own two colours in it, and
   this rule is more specific than anything the library can write — a generic
   `button {}` would quietly take its shape back, and the hover would put
   orange text on an orange gradient. */
button:not(.screens-start) {
  background: #1a2340;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}

button:not(.screens-start):hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
button:not(.screens-start):disabled { opacity: 0.4; cursor: default; }

/* ---------- upgrade choice ---------- */

.choice-list {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.choice-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  width: 240px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.choice-card:hover { border-color: var(--good); }

.choice-tag { font-size: 11px; letter-spacing: 1px; color: var(--dim); }

.choice-card .name { font-size: 15px; font-weight: bold; color: var(--good); }
.choice-card:hover .name { color: var(--good); }
.choice-card.selected .name { color: var(--accent); }

.choice-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(255, 177, 77, 0.35);
}

.choice-card .desc { font-size: 12px; color: var(--dim); line-height: 1.4; }

/* The risk bar is a meter chip now — Screens.chips draws it from
   { value, max, text }, in the highlight colour a number wears. The only
   thing left to say about it is how wide it is, since the library's default
   is sized for a Lives-style chip rather than a bar you watch. */
body .screens-chip-meter { width: clamp(36px, 9vw, 90px); }

/* ---------- run breakdown ---------- */

/* Handed to Screens.title({ extra }), so it fills the panel it sits in and
   keeps its distance from the hint above it. */
.breakdown {
  width: 100%;
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  font-size: 13px;
}

.breakdown .brow {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.breakdown .blabel { color: var(--dim); }
.breakdown .bvalue { color: var(--text); font-variant-numeric: tabular-nums; }

.breakdown .bsub {
  color: var(--dim);
  font-size: 12px;
  line-height: 1.5;
}

.breakdown .bsection {
  margin-top: 10px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 2px;
}
.breakdown .bsection:first-child { margin-top: 0; }
