:root {
  color-scheme: dark;
  --ink: #0a0612;
  --paper: #fff6ff;
  --muted: #a78fce;
  --panel: #241a36;
  --panel-2: #181124;
  --yellow: #c6ff36;
  --pink: #ff2d8e;
  --green: #c6ff36;
  --blue: #28e6ff;
  --orange: #ff9d2e;
  --purple: #9b6bff;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 22% 16%, rgba(255, 45, 142, 0.24), transparent 24%),
    radial-gradient(circle at 86% 12%, rgba(40, 230, 255, 0.18), transparent 26%),
    radial-gradient(circle at 50% 92%, rgba(198, 255, 54, 0.10), transparent 24%),
    #15101f;
  color: var(--paper);
  font-family: "Baloo 2", ui-rounded, "Avenir Next", system-ui, sans-serif;
}

body.game-active {
  height: 100dvh;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 12px 12px;
  mask-image: linear-gradient(to bottom, #000, transparent 90%);
}

button,
a {
  font: inherit;
}

.live-shell {
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
}

body.game-active .live-shell {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
}

.hidden {
  display: none !important;
}

.panel {
  width: min(560px, 100%);
  padding: 24px;
  border: 4px solid #05020b;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(36, 26, 54, 0.96), rgba(19, 13, 31, 0.98));
  box-shadow: 0 0 0 2px rgba(255, 45, 142, 0.34), 10px 10px 0 rgba(0, 0, 0, 0.46), 0 0 30px rgba(255, 45, 142, 0.22);
  text-align: center;
}

.panel.game-over-panel {
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px 8px),
    linear-gradient(180deg, rgba(23, 5, 33, 0.98), rgba(5, 2, 11, 0.99));
  box-shadow: 0 0 0 2px rgba(198, 255, 54, 0.42), 10px 10px 0 rgba(0, 0, 0, 0.54), 0 0 42px rgba(255, 45, 142, 0.38);
}

.panel.game-over-panel h2 {
  color: var(--blue);
  text-shadow: 4px 4px 0 var(--pink), 0 0 20px rgba(40, 230, 255, 0.7);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 1000;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--pink);
  font-family: "Bangers", "Baloo 2", ui-rounded, sans-serif;
  font-size: clamp(42px, 12vw, 64px);
  line-height: 0.95;
  letter-spacing: 0;
  text-shadow: 3px 3px 0 #05020b, 0 0 16px rgba(255, 45, 142, 0.6);
}

.lede {
  margin: 16px 0 22px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
}

.note,
.status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.primary,
.ghost,
.mouth-button {
  width: 100%;
  min-height: 60px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  font-size: 22px;
  font-weight: 1000;
  color: #08030f;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.46), 0 0 20px rgba(255, 45, 142, 0.22);
}

.mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 3px solid #05020b;
  border-radius: 16px;
  background: #150f21;
  color: var(--paper);
  font-weight: 1000;
}

.mode-toggle input {
  width: 22px;
  height: 22px;
  accent-color: var(--pink);
}

.primary {
  background: linear-gradient(180deg, var(--yellow), #92e900);
}

.tutorial-link {
  display: block;
  width: 100%;
  min-height: 56px;
  margin: 0 0 12px;
  padding: 13px 16px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: linear-gradient(180deg, #28e6ff, #54a7ff);
  color: #08030f;
  font-size: 20px;
  font-weight: 1000;
  text-decoration: none;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.46), 0 0 20px rgba(40, 230, 255, 0.22);
}

.ghost {
  background: #33244d;
  color: var(--paper);
}

.secondary-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--blue);
  font-weight: 1000;
}

.game-panel {
  width: min(560px, 100%);
  display: grid;
  gap: 10px;
}

