/* =============================================================
   daviplay.com Portal — styles.css
   Complete design system: palette tokens, typography, layout,
   component styles, motion gates.
   ============================================================= */

/* =============================================================
   CANVAS STACKING CONTRACT (VFX-03)
   All canvas/overlay layers are registered here. Every canvas
   element MUST have pointer-events: none unless it requires
   direct interaction. New layers MUST be added here first.

   z-index  | ID / selector              | Phase | pointer-events
   ---------|----------------------------|-------|--------------
   0        | main::before (margin line) | v1.0  | none
   1        | .notebook-holes            | v1.0  | none
   -1       | #particles-bg (+ canvas)   | 8     | none
   502      | #cursor-trail-canvas       | 9     | none
   504      | #water-ripple-canvas       | 9     | none
   506      | #face-emoji-canvas         | 11    | none
   900      | .counter-hud               | v1.0  | auto
   910      | #camera-consent-panel      | 11    | auto
   950      | #gravity-toy-cta           | 9     | auto
   980      | #camera-face-cta           | 11    | auto
   1000     | #controls-strip            | v1.0  | auto
   1000     | .confetti-canvas (dynamic) | v1.0  | none
   ============================================================= */

/* Baseline: all canvases with standard naming are non-interactive.
   !important required: tsParticles sets inline style="pointer-events: initial"
   on its canvas, which overrides normal specificity. */
canvas[id$="-canvas"],
[id$="-bg"] canvas {
  pointer-events: none !important;
}

/* VFX-01 particle background container */
#particles-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

#particles-bg canvas {
  display: block;
}

/* =============================================================
   SECTION 1 — @font-face declarations (must precede all rules)
   URL prefix: /portal/fonts/ (nginx serves public/portal/ at /portal/)
   ============================================================= */

@font-face {
  font-family: 'Caveat';
  src: url('/portal/fonts/caveat-regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
  font-style: normal;
}

@font-face {
  font-family: 'Caveat';
  src: url('/portal/fonts/caveat-bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
  font-style: normal;
}

@font-face {
  font-family: 'Fredoka One';
  src: url('/portal/fonts/fredoka-one-regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
  font-style: normal;
}

/* =============================================================
   SECTION 2 — Custom properties on :root
   ============================================================= */

:root {
  /* Colour */
  --color-bg: #FFF9F0;
  --color-card: #FFF0D4;
  --color-accent: #FF4D6D;
  --color-accent-2: #7B2FFF;
  --color-accent-3: #00C9A7;
  --color-chaos: #FF9500;
  --color-text: #1A1A1A;
  --color-text-muted: rgba(26, 26, 26, 0.55);
  --color-text-on-accent: #FFFFFF;
  --color-danger: #E53E3E;

  /* Notebook aesthetic */
  --color-ruled-line: rgba(96, 130, 182, 0.09);
  --color-margin: rgba(220, 80, 60, 0.16);

  /* Spacing (8-point grid) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --radius-circle: 50%;

  /* Typography */
  --font-handwriting: 'Caveat', cursive;
  --font-display: 'Fredoka One', 'Nunito', sans-serif;
  --font-size-sm: 14px;
  --font-size-md: 16px;
  --font-size-lg: 20px;
  --font-size-hero: clamp(36px, 8vw, 64px);
}

/* =============================================================
   SECTION 3 — CSS reset
   ============================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* =============================================================
   SECTION 4 — Body base styles
   ============================================================= */

body {
  background-color: var(--color-bg);
  background-image: linear-gradient(var(--color-ruled-line) 1px, transparent 1px);
  background-size: 100% 36px;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  line-height: 1.5;
}

/* Notebook margin line — red rule on left edge, desktop only */
@media (min-width: 640px) {
  main {
    position: relative;
  }

  main::before {
    content: '';
    position: absolute;
    left: clamp(40px, 6vw, 80px);
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-margin);
    pointer-events: none;
    z-index: 0;
  }
}

/* =============================================================
   SECTION 5 — Fixed controls strip (#controls-strip)
   ============================================================= */

#controls-strip {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

#controls-strip button {
  min-height: 44px;
  min-width: 44px;
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  cursor: pointer;
  border-radius: var(--radius-md);
  border: none;
  padding: var(--space-sm) var(--space-md);
}

/* Chaos toggle — normal state */
#chaos-toggle {
  background: var(--color-card);
  color: var(--color-text);
}

