:root {
  --sky: #1b2229;
  --olive: #5c5a2e;
  --brass: #f4b63f;
  --saddle: #8b4f24;
  --jungle: #1f3a26;
  --bone: #ede3c8;
  --glow: 0 0 18px rgba(244, 182, 63, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--sky);
  color: var(--bone);
  font-family: "Chakra Petch", "Trebuchet MS", system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(ellipse at 50% 120%, rgba(31, 58, 38, 0.9), transparent 60%),
    var(--sky);
}

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  box-shadow: 0 0 0 1px rgba(244, 182, 63, 0.25), 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  background: #26303a;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4%;
  padding: 3%;
  background: rgba(15, 20, 24, 0.72);
  backdrop-filter: blur(2px);
}
.hidden { display: none !important; }

.hero {
  height: 88%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--brass), 0 0 60px rgba(244, 182, 63, 0.45);
}

.panel { max-width: 44ch; }
.panel.center { text-align: center; }

h1 {
  font-family: "Saira Stencil One", "Impact", sans-serif;
  font-weight: 400;
  font-size: clamp(2.2rem, 7.5vw, 5.4rem);
  line-height: 0.88;
  margin: 0 0 0.3em;
  color: var(--brass);
  text-shadow: var(--glow), 0 3px 0 #6b3a18;
  letter-spacing: 0.01em;
}
h2 {
  font-family: "Saira Stencil One", "Impact", sans-serif;
  font-weight: 400;
  font-size: clamp(2rem, 6vw, 4rem);
  margin: 0 0 0.25em;
  color: var(--brass);
  text-shadow: var(--glow);
}

.tag { margin: 0 0 1.2em; font-size: clamp(0.85rem, 1.7vw, 1.15rem); opacity: 0.9; }
.note { font-size: clamp(0.7rem, 1.3vw, 0.9rem); opacity: 0.75; margin: 0.8em 0 0.3em; }
.best { font-size: clamp(0.7rem, 1.3vw, 0.9rem); color: var(--brass); margin: 0; }
#overText { font-size: clamp(0.85rem, 1.7vw, 1.1rem); line-height: 1.5; margin: 0 0 1.2em; }

.btn {
  font: 700 clamp(0.9rem, 1.8vw, 1.2rem) "Chakra Petch", sans-serif;
  color: #1b1405;
  background: var(--brass);
  border: 0;
  padding: 0.6em 1.4em;
  border-radius: 999px 999px 999px 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 #9a6a14, var(--glow);
  transition: transform 0.08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #9a6a14, var(--glow); }
.btn:focus-visible, .mini:focus-visible { outline: 3px solid var(--bone); outline-offset: 3px; }
.btn.ghost { background: transparent; color: var(--bone); box-shadow: inset 0 0 0 2px rgba(237, 227, 200, 0.5); margin-left: 0.5em; }

.controls {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25em 1em;
  margin: 1.3em 0 0;
  font-size: clamp(0.7rem, 1.35vw, 0.95rem);
}
.controls dt { color: var(--brass); font-weight: 600; }
.controls dd { margin: 0; opacity: 0.85; }

.corner { position: absolute; top: 1.2%; right: 1%; display: flex; gap: 6px; }
.mini {
  font: 600 clamp(0.6rem, 1.1vw, 0.8rem) "Chakra Petch", sans-serif;
  color: var(--bone);
  background: rgba(15, 20, 24, 0.55);
  border: 1px solid rgba(244, 182, 63, 0.4);
  border-radius: 6px;
  padding: 0.3em 0.7em;
  cursor: pointer;
  margin-top: 2.6em;
}

/* Touch controls */
#touch { display: none; position: absolute; inset: 0; pointer-events: none; }
body.touch.playing #touch { display: block; }
#stick {
  position: absolute; left: 3%; bottom: 6%;
  width: 18%; aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(237, 227, 200, 0.08);
  border: 2px solid rgba(244, 182, 63, 0.35);
  pointer-events: auto;
}
#knob {
  position: absolute; left: 50%; top: 50%;
  width: 40%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(244, 182, 63, 0.55);
}
.tbtns { position: absolute; right: 3%; bottom: 6%; display: flex; gap: 3vw; align-items: flex-end; pointer-events: auto; }
.tbtn {
  width: 10vw; max-width: 96px; aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid rgba(244, 182, 63, 0.6);
  background: rgba(15, 20, 24, 0.45);
  color: var(--bone);
  font: 700 clamp(0.7rem, 2vw, 1rem) "Chakra Petch", sans-serif;
}
.tbtn.fire { width: 12.5vw; max-width: 116px; background: rgba(244, 182, 63, 0.25); margin-bottom: 3vw; }
.tbtn.on { background: rgba(244, 182, 63, 0.75); color: #1b1405; }

#rotate { display: none; }

@media (max-aspect-ratio: 1/1) {
  .screen { flex-direction: column; gap: 2%; }
  .hero { height: 38%; }
  .controls { display: none; }
  body.touch #rotate {
    display: block; position: fixed; bottom: 12px; left: 0; right: 0;
    text-align: center; color: var(--brass); font-size: 0.9rem; margin: 0;
  }
}

@media (max-height: 420px) {
  .controls, .note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
