*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --green:   #00e676;
  --yellow:  #FFD600;
  --red:     #FF5252;
  --white:   #ffffff;
  --radius:  14px;
}

html, body {
  height: 100%; width: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── VIDEO + CANVAS ── */
#video {
  display: none; /* canvas dibuja el frame espejado */
}

#canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

/* ── STATUS BADGE ── */
.status-badge {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.15);
  white-space: nowrap;
  transition: background 0.4s, color 0.4s;
}
#status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.4s;
}

/* Estados del badge */
.status-badge.searching {
  background: rgba(30,30,30,0.75);
  color: #aaa;
}
.status-badge.searching #status-dot {
  background: #555;
  animation: pulse 1.8s infinite;
}
.status-badge.adjusting {
  background: rgba(60,50,0,0.80);
  color: var(--yellow);
}
.status-badge.adjusting #status-dot {
  background: var(--yellow);
  animation: pulse 1s infinite;
}
.status-badge.ready {
  background: rgba(0,60,20,0.80);
  color: var(--green);
}
.status-badge.ready #status-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.85); }
}

/* ── PANEL INFERIOR ── */
#bottom-ui {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  padding: 12px 20px calc(18px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(0,0,0,0.88) 0%, transparent 100%);
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Selector horizontal */
#team-strip-wrap {
  flex: 1;
  overflow: hidden;
}
#team-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 2px;
}
#team-strip::-webkit-scrollbar { display: none; }

.team-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 99px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.12s;
}
.team-btn:active { transform: scale(0.95); }
.team-btn.active {
  background: rgba(0,230,118,0.2);
  border-color: var(--green);
}
.team-btn-flag  { font-size: 20px; line-height: 1; }
.team-btn-name  { font-size: 12px; font-weight: 700; color: #fff; }

/* Botón captura circular */
#btn-capture {
  flex-shrink: 0;
  position: relative;
  width: 68px; height: 68px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s;
}
#btn-capture:active { transform: scale(0.92); }
#btn-capture:disabled { opacity: 0.4; cursor: not-allowed; }

.capture-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 3px solid var(--white);
  transition: border-color 0.3s;
}
#btn-capture:not(:disabled) .capture-ring {
  border-color: var(--green);
  box-shadow: 0 0 14px rgba(0,230,118,0.5);
}
.capture-inner {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

/* ── ERROR CÁMARA ── */
#camera-error {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}
.error-card {
  background: #1a1a1a;
  border-radius: 20px;
  padding: 36px 28px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  border: 1px solid rgba(255,255,255,0.08);
}
.error-icon { font-size: 48px; margin-bottom: 14px; }
.error-card h2 { color: #fff; font-size: 18px; margin-bottom: 10px; }
.error-card p  { color: #888; font-size: 13px; line-height: 1.6; margin-bottom: 20px; }
.error-card button {
  background: var(--green); color: #000;
  border: none; border-radius: 12px;
  padding: 14px 28px; font-size: 15px; font-weight: 700;
  cursor: pointer; width: 100%;
}

/* ── PANTALLA DE FOTO ── */
#photo-screen {
  position: fixed; inset: 0;
  background: #000;
  display: none;
  flex-direction: column;
  z-index: 60;
}
#photo-screen.active { display: flex; }

#photo-topbar {
  padding: 16px 20px calc(10px + env(safe-area-inset-top, 0px));
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 16px;
  background: #111;
  border-bottom: 1px solid #222;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
#btn-retake {
  background: none; border: none; color: #888;
  font-size: 14px; font-weight: 600; cursor: pointer;
}

#photo-img-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  overflow: hidden;
}
#photo-preview {
  max-width: 100%; max-height: 100%;
  border-radius: 14px;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
#photo-actions {
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
}
.btn-green {
  width: 100%;
  padding: 16px;
  background: var(--green);
  color: #000;
  border: none; border-radius: 14px;
  font-size: 16px; font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s;
}
.btn-green:active { transform: scale(0.97); }

/* ── LOADER ── */
#loader {
  position: fixed; inset: 0;
  background: #0a0a0a;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  transition: opacity 0.5s, visibility 0.5s;
}
#loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-inner {
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  padding: 24px;
}
.loader-spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-title { font-size: 24px; font-weight: 900; color: #fff; letter-spacing: -0.02em; }
.loader-sub   { font-size: 13px; color: #666; }
.loader-track {
  width: 180px; height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px; overflow: hidden;
}
#loader-bar {
  height: 100%; width: 0%;
  background: var(--green);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── FLASH DE FOTO ── */
.flash {
  position: fixed; inset: 0;
  background: #fff;
  z-index: 200;
  animation: flash-anim 0.35s ease-out forwards;
  pointer-events: none;
}
@keyframes flash-anim {
  0%   { opacity: 0.9; }
  100% { opacity: 0; }
}

/* ── UTILS ── */
.hidden { display: none !important; }