/* Chaos toggle — CHAOS active state */
#chaos-toggle.chaos-active {
  background: var(--color-chaos);
  color: #fff;
  box-shadow: 0 0 16px rgba(255, 149, 0, 0.6);
}

/* Mute toggle */
#mute-toggle {
  background: var(--color-card);
  color: var(--color-text);
}

/* Mute toggle — muted state */
#mute-toggle.muted {
  opacity: 0.6;
}

/* =============================================================
   SECTION 6 — Cursor trail canvas overlay (#cursor-trail-canvas)
   ============================================================= */

#cursor-trail-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 502;
}

#water-ripple-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 504;
}

/* =============================================================
   SECTION 7 — Hero section (#hero)
   ============================================================= */

#hero {
  text-align: center;
  padding: var(--space-2xl) var(--space-md) var(--space-xl);
  max-width: 600px;
  margin: 0 auto;
  position: relative;    /* required: contains #particles-bg absolute canvas */
  overflow: hidden;      /* required: clips particles to hero boundary */
  isolation: isolate;    /* required: creates stacking context so z-index:-1 #particles-bg is behind hero content but visible through transparent background */
}

#david-avatar {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-circle);
  border: 3px solid var(--color-accent);
  box-shadow:
    0 0 0 6px rgba(255, 77, 109, 0.15),
    0 0 0 12px rgba(123, 47, 255, 0.10),
    0 0 28px rgba(255, 77, 109, 0.40);
  cursor: pointer;
  display: block;
  margin: 0 auto var(--space-lg);
}

#hero h1 {
  font-family: var(--font-handwriting);
  font-size: var(--font-size-hero);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
  margin-bottom: var(--space-sm);
  position: relative;
  display: inline-block;
}

.hero-subtitle {
  font-family: var(--font-handwriting);
  font-size: clamp(20px, 4vw, 30px);
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: var(--space-lg);
}

.hero-ctas {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  align-items: center;
}

/* Tablet and above: avatar larger, buttons side-by-side */
@media (min-width: 640px) {
  #david-avatar {
    width: 160px;
    height: 160px;
  }

  .hero-ctas {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* =============================================================
   SECTION 8 — Buttons (.btn)
   ============================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 400;
  min-height: 48px;
  min-width: 140px;
  padding: var(--space-sm) var(--space-xl);
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text-on-accent);
}

.btn-primary {
  background: var(--color-accent);
  box-shadow: 3px 4px 0 rgba(180, 20, 50, 0.45);
}

.btn-chaos {
  background: var(--color-accent-2);
  box-shadow: 3px 4px 0 rgba(70, 15, 160, 0.45);
}

.btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* =============================================================
   SECTION 9 — Scroll zone (#scroll-zone)
   ============================================================= */

#scroll-zone {
  position: relative;
  padding: var(--space-3xl) var(--space-md);
  min-height: 300px;
}

.character-left {
  position: absolute;
  left: 8px;
  top: 20%;
  font-size: 48px;
  transform: translateX(-80px);
  opacity: 0;
}

.character-right {
  position: absolute;
  right: 8px;
  top: 40%;
  font-size: 48px;
  transform: translateX(80px);
  opacity: 0;
}

.scroll-tagline {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  text-align: center;
  color: var(--color-text-muted);
}

.section-content {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
}

/* =============================================================
   SECTION 11 — Footer
   ============================================================= */

footer {
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
}

.footer-link {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  color: var(--color-accent);
  text-decoration: none;
}

/* =============================================================
   SECTION 12 — Easter eggs (.easter-egg)
   ============================================================= */

.easter-egg {
  font-size: 14px;
  opacity: 0.4;
  cursor: pointer;
  user-select: none;
  line-height: 1;
  transition: opacity 0.2s;
}

.easter-egg:hover,
.easter-egg:focus-visible {
  opacity: 0.7;
}

.easter-egg:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

@keyframes egg-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.6; }
}

@media (prefers-reduced-motion: no-preference) {
  .easter-egg {
    animation: egg-pulse 8s ease-in-out infinite;
    transition: opacity 0.2s, transform 0.2s;
  }

  .easter-egg:hover,
  .easter-egg:focus-visible {
    transform: scale(1.4);
  }
}

