.play-root {
  --play-ink: #2a2118;
  --play-paper: color-mix(in oklab, var(--surface) 86%, #f4ead2 14%);
  --play-brass: #9c6b2f;
  --play-green: #486b57;
  --play-red: #8a3f3f;
  --play-blue: #3e5f8a;
  max-width: 1100px;
  margin: 2rem auto 4rem;
  padding: 0 1rem;
}

.play-root * {
  box-sizing: border-box;
}

.play-root.is-odd {
  filter: saturate(1.08) contrast(1.02);
}

.play-hero,
.play-console,
.play-tool {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--play-paper);
  box-shadow: 0 18px 45px rgba(35, 26, 16, 0.08);
}

.play-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  align-items: center;
  gap: 2rem;
  padding: clamp(1.25rem, 4vw, 3rem);
  overflow: hidden;
}

.play-kicker {
  margin: 0 0 0.45rem;
  color: var(--play-brass);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.play-hero h1,
.play-page-head h1 {
  margin: 0;
  color: var(--heading);
}

.play-lede,
.play-page-head p {
  max-width: 62ch;
  margin-top: 0.75rem;
  color: var(--muted);
}

.play-orbit {
  position: relative;
  aspect-ratio: 1;
  min-height: 300px;
  border: 1px dashed color-mix(in oklab, var(--border) 70%, var(--play-brass));
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 49.8%, color-mix(in oklab, var(--border) 70%, transparent) 50%, transparent 50.2%),
    linear-gradient(0deg, transparent 49.8%, color-mix(in oklab, var(--border) 70%, transparent) 50%, transparent 50.2%);
}

.play-orbit::after {
  content: "PLAY";
  position: absolute;
  inset: 35%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.16em;
}

.play-orbit__node {
  position: absolute;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  transform: translate(-50%, -50%);
}

.play-orbit__node.is-active,
.play-orbit__node:hover {
  background: var(--play-brass);
  color: #fff8e8;
}

.play-console {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  margin: 1rem 0;
  padding: 1rem;
}

.play-console__screen {
  min-height: 190px;
  padding: 1.25rem;
  border-radius: 6px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.025), rgba(0, 0, 0, 0.025) 1px, transparent 1px, transparent 7px),
    color-mix(in oklab, var(--surface) 92%, var(--play-green) 8%);
}

.play-console__screen h2 {
  margin: 0.2rem 0 0.5rem;
}

.play-whisper,
.play-live-note {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-style: italic;
}

.play-console__eyebrow {
  margin: 0;
  color: var(--play-green);
  font-weight: 800;
  text-transform: uppercase;
}

.play-console__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-content: start;
}

.play-root button,
.play-primary,
.sigil-form button {
  min-height: 42px;
  border: 1px solid color-mix(in oklab, var(--border) 70%, var(--play-brass));
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}

.play-root button:hover,
.play-primary:hover,
.sigil-form button:hover {
  background: var(--play-ink);
  color: #fff8e8;
  text-decoration: none;
}

.play-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.5rem;
  background: var(--play-brass);
  color: #fff8e8;
  font-weight: 800;
}

.play-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.8rem;
}

.play-grid a {
  min-height: 135px;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in oklab, var(--surface) 88%, var(--play-paper) 12%);
  color: var(--fg);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.play-grid a:hover,
.play-grid a.is-active {
  transform: translateY(-3px);
  border-color: var(--play-brass);
  background: color-mix(in oklab, var(--surface) 76%, var(--play-brass) 24%);
  text-decoration: none;
}

.play-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.play-grid strong {
  display: block;
  margin-top: 2rem;
  color: var(--heading);
  font-size: 1.05rem;
}

.play-back {
  display: inline-flex;
  margin-bottom: 1rem;
  color: var(--muted);
}

.play-page-head {
  margin-bottom: 1rem;
}

.play-tool {
  padding: 1rem;
}

.play-scorebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  color: var(--muted);
}

.memory-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 0.7rem;
}

.memory-card {
  aspect-ratio: 1.08;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 38%, rgba(246, 216, 137, 0.15), transparent 28%),
    linear-gradient(135deg, #211812, var(--play-ink));
  color: #e7c978;
  font-size: clamp(1.3rem, 4vw, 2.2rem);
  font-weight: 900;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

.memory-card.is-open,
.memory-card.is-matched,
.memory-card.is-peeking {
  background: color-mix(in oklab, var(--surface) 72%, var(--play-green) 28%);
  color: var(--fg);
  transform: rotate(0deg) translateY(-2px);
}

.memory-card.is-matched {
  outline: 2px solid color-mix(in oklab, var(--play-brass) 70%, transparent);
}

.play-canvas,
.sigil-canvas {
  display: block;
  width: 100%;
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #18130f;
}

.poem-tool {
  display: grid;
  gap: 1rem;
}

.poem-slip {
  min-height: 220px;
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  line-height: 1.7;
}

.poem-slip[data-stamp]:not([data-stamp=""])::after {
  content: attr(data-stamp);
  display: inline-block;
  margin-top: 1rem;
  padding: 0.2rem 0.5rem;
  border: 2px solid var(--play-red);
  color: var(--play-red);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  transform: rotate(-4deg);
}

.bookshelf,
.timeline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: stretch;
}

