/* The page chrome: header, toolbar, stage, overlay, footer. The guide's own
   stylesheet (guide.css) is a separate file, and the two read as one document
   because every colour, font and width comes from the tokens declared here —
   this is the ONLY place they are defined. The look is a technical manual:
   light page, thin top rule, one centred column, mono headings, buttons that
   look like documentation chips, kbd like a keycap. No web fonts, no
   external requests. */

:root {
  --bg: #f6f7f8; --panel: #ffffff; --ink: #1b1f23; --muted: #5c6570;
  --line: #d7dce2; --accent: #8a5a00; --code-bg: #eef1f4;
  --kbd-bg: #fafbfc; --kbd-border: #c9d1d9; --kbd-shadow: #b3bcc6;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --maxw: 1100px;
}

/* --- Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 16px/1.55 var(--font);
  -webkit-text-size-adjust: 100%;
  /* The thin top rule. */
  border-top: 2px solid var(--accent);
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

a { color: var(--accent); }

h1, h2, h3, h4 {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.25;
  margin: 1.6em 0 0.5em;
}
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; border-bottom: 1px solid var(--line); padding-bottom: 0.3em; }
h3 { font-size: 1rem; }

/* The letter-spaced small label that prefixes a heading ("play", "saves",
   a guide section's number). Uppercase by transform so the source stays
   readable. */
.section-label {
  font-family: var(--mono);
  font-size: 0.72em;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.4em;
}

code, pre {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--code-bg);
  border-radius: 3px;
}
code { padding: 1px 4px; }
pre { padding: 10px 12px; overflow-x: auto; }
pre code { padding: 0; background: none; }

/* A keycap. Defined here because both the toolbar hints and the guide use
   it, and a key has to look the same in both. */
kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.85em;
  line-height: 1.2;
  color: var(--ink);
  background: var(--kbd-bg);
  border: 1px solid var(--kbd-border);
  border-radius: 3px;
  box-shadow: 0 2px 0 var(--kbd-shadow);
  padding: 2px 6px;
  vertical-align: baseline;
  white-space: nowrap;
}

.muted { color: var(--muted); }

/* --- Header + toolbar ------------------------------------------------------ */
#top {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

#top .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-height: 52px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  margin: 0;
  font-size: 1.1rem;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* A documentation chip: mono, one hairline, the panel colour, no gradient.
   Shared by <button> and the <label> that fronts the file input so the three
   controls read as one row. */
.btn {
  display: inline-block;
  font: 500 0.82rem/1.2 var(--mono);
  letter-spacing: 0.02em;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 6px 10px;
  margin: 0;
  cursor: pointer;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { background: var(--code-bg); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn[disabled] { opacity: 0.5; cursor: default; }

.status {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 6ch;
}

/* --- Stage ----------------------------------------------------------------- */
/* 16:9, the full content column wide, but never taller than 85vh — so the
   width is the smaller of the column and what 85vh allows at 16:9, and the
   box is centred when the height wins. The canvas fills the box; app.js
   reports the box's size to the game. */
#stage {
  position: relative;
  width: min(100%, calc(85vh * 16 / 9));
  aspect-ratio: 16 / 9;
  margin: 16px auto 0;
  background: #0b0d10;
  border: 1px solid var(--line);
  overflow: hidden;
}

/* SDL sets the canvas's inline CSS size to what the game asked for, and the
   two agree once app.js has reported the box — but a drag changes the box
   before the debounced report lands, and for that tenth of a second the
   canvas must still fill it, hence !important. */
#canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
  background: #0b0d10;
  image-rendering: pixelated;
}

#stage:fullscreen {
  width: 100%;
  height: 100%;
  max-height: none;
  aspect-ratio: auto;
  margin: 0;
  border: 0;
}

/* Centred mono text on a translucent dark panel; hidden by the attribute so
   the script only ever toggles `hidden`. */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: #f2f4f6;
  background: rgba(11, 13, 16, 0.72);
  pointer-events: none;
}
.overlay[hidden] { display: none; }

/* --- Guide host + footer ------------------------------------------------------ */
.guide-host {
  margin-top: 32px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.foot {
  margin-top: 40px;
  padding-top: 12px;
  padding-bottom: 32px;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--muted);
}

/* --- Narrow screens ------------------------------------------------------------ */
@media (max-width: 600px) {
  body { font-size: 15px; }
  #top .wrap { flex-direction: column; align-items: flex-start; }
  .toolbar { width: 100%; }
  .btn { padding: 6px 8px; }
  #stage { margin-top: 12px; }
}
