:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #2d333b;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4f8cff;
}

* { box-sizing: border-box; }

/* The .controls/.test-note display rules below would otherwise beat the
   hidden attribute's default display:none. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 700px at 50% -10%, #1b2330 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
}

/* Fixed-size frame: animals have different aspect ratios, so the canvas is
   letterboxed inside a constant box and the layout never shifts. */
.frame {
  position: relative;
  width: min(92vw, 520px);
  height: min(56vh, 540px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  background: var(--bg);
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

#cam {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 2px;
  height: 2px;
  object-fit: cover;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  line-height: 1.45;
  background: rgba(6, 9, 14, 0.72);
  backdrop-filter: blur(3px);
  transition: opacity 0.35s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.5px;
}

.overlay p {
  margin: 0;
  max-width: 34ch;
  color: var(--muted);
  font-size: 14px;
}

.status {
  min-height: 1.2em;
  color: #ff8b8b !important;
  font-size: 13px !important;
}

.loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(6, 9, 14, 0.78);
  backdrop-filter: blur(3px);
  line-height: 1.4;
}

.loader p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Stable widths so label changes ("On/Off", animal names, badge state)
   never move the buttons around. */
#puppet-btn { min-width: 10.5em; }
#mirror-btn { min-width: 7em; }
#fuckedup-btn { min-width: 8.5em; }
#snap-btn { min-width: 8em; }
#face-badge { min-width: 21em; text-align: center; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover { border-color: #444c56; }
.btn:active { transform: scale(0.97); }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: white;
  font-weight: 600;
  font-size: 16px;
  padding: 12px 26px;
}

.btn:disabled { opacity: 0.55; cursor: wait; }

.badge {
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  background: rgba(22, 27, 34, 0.7);
}

.badge.ok { color: #7ee2a8; border-color: #2ea04366; }
.badge.searching { color: #e3b341; border-color: #bb800966; }

.test-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