.book-spine,
.timeline-card {
  touch-action: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.8rem;
  background: var(--surface);
  cursor: grab;
  user-select: none;
}

.book-spine {
  width: 120px;
  min-height: 230px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  color: #fff8e8;
  font-weight: 800;
}

.book-spine:nth-child(3n+1) { background: var(--play-red); }
.book-spine:nth-child(3n+2) { background: var(--play-green); }
.book-spine:nth-child(3n+3) { background: var(--play-blue); }

.booklet {
  flex: 1 1 220px;
  min-height: 110px;
  padding: 0.9rem;
  border: 1px dashed var(--play-brass);
  border-radius: 7px;
  background: color-mix(in oklab, var(--surface) 74%, var(--play-brass) 26%);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.timeline-list {
  flex-direction: column;
}

.timeline-card {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 1rem;
}

.timeline-card span {
  color: var(--play-brass);
  font-weight: 900;
}

.recipe-tool {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
}

.recipe-wheel {
  aspect-ratio: 1;
  width: 100%;
  border-radius: 50% !important;
  background:
    conic-gradient(from 0deg, var(--play-red), var(--play-brass), var(--play-green), var(--play-blue), var(--play-red));
  color: #fff8e8 !important;
  font-weight: 900;
  transition: transform 900ms cubic-bezier(.18, .88, .2, 1.15);
}

.recipe-result {
  display: grid;
  gap: 0.7rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.recipe-result li {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.terminal-tool {
  background: #15120e;
  color: #f2e3bd;
}

.terminal-log {
  min-height: 310px;
  max-height: 460px;
  overflow: auto;
  padding: 1rem;
  border: 1px solid rgba(242, 227, 189, 0.2);
  border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
}

.terminal-form {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.terminal-form label {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.5rem;
}

.terminal-form input,
.sigil-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
}

.study-tool {
  display: grid;
  justify-items: center;
  gap: 1rem;
}

.study-scene {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 1.6;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 22%, rgba(244, 210, 113, var(--lamp, 0.18)), transparent 30%),
    linear-gradient(#27211b 0 62%, #4b3425 62% 100%);
  overflow: hidden;
}

.study-scene span {
  position: absolute;
  left: 42%;
  bottom: 30%;
  width: 16%;
  height: 38%;
  border-radius: 50% 50% 6px 6px;
  background: #b88639;
  box-shadow: 0 0 calc(20px + var(--glow, 0px)) rgba(244, 210, 113, 0.7);
}

.study-time {
  font-size: clamp(2.4rem, 8vw, 5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.sigil-tool {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 520px);
  gap: 1rem;
  align-items: start;
}

.sigil-form {
  display: grid;
  gap: 0.85rem;
}

.sigil-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
}

.sigil-canvas {
  background: var(--surface);
}

.rpg-shell {
  display: grid;
  grid-template-columns: minmax(0, 960px) minmax(280px, 1fr);
  gap: 1rem;
  align-items: start;
}

.ash-rpg-root {
  --ash-black: #05070c;
  --ash-ink: #0d1420;
  --ash-panel: #121a27;
  --ash-line: #344154;
  --ash-gold: #e0a451;
  --ash-cold: #8bd3ff;
  --ash-red: #db4f62;
  --ash-text: #f8efe0;
  --ash-muted: #a8b4c2;
  max-width: 1380px;
}

.ash-rpg-root .play-page-head {
  padding: 1rem 0;
  border-bottom: 1px solid rgba(139, 211, 255, 0.18);
}

.ash-rpg-root .play-page-head h1 {
  color: var(--ash-text);
  font-family: Georgia, "Times New Roman", serif;
  text-shadow: 0 0 18px rgba(139, 211, 255, 0.22);
}

.ash-rpg-root .play-page-head p,
.ash-rpg-root .play-back {
  color: var(--ash-muted);
}

.ash-rpg-shell {
  position: relative;
  border-color: rgba(139, 211, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(12, 20, 32, 0.96), rgba(4, 7, 12, 0.98)),
    var(--ash-black);
  box-shadow:
    0 0 0 1px rgba(224, 164, 81, 0.14) inset,
    0 28px 80px rgba(0, 0, 0, 0.42);
}

.ash-rpg-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 8px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.025) 1px, transparent 1px, transparent 4px);
  mix-blend-mode: screen;
  opacity: 0.35;
}

.rpg-stage {
  display: grid;
  gap: 0.75rem;
}

.rpg-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  border: 2px solid var(--ash-line);
  border-radius: 8px;
  background: var(--ash-black);
  box-shadow:
    0 0 0 4px #05070c,
    0 0 34px rgba(139, 211, 255, 0.16);
}

.ash-rpg-canvas {
  min-height: 360px;
}

