:root {
  --bg: #06131a;
  --panel: rgba(7, 24, 30, 0.72);
  --line: rgba(117, 229, 255, 0.22);
  --text: #ecfbff;
  --muted: #93b4bc;
  --accent: #6ef2ff;
  --accent-2: #37d1a5;
  --danger: #ff8ea1;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(55, 209, 165, 0.18), transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(110, 242, 255, 0.24), transparent 20%),
    linear-gradient(145deg, #02070a 0%, #07141d 45%, #031018 100%);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

body {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}

body.is-webcam-active .app-shell {
  place-items: stretch;
  padding: 0;
}

.hero-copy,
.stage-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.hero-copy {
  width: min(100%, 420px);
  padding: 22px;
  transition: padding 220ms ease, transform 220ms ease, opacity 220ms ease;
}

.stage-panel {
  display: none;
  width: 100%;
}

.hero-copy::before,
.stage-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(110, 242, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 242, 255, 0.08) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.8vw, 2.8rem);
  line-height: 0.95;
  transition: font-size 220ms ease;
}

.lede {
  max-width: 36ch;
  margin: 16px 0 22px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  transition: font-size 220ms ease, margin 220ms ease;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #041015;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
  box-shadow: 0 12px 40px rgba(55, 209, 165, 0.28);
}

button:hover {
  transform: translateY(-1px) scale(1.01);
}

#statusText {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.tips {
  margin: 20px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
  transition: opacity 180ms ease, max-height 220ms ease, margin 220ms ease;
  max-height: 220px;
  overflow: hidden;
}

body.is-webcam-active .hero-copy {
  display: none;
}

body.is-webcam-active h1 {
  font-size: clamp(1.3rem, 1.7vw, 1.7rem);
}

body.is-webcam-active .lede {
  margin: 10px 0 14px;
  font-size: 0.82rem;
}

body.is-webcam-active .tips {
  opacity: 0;
  max-height: 0;
  margin-top: 8px;
}

.stage-panel {
  min-height: 680px;
}

body.is-webcam-active .controls {
  gap: 10px;
}

body.is-webcam-active .stage-panel {
  display: block;
  min-height: 680px;
  height: 100vh;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}

.hud {
  position: absolute;
  z-index: 3;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  color: var(--accent);
}

.scoreboard {
  position: absolute;
  z-index: 3;
  top: 56px;
  right: 18px;
  display: flex;
  gap: 10px;
}

.reset-button {
  position: absolute;
  z-index: 3;
  top: 148px;
  right: 18px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(4, 18, 24, 0.72);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: none;
}

.reset-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.score-card {
  min-width: 84px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(4, 18, 24, 0.66);
  text-align: center;
}

.score-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
}

.score-card strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 1.8rem;
}

.game-message {
  position: absolute;
  z-index: 3;
  left: 18px;
  right: 18px;
  bottom: 18px;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(4, 18, 24, 0.72);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}

#scene,
#webcam,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#scene canvas,
#overlay,
#webcam {
  border-radius: 28px;
}

body.is-webcam-active #scene canvas,
body.is-webcam-active #overlay,
body.is-webcam-active #webcam {
  border-radius: 0;
}

#webcam {
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0.18;
  filter: saturate(0.7) contrast(1.05);
}

#overlay {
  z-index: 2;
  pointer-events: none;
}

#scene {
  z-index: 1;
}

@media (max-width: 980px) {
  .app-shell {
    place-items: center;
  }

  .stage-panel {
    min-height: 72vh;
  }

  body.is-webcam-active .app-shell {
    place-items: stretch;
  }
}
