:root {
  --bone: #f2ead8;
  --muted: #b5a997;
  --night: #080503;
  --night-soft: #120b06;
  --stone: #21150d;
  --stone-light: #3c2818;
  --sun: #ffd78a;
  --sun-bright: #fff1c4;
  --ember: #da7d3e;
  --ash: #6d4d37;
  --line: rgba(255, 232, 193, .18);
  --line-strong: rgba(255, 232, 193, .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; }
body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -15%, rgba(218, 125, 62, .17), transparent 38rem),
    linear-gradient(#0d0804, #050302 72%);
  color: var(--bone);
  font-family: var(--sans);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  content: "";
  opacity: .13;
  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='.84' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.38'/%3E%3C/svg%3E");
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.sunshard-shell {
  width: min(calc(100% - 34px), 1160px);
  margin: 0 auto;
  padding: 28px 0 46px;
}

.game-header {
  min-height: 92px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 28px;
}

.back-link,
.sound-button {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .17em;
  text-decoration: none;
  text-transform: uppercase;
}

.back-link:hover,
.back-link:focus-visible,
.sound-button:hover,
.sound-button:focus-visible { color: var(--sun-bright); }

.title-lockup { text-align: center; }
.title-lockup > span {
  color: var(--ember);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .24em;
  text-transform: uppercase;
}
.title-lockup h1 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: clamp(2.3rem, 5vw, 4.8rem);
  font-weight: 400;
  letter-spacing: -.045em;
  line-height: .9;
}

.sound-button {
  justify-self: end;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.game-stage { position: relative; }
.stone-frame {
  position: relative;
  padding: clamp(12px, 2.4vw, 28px);
  overflow: hidden;
  border: 1px solid rgba(255, 225, 176, .26);
  background:
    linear-gradient(135deg, rgba(255,255,255,.035), transparent 25%),
    repeating-linear-gradient(87deg, transparent 0 90px, rgba(255,255,255,.018) 91px 92px),
    #171008;
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.9),
    inset 0 0 55px rgba(0,0,0,.75),
    0 36px 90px rgba(0,0,0,.5);
}

.stone-frame::before,
.stone-frame::after {
  position: absolute;
  z-index: 0;
  content: "";
}
.stone-frame::before {
  inset: 10px;
  border: 1px solid rgba(255, 225, 176, .08);
}
.stone-frame::after {
  right: 4%;
  bottom: 2%;
  left: 4%;
  height: 22%;
  opacity: .28;
  filter: blur(28px);
  background: radial-gradient(ellipse, rgba(218, 125, 62, .42), transparent 68%);
}

.sun-disc {
  position: absolute;
  top: -24%;
  left: 50%;
  z-index: 0;
  width: min(56vw, 620px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 215, 138, .14);
  border-radius: 50%;
  transform: translateX(-50%);
  animation: sun-turn 65s linear infinite;
}
.sun-disc::before,
.sun-disc::after,
.sun-disc span::before,
.sun-disc span::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 126%;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 215, 138, .13), transparent);
  transform: translate(-50%, -50%);
}
.sun-disc::after { transform: translate(-50%, -50%) rotate(90deg); }
.sun-disc span::before { transform: translate(-50%, -50%) rotate(45deg); }
.sun-disc span::after { transform: translate(-50%, -50%) rotate(-45deg); }
.sun-disc span {
  position: absolute;
  inset: 22%;
  border: 1px solid rgba(255, 215, 138, .16);
  border-radius: 50%;
}

.canvas-wrap {
  position: relative;
  z-index: 2;
  overflow: hidden;
  border: 1px solid rgba(255, 222, 168, .22);
  background: #050302;
  box-shadow: inset 0 0 46px rgba(0,0,0,.9);
  touch-action: none;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 8 / 5;
  background: #050302;
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: .28;
  background:
    repeating-linear-gradient(to bottom, transparent 0 3px, rgba(255, 223, 175, .045) 4px 5px),
    radial-gradient(ellipse at center, transparent 48%, rgba(0,0,0,.72));
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  padding: 24px;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  background: rgba(6, 3, 1, .76);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.game-overlay.is-visible { opacity: 1; pointer-events: auto; }
.overlay-kicker {
  margin: 0 0 14px;
  color: var(--ember);
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .25em;
  text-transform: uppercase;
}
.game-overlay h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.6rem, 7vw, 6.5rem);
  font-weight: 400;
  letter-spacing: -.05em;
  line-height: .9;
}
.game-overlay > p:not(.overlay-kicker) {
  max-width: 560px;
  margin: 24px 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: clamp(.95rem, 1.6vw, 1.18rem);
}
.game-overlay button {
  min-width: 150px;
  margin-top: 30px;
  padding: 13px 22px;
  border: 1px solid var(--sun);
  background: var(--sun);
  color: #160b04;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
}
.game-overlay button:hover,
.game-overlay button:focus-visible { background: var(--sun-bright); }
.game-overlay small {
  margin-top: 18px;
  color: #897b6b;
  font-size: .66rem;
  letter-spacing: .08em;
}

.mobile-controls {
  margin-top: 16px;
  display: none;
  grid-template-columns: 1fr .75fr 1fr;
  gap: 10px;
}
.mobile-controls button {
  min-height: 62px;
  border: 1px solid var(--line-strong);
  background: rgba(28, 17, 9, .86);
  color: var(--sun-bright);
  font-size: 1.35rem;
  touch-action: none;
}
.mobile-controls button:active { background: rgba(90, 49, 24, .9); }

.game-notes {
  padding: 18px 4px 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 34px;
  color: #8f8274;
  font-size: .67rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.game-notes p { margin: 0; }
.game-notes strong { color: var(--sun); }
.status-line {
  min-height: 1.5em;
  margin: 16px 0 0;
  color: var(--muted);
  font-family: var(--serif);
  text-align: center;
}

@keyframes sun-turn { to { transform: translateX(-50%) rotate(360deg); } }

@media (max-width: 720px) {
  .sunshard-shell { width: min(calc(100% - 18px), 1160px); padding-top: 14px; }
  .game-header { min-height: 78px; grid-template-columns: 1fr auto; }
  .title-lockup { grid-row: 1; grid-column: 1 / -1; }
  .back-link { grid-row: 2; grid-column: 1; }
  .sound-button { grid-row: 2; grid-column: 2; }
  .stone-frame { padding: 8px; }
  .mobile-controls { display: grid; }
  .game-notes { display: none; }
  .game-overlay small { display: none; }
}

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