:root {
  --bg: #06060b;
  --panel: rgba(18, 18, 30, 0.72);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f4fb;
  --muted: #9a9ab5;
  --accent: #8b5cf6;
  --accent2: #22d3ee;
  --ink: #ffd60a;
  --laser: #ff2d55;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

kbd {
  font: 600 11px "JetBrains Mono", monospace;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.grad {
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.kicker {
  font: 700 12px "JetBrains Mono", monospace;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent2);
}

/* ---------- stage ---------- */
#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60vw 60vh at 15% 10%, rgba(139, 92, 246, 0.14), transparent 60%),
    radial-gradient(50vw 50vh at 90% 95%, rgba(34, 211, 238, 0.10), transparent 60%),
    var(--bg);
}

#slide-wrap {
  position: relative;
  width: min(94vw, calc(86vh * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  container-type: inline-size;
  border: 1px solid var(--line);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(139, 92, 246, 0.08);
  background:
    radial-gradient(70% 90% at 0% 0%, rgba(139, 92, 246, 0.22), transparent 60%),
    radial-gradient(60% 80% at 100% 100%, rgba(34, 211, 238, 0.14), transparent 60%),
    #0d0d17;
}

#ink, #fx, #blackout {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#blackout {
  background: #000;
  opacity: 0;
  transition: opacity 0.35s ease;
  display: grid;
  place-items: end center;
  padding-bottom: 3cqw;
}
#blackout span { font: 500 1.2cqw "JetBrains Mono", monospace; color: #333; }
#blackout.on { opacity: 1; }

/* ---------- slide content ---------- */
.slide {
  position: absolute;
  inset: 0;
  padding: 5.5cqw 7cqw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.2cqw;
}
.slide .kicker { font-size: 1.25cqw; }
.slide h1.hero {
  font-size: 12cqw;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.95;
}
.slide h1.hero.small { font-size: 9cqw; }
.slide h2 {
  font-size: 4.4cqw;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 1.6cqw;
  max-width: 80%;
}
.slide .lead { font-size: 2.1cqw; color: var(--muted); max-width: 70%; line-height: 1.4; }
.slide .foot { font: 500 1.3cqw "JetBrains Mono", monospace; color: var(--accent2); margin-top: 1.5cqw; }
.slide .hint {
  align-self: flex-start;
  margin-top: 2.5cqw;
  font-size: 1.5cqw;
  padding: 0.9cqw 1.8cqw;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  animation: pulse 2.4s ease-in-out infinite;
}
.slide .points { list-style: none; display: grid; gap: 1.5cqw; }
.slide .points li {
  font-size: 2.1cqw;
  color: var(--muted);
  padding-left: 2.6cqw;
  position: relative;
}
.slide .points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.75cqw;
  width: 1cqw;
  height: 1cqw;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.slide .points b { color: var(--text); }

.slide .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.4cqw; }
.slide .grid.three { grid-template-columns: repeat(3, 1fr); }
.slide .card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 1.2cqw;
  padding: 1.6cqw 1.8cqw;
  display: flex;
  flex-direction: column;
  gap: 0.4cqw;
}
.slide .card .e { font-size: 3.2cqw; line-height: 1.2; }
.slide .card b { font-size: 1.7cqw; }
.slide .card span { font-size: 1.25cqw; color: var(--muted); line-height: 1.35; }

.slide .flow { display: flex; align-items: stretch; gap: 1cqw; }
.slide .flow .card { flex: 1; }
.slide .flow .arrow { align-self: center; font-size: 2.6cqw; color: var(--muted); }

.slide .playground {
  flex: 1;
  border: 0.2cqw dashed rgba(255, 214, 10, 0.35);
  border-radius: 1.6cqw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1cqw;
  font-size: 1.8cqw;
  color: var(--muted);
}

.slide .stats { display: flex; gap: 5cqw; margin: 1cqw 0 2.5cqw; }
.slide .stats .num { font-size: 6.5cqw; font-weight: 800; letter-spacing: -0.04em; }
.slide .stats span { font-size: 1.5cqw; color: var(--muted); }

