:root {
  color-scheme: dark;
  --ink: #070705;
  --deep: #0b0a08;
  --stone: #25251f;
  --stone-light: #a7a48e;
  --bone: #eee7d7;
  --muted: #a7aa9c;
  --moss: #8fa474;
  --light: #cbd9ad;
  --gold: #d1aa68;
  --ember: #b86f4f;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ink); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--bone);
  background:
    radial-gradient(circle at 50% 0%, rgba(143,164,116,.09), transparent 34rem),
    linear-gradient(#080806, #040403);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, a { font: inherit; }
button { color: inherit; }

.stone-shell { width: min(1180px, 100%); margin: 0 auto; padding: 22px clamp(12px, 3vw, 34px) 40px; }
.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}
.back-link, .sound-button {
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
}
.back-link:hover, .back-link:focus-visible { color: var(--bone); }
.sound-button {
  justify-self: end;
  border: 1px solid rgba(203,217,173,.22);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(15,16,12,.8);
  cursor: pointer;
}
.sound-button:hover, .sound-button:focus-visible { border-color: rgba(203,217,173,.52); color: var(--bone); }
.title-lockup { text-align: center; }
.title-lockup span { display: block; color: var(--moss); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; }
.title-lockup h1 { margin: 4px 0 0; font: 400 clamp(30px, 5vw, 52px)/1 Georgia, serif; letter-spacing: .03em; }

.game-stage { display: grid; justify-items: center; }
.sanctuary-frame {
  position: relative;
  width: min(100%, 1030px);
  padding: clamp(8px, 1.7vw, 16px);
  border: 1px solid rgba(203,217,173,.16);
  background: linear-gradient(135deg, rgba(39,40,31,.7), rgba(9,9,7,.95));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.025), 0 24px 70px rgba(0,0,0,.35);
}
.sanctuary-frame::before, .sanctuary-frame::after {
  position: absolute;
  top: 50%;
  width: 17px;
  height: 68%;
  border: 1px solid rgba(203,217,173,.15);
  content: "";
  transform: translateY(-50%);
}
.sanctuary-frame::before { left: -9px; border-right: 0; }
.sanctuary-frame::after { right: -9px; border-left: 0; }
.crown-rune {
  position: absolute;
  top: -13px;
  left: 50%;
  z-index: 3;
  width: 42px;
  height: 26px;
  border: 1px solid rgba(203,217,173,.25);
  background: #0b0a08;
  transform: translateX(-50%);
}
.crown-rune::before, .crown-rune::after, .crown-rune span::before, .crown-rune span::after {
  position: absolute;
  content: "";
  background: rgba(203,217,173,.55);
}
.crown-rune::before { top: 4px; bottom: 4px; left: 50%; width: 1px; }
.crown-rune::after { top: 50%; left: 9px; right: 9px; height: 1px; }
.crown-rune span::before { width: 14px; height: 1px; top: 12px; left: 6px; transform: rotate(45deg); }
.crown-rune span::after { width: 14px; height: 1px; top: 12px; right: 6px; transform: rotate(-45deg); }
.canvas-wrap { position: relative; overflow: hidden; background: #050504; }
canvas { display: block; width: 100%; height: auto; touch-action: none; }
.grain {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: .13;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 18% 30%, rgba(255,255,255,.12) 0 .5px, transparent 1px),
    radial-gradient(circle at 75% 72%, rgba(255,255,255,.09) 0 .5px, transparent 1px);
  background-size: auto, 17px 17px, 23px 23px;
  mix-blend-mode: soft-light;
}
.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 30px;
  text-align: center;
  background: radial-gradient(circle at 50% 46%, rgba(18,19,14,.83), rgba(4,4,3,.95) 66%);
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
}
.game-overlay.is-visible { opacity: 1; visibility: visible; }
.overlay-kicker { margin: 0 0 10px; color: var(--gold); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; }
.game-overlay h2 { max-width: 650px; margin: 0; font: 400 clamp(30px, 5vw, 58px)/1.03 Georgia, serif; }
.game-overlay > p:not(.overlay-kicker) { max-width: 570px; margin: 17px 0 23px; color: #c7c3b4; line-height: 1.65; }
.game-overlay button {
  border: 1px solid rgba(203,217,173,.42);
  border-radius: 999px;
  padding: 12px 22px;
  background: rgba(143,164,116,.14);
  cursor: pointer;
  letter-spacing: .06em;
}
.game-overlay button:hover, .game-overlay button:focus-visible { background: rgba(143,164,116,.25); border-color: var(--light); }
.game-overlay small { margin-top: 14px; color: #8f9187; }

.mobile-controls { display: none; grid-template-columns: repeat(5, minmax(48px, 68px)); gap: 8px; margin-top: 15px; }
.mobile-controls button {
  min-height: 52px;
  border: 1px solid rgba(203,217,173,.24);
  border-radius: 12px;
  background: rgba(20,21,16,.92);
  font-size: 22px;
  touch-action: manipulation;
}
.mobile-controls button:active { background: rgba(143,164,116,.25); }
.mobile-controls .drop-control { color: var(--gold); }
.game-notes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .04em;
}
.game-notes p { margin: 0; }
.game-notes strong { color: var(--bone); font-weight: 600; }
.status-line { min-height: 1.5em; margin: 12px 0 0; color: var(--moss); text-align: center; font-size: 13px; }

@media (max-width: 760px) {
  .stone-shell { padding-top: 12px; }
  .game-header { grid-template-columns: 1fr auto; }
  .title-lockup { grid-column: 1 / -1; grid-row: 1; }
  .back-link { grid-column: 1; grid-row: 2; }
  .sound-button { grid-column: 2; grid-row: 2; }
  .mobile-controls { display: grid; }
  .game-notes { display: none; }
  .game-overlay { padding: 18px; }
  .game-overlay small { font-size: 10px; }
}

@media (max-width: 420px) {
  .mobile-controls { width: 100%; grid-template-columns: repeat(5, 1fr); }
  .mobile-controls button { min-width: 0; min-height: 48px; }
  .title-lockup h1 { font-size: 34px; }
}