/* =============================================================
   SECTION 13 — Motion gates (CRITICAL — prefers-reduced-motion)
   All transform/opacity transitions gated on no-preference.
   Fallback: colour/opacity only for reduced-motion users.
   ============================================================= */

@media (prefers-reduced-motion: no-preference) {
  .btn-primary:hover {
    transform: scale(1.04);
  }

  .btn-chaos:hover {
    transform: scale(1.04);
  }

  #david-avatar:hover {
    transform: scale(1.05);
  }

  .btn-primary,
  .btn-chaos,
  #david-avatar {
    transition: transform 0.15s ease;
  }

  .footer-link:hover {
    opacity: 0.8;
    transition: opacity 0.15s ease;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Characters appear in place — no translate animation */
  .character-left,
  .character-right {
    transform: none;
    opacity: 1;
  }

  /* Cursor trail hidden — pure delight layer, not informational */
  #cursor-trail-canvas {
    display: none;
  }
  /* Water ripple hidden — pure delight layer */
  #water-ripple-canvas {
    display: none;
  }
}

/* =============================================================
   SECTION 14 — Chaos mode active state (.chaos-mode on <body>)
   ============================================================= */

body.chaos-mode .btn-chaos {
  background: repeating-linear-gradient(
    45deg,
    var(--color-chaos),
    var(--color-accent-2) 20px
  );
}

/* --- Keyframe declarations (global — outside media queries) --- */

@keyframes chaos-hue-cycle {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

@keyframes chaos-shake {
  0%,  100% { transform: translate(0, 0); }
  10%       { transform: translate(-4px, -2px); }
  20%       { transform: translate( 4px,  2px); }
  30%       { transform: translate(-3px,  3px); }
  40%       { transform: translate( 3px, -3px); }
  50%       { transform: translate(-2px, -4px); }
  60%       { transform: translate( 2px,  4px); }
  70%       { transform: translate(-4px,  2px); }
  80%       { transform: translate( 4px, -2px); }
  90%       { transform: translate(-2px,  3px); }
}

@keyframes chaos-rainbow-text {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* --- Colour effects — OUTSIDE motion gate (applies to ALL users) --- */

/* Colour shift visible to all users including reduced-motion */
body.chaos-mode {
  background-color: #1A0533;
}

body.chaos-mode #hero {
  background: linear-gradient(135deg, #FF0080, #7B2FFF, #FF9500);
  background-size: 400% 400%;
}

/* --- Motion effects — INSIDE prefers-reduced-motion: no-preference gate --- */

@media (prefers-reduced-motion: no-preference) {
  /* Hue-rotate cycles the entire body colour */
  body.chaos-mode {
    animation: chaos-hue-cycle 3s linear infinite;
  }

  /* Body shake/tremor — earthquake effect */
  body.chaos-mode #hero {
    animation: chaos-shake 0.5s ease-in-out infinite;
  }

  /* CRITICAL: ENTIRE rainbow text block must be inside this gate.
     If -webkit-text-fill-color: transparent leaks outside,
     text becomes invisible for reduced-motion users (RESEARCH.md Pitfall 6). */
  body.chaos-mode #hero h1,
  body.chaos-mode .hero-subtitle {
    background: linear-gradient(
      270deg,
      #FF4D6D, #FF9500, #FFFF00, #00C9A7, #00FFFF, #7B2FFF, #FF00FF, #FF4D6D
    );
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    animation: chaos-rainbow-text 4s ease infinite;
  }
}

/* --- Reduced-motion fallback — vivid static colour for chaos text --- */

@media (prefers-reduced-motion: reduce) {
  /* Chaos is still visually distinct for reduced-motion users —
     vivid static colour, no animation */
  body.chaos-mode #hero h1,
  body.chaos-mode .hero-subtitle {
    color: #FF4D6D;
  }
}

/* =============================================================
   SECTION 15 — Counter HUD (.counter-hud)
   Fixed-corner floating counters — visitors (bottom-left) and chaos (bottom-right)
   ============================================================= */

.counter-hud {
  position: fixed;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(255, 240, 212, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid var(--color-chaos);
  border-radius: var(--radius-pill);
  padding: var(--space-sm) var(--space-md);
  min-height: 44px;
  min-width: 80px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 12px rgba(255, 149, 0, 0.25);
}

#counter-visitors {
  bottom: 20px;
  left: 20px;
}

#counter-chaos {
  bottom: 20px;
  right: 20px;
}

