:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #131e2f;
  color: #eaf2fb;
  --muted: #bbccdf;
  --line: #6f899e66;
  --panel: #18283b;
  --mint: #a3ebcf;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(ellipse 65rem 46rem at 50% -14rem, #335274, transparent), #131e2f;
  line-height: 1.5;
}
.shell { width: min(66rem, calc(100% - 2rem)); margin-inline: auto; }
.topbar {
  display: flex; justify-content: space-between; flex-wrap: wrap;
  gap: .3rem .8rem; align-items: center; min-height: 64px;
}
a { color: #ade9d8; text-underline-offset: .25em; }
.topbar a { display: inline-flex; align-items: center; min-height: 44px; font-size: .88rem; font-weight: 650; }
:focus-visible { outline: 3px solid #ffdf8a; outline-offset: 4px; }
button, select { font: inherit; }
button {
  min-height: 44px; padding: .54rem .85rem; border: 1px solid #58758c;
  border-radius: .58rem; background: #243b51; color: #fff; font-weight: 650; cursor: pointer;
  touch-action: manipulation;
}
button:disabled { cursor: default; }
button:not(:disabled):hover { background: #355672; }
button.primary { background: #a1eacb; color: #142c2b; border-color: #b9f6dc; }
button.primary:hover { background: #c3fae3; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: Georgia, serif; line-height: 1.06; font-weight: 500; }
.intro {
  min-height: clamp(20rem, 42vw, 29rem); position: relative; display: grid;
  align-items: end; isolation: isolate; overflow: hidden; border: 1px solid var(--line);
  border-radius: 1rem; background: #203749; box-shadow: 0 18px 55px #05091675;
}
.intro img, .scene img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.intro img { object-position: 50% 52%; z-index: -2; }
.intro::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(0deg, #0a1525 2%, #0a1525bf 37%, transparent 85%),
    linear-gradient(90deg, #0a1525aa, transparent 84%);
}
.intro-copy { padding: clamp(1.2rem, 4vw, 3rem); }
.eyebrow { color: var(--chapter, var(--mint)); font-size: .82rem; font-weight: 700; letter-spacing: .055em; }
.intro h1 { font-size: clamp(3rem, 10vw, 6.5rem); margin-block: .22rem .45rem; }
.intro-copy p:not(.eyebrow) { max-width: 33rem; margin-bottom: 1rem; color: #edfbff; }
.board { border: 1px solid var(--line); border-radius: 1rem; padding: clamp(.75rem, 2.7vw, 1.65rem); background: #172a3d; }
.board-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .65rem; margin-bottom: .8rem; }
.board-heading h2 { font-size: clamp(1.9rem, 5vw, 3.2rem); padding-top: .22rem; }
.score { display: flex; align-items: center; gap: .7rem; }
.score span { color: #ffdf8a; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.score button { min-width: 5.1rem; }
.scene {
  overflow: hidden; isolation: isolate; background: #21384d; position: relative; min-height: clamp(6.9rem, 22vw, 13.5rem);
  display: grid; align-content: end; justify-items: center; border: 1px solid var(--line); border-radius: .7rem;
}
.scene img { object-position: 50% 52%; opacity: .84; z-index: -2; }
.scene::after {
  content: ""; z-index: -1; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(0deg, #0c1829 2%, #121b327d 65%, #15223824);
  border-top: 3px solid var(--chapter);
}
.board[data-chapter="1"] .scene img { object-position: center 72%; filter: hue-rotate(-14deg); }
.board[data-chapter="2"] .scene img { object-position: center 30%; filter: saturate(.62) brightness(1.1); }
.board[data-chapter="3"] .scene img { filter: hue-rotate(27deg) saturate(1.35); }
.bridge-lights { display: flex; padding-inline: .65rem; justify-content: center; gap: clamp(.28rem, 1.1vw, .85rem); }
.bridge-lights span {
  display: block; width: clamp(1rem, 5.3vw, 3rem); height: .42rem; border-radius: 1rem;
  border: 1px solid #d1dce88c; background: #0b1829ce;
}
.bridge-lights span.lit { background: var(--chapter); box-shadow: 0 0 14px var(--chapter); }
.signal { text-align: center; font-size: clamp(.98rem, 3vw, 1.25rem); font-weight: 700; min-height: 2.8rem; padding: .46rem .55rem; }
.rules { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; padding-block: .75rem; }
.rules p { flex: 1 1 18rem; color: #e9f1fa; }
.rules label { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; font-size: .86rem; }
select { max-width: 100%; min-height: 44px; padding-inline: .45rem; border: 1px solid #81a1b5; border-radius: .5rem; background: #1a2b40; color: #eef7ff; }
.pads { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(.34rem, 1vw, .7rem); }
.pad {
  min-height: 80px; padding: .3rem .4rem .42rem; color: var(--stone); border-color: var(--stone);
  border-bottom: 4px solid var(--stone); background: linear-gradient(155deg, #293d52, #132235 88%);
  position: relative; display: grid; place-items: center;
}
.pad .rune { font-size: clamp(1.45rem, 4vw, 2.4rem); line-height: 1.2; }
.pad kbd { position: absolute; left: .42rem; top: .36rem; font-size: .78rem; color: #ecf3fb; }
.pad .stone-name { font-size: clamp(.69rem, 2.2vw, .87rem); white-space: nowrap; }
.pad:disabled:not([data-flash]) { border-color: #7d90a4; }
.pad[data-flash="clue"], .pad[data-flash="right"] {
  background: var(--stone); border-color: #fff; color: #102232; box-shadow: 0 0 22px var(--stone);
}
.pad[data-flash="clue"] kbd, .pad[data-flash="right"] kbd { color: #102232; }
.pad[data-flash="wrong"] { background: #662c3e; color: #fff; border-color: #ffb1a8; }
.round-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .75rem; min-height: 44px; }
#feedback { color: var(--muted); min-height: 1.5em; margin-top: .5rem; }
.lower { display: grid; grid-template-columns: 1.2fr 1fr; gap: .8rem; margin-top: .8rem; }
.card { padding: clamp(.9rem, 2.5vw, 1.4rem); border: 1px solid var(--line); border-radius: .8rem; background: var(--panel); }
.card h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); margin-bottom: .65rem; }
.card ol { padding-left: 1.25rem; margin: 0 0 .65rem; }
.card li + li { margin-top: .38rem; }
.small, footer { color: var(--muted); font-size: .87rem; }
.map { display: grid; gap: .55rem; margin-bottom: .55rem; }
.map-group h3 { font-size: .84rem; color: var(--chapter); margin-bottom: .24rem; }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .35rem; }
.tiles button { padding: .24rem; font-variant-numeric: tabular-nums; }
.tiles button:disabled { color: #adbecf; border-color: #576879; background: #202f42; }
.tiles button.cleared { background: #294b4b; color: #ccece0; }
.tiles button[aria-current="step"] { border-color: var(--chapter); box-shadow: inset 0 -3px var(--chapter); }
footer { min-height: 64px; padding-block: 1rem; }
@media (max-width: 44rem) {
  .shell { width: calc(100% - 1.2rem); }
  .lower { grid-template-columns: 1fr; }
  .pads { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pad { min-height: 63px; }
  .board-heading { gap: .35rem .65rem; }
}
@media (max-width: 23rem) {
  .topbar a { font-size: .8rem; }
  .topbar { min-height: 50px; }
  .intro h1 { font-size: 2.75rem; }
}
