:root {
  --bg: #0b0910;
  --panel: rgba(11, 9, 16, 0.86);
  --text: #e9e4f2;
  --muted: #a49cb4;
  --accent: #57e04d;      /* the game's title green */
  --accent-ink: #08130a;
  --line: #2c2638;
  --header-h: 3.25rem;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
}

header {
  height: var(--header-h);
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 16px 0;
}
h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.credit { margin: 0; color: var(--muted); font-size: 0.85rem; }

main {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 16px;
  container-type: size;
}

/* 4:3, as large as fits between header and footer. */
#frame {
  position: relative;
  aspect-ratio: 4 / 3;
  width: min(100cqw, 100cqh * 4 / 3);
  background: #000;
  box-shadow: 0 0 0 1px var(--line), 0 12px 40px rgba(0, 0, 0, 0.6);
}
#canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
}
#overlay[hidden] { display: none; }
.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
  padding: 1rem;
}
.panel[hidden] { display: none; }
.big { font-size: 1.5rem; margin: 0; }
.note { color: var(--muted); margin: 0; }
#load-text { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
progress { width: min(18rem, 70vw); accent-color: var(--accent); }

button {
  font: inherit;
  color: var(--text);
  background: #1b1724;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
}
button:hover { border-color: var(--muted); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#play, #again {
  font-size: 1.4rem;
  padding: 0.6rem 2.4rem;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 0.5rem 16px 0.75rem;
}
.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.keys div { display: flex; gap: 0.35rem; align-items: baseline; }
.keys dt, .keys dd { margin: 0; }
.keys dd { color: var(--text); }
kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.3em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #16121e;
  color: var(--text);
  font: 0.8rem/1.4 ui-monospace, monospace;
  text-align: center;
}
.settings { display: flex; align-items: center; gap: 0.75rem; }
#music-status { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* Fullscreen: just the game, letterboxed. */
#frame:fullscreen {
  width: auto;
  height: 100%;
  max-width: 100%;
  margin: auto;
  box-shadow: none;
}
#frame:fullscreen::backdrop { background: #000; }

@media (max-width: 700px) {
  .credit { display: none; }
}

/* Credits page: a scrolling document instead of the game layout. */
a { color: var(--accent); }
h1 a { text-decoration: none; }
body.doc { overflow: auto; height: auto; }
body.doc main { display: block; container-type: normal; margin: 0 16px 3rem; }
body.doc article { max-width: 46rem; overflow-wrap: anywhere; }
body.doc h2 { font-size: 1.1rem; margin: 1.75rem 0 0.5rem; }
body.doc table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
body.doc th, body.doc td { text-align: left; vertical-align: top; padding: 0.35rem 0.75rem 0.35rem 0; border-bottom: 1px solid var(--line); }
body.doc th { color: var(--muted); font-weight: normal; }
.credits-link { margin-left: auto; font-size: 0.85rem; color: var(--muted); }
