:root {
  color-scheme: dark;
  --ink: #382717;
  --parchment: #d6b479;
  --board-size: min(56vw, 650px, 75svh);
  font-family: Georgia, 'Times New Roman', serif;
  font-synthesis: none;
  background: #17100b;
  color: var(--ink);
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100svh; isolation: isolate; background: #17100b; }
/* Keep the tabletop photograph sharp; only the distant room receives blur. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, #05060527 0%, transparent 40%, #0a050432 100%),
    url('assets/dungeon-table.png') center bottom / cover no-repeat,
    repeating-linear-gradient(1deg, #3e281a 0 3px, #42291b 4px 7px, #352217 8px 10px);
  transform: scale(1.13);
  transform-origin: bottom center;
}
body::after {
  content: '';
  position: fixed;
  inset: 0 0 auto;
  height: 23svh;
  z-index: -1;
  background: linear-gradient(#04060526, transparent);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  mask-image: linear-gradient(#000 0 72%, transparent);
  pointer-events: none;
}
button { font: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid #a7b8a0; outline-offset: 4px; }
[hidden] { display: none !important; }
.lair-stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: var(--board-size) 320px;
  justify-content: center;
  align-items: center;
  align-content: center;
  column-gap: clamp(24px, 3.2vw, 60px);
  padding: 17svh 24px 2svh;
}
.object-section { min-width: 0; width: 100%; }
.board-shell {
  position: relative;
  filter: drop-shadow(5px 22px 14px #030302a6) drop-shadow(0 3px 2px #080604b3);
  margin: 4px -8px 0;
}
/* These dimensions match the photographed frame and the tile crop coordinates. */
.puzzle-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: url('assets/spooker-puzzle.png') center / 100% 100% no-repeat, #5e5a4d;
  clip-path: inset(4.4% 4.8% 5% 5% round 3%);
}
.tray {
  position: absolute;
  left: 10.35%;
  top: 9.9%;
  width: 79.1%;
  height: 79.1%;
  border-radius: 2.6%;
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, #00000009 0px, #ffffff09 .6px, #00000006 1px, #ffffff0a 1.5px),
    linear-gradient(110deg, #3e3e3a, #77756e 25%, #4b4b45 50%, #6e6c64 78%, #44453f);
  box-shadow: inset 0 3px 7px 3px #090b0ac9, inset 0 0 0 2px #242823;
}
.rail {
  position: absolute;
  background: linear-gradient(#101310, #22231e 70%, #10120f);
  box-shadow: 0 1px 1px #eee9cf83, inset 0 2px 3px #000;
  border-radius: 30px;
}
.rail.horizontal { left: 0; width: 100%; height: 2.2%; }
.rail.vertical { top: 0; height: 100%; width: 2.2%; }
.r1 { top: 15.6%; }
.r2 { top: 48.9%; }
.r3 { top: 82.2%; }
.c1 { left: 15.6%; }
.c2 { left: 48.9%; }
.c3 { left: 82.2%; }
.playfield {
  position: absolute;
  left: 10.76%;
  top: 10.18%;
  width: 78.5%;
  height: 78.5%;
  isolation: isolate;
}
.tile {
  position: absolute;
  width: 32.85%;
  height: 32.85%;
  border: 0;
  padding: 0;
  border-radius: 10%;
  background: transparent;
  transition: left 225ms cubic-bezier(.22,.72,.3,1), top 225ms cubic-bezier(.22,.72,.3,1), transform 180ms ease;
  box-shadow: 0 2px 2px #111a, 0 4px 5px #0004;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  will-change: left, top;
  isolation: isolate;
  container-type: inline-size;
}
.tile-face {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background-color: #ccc3aa;
  background-image: url('assets/spooker-puzzle.png');
  background-size: 388.235294% 388.235294%;
  background-position: var(--bx) var(--by);
  pointer-events: none;
}
.tile-number {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: #282922;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(34px, 63cqw, 95px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.06em;
  text-indent: -.06em;
  text-shadow: 0 1px 0 #eeead799, 0 -1px 1px #12150e9c, 1px 0 1px #12150e68;
  -webkit-text-stroke: .5px #292b24;
  pointer-events: none;
}
.tile[aria-disabled=false] { cursor: grab; }
.tile[aria-disabled=true] { cursor: default; }
.tile.dragging { cursor: grabbing; z-index: 3; box-shadow: 0 4px 6px #0007; }
.tile:focus-visible { outline: 2px solid #b6c8a4; outline-offset: -7px; }
/* Light escapes around the underside. The opaque stone face keeps its own color. */
.tile.correct::before,
.tile.correct::after {
  content: '';
  position: absolute;
  pointer-events: none;
  animation: correct-glow 1.12s ease-in-out infinite;
}
.tile.correct::before {
  inset: 2px;
  z-index: -1;
  border-radius: inherit;
  box-shadow: 0 4px 5px 3px #59ff859c, 0 5px 13px 3px #21d85a70, 0 1px 2px 3px #a6ffbd75;
}
.tile.correct::after {
  z-index: 0;
  left: 9%;
  right: 9%;
  bottom: -1px;
  height: 3px;
  border-radius: 50%;
  background: #82ff9e;
  filter: blur(1px);
  box-shadow: 0 3px 9px #23e65e96;
}
.tile.correct:nth-child(2n)::before,
.tile.correct:nth-child(2n)::after { animation-duration: .94s; animation-delay: -.4s; }
.tile.correct:nth-child(3n)::before,
.tile.correct:nth-child(3n)::after { animation-duration: 1.2s; animation-delay: -.7s; }
@keyframes correct-glow {
  0%, 100% { opacity: .48; }
  43% { opacity: .9; }
  68% { opacity: .61; }
}
.rules-note {
  position: relative;
  width: 320px;
  padding: 26px 29px 23px;
  border-radius: 3px 6px 4px 8px / 9px 3px 7px 3px;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 2% 6%, #7143224d 0, transparent 26%),
    radial-gradient(ellipse at 95% 97%, #8b522950 0, transparent 31%),
    radial-gradient(ellipse at 88% 6%, #fff2c750 0, transparent 38%),
    repeating-linear-gradient(97deg, #82603508 0 1px, transparent 1px 4px),
    repeating-linear-gradient(2deg, #ffedb90a 0 1px, #68411e06 1px 3px),
    linear-gradient(117deg, #c6a36c, #e3c994 27%, #d9bb82 66%, #c9a16a);
  border: 1px solid #9b76463d;
  box-shadow: inset 0 0 20px #7e4e2352, inset 0 0 2px 1px #8357246b, 3px 5px 3px #08040266, 10px 20px 22px #03020175;
  transform: rotate(-2deg);
  transform-origin: center;
}
.rules-note::before,
.rules-note::after {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px solid #6f492026;
  border-radius: 2px;
  pointer-events: none;
}
.rules-note::after { inset: 10px; border-color: #6f492015; }
.note-web {
  position: absolute;
  top: 0;
  right: 0;
  width: 69px;
  height: 69px;
  opacity: .19;
  stroke: #4f341b;
  stroke-width: .85;
  pointer-events: none;
}
.note-kicker {
  position: relative;
  margin: 0 0 12px;
  color: #74532c;
  text-align: center;
  font-size: 7px;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 1.6px;
}
h1 {
  position: relative;
  margin: 0;
  color: #342616;
  font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  font-size: 31px;
  font-weight: 700;
  line-height: 1.04;
  text-align: center;
  letter-spacing: -.9px;
  text-shadow: 0 1px #f7dfae8c;
  text-wrap: balance;
}
.note-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 15px 10px 14px;
  color: #795830;
  font-size: 11px;
  opacity: .7;
}
.note-divider::before,
.note-divider::after { content: ''; width: 46px; height: 1px; background: linear-gradient(90deg, transparent, #7a572f); }
.note-divider::after { transform: rotate(180deg); }
.greeting { margin: 0 0 15px; font-size: 15px; font-style: italic; line-height: 1.4; }
.rules-list { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.45; }
.rules-list li { padding-left: 3px; margin: 0 0 12px; }
.rules-list li::marker { color: #73502b; font-size: 12px; }
.rules-list li:last-child { margin-bottom: 0; }
.note-signoff { display: flex; align-items: center; justify-content: space-between; margin-top: 17px; min-height: 49px; }
.signature { margin: 0; font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif; font-size: 21px; font-style: italic; letter-spacing: -.7px; transform: rotate(-3deg); }
.wax-seal {
  display: grid;
  place-items: center;
  width: 45px;
  height: 46px;
  margin-right: 5px;
  border-radius: 47% 52% 49% 46% / 45% 49% 47% 53%;
  border: 3px solid #171612;
  background: radial-gradient(circle at 38% 27%, #3c392e, #1f1e18 56%, #11120e 82%);
  box-shadow: inset 0 1px 1px #6b685b78, inset 0 0 0 2px #0b0c09, inset 0 0 0 3px #48463959, 1px 3px 2px #3d281c5c;
  transform: rotate(12deg);
}
.wax-seal svg { width: 29px; height: 29px; stroke: #77715b; stroke-width: 1.1; opacity: .74; filter: drop-shadow(0 1px #030402); }
.challenge-status { margin: 14px 0 0; padding-top: 11px; border-top: 1px solid #6d56283d; color: #304d23; font-size: 14px; font-style: italic; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (min-width: 951px) and (max-height: 720px) {
  .lair-stage { padding-top: 15svh; padding-bottom: 2svh; }
  .rules-note { padding: 20px 27px 18px; }
  .note-kicker { margin-bottom: 8px; font-size: 6px; }
  h1 { font-size: 27px; }
  .note-divider { margin-top: 10px; margin-bottom: 9px; }
  .greeting { font-size: 14px; margin-bottom: 11px; }
  .rules-list { font-size: 12.5px; line-height: 1.4; }
  .rules-list li { margin-bottom: 9px; }
  .note-signoff { margin-top: 11px; min-height: 41px; }
  .signature { font-size: 20px; }
  .wax-seal { width: 40px; height: 41px; }
}
@media (max-width: 950px) {
  :root { --board-size: min(90vw, 600px); }
  body::before { background-position: center bottom; transform: scale(1.08); }
  .lair-stage { grid-template-columns: minmax(0, var(--board-size)); row-gap: 21px; padding: 10svh 20px 55px; align-content: start; }
  .rules-note { justify-self: center; width: min(360px, 100% - 18px); padding: 28px 31px 25px; }
  h1 { max-width: 290px; margin-inline: auto; }
  .rules-list { font-size: 14px; line-height: 1.45; }
  .tile-number { font-size: clamp(34px, 63cqw, 95px); }
}
@media (max-width: 420px) {
  :root { --board-size: calc(100vw - 18px); }
  .lair-stage { padding: 8svh 9px 38px; row-gap: 15px; }
  .board-shell { margin-inline: -3px; }
  .rules-note { width: calc(100% - 27px); padding: 26px 26px 23px; }
  h1 { font-size: 29px; }
  .note-kicker { letter-spacing: 1.3px; }
  .rules-list { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .tile.correct::before, .tile.correct::after { opacity: .78; }
}

@media(min-width:760px) and (max-width:950px){:root{--board-size:min(50vw,68svh)}.lair-stage{grid-template-columns:var(--board-size) 290px;column-gap:18px;padding:16svh 15px 3svh;align-content:center}.rules-note{width:290px;padding:21px 24px;justify-self:center}.rules-list{font-size:12px;line-height:1.35}.rules-list li{margin-bottom:9px}h1{font-size:27px}.greeting{font-size:13px}.note-signoff{margin-top:12px}body::before{transform:scale(1.13);background-position:center bottom;transform-origin:bottom center}}
