:root {
  --bg: #070812;
  --panel: rgba(14, 18, 34, 0.78);
  --panel-strong: rgba(12, 17, 34, 0.94);
  --line: rgba(130, 245, 255, 0.17);
  --text: #f4fbff;
  --muted: #91a4b7;
  --cyan: #56f3ff;
  --pink: #ff4fd8;
  --green: #60ff9f;
  --yellow: #ffd166;
  --danger: #ff5d7a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top left, rgba(86, 243, 255, 0.22), transparent 30%),
    radial-gradient(circle at bottom right, rgba(255, 79, 216, 0.18), transparent 35%),
    var(--bg);
  color: var(--text);
}

body {
  overflow-x: hidden;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(86, 243, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(86, 243, 255, 0.07) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 88%);
}

.light-wash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 260ms ease, background 260ms ease;
  background: radial-gradient(circle at 50% 30%, rgba(255, 255, 210, 0.2), rgba(86, 243, 255, 0.08), transparent 62%);
  mix-blend-mode: screen;
}

.light-wash.on {
  opacity: 1;
}

.app-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 34px;
  display: grid;
  grid-template-columns: 0.82fr 1.18fr;
  gap: 20px;
}

.hero-panel,
.stage-panel,
.hud-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(14, 18, 34, 0.86), rgba(14, 18, 34, 0.58));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero-panel {
  border-radius: 30px;
  padding: 28px;
  min-height: 580px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 58px;
  height: 58px;
  filter: drop-shadow(0 0 18px rgba(86, 243, 255, 0.55));
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 5.2rem);
  line-height: 0.92;
  letter-spacing: -0.08em;
}

.hero-copy {
  margin: 34px 0 0;
  max-width: 520px;
  color: #cdd9e7;
  font-size: 1.04rem;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 26px 0;
}

.primary-btn,
.ghost-btn,
.tiny-btn,
.mode-chip {
  border-radius: 999px;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.primary-btn,
.ghost-btn {
  padding: 14px 18px;
  font-weight: 800;
}

.primary-btn {
  color: #051014;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 14px 40px rgba(86, 243, 255, 0.2);
}

.ghost-btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

.primary-btn:hover:not(:disabled),
.ghost-btn:hover:not(:disabled),
.tiny-btn:hover:not(:disabled),
.mode-chip:hover:not(:disabled) {
  transform: translateY(-2px);
}

.gesture-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-radius: 24px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.label,
.hud-card span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 800;
}

.gesture-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
}

.pulse-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 24px var(--danger);
}

.pulse-dot.live {
  background: var(--green);
  box-shadow: 0 0 28px var(--green);
  animation: breathe 1.2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(0.9); opacity: 0.72; }
  50% { transform: scale(1.16); opacity: 1; }
}

.mini-help {
  margin-top: 18px;
  padding: 16px;
  border-radius: 20px;
  color: #d6e6f2;
  background: rgba(86, 243, 255, 0.08);
  border: 1px solid rgba(86, 243, 255, 0.16);
  line-height: 1.55;
}

.mini-help strong {
  display: block;
  margin-bottom: 6px;
  color: var(--cyan);
}

.stage-panel {
  border-radius: 30px;
  padding: 16px;
}

.stage-topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.status-pill,
.tiny-btn {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #061015;
  background: var(--yellow);
  font-size: 0.82rem;
  font-weight: 900;
}

.status-pill.soft {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-pill.online {
  background: var(--green);
}

.tiny-btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.camera-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 24px;
  background: #02040a;
  border: 1px solid rgba(86, 243, 255, 0.18);
}

#inputVideo {
  display: none;
}

#outputCanvas,
#fxCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#fxCanvas {
  pointer-events: none;
}

.filter-normal #outputCanvas { filter: saturate(1.05) contrast(1.05); }
.filter-neon #outputCanvas { filter: saturate(1.9) contrast(1.24) hue-rotate(18deg); }
.filter-thermal #outputCanvas { filter: saturate(2.2) contrast(1.25) sepia(0.8) hue-rotate(-38deg); }
.filter-mono #outputCanvas { filter: grayscale(1) contrast(1.28) brightness(1.08); }
.filter-glitch #outputCanvas { filter: saturate(1.8) contrast(1.34) hue-rotate(145deg); }

.scanline {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image: repeating-linear-gradient(to bottom, transparent 0 8px, rgba(255, 255, 255, 0.5) 9px, transparent 10px);
  mix-blend-mode: overlay;
}

.clap-flash {
  position: absolute;
  inset: -12%;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.88), rgba(86, 243, 255, 0.22), transparent 58%);
}

.clap-flash.fire {
  animation: flash 420ms ease-out;
}

@keyframes flash {
  0% { opacity: 0.9; transform: scale(0.6); }
  100% { opacity: 0; transform: scale(1.25); }
}

.permission-cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(135deg, rgba(4, 7, 14, 0.86), rgba(18, 8, 30, 0.72));
  text-align: center;
  transition: opacity 240ms ease, visibility 240ms ease;
}

.permission-cover.hidden {
  opacity: 0;
  visibility: hidden;
}

.permission-inner {
  max-width: 390px;
}

.permission-inner h2 {
  margin: 18px 0 8px;
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.permission-inner p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.big-orb {
  display: inline-block;
  width: 94px;
  height: 94px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, white, var(--cyan) 35%, rgba(255, 79, 216, 0.56) 68%, transparent 70%);
  box-shadow: 0 0 46px rgba(86, 243, 255, 0.5);
}

.control-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
}

.mode-chip {
  color: var(--text);
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 800;
  font-size: 0.86rem;
}

.mode-chip.active {
  color: #061015;
  background: linear-gradient(135deg, var(--cyan), var(--pink));
  border-color: transparent;
  box-shadow: 0 10px 32px rgba(86, 243, 255, 0.18);
}

.hud-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

.hud-card {
  border-radius: 22px;
  padding: 16px;
}

.hud-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.4rem, 3vw, 2.15rem);
  letter-spacing: -0.04em;
}

.hud-card.wide {
  grid-column: span 1;
}

body.light-mode {
  --bg: #f4fbff;
  --panel: rgba(255, 255, 255, 0.74);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --line: rgba(0, 151, 170, 0.22);
  --text: #071018;
  --muted: #566776;
  background: radial-gradient(circle at top left, rgba(86, 243, 255, 0.32), transparent 32%),
    radial-gradient(circle at bottom right, rgba(255, 79, 216, 0.18), transparent 35%),
    var(--bg);
}

body.light-mode .hero-copy,
body.light-mode .mini-help,
body.light-mode .permission-inner p {
  color: #415160;
}

body.light-mode .ghost-btn,
body.light-mode .tiny-btn,
body.light-mode .mode-chip,
body.light-mode .status-pill.soft {
  color: #071018;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: auto;
  }

  .hud-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1220px);
    padding-top: 12px;
  }

  .hero-panel,
  .stage-panel {
    border-radius: 22px;
  }

  .hero-panel {
    padding: 20px;
  }

  .camera-frame {
    aspect-ratio: 4 / 5;
  }

  .hud-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stage-topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