.slide.pdf { padding: 0; background: #fff; }
.slide.pdf img { width: 100%; height: 100%; object-fit: contain; display: block; }

.slide.enter-next { animation: enterNext 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.slide.enter-prev { animation: enterPrev 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.slide.bump { animation: bump 0.35s ease; }

@keyframes enterNext { from { transform: translateX(7%); opacity: 0; filter: blur(6px); } }
@keyframes enterPrev { from { transform: translateX(-7%); opacity: 0; filter: blur(6px); } }
@keyframes bump {
  25% { transform: translateX(-1.2%); }
  75% { transform: translateX(1.2%); }
}
@keyframes pulse { 50% { opacity: 0.55; } }

/* ---------- progress / counter / flash ---------- */
#progress {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
}
#progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
}
#counter {
  position: fixed;
  top: 16px;
  right: 20px;
  font: 600 13px "JetBrains Mono", monospace;
  color: var(--muted);
}
.flash {
  position: fixed;
  top: 50%;
  translate: 0 -50%;
  font-size: 140px;
  font-weight: 300;
  color: var(--accent2);
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 40px var(--accent2);
}
#flash-left { left: 12px; }
#flash-right { right: 12px; }
.flash.show { animation: flash 0.5s ease-out; }
@keyframes flash {
  0% { opacity: 0.9; scale: 1.2; }
  100% { opacity: 0; scale: 0.9; }
}

/* ---------- camera PIP ---------- */
#cam {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 320px;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  z-index: 5;
}
#cam.live { opacity: 1; }
#cam.hand { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.4), 0 12px 40px rgba(0, 0, 0, 0.5); }
#cam.back { border-color: #ff5a5a; box-shadow: 0 0 0 2px rgba(255, 90, 90, 0.35), 0 12px 40px rgba(0, 0, 0, 0.5); }
#cam.hidden-pip { opacity: 0; pointer-events: none; }
#video, #cam-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
#video { opacity: 0.55; }
#cam { cursor: crosshair; }

#swipe-zone {
  position: absolute;
  border: 2px dashed rgba(34, 211, 238, 0.55);
  border-radius: 10px;
  background: rgba(34, 211, 238, 0.06);
  transition: background 0.15s, border-color 0.15s, opacity 0.2s;
  pointer-events: none;
}
#swipe-zone span {
  position: absolute;
  top: 3px;
  left: 6px;
  font: 700 9px "JetBrains Mono", monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(34, 211, 238, 0.8);
}
#swipe-zone.active { border-style: solid; border-color: var(--accent2); background: rgba(34, 211, 238, 0.16); }
#swipe-zone.fired { animation: zoneFire 0.4s ease-out; }
#swipe-zone.off { opacity: 0; }
@keyframes zoneFire {
  0% { background: rgba(34, 211, 238, 0.55); box-shadow: 0 0 24px var(--accent2); }
}
#hud {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 12px "JetBrains Mono", monospace;
}
#gesture-name {
  padding: 4px 9px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
}
#hold-ring {
  --p: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: conic-gradient(var(--accent2) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.12) 0);
  -webkit-mask: radial-gradient(circle, transparent 5px, #000 6px);
  mask: radial-gradient(circle, transparent 5px, #000 6px);
  opacity: 0;
  transition: opacity 0.15s;
}
#hold-ring.active { opacity: 1; }
#fps { margin-left: auto; color: var(--muted); font-size: 11px; }

/* ---------- Pikachu (voice) ---------- */
#pikachu {
  position: fixed;
  top: 14px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  z-index: 6;
  max-width: min(460px, calc(100vw - 120px));
  transition: border-color 0.2s, box-shadow 0.2s;
}
#pikachu.awake { border-color: rgba(34, 211, 238, 0.6); box-shadow: 0 0 24px rgba(34, 211, 238, 0.25); }
#pikachu.fired { animation: pikachuFire 0.5s ease-out; }
@keyframes pikachuFire { 0% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.45); } }

#pikachu-orb {
  width: 38px;
  height: 38px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
}
#pikachu-orb .orb {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--accent2), #f472b6, var(--accent));
  box-shadow: 0 0 14px rgba(139, 92, 246, 0.6);
  animation: spin 6s linear infinite;
  transition: filter 0.2s, transform 0.2s;
}
#pikachu.off #pikachu-orb .orb { filter: grayscale(1) brightness(0.5); animation-play-state: paused; box-shadow: none; }
#pikachu.awake #pikachu-orb .orb { animation-duration: 1.4s; transform: scale(1.12); }
@keyframes spin { to { rotate: 360deg; } }

