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

body {
  background: #000;
  overflow: hidden;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', monospace;
}

/* Curseur caché en plein écran */
body.in-fullscreen {
  cursor: none;
}

/* ── Canvas ─────────────────────────────────────────────────────── */
canvas {
  display: block;
  flex-shrink: 0;
}

/* ── Overlay (chargement / compte à rebours) ─────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: white;
  text-align: center;
  gap: 16px;
  transition: opacity 0.8s;
}

#status {
  font-size: clamp(0.75rem, 2.5vw, 1.1rem);
  text-shadow: 0 0 20px #00ccff;
  padding: 0.5rem 1.5rem;
  white-space: pre-line;
  transition: opacity 0.8s;
}

#count {
  font-size: clamp(3.5rem, 15vw, 7rem);
  font-weight: bold;
  line-height: 1;
  text-shadow: 0 0 40px #00ccff, 0 0 80px #0055ff;
}

/* ── Indicateur REC ──────────────────────────────────────────────── */
#rec-dot {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  left: max(1.2rem, env(safe-area-inset-left));
  display: none;
  align-items: center;
  gap: 6px;
  font-size: clamp(0.6rem, 2vw, 0.72rem);
  color: #ff3333;
  letter-spacing: 0.1em;
  pointer-events: none;
}

#rec-dot.active {
  display: flex;
}

#rec-dot .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff3333;
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.1; }
}

/* ── Barre de raccourcis clavier ─────────────────────────────────── */
#tip {
  position: fixed;
  bottom: 1.2rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(0.55rem, 1.5vw, 0.72rem);
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.04em;
  pointer-events: none;
  transition: opacity 0.8s;
  padding: 0 1rem;
}

/* ── Indicateur de pincement ─────────────────────────────────────── */
#pinch-dot {
  position: fixed;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  right: max(1.2rem, env(safe-area-inset-right));
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.25);
  pointer-events: none;
  transition: background 0.08s, box-shadow 0.08s;
}

#pinch-dot.active {
  background: #00ff88;
  box-shadow: 0 0 10px #00ff88, 0 0 20px #00cc66;
}

/* ── Mode UI caché (touche H) ────────────────────────────────────── */
body.ui-hidden #overlay,
body.ui-hidden #tip,
body.ui-hidden #rec-dot,
body.ui-hidden #pinch-dot {
  opacity: 0 !important;
  pointer-events: none;
}

/* ── Barre de boutons tactiles ───────────────────────────────────── */
#touch-bar {
  display: none;
  position: fixed;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  gap: clamp(0.3rem, 2vw, 0.6rem);
  z-index: 10;
  max-width: calc(100vw - 2rem);
  flex-wrap: wrap;
  justify-content: center;
}

body.touch #touch-bar {
  display: flex;
}

body.touch #tip {
  display: none;
}

#touch-bar button {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  font-family: 'Courier New', monospace;
  font-size: clamp(0.62rem, 2.5vw, 0.72rem);
  padding: clamp(0.4rem, 1.5vw, 0.55rem) clamp(0.6rem, 2.5vw, 1rem);
  border-radius: 2rem;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  touch-action: manipulation;
  user-select: none;
}

#touch-bar button:active {
  background: rgba(255,255,255,0.28);
}

#touch-bar button.active {
  background: rgba(255, 50, 50, 0.35);
  border-color: #ff3333;
  color: #ff9999;
}