.counter-emoji {
  font-size: 24px;
  line-height: 1;
}

.counter-number {
  font-family: var(--font-handwriting);
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  line-height: 1;
  color: var(--color-chaos);
}

.counter-label {
  font-family: var(--font-handwriting);
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-text-muted);
  line-height: 1.3;
}

.counter-hud:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* Mobile: tighter corner offset and slightly smaller pill */
@media (max-width: 480px) {
  #counter-visitors {
    bottom: 12px;
    left: 12px;
  }
  #counter-chaos {
    bottom: 12px;
    right: 12px;
  }
  .counter-hud {
    min-width: 72px;
  }
}

/* =============================================================
   SECTION 16 — Notebook aesthetic (frontend-design)
   Draw-underline animation, hero badge sticker, punch holes.
   ============================================================= */

/* Animated rainbow underline draws itself on load */
@keyframes draw-underline {
  from { width: 0; }
  to   { width: 100%; }
}

#hero h1::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    var(--color-accent),
    var(--color-chaos),
    var(--color-accent-3),
    var(--color-accent-2)
  );
  width: 0;
}

@media (prefers-reduced-motion: no-preference) {
  #hero h1::after {
    animation: draw-underline 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.4s forwards;
  }
}

@media (prefers-reduced-motion: reduce) {
  #hero h1::after {
    width: 100%;
  }
}

/* Hero badge — handwritten sticker tag */
.hero-badge {
  font-family: var(--font-handwriting);
  font-size: 16px;
  font-weight: 700;
  color: var(--color-accent-2);
  background: rgba(123, 47, 255, 0.08);
  border: 2px dashed rgba(123, 47, 255, 0.30);
  border-radius: var(--radius-sm);
  padding: 2px 10px;
  display: inline-block;
  margin-bottom: var(--space-sm);
  transform: rotate(-1.5deg);
}

/* Notebook punch holes — decorative left-edge circles, wide screens only */
.notebook-holes {
  position: fixed;
  top: 0;
  left: 18px;
  bottom: 0;
  display: none;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  pointer-events: none;
  z-index: 1;
}

@media (min-width: 900px) {
  .notebook-holes {
    display: flex;
  }
}

.notebook-hole {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 2px solid rgba(96, 130, 182, 0.25);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* =============================================================
   SECTION 17 — Gravity toy section (#gravity-toy-section)
   ============================================================= */

#gravity-toy-section {
  display: none;
  position: relative;
  width: 100%;
  min-height: 60vh;
  overflow: hidden;
  touch-action: none;           /* iOS Safari first-layer scroll prevention */
  background: var(--color-card);
  border-top: 3px dashed rgba(26, 26, 26, 0.15);
  padding: var(--space-3xl) var(--space-md);
}

#gravity-toy-section canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: auto !important;  /* gravity toy canvas MUST receive clicks/drags */
}

#gravity-toy-section .gravity-heading {
  position: absolute;
  top: var(--space-lg);
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-handwriting);
  font-size: var(--font-size-hero);
  font-weight: 700;
  color: var(--color-text);
  opacity: 0.7;
  pointer-events: none;
  z-index: 2;
}

#gravity-toy-section .gravity-subheading {
  position: absolute;
  top: calc(var(--space-lg) + 60px);
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
  pointer-events: none;
  z-index: 2;
}

/* =============================================================
   SECTION 18 — Gravity CTA button (#gravity-toy-cta)
   Inline in hero-ctas — inherits .btn .btn-primary styles.
   ============================================================= */

/* =============================================================
   SECTION 19 -- Synth keyboard section (#synth-section) -- Phase 10
   ============================================================= */

#synth-section {
  display: block;
  position: relative;
  width: 100%;
  background: var(--color-card);
  border-top: 3px dashed rgba(26, 26, 26, 0.15);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
}

@media (max-width: 600px) {
  #synth-section {
    padding: var(--space-xl) var(--space-md);
  }
}

