:root {
  color-scheme: dark;
  font-family: system-ui,sans-serif;
  background: #132037;
  color: #f7f3ee;
  --gold: #ffd18d;
  --muted: #c5d2e4;
  --border: #5d6c83;
  --panel: #1c2a42;
}
*,*::before,*::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 18% 0,#294664,transparent 60%),#132037; }
.shell { max-width: 1050px; margin: auto; padding: clamp(12px,3vw,32px); }
.mast,.stageHead { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.mast { margin-bottom: 14px; }
.eyebrow { margin: 0 0 .32rem; color: var(--gold); text-transform: uppercase; font-size: .75rem; letter-spacing: .14em; font-weight: 800; }
h1,h2,h3,p,dl,dd { margin: 0; }
h1,h2,h3 { font-family: Georgia,serif; line-height: 1.1; }
h1 { font-size: clamp(1.7rem,7.1vw,4rem); }
h2 { font-size: clamp(1.48rem,4vw,2.3rem); }
button,summary { font: inherit; touch-action: manipulation; cursor: pointer; }
button { min-height: 46px; padding: .5rem .7rem; border: 1px solid #78879e; border-radius: 9px; background: #2d405e; color: #f8f6f0; font-weight: 700; }
button:hover:enabled { background: #465d7c; }
button:disabled { opacity: .57; cursor: default; }
button:focus-visible,summary:focus-visible { outline: 3px solid #ffdfac; outline-offset: 2px; }
.primary { background: var(--gold); color: #27243a; border-color: #ffe6bf; }
.primary:hover:enabled { background: #ffeabf; }
#sound { white-space: nowrap; }
.intro,.scene,.panel,details { background: var(--panel); border: 1px solid var(--border); border-radius: 17px; }
.intro { display: grid; grid-template-columns: 1.3fr 1fr; overflow: hidden; }
.intro img { width: 100%; height: 100%; object-fit: cover; }
.intro div { display: grid; gap: .7rem; justify-items: start; align-content: center; padding: clamp(14px,4vw,36px); }
.intro div > p:not(.eyebrow),.panel > p:not(.topline),details,footer { color: var(--muted); }
.intro p,.panel,details { line-height: 1.5; }
.play { display: grid; grid-template-columns: minmax(0,1.33fr) minmax(0,1fr); gap: .7rem; align-items: start; }
.scene { padding: clamp(9px,2.6vw,19px); background: radial-gradient(ellipse at 20% 15%,#385774,transparent 70%),#182b46; }
.scene[data-region="1"] { background: radial-gradient(ellipse at 80% 0,#735c56,transparent 66%),#26344e; }
.scene[data-region="2"] { background: radial-gradient(ellipse at 0 55%,#305c70,transparent 76%),#172d45; }
.scene[data-region="3"] { background: radial-gradient(ellipse at 62% 15%,#59547b,transparent 63%),#242f53; }
.stageHead { margin-bottom: .5rem; }
.stageHead p { margin: 0; }
.stageHead span { color: var(--muted); font-size: .83rem; white-space: nowrap; }
.board {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0,1fr)); gap: clamp(3px,1vw,7px);
  max-width: 510px; min-height: 118px; align-content: center; margin: auto; padding: 8px;
  border: 1px solid #7691af; border-radius: 12px;
  background: radial-gradient(circle at 78% 12%,#88a3b83c,transparent 30%),radial-gradient(circle at 15% 90%,#9fa5c13a,transparent 33%),#101f38;
}
.stone {
  display: grid; position: relative; place-items: center; aspect-ratio: 1;
  min-width: 0; min-height: 0; border: 1px solid #70818d; border-radius: 6px;
  background: linear-gradient(145deg,#445d64,#273e49);
  box-shadow: inset 0 0 0 2px #131b2a50, inset 0 -5px #1b2c3e;
  color: var(--face,#d2e5ff); font-size: clamp(1rem,3.9vw,2.05rem);
  user-select: none; touch-action: manipulation;
}
.stone.void { background: transparent; border: 0; box-shadow: none; }
.stone[data-adjacent] { cursor: pointer; }
.stone[data-adjacent]:hover { border-color: #f7ce90; }
.stone.lantern::before { content: ''; position: absolute; inset: 17%; border: 1px solid currentColor; border-radius: 50%; }
.stone[data-lit] { background: radial-gradient(circle,color-mix(in srgb,var(--face),#1e4050 65%),#254652); box-shadow: inset 0 0 9px var(--face), 0 0 8px #ffdea54f; }
.stone.gate { border: 2px dashed currentColor; }
.stone.goal { border: 2px solid #ffcf8b; }
.stone.goal::before { content: ''; position: absolute; width: 66%; height: 73%; border: 2px solid #f7c885; border-bottom: 0; border-radius: 50% 50% 0 0; }
.stone .mark { transform: translateY(-.07em); font-weight: 750; }
.cube {
  position: absolute; inset: 12% 14% 19%; display: grid; place-items: center;
  border: 2px solid #ffe2a8; border-radius: 7px; color: #142239; z-index: 1;
  background: linear-gradient(135deg,#fff6df,var(--top) 78%);
  box-shadow: 2px 6px 0 #70503b, -2px 3px 0 #dba475, 0 0 13px var(--top);
  font-weight: 900; line-height: 1;
}
.cube.roll { animation: roll .18s ease-out both; }
@keyframes roll { from { transform: scale(.82) rotate(-12deg); } to { transform: none; } }
.numbers { display: grid; grid-template-columns: repeat(3,1fr); gap: .3rem; text-align: center; margin-top: .6rem; }
.numbers dt { font-size: .75rem; color: var(--muted); }
.numbers dd { color: var(--gold); font-weight: 800; font-variant-numeric: tabular-nums; }
.panel { padding: clamp(12px,2.2vw,19px); display: grid; gap: .55rem; }
.topline { font-weight: 750; min-height: 1.5em; }
.directionPad { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .33rem; }
.directionPad button { min-height: 58px; padding: .22rem; display: grid; justify-items: center; align-content: center; }
.directionPad b { font-size: 1.21rem; line-height: 1.05; }
.directionPad span { font-size: .7rem; }
.directionPad [data-hint] { outline: 2px solid #ffd28b; }
.toolbar { display: flex; flex-wrap: wrap; gap: .35rem; }
.toolbar button { padding-inline: .48rem; }
.panel #status { min-height: 1.5em; color: var(--gold); }
.result { padding: .7rem; border: 1px solid #998c76; background: #2e3f4a; border-radius: 10px; }
.result h3 { font-size: 1.36rem; margin: .22rem 0 .55rem; }
.result p { color: var(--gold); letter-spacing: .12em; }
details { margin-top: .65rem; padding: 0 .75rem; }
details[open] { padding-bottom: .7rem; }
summary { min-height: 46px; line-height: 46px; font-weight: 730; color: #f3f5fa; }
summary span { color: var(--muted); font-weight: 470; margin-left: .4rem; }
details p + p { margin-top: .5rem; }
.levels { display: grid; grid-template-columns: repeat(auto-fill,minmax(86px,1fr)); gap: .35rem; }
.levels button { font-size: .84rem; padding: .35rem; }
.levels [aria-current="true"] { border-color: var(--gold); }
footer { margin-top: .8rem; font-size: .85rem; }
@media(max-width:675px) {
  .intro,.play { grid-template-columns: 1fr; }
  .intro img { height: min(46vw,265px); }
  .mast { margin-bottom: .65rem; }
  .board { max-width: 448px; }
  .toolbar button { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { .cube.roll { animation: none; } }