body.game-active .game-panel {
  width: min(100%, calc((100dvh - 188px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.6667), 560px);
  height: 100%;
  max-height: calc(100dvh - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
  grid-template-rows: auto minmax(0, auto) auto auto;
  align-content: center;
  gap: clamp(5px, 0.9dvh, 10px);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.hud.two-player {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.hud > div {
  padding: 10px 8px;
  border: 3px solid #05020b;
  border-radius: 16px;
  background: linear-gradient(180deg, #2b1f40, #191126);
  text-align: center;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.44), inset 0 0 18px rgba(255, 45, 142, 0.08);
}

body.game-active .hud {
  gap: clamp(4px, 1.2vw, 8px);
}

body.game-active .hud > div {
  padding: clamp(6px, 1.2dvh, 10px) 6px;
  border-radius: 14px;
}

.hud span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 1000;
  text-transform: uppercase;
}

body.game-active .hud span {
  font-size: clamp(9px, 2.7vw, 12px);
}

.hud strong {
  display: block;
  color: var(--paper);
  font-size: clamp(20px, 6vw, 27px);
  font-weight: 1000;
}

body.game-active .hud strong {
  font-size: clamp(18px, 5.6vw, 26px);
  line-height: 1.05;
}

.hud .energy-low strong {
  color: var(--pink);
}

.hud .energy-good strong {
  color: var(--yellow);
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 4px solid #05020b;
  border-radius: 24px;
  background: #08030f;
  box-shadow: 0 9px 0 rgba(0, 0, 0, 0.5), 0 0 28px rgba(40, 230, 255, 0.20);
}

body.game-active .stage {
  align-self: center;
  max-height: 100%;
}

#cameraVideo,
#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#cameraVideo {
  transform: scaleX(-1);
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
}

body.game-active .controls {
  gap: clamp(6px, 1.2vw, 10px);
}

.mouth-button {
  background: var(--pink);
  color: #fff;
}

.mouth-button.open {
  background: var(--green);
  color: #07040c;
  transform: translateY(5px);
  box-shadow: 0 2px 0 rgba(19, 27, 42, 0.2);
}

.mouth-button.tired {
  background: #ffd8df;
  color: var(--ink);
}

.audio-toggle {
  min-width: 116px;
}

.audio-toggle.off {
  background: #150f21;
  color: var(--muted);
}

.tracking-pill {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 3;
  padding: 8px 10px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: rgba(36, 26, 54, 0.88);
  color: var(--paper);
  font-size: 12px;
  font-weight: 1000;
  box-shadow: 0 4px 0 rgba(19, 27, 42, 0.18);
}

.tracking-pill.ready {
  background: rgba(198, 255, 54, 0.92);
  color: #07040c;
}

.tracking-pill.open {
  background: rgba(255, 45, 142, 0.94);
}

.tracking-pill.fallback {
  background: rgba(255, 157, 46, 0.94);
  color: #07040c;
}

.controls .ghost {
  width: auto;
  min-width: 112px;
  font-size: 18px;
}

body.game-active .primary,
body.game-active .ghost,
body.game-active .mouth-button {
  min-height: clamp(48px, 7dvh, 60px);
  border-radius: 16px;
  font-size: clamp(16px, 4.2vw, 20px);
}

body.game-active .controls .ghost {
  min-width: clamp(86px, 23vw, 112px);
  padding-left: 8px;
  padding-right: 8px;
}

body.game-active .status {
  margin: 0;
  font-size: clamp(11px, 3vw, 13px);
  line-height: 1.25;
}

@media (max-height: 720px) {
  body.game-active .game-panel {
    width: min(100%, calc((100dvh - 162px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.6667), 520px);
  }

  body.game-active .tracking-pill {
    top: 8px;
    left: 8px;
    padding: 6px 8px;
    font-size: 11px;
  }

  body.game-active .status {
    display: none;
  }
}

@media (min-width: 760px) and (min-height: 820px) {
  body.game-active .game-panel {
    width: min(560px, calc((100dvh - 196px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.6667));
  }
}

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.result-shot {
  display: block;
  width: min(220px, 72%);
  aspect-ratio: 2 / 3;
  object-fit: cover;
  margin: 16px auto 10px;
  border: 6px solid #fff6ff;
  border-radius: 10px;
  transform: rotate(-4deg);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.55), 0 0 24px rgba(198, 255, 54, 0.24);
  background: #08030f;
}

button:disabled {
  opacity: 0.55;
}