.pikachu-text { min-width: 0; }
.pikachu-name { font-weight: 800; font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
#pikachu-state { font: 600 11px "JetBrains Mono", monospace; color: var(--muted); }
#pikachu.awake #pikachu-state { color: var(--accent2); }
#pikachu-line {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#pikachu-line.heard { color: var(--text); font-style: italic; }
#pikachu-line.done { color: #4ade80; font-weight: 600; }
#pikachu-line.said { color: #fbbf24; }

#pikachu-cmds {
  position: fixed;
  top: 70px;
  left: 16px;
  width: min(440px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  font-size: 13px;
  z-index: 6;
  transition: opacity 0.2s, translate 0.2s;
}
#pikachu-cmds.hidden { opacity: 0; translate: 0 -8px; pointer-events: none; }
#pikachu-cmds-close { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; }
.cmd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 6px 0 10px; }
.cmd-grid span { color: var(--text); }
.cmd-grid span::before { content: "“"; color: var(--accent2); }
.cmd-grid span::after { content: "”"; color: var(--accent2); }
#pikachu-cmds p { color: var(--muted); font-size: 12px; }

/* ---------- help ---------- */
#help {
  position: fixed;
  left: 16px;
  bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  font-size: 12px;
  display: grid;
  gap: 5px;
  z-index: 5;
  transition: opacity 0.25s, translate 0.25s;
}
#help.hidden { opacity: 0; translate: -10px 0; pointer-events: none; }
.help-title { font-weight: 700; display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.help-row { display: grid; grid-template-columns: 52px 1fr; color: var(--muted); }
.help-row span { color: var(--text); }
.help-keys { margin-top: 6px; color: var(--muted); display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }

/* ---------- start ---------- */
#start {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 6, 11, 0.82);
  backdrop-filter: blur(14px);
  z-index: 20;
  transition: opacity 0.4s;
}
#start.hidden { opacity: 0; pointer-events: none; }
.start-card { max-width: 620px; text-align: center; display: grid; gap: 18px; justify-items: center; }
.start-card h1 { font-size: clamp(56px, 12vw, 104px); font-weight: 800; letter-spacing: -0.05em; line-height: 1; }
.start-card p { color: var(--muted); font-size: 17px; line-height: 1.5; }
.start-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn {
  font: 600 15px Inter, sans-serif;
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.09); }
.btn.primary { background: linear-gradient(100deg, var(--accent), #6d28d9); border-color: transparent; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn:disabled { opacity: 0.6; cursor: progress; }
#status { min-height: 1.5em; font: 500 13px "JetBrains Mono", monospace; color: var(--accent2); }
.start-card .tip { font-size: 13px; }

/* ---------- toast / reactions / drop ---------- */
#toast {
  position: fixed;
  top: 18px;
  left: 50%;
  translate: -50% -20px;
  padding: 9px 16px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.25s, translate 0.25s;
  z-index: 30;
  pointer-events: none;
}
#toast.show { opacity: 1; translate: -50% 0; }

#reactions { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 15; }
#reactions span {
  position: absolute;
  bottom: -60px;
  font-size: 48px;
  animation: floatUp 2.2s cubic-bezier(0.2, 0.6, 0.3, 1) forwards;
}
@keyframes floatUp {
  to { transform: translate(var(--dx), -105vh) rotate(var(--rot)); opacity: 0; }
}

#drop-hint {
  position: fixed;
  inset: 16px;
  border: 2px dashed var(--accent2);
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 700;
  background: rgba(6, 6, 11, 0.85);
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: opacity 0.2s;
}
#drop-hint.show { opacity: 1; }

@media (max-width: 720px) {
  #help { display: none; }
  #cam { width: 160px; }
}

#pikachu.thinking #pikachu-orb .orb { animation-duration: 0.6s; filter: hue-rotate(60deg) brightness(1.2); }
#pikachu-cmds .cmd-intro { color: var(--text); margin: 4px 0 2px; }