.synth-heading {
  font-family: var(--font-handwriting);
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-text);
  margin: 0 0 var(--space-sm) 0;
}

.synth-subheading {
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-lg) 0;
}

.synth-style-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.synth-style-arrow {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  background: transparent;
  border: 2px solid var(--color-text-muted);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  cursor: pointer;
  color: var(--color-text);
  min-width: 44px;
  min-height: 44px;
  line-height: 1;
}

.synth-style-arrow:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .synth-style-arrow:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
  }
  .synth-style-arrow:active {
    transform: scale(0.92);
  }
}

.synth-style-name {
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  color: var(--color-text);
  min-width: 160px;
  text-align: center;
  display: inline-block;
}

/* Style 1: Colored tap pads */
.synth-pad-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-sm);
  max-width: 600px;
  margin: 0 auto;
}

.synth-pad {
  min-height: 64px;
  min-width: 48px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  font-family: var(--font-display);
  font-size: 18px;
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.synth-pad:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  .synth-pad:hover {
    filter: brightness(1.1);
    transform: scale(1.06);
  }
  .synth-pad:active {
    transform: scale(0.93);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
    filter: brightness(0.88);
  }
}

/* Style 2: Piano keys */
.synth-piano {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  max-width: 600px;
  margin: 0 auto;
  height: 120px;
}

.synth-key {
  flex: 1;
  background: var(--color-card);
  border: 1px solid rgba(26, 26, 26, 0.2);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: var(--space-sm);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.synth-key:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.synth-key:active,
.synth-key[aria-pressed="true"] {
  background: var(--color-accent-2);
  color: #FFFFFF;
}

/* Style 3: Emoji instrument buttons */
.synth-emoji-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-md);
  max-width: 600px;
  margin: 0 auto;
}

.synth-emoji-btn {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-circle);
  background: var(--color-card);
  border: 3px solid var(--color-chaos);
  font-size: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.synth-emoji-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  .synth-emoji-btn:active {
    background: rgba(255, 77, 109, 0.12);
    border-color: var(--color-accent);
    transform: scale(0.92);
  }
}

/* =============================================================
   SECTION 20 -- Mic permission prompt (#clap-prompt) -- Phase 10
   ============================================================= */

#clap-prompt {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 910;
  width: clamp(280px, 90vw, 400px);
  background: var(--color-card);
  border: 3px solid var(--color-chaos);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
}

@media (prefers-reduced-motion: no-preference) {
  #clap-prompt.clap-prompt-visible {
    animation: clap-prompt-in 200ms ease-out forwards;
  }
}

@keyframes clap-prompt-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.clap-prompt-heading {
  font-family: var(--font-handwriting);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--space-sm) 0;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.clap-prompt-body {
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-md) 0;
}

.clap-prompt-buttons {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

#clap-allow-btn {
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  border: none;
  border-radius: var(--radius-pill);
  padding: 0 var(--space-lg);
  min-height: 48px;
  min-width: 100px;
  cursor: pointer;
}

#clap-allow-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  #clap-allow-btn:hover { filter: brightness(1.08); }
  #clap-allow-btn:active { transform: scale(0.96); }
}

#clap-decline-btn {
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  background: transparent;
  color: var(--color-text-muted);
  border: none;
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  min-height: 44px;
  min-width: 80px;
  cursor: pointer;
}

#clap-decline-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* =============================================================
   SECTION 21 -- Audio-reactive pulse (.pulse-scale, .pulse-glow) -- Phase 10
   ============================================================= */

/* Base transitions on pulse targets -- allow classes to animate on AND off */
#visitors-number,
#chaos-number,
#hero h1 {
  transition: filter 150ms ease-in;
}

@media (prefers-reduced-motion: no-preference) {
  #visitors-number,
  #chaos-number,
  #hero h1 {
    transition: transform 150ms ease-in, filter 150ms ease-in;
  }
}

