:root {
  --accent: #be3a2b;
  --track: rgba(74, 45, 10, 0.22);
  --background: #FFB224;
  --ink: #4a2d0a;
  --icy: #9AC4F8;
  --hand-height: min(88vh, 900px);
  --panel-min-width: 340px;
}

* { box-sizing: border-box; }

body {
  background-color: var(--background);
  color: var(--ink);
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  font: 15px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
}


.stage {
  display: grid;
  grid-template-columns: auto minmax(var(--panel-min-width), max-content);
  gap: 40px;
  align-items: center;
  padding: 24px;
}


#hand {
  height: var(--hand-height);
  width: auto;
}

.line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-track { stroke: var(--track); }

.line-fill {
  stroke: var(--accent);
  transition: stroke-width 120ms ease;
}

.line-fill.is-active { stroke: #7d1f14; }

/* --- control panel --- */

.panel {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
}


.panel-rows {
  display: grid;
  grid-template-columns: max-content 1fr 3ch;
  align-items: center;
  column-gap: 12px;
}

.row { display: contents; }

.row-name,
.row input[type="range"],
.row-readout {
  padding-block: 5px;
}
.row input[type="text"] {
  grid-column-end: span 2;
  margin-right: 6px;
}

.row.is-active > * { background: rgba(255, 255, 255, 0.35); }

.row-name {
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  padding-left: 6px;
}

.row input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

.row-readout {
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  padding-right: 6px;
}


.button {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 18px;
  padding: 10px 18px;
  border: 1px solid #fff;
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, transform 80ms ease;
}

.button.primary {
  background-color: var(--icy);
} 

.button:hover {
  background: rgba(255, 255, 255, 0.35);
}

.button:active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(1px);
}

.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- game over / story --- */

[hidden] { display: none !important; }

.game-over,
.story {
  position: fixed;
  inset: 0;
  background-color: var(--background);
  display: flex;
  flex-direction: row;
}

.story-text {
  background-color: rgba(0,0,0,0.8);
  color: #eee;
  padding: 20px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.5em;
}


.game-over {
  z-index: 1;
  display: grid;
  place-items: center;
  font-size: clamp(64px, 14vw, 220px);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  animation: game-over 3.5s ease forwards;
}

/* The words snap on, hold, then the whole layer fades out. */
@keyframes game-over {
  0%, 65% { opacity: 1; }
  100%    { opacity: 0; }
}

.story {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 32px;
}

.story-text {
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 65ch;
  overflow-y: auto;
  white-space: pre-line;
  opacity: 0;
  transition: opacity 800ms ease;
}

.story.is-visible .story-text { opacity: 1; }


.story-text blockquote {
  margin: 1em 0 1em 1.5ch;
  padding: 0.25em 0 0.25em 2ch;
  border-left: 3px solid var(--accent);
  color: #c9c2b8;
  font-style: italic;
}


.story-text blockquote.epigraph {
  margin-top: 2em;
}

.story-text blockquote cite {
  display: block;
  margin-top: 0.75em;
  text-align: right;
  font-style: normal;
  color: var(--accent);
}


/* Hidden (and unclickable) until the story text has finished fading in, then fades in
   itself. Leaving is-visible snaps it away, since only the delayed rule animates opacity. */
.story .button {
  margin-top: 24px;
  opacity: 0;
  visibility: hidden;
}

.story.is-visible .button {
  opacity: 1;
  visibility: visible;
  transition: opacity 400ms ease 800ms, visibility 0s linear 800ms,
              background-color 120ms ease, color 120ms ease, transform 80ms ease;
}

@media (max-width: 720px) {
  .stage {
    grid-template-columns: min(80vw, 420px);
    gap: 16px;
  }
}
