:root {
  --bone: #eee7d7;
  --muted: #a7aa9c;
  --night: #050806;
  --deep: #071008;
  --grove: #101c12;
  --moss: #90a978;
  --moss-light: #d0e6a9;
  --gold: #d9ad67;
  --ember: #bb7650;
  --line: rgba(238, 231, 215, .14);
  --line-strong: rgba(208, 230, 169, .34);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--night); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 8%, rgba(144,169,120,.13), transparent 28rem),
    linear-gradient(#071008, #050806 64%);
  color: var(--bone);
  font-family: var(--sans);
}
body::before {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  content: "";
  opacity: .11;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.wyrm-shell {
  width: min(calc(100% - 32px), 1180px);
  margin: 0 auto;
  padding: 30px 0 56px;
}
.game-header {
  min-height: 86px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  margin-bottom: 22px;
}
.back-link,
.sound-button {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.back-link { justify-self: start; text-underline-offset: 7px; }
.sound-button {
  justify-self: end;
  padding: 11px 14px;
  border: 1px solid var(--line);
  background: rgba(5,8,6,.48);
  cursor: pointer;
}
.sound-button:hover,
.sound-button:focus-visible,
.back-link:hover,
.back-link:focus-visible { color: var(--bone); }
.game-title { text-align: center; }
.game-title span {
  color: var(--moss-light);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .24em;
  text-transform: uppercase;
}
.game-title h1 {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4.5vw, 4.5rem);
  font-weight: 400;
  line-height: .94;
  letter-spacing: -.05em;
}

.game-stage { position: relative; }
.grove-frame {
  position: relative;
  isolation: isolate;
  padding: clamp(12px, 2vw, 22px);
  border: 1px solid rgba(208,230,169,.22);
  background:
    linear-gradient(135deg, rgba(208,230,169,.08), transparent 28%),
    #0a100b;
  box-shadow: 0 36px 90px rgba(0,0,0,.44);
}
.grove-frame::before,
.grove-frame::after {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  content: "";
}
.grove-frame::before {
  inset: 7px;
  border: 1px solid rgba(208,230,169,.11);
}
.grove-frame::after {
  inset: -1px;
  background:
    linear-gradient(90deg, transparent 0 4%, rgba(208,230,169,.2) 4.2% 4.35%, transparent 4.5% 95.5%, rgba(208,230,169,.2) 95.65% 95.8%, transparent 96%),
    linear-gradient(transparent 0 7%, rgba(208,230,169,.12) 7.2% 7.35%, transparent 7.5% 92.5%, rgba(208,230,169,.12) 92.65% 92.8%, transparent 93%);
}
.root-crown {
  position: absolute;
  top: -38px;
  left: 50%;
  z-index: 5;
  width: 122px;
  aspect-ratio: 1;
  border: 1px solid rgba(208,230,169,.38);
  border-radius: 50%;
  background: #071008;
  transform: translateX(-50%);
}
.root-crown::before,
.root-crown::after,
.root-crown span::before,
.root-crown span::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72%;
  height: 1px;
  background: rgba(208,230,169,.34);
  content: "";
  transform: translate(-50%,-50%);
}
.root-crown::after { transform: translate(-50%,-50%) rotate(90deg); }
.root-crown span::before { transform: translate(-50%,-50%) rotate(45deg); }
.root-crown span::after { transform: translate(-50%,-50%) rotate(-45deg); }
.root-crown span {
  position: absolute;
  inset: 35%;
  border: 1px solid var(--moss-light);
  transform: rotate(45deg);
}
.canvas-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 2;
  background: #030604;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  touch-action: none;
}
.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  mix-blend-mode: soft-light;
  background:
    repeating-linear-gradient(to bottom, transparent 0 3px, rgba(208,230,169,.035) 4px 5px),
    radial-gradient(ellipse at center, transparent 42%, rgba(0,0,0,.72));
}
.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  padding: 28px;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  background: rgba(3,6,4,.78);
  backdrop-filter: blur(7px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.game-overlay.is-visible { opacity: 1; pointer-events: auto; }
.overlay-kicker {
  margin: 0 0 18px;
  color: var(--moss-light);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .28em;
  text-transform: uppercase;
}
.game-overlay h2 {
  max-width: 760px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3rem, 8vw, 7.6rem);
  font-weight: 400;
  line-height: .82;
  letter-spacing: -.06em;
}
.game-overlay p:not(.overlay-kicker) {
  max-width: 560px;
  margin: 28px 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: clamp(.95rem, 1.8vw, 1.2rem);
}
.game-overlay button {
  margin-top: 32px;
  padding: 14px 28px;
  border: 1px solid var(--moss-light);
  background: rgba(144,169,120,.1);
  color: var(--bone);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .22em;
  text-transform: uppercase;
  cursor: pointer;
}
.game-overlay button:hover,
.game-overlay button:focus-visible { background: var(--moss-light); color: #071008; }
.game-overlay small {
  margin-top: 20px;
  color: rgba(238,231,215,.52);
  font-size: .65rem;
  letter-spacing: .08em;
}

.touch-wheel {
  width: 190px;
  margin: 24px auto 0;
  display: none;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  justify-content: center;
  gap: 6px;
}
.touch-wheel button {
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(13,24,15,.78);
  color: var(--moss-light);
  font-size: 1.25rem;
  touch-action: manipulation;
}
.touch-wheel button:active { background: var(--moss-light); color: var(--night); }
.touch-wheel [data-dir="up"] { grid-column: 2; grid-row: 1; }
.touch-wheel [data-dir="left"] { grid-column: 1; grid-row: 2; }
.touch-wheel .wheel-core { grid-column: 2; grid-row: 2; color: var(--gold); }
.touch-wheel [data-dir="right"] { grid-column: 3; grid-row: 2; }
.touch-wheel [data-dir="down"] { grid-column: 2; grid-row: 3; }

.game-notes {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 34px;
  padding: 24px 12px 0;
  color: var(--muted);
  font-size: .69rem;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.game-notes p { margin: 0; }
.game-notes strong { color: var(--bone); }
.status-line {
  min-height: 1.4em;
  margin: 18px 0 0;
  color: rgba(208,230,169,.65);
  text-align: center;
  font-family: var(--serif);
  font-size: .88rem;
}

@media (max-width: 760px) {
  .wyrm-shell { width: min(calc(100% - 18px), 1180px); padding-top: 14px; }
  .game-header { grid-template-columns: 1fr auto; min-height: 76px; }
  .game-title { grid-column: 1 / -1; grid-row: 1; }
  .back-link { grid-column: 1; grid-row: 2; }
  .sound-button { grid-column: 2; grid-row: 2; }
  .grove-frame { padding: 8px; }
  .root-crown { width: 82px; top: -26px; }
  .canvas-wrap { aspect-ratio: 3 / 2; }
  .touch-wheel { display: grid; }
  .game-overlay { padding: 18px; }
  .game-overlay h2 { font-size: clamp(2.8rem, 15vw, 5.5rem); }
  .game-overlay small { max-width: 270px; line-height: 1.5; }
  .game-notes { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