/* Pulse glow -- always active regardless of reduced-motion (D-14) */
.pulse-glow {
  filter: drop-shadow(0 0 12px #FFD700) drop-shadow(0 0 24px rgba(123, 47, 255, 0.6));
  transition: filter 50ms ease-out;
}

/* Pulse scale -- gated on no-preference (D-14) */
@media (prefers-reduced-motion: no-preference) {
  .pulse-scale {
    transform: scale(1.08);
    transition: transform 50ms ease-out;
  }
}

/* z-index contract update: #clap-prompt = 910 (above counter HUDs at 900, below controls-strip at 1000) */

/* =============================================================
   SECTION 22 -- Camera face section (#camera-face-section) -- Phase 11
   ============================================================= */

#camera-face-section {
  display: none;
  position: relative;
  width: 100%;
  background: var(--color-card);
  border-top: 3px dashed rgba(26, 26, 26, 0.15);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
}

@media (max-width: 600px) {
  #camera-face-section {
    padding: var(--space-xl) var(--space-md);
  }
}

/* =============================================================
   SECTION 23 -- Camera CTA button (#camera-face-cta) -- Phase 11
   Inline in hero-ctas — inherits .btn .btn-primary styles.
   ============================================================= */

/* =============================================================
   SECTION 24 -- Camera consent panel (#camera-consent-panel) -- Phase 11
   Mirrors #clap-prompt (section 20) -- different border color (--color-accent-3 teal).
   ============================================================= */

#camera-consent-panel {
  position: relative;
  z-index: 910;
  width: clamp(280px, 90%, 420px);
  margin: var(--space-xl) auto;
  background: var(--color-card);
  border: 3px solid var(--color-accent-3);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-xl);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  text-align: left;
}

@keyframes camera-consent-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  #camera-consent-panel.camera-consent-visible {
    animation: camera-consent-in 200ms ease-out forwards;
  }
}

.camera-consent-heading {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-handwriting);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.camera-consent-body {
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}

.camera-consent-buttons {
  display: flex;
  flex-direction: row;
  gap: var(--space-sm);
  justify-content: center;
  flex-wrap: wrap;
}

#camera-allow-btn {
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  border: none;
  border-radius: var(--radius-pill);
  padding: 0 var(--space-lg);
  min-height: 48px;
  min-width: 120px;
  cursor: pointer;
}

#camera-allow-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  #camera-allow-btn:hover { filter: brightness(1.08); }
  #camera-allow-btn:active { transform: scale(0.96); }
}

#camera-decline-btn {
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  background: transparent;
  color: var(--color-text-muted);
  border: none;
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  min-height: 44px;
  min-width: 80px;
  cursor: pointer;
}

#camera-decline-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* =============================================================
   SECTION 25 -- Camera viewport and video element -- Phase 11
   #face-emoji-canvas inherits pointer-events: none !important from
   the canvas[id$="-canvas"] selector in the stacking contract block.
   Stacking order: 506 places it above water-ripple-canvas (504).
   ============================================================= */

.camera-viewport {
  position: relative;
  max-width: 480px;
  margin: var(--space-lg) auto 0;
}

#camera-video {
  display: block;
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg);
}

#face-emoji-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 506;
  /* pointer-events: none !important inherited from canvas[id$="-canvas"] selector */
}

#camera-stop-btn {
  display: block;
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  background: var(--color-accent-2);
  color: var(--color-text-on-accent);
  border: none;
  border-radius: var(--radius-pill);
  padding: var(--space-sm) var(--space-xl);
  min-height: 44px;
  margin: var(--space-md) auto 0;
  cursor: pointer;
}

#camera-stop-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  #camera-stop-btn:hover { filter: brightness(1.08); }
}

/* =============================================================
   SECTION 26 -- Contact + privacy section (#contact-section)
   ============================================================= */

#contact-section {
  padding: var(--space-3xl) var(--space-md) var(--space-2xl);
  text-align: center;
  border-top: 2px dashed rgba(255, 255, 255, 0.15);
}

#contact-greeting {
  font-family: var(--font-handwriting);
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  color: var(--color-text);
  margin: 0 0 var(--space-md);
  letter-spacing: 0.03em;
}

.contact-email-link {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.5vw, 1.4rem);
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 2px dotted var(--color-accent);
  padding-bottom: 2px;
  transition: color 0.2s ease;
}

.contact-parents {
  margin-top: var(--space-2xl);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.contact-parents-label {
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 var(--space-sm);
}

.contact-parents-text {
  font-family: var(--font-handwriting);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .contact-email-link:hover {
    color: var(--color-accent-2);
    border-bottom-color: var(--color-accent-2);
  }
}
