@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

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

:root {
  --col-left: #00ffcc;
  --col-right: #ff3cac;
  --col-accent: #7b2fff;
  --col-accent2: #4a90e2;
  --bg: #050510;
  --card-bg: rgba(10, 8, 28, 0.96);
  --card-border: rgba(123, 47, 255, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Orbitron', monospace;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* ── Canvas & Video ──────────────────────────────────── */
#video {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0;
  pointer-events: none;
}

#canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

/* ── HUD Buttons ─────────────────────────────────────── */
.hud-btn {
  position: fixed;
  width: 44px; height: 44px;
  background: rgba(10, 8, 28, 0.75);
  border: 1.5px solid rgba(123, 47, 255, 0.45);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.1s;
  z-index: 50;
  padding: 0;
  touch-action: manipulation;
}

.hud-btn svg { width: 18px; height: 18px; }

.hud-btn:hover, .hud-btn:active {
  background: rgba(123, 47, 255, 0.3);
  border-color: var(--col-accent);
  color: #fff;
  transform: scale(1.08);
}

#btn-fullscreen {
  top: calc(14px + var(--safe-top));
  right: calc(14px + var(--safe-right));
}

.hud-btn-mode {
  top: calc(68px + var(--safe-top));
  right: calc(14px + var(--safe-right));
}

.hud-btn-mode.cam-active {
  border-color: var(--col-left);
  color: var(--col-left);
  box-shadow: 0 0 12px rgba(0, 255, 204, 0.4);
}

.hidden { display: none !important; }

/* ── Hand indicators ─────────────────────────────────── */
.hand-indicator {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  opacity: 0.22;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 40;
}

.hand-indicator.left  { left: calc(10px + var(--safe-left)); }
.hand-indicator.right { right: calc(10px + var(--safe-right)); }
.hand-indicator.active { opacity: 1; }

.hand-icon {
  font-size: clamp(20px, 4vw, 28px);
  filter: drop-shadow(0 0 8px currentColor);
}

.hand-label {
  font-size: clamp(7px, 1.5vw, 10px);
  font-weight: 700;
  letter-spacing: 2px;
}

.hand-indicator.left  .hand-icon,
.hand-indicator.left  .hand-label { color: var(--col-left);  text-shadow: 0 0 8px var(--col-left); }
.hand-indicator.right .hand-icon,
.hand-indicator.right .hand-label { color: var(--col-right); text-shadow: 0 0 8px var(--col-right); }

/* ── Rotate warning ──────────────────────────────────── */
#rotate-warning {
  display: none;
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 9999;
  align-items: center; justify-content: center;
  flex-direction: column;
}

.rotate-inner {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}

.rotate-icon {
  font-size: 64px;
  animation: spin90 1.4s ease-in-out infinite alternate;
  color: var(--col-accent);
  text-shadow: 0 0 30px var(--col-accent);
}

@keyframes spin90 {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-90deg); }
}

.rotate-title {
  font-size: 20px; font-weight: 700; letter-spacing: 4px; color: #fff;
  text-shadow: 0 0 20px rgba(123,47,255,0.7);
}

.rotate-sub {
  font-size: 11px; letter-spacing: 2px; color: rgba(255,255,255,0.45);
}

/* Show only in portrait on small devices */
@media (orientation: portrait) and (max-width: 768px) {
  #rotate-warning { display: flex; }
}

/* ── Shared overlay card styles ──────────────────────── */
.prompt-card, .picker-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: clamp(24px, 5vw, 44px);
  box-shadow: 0 0 60px rgba(123, 47, 255, 0.15), 0 8px 32px rgba(0,0,0,0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  max-width: min(480px, 90vw);
  width: 100%;
  text-align: center;
}

/* ── Camera permission ───────────────────────────────── */
#cam-prompt {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 5, 16, 0.97);
  transition: opacity 0.4s;
}

#cam-prompt.hiding { opacity: 0; pointer-events: none; }

.prompt-logo {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 20px; gap: 0;
  line-height: 1;
}

.logo-m {
  font-size: clamp(32px, 8vw, 52px);
  font-weight: 900; letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 0 40px rgba(123,47,255,0.8);
}

