:root {
  --navy: #003057;
  --gold: #f7c145;
  --ink: #f4f1e8;
  --dim: #9aa4b5;
  --s: 1px; /* stage height / 1080, set by player.js */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--ink);
  font-family: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  overflow: hidden;
}

/* the 16:9 stage, as large as the window allows */
#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #000;
  overflow: hidden;
  cursor: default;
}
#stage.idle { cursor: none; }

.layer {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  background: #000; /* a 4:3 machine is pillarboxed, and the black fades with it */
}
.layer canvas {
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* black over the hall: before Play, and fading out during the silent lead-in */
.black { position: absolute; inset: 0; background: #000; pointer-events: none; }

/* the machine's title card: platform, and the sound chip heard */
.card {
  position: absolute;
  left: calc(56 * var(--s));
  bottom: calc(56 * var(--s));
  display: flex;
  background: rgba(0, 48, 87, 0.91);
  pointer-events: none;
  will-change: transform, opacity;
}
.card .bar { width: calc(9 * var(--s)); background: var(--gold); }
.card .text { padding: calc(22 * var(--s)) calc(36 * var(--s)) calc(26 * var(--s)) calc(30 * var(--s)); }
.card .title { font-weight: 700; font-size: calc(60 * var(--s)); line-height: 1.05; color: #fff; white-space: nowrap; }
.card .sound { font-weight: 500; font-size: calc(36 * var(--s)); line-height: 1.15; color: var(--gold); white-space: nowrap; }
.card .sound:empty { display: none; }

/* the closing credits over the darkened hall */
.credits {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: rgb(240, 220, 160);
  text-align: center;
}
.credits div { position: absolute; left: 0; right: 0; line-height: 1; letter-spacing: 0.04em; font-weight: 500; }

/* start / replay */
.start {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(18 * var(--s));
  background: #000;
  transition: opacity 0.4s ease;
  text-align: center;
  padding: 0 calc(80 * var(--s));
}
.start h1 { margin: 0; font-size: max(calc(84 * var(--s)), 24px); font-weight: 700; line-height: 1; }
.start p { margin: 0; font-size: max(calc(34 * var(--s)), 14px); color: var(--dim); font-weight: 500; }
.start button, .end button {
  margin-top: calc(24 * var(--s));
  font: inherit;
  font-weight: 700;
  font-size: max(calc(38 * var(--s)), 18px);
  color: var(--navy);
  background: var(--gold);
  border: 0;
  padding: max(calc(14 * var(--s)), 8px) max(calc(48 * var(--s)), 24px);
  cursor: pointer;
}
.start.leaving { opacity: 0; pointer-events: none; }
.start button:disabled { opacity: 0.5; cursor: progress; }
.start button:focus-visible, .end button:focus-visible, .controls button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* the end: the hall fades fully to black, then a thank-you */
.end {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(28 * var(--s));
  background: #000;
  opacity: 0;
  transition: opacity 1.6s ease;
}
.end.shown { opacity: 1; }
.end p { margin: 0; font-size: max(calc(64 * var(--s)), 22px); font-weight: 700; color: #fff; }
.end p, .end .buttons { opacity: 0; transition: opacity 0.8s ease 1.6s; }
.end.shown p, .end.shown .buttons { opacity: 1; }
.end .buttons { display: flex; gap: calc(24 * var(--s)); flex-wrap: wrap; justify-content: center; }
.end .buttons button { margin-top: 0; }
.end button.secondary { background: none; color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }
/* controls, shown on mouse movement */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 26px 18px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  transition: opacity 0.3s;
}
#stage.idle .controls, .controls.hidden { opacity: 0; pointer-events: none; }
.controls button {
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 4px 8px;
  cursor: pointer;
  min-width: 44px;
  min-height: 36px;
}
.track { position: relative; flex: 1; height: 36px; display: flex; align-items: center; }
.track input { width: 100%; margin: 0; accent-color: var(--gold); cursor: pointer; }
.ticks { position: absolute; left: 0; right: 0; top: 0; height: 8px; pointer-events: none; }
.ticks span { position: absolute; top: 0; width: 2px; height: 8px; background: rgba(255, 255, 255, 0.45); }

/* about */
.about {
  position: absolute;
  inset: 6% 10%;
  overflow: auto;
  background: rgba(8, 16, 30, 0.96);
  border-left: 6px solid var(--gold);
  padding: 28px 36px;
  font-family: "Source Sans 3", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #dfe3ea;
}
.about[hidden] { display: none; }
.about h2 { font-family: "Barlow Semi Condensed", sans-serif; font-size: 30px; margin: 0 0 8px; color: #fff; }
.about h3 { font-family: "Barlow Semi Condensed", sans-serif; font-size: 20px; margin: 22px 0 6px; color: var(--gold); }
.about p, .about ul { margin: 0 0 8px; }
.about ul { padding-left: 20px; }
.about a { color: #9cc9ff; }
.about .close { position: sticky; top: 0; float: right; font-size: 18px; color: #fff; background: none; border: 0; cursor: pointer; }

@media (max-width: 700px) {
  .about { inset: 0; padding: 20px 16px; }
  .controls { gap: 6px; padding: 18px 8px 8px; }
}

[hidden] { display: none !important; }