.rpg-dialogue,
.rpg-panel {
  border: 1px solid var(--ash-line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(21, 31, 46, 0.95), rgba(8, 12, 18, 0.96)),
    var(--ash-panel);
  color: var(--ash-text);
}

.rpg-dialogue {
  min-height: 130px;
  padding: 1rem;
  box-shadow: 0 0 0 1px rgba(248, 239, 224, 0.05) inset;
}

.rpg-dialogue strong,
.rpg-list h2 {
  color: var(--ash-gold);
}

.rpg-dialogue p,
.rpg-status {
  margin: 0.35rem 0 0;
  color: var(--ash-muted);
  line-height: 1.55;
}

.rpg-panel {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  align-content: start;
}

.rpg-actions,
.rpg-mobile-pad {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.ash-rpg-root button {
  border-color: rgba(139, 211, 255, 0.28);
  background: linear-gradient(180deg, #1a2638, #0c121c);
  color: var(--ash-text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 800;
  text-transform: uppercase;
}

.ash-rpg-root button:hover:not(:disabled),
.ash-rpg-root button:focus-visible {
  background: linear-gradient(180deg, #31435f, #142236);
  color: #ffffff;
  box-shadow: 0 0 18px rgba(139, 211, 255, 0.22);
}

.ash-rpg-root button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.rpg-mobile-pad {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.rpg-mobile-pad [data-rpg-move="up"],
.rpg-mobile-pad [data-rpg-move="down"] {
  grid-column: 2;
}

.rpg-mobile-pad [data-rpg-move="left"] {
  grid-column: 1;
}

.rpg-mobile-pad [data-rpg-act] {
  grid-column: 2;
}

.rpg-mobile-pad [data-rpg-move="right"] {
  grid-column: 3;
}

.rpg-stats {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.rpg-stats div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(139, 211, 255, 0.16);
}

.rpg-stats dt,
.rpg-list h2 {
  margin: 0;
  color: var(--ash-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.rpg-stats dd {
  margin: 0;
  font-weight: 800;
}

.rpg-list ul {
  display: grid;
  gap: 0.45rem;
  margin: 0.45rem 0 0;
  padding: 0;
  list-style: none;
}

.rpg-list li {
  padding: 0.55rem;
  border: 1px solid rgba(139, 211, 255, 0.16);
  border-radius: 6px;
  background: rgba(5, 7, 12, 0.62);
  color: var(--ash-text);
  font-size: 0.92rem;
}

.rpg-list li.is-done {
  border-color: rgba(102, 199, 162, 0.42);
  background: rgba(45, 91, 77, 0.34);
}

.rpg-list li.is-erased {
  border-color: rgba(219, 79, 98, 0.32);
  color: rgba(248, 239, 224, 0.42);
  background: repeating-linear-gradient(90deg, rgba(219, 79, 98, 0.08), rgba(219, 79, 98, 0.08) 6px, rgba(5, 7, 12, 0.6) 6px, rgba(5, 7, 12, 0.6) 12px);
  text-decoration: line-through;
}

.ash-choicebar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.ash-choicebar button {
  min-height: 50px;
}

.ash-memory-meter {
  position: relative;
  display: grid;
  gap: 0.45rem;
  color: var(--ash-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ash-memory-meter::after {
  content: "";
  display: block;
  height: 10px;
  border: 1px solid rgba(139, 211, 255, 0.24);
  border-radius: 999px;
  background: #05070c;
}

.ash-memory-meter i {
  position: absolute;
  left: 1px;
  right: auto;
  bottom: 1px;
  width: 0;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ash-cold), var(--ash-red));
  transition: width 220ms ease;
}

.ash-name-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: end;
}

.ash-name-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--ash-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ash-name-form input {
  width: 100%;
  border: 1px solid rgba(139, 211, 255, 0.24);
  border-radius: 6px;
  padding: 0.65rem;
  background: #05070c;
  color: var(--ash-text);
  font: inherit;
}

.ash-rpg-root.is-lake-awake .rpg-dialogue,
.ash-rpg-root.is-lake-awake .rpg-panel {
  border-color: rgba(219, 79, 98, 0.36);
}

.ash-rpg-root.is-lake-awake .ash-rpg-canvas {
  box-shadow:
    0 0 0 4px #05070c,
    0 0 38px rgba(219, 79, 98, 0.22);
}

.ash-rpg-root.is-ending .rpg-panel {
  box-shadow: 0 0 34px rgba(224, 164, 81, 0.16);
}

@media (max-width: 760px) {
  .play-hero,
  .play-console,
  .recipe-tool,
  .sigil-tool,
  .rpg-shell {
    grid-template-columns: 1fr;
  }

  .play-orbit {
    min-height: 260px;
  }

  .memory-board {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
  }

  .book-spine {
    width: calc(50% - 0.4rem);
    min-height: 160px;
  }

  .ash-choicebar,
  .ash-name-form {
    grid-template-columns: 1fr;
  }

  .ash-rpg-canvas {
    min-height: auto;
  }
}