.logo-p {
  font-size: clamp(44px, 11vw, 72px);
  font-weight: 900; letter-spacing: 8px;
  color: var(--col-right);
  text-shadow: 0 0 40px var(--col-right);
  margin-top: -8px;
}

.prompt-tagline {
  font-size: clamp(8px, 1.8vw, 11px);
  letter-spacing: 3px; color: rgba(255,255,255,0.4);
  margin-bottom: 20px;
}

.prompt-body {
  font-size: clamp(11px, 2.2vw, 13px);
  color: rgba(255,255,255,0.55);
  line-height: 1.9; margin-bottom: 32px;
  font-family: system-ui, sans-serif;
  font-weight: 400;
}

#cam-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 15px 36px;
  background: transparent;
  border: 2px solid var(--col-accent);
  border-radius: 8px;
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-size: clamp(11px, 2.5vw, 14px);
  font-weight: 700; letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(123,47,255,0.4), inset 0 0 24px rgba(123,47,255,0.08);
  transition: box-shadow 0.2s, background 0.2s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#cam-btn:hover, #cam-btn:active {
  background: rgba(123, 47, 255, 0.2);
  box-shadow: 0 0 40px rgba(123,47,255,0.7), inset 0 0 30px rgba(123,47,255,0.15);
  transform: scale(1.03);
}

/* ── Mode picker ─────────────────────────────────────── */
#mode-picker {
  position: fixed; inset: 0; z-index: 190;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 5, 16, 0.94);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.35s;
}

#mode-picker.hiding { opacity: 0; pointer-events: none; }

.picker-card { max-width: min(540px, 92vw); }

.picker-title {
  font-size: clamp(13px, 3vw, 17px);
  font-weight: 700; letter-spacing: 4px;
  color: rgba(255,255,255,0.85);
  margin-bottom: 28px;
}

.mode-options {
  display: flex; flex-direction: column; gap: 14px;
  margin-bottom: 22px;
}

@media (min-width: 500px) and (orientation: landscape) {
  .mode-options { flex-direction: row; }
}

.mode-card {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 18px 16px 16px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
  position: relative;
  transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mode-card:hover, .mode-card:active {
  transform: translateY(-2px);
}

#mode-camera:hover, #mode-camera:active {
  border-color: var(--col-left);
  background: rgba(0, 255, 204, 0.06);
  box-shadow: 0 0 24px rgba(0,255,204,0.15);
}

#mode-classic:hover, #mode-classic:active {
  border-color: var(--col-accent);
  background: rgba(123, 47, 255, 0.08);
  box-shadow: 0 0 24px rgba(123,47,255,0.18);
}

.mode-preview {
  width: 100%; height: 70px;
  border-radius: 8px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

.mode-preview--cam {
  background: linear-gradient(135deg, #0a0818 0%, #0d1a14 100%);
  border: 1px solid rgba(0,255,204,0.2);
}

.mode-preview--classic {
  background: #050510;
  border: 1px solid rgba(123,47,255,0.2);
}

.mode-info {
  display: flex; flex-direction: column; gap: 5px;
}

.mode-name {
  font-size: clamp(11px, 2.5vw, 13px);
  font-weight: 700; letter-spacing: 3px;
  color: #fff;
}

.mode-desc {
  font-size: clamp(9px, 1.8vw, 11px);
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.5px;
  font-family: system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.4;
}

.mode-badge {
  font-size: 9px; letter-spacing: 2px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
  background: rgba(0,255,204,0.12);
  color: var(--col-left);
  border: 1px solid rgba(0,255,204,0.25);
}

.mode-badge--alt {
  background: rgba(123,47,255,0.12);
  color: #b980ff;
  border-color: rgba(123,47,255,0.3);
}

.picker-hint {
  font-size: clamp(9px, 1.8vw, 11px);
  color: rgba(255,255,255,0.3);
  letter-spacing: 1px;
  font-family: system-ui, sans-serif;
  font-weight: 400;
}

/* ── Debug ───────────────────────────────────────────── */
#debug {
  position: fixed;
  bottom: calc(10px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 1px;
  color: rgba(255,255,255,0.25);
  display: none; z-index: 60;
  white-space: nowrap;
}
