* { box-sizing: border-box; }
:root { color-scheme: dark; font-family: "Avenir Next", system-ui, sans-serif; }
body {
  --back: #24172d; --surface: #342045; --line: #674a78; --ink: #fff7e1;
  --accent: #ffd44e; --accent-ink: #27162e; --muted: #ddcde6;
  margin: 0; background: var(--back); color: var(--ink);
}
body.murder {
  --back: #241820; --surface: #37232d; --line: #725263; --ink: #fff6dd;
  --accent: #f5cb70; --accent-ink: #301b29; --muted: #e6c8cd;
}
[hidden] { display: none !important; }
button, a { -webkit-tap-highlight-color: transparent; }
button {
  color: inherit; font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--surface); border-radius: 8px; min-height: 40px; padding: 6px 12px;
  font-weight: 650;
}
button:disabled { cursor: default; opacity: .47; }
button:not(:disabled):hover { border-color: var(--accent); }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.shell { width: min(100% - 24px, 940px); margin: 0 auto; padding-block: 10px 12px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 8px; }
header > a { font-size: .83rem; color: var(--muted); white-space: nowrap; }
nav { display: flex; align-items: center; justify-content: end; gap: 6px; }
nav button { min-height: 34px; font-size: .76rem; padding-inline: 8px; }
h1 { margin: 0; font-weight: 850; font-size: clamp(1.1rem, 3vw, 1.65rem); letter-spacing: -.04em; }
.meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0 7px; }
.meta strong { font-size: .88rem; }
.meta span { color: var(--muted); font-size: .78rem; text-align: right; }
.stage {
  position: relative; overflow: hidden; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); isolation: isolate;
}
canvas { width: 100%; display: block; aspect-ratio: 16 / 9; }
.level canvas { image-rendering: pixelated; }
.overlay {
  position: absolute; inset: 0; padding: 12px; display: grid; place-items: center;
  background: #140d1c9e;
}
.overlay > div {
  width: min(100%, 400px); max-height: 100%; overflow: auto;
  text-align: center; border: 1px solid var(--line); border-radius: 12px; padding: clamp(10px, 3vw, 26px);
  background: var(--back); box-shadow: 0 7px 28px #160c19a8;
}
.overlay h2 { margin: 0; font-size: clamp(1.1rem, 4.4vw, 2rem); font-weight: 850; letter-spacing: -.035em; }
.overlay p { margin: .48em 0 .8em; font-size: clamp(.74rem, 2.1vw, 1rem); color: var(--muted); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 850; }
.primary:hover { filter: brightness(1.1); }
.controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.controls > div { display: flex; gap: 7px; }
.pad { touch-action: none; user-select: none; min-width: 48px; min-height: 46px; }
.pad[data-pressed=true] { background: var(--accent); color: var(--accent-ink); }
#action { min-width: min(100%, 230px); }
#hint { margin: 8px 0 0; font-size: .8rem; color: var(--muted); line-height: 1.5; }
dialog {
  border: 1px solid var(--line); background: var(--back); color: var(--ink); border-radius: 12px;
  padding: 16px; width: min(100% - 28px, 580px); max-height: 85dvh; overflow: auto;
}
dialog::backdrop { background: #120b18ba; }
.dialog-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-top h2 { margin: 0; font-size: 1.16rem; }
.room-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.room-list button { display: grid; place-items: center; gap: 1px; text-align: center; padding-inline: 4px; }
.room-list small { font-weight: 550; }
.room-list [aria-current=true] { color: var(--accent); border-color: var(--accent); }
.credit { display: inline-block; color: var(--muted); font-size: .72rem; margin-top: 9px; }
@media (max-width: 420px) {
  .shell { width: calc(100% - 14px); }
  header > a { font-size: .72rem; }
  nav { gap: 4px; }
  nav button { padding-inline: 5px; }
  .meta span { font-size: .71rem; }
  .controls button { padding-inline: 8px; }
}
