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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body.strobing {
  cursor: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

#screen-strobe.active {
  display: block;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ── Intro / Done panels ── */
.panel {
  max-width: 440px;
  padding: 2rem 1.5rem;
  text-align: center;
}

.panel h1 {
  font-size: 1.85rem;
  margin-bottom: 0.75rem;
}

.lead {
  font-size: 1.05rem;
  margin-bottom: 1rem;
  line-height: 1.55;
  opacity: 0.92;
}

.panel p {
  margin-bottom: 0.65rem;
  line-height: 1.5;
  opacity: 0.82;
  font-size: 0.95rem;
}

.muted {
  opacity: 0.5 !important;
  font-size: 0.85rem !important;
}

.steps {
  text-align: left;
  margin: 1.25rem 0;
  padding-left: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.6;
  opacity: 0.9;
}

.steps li {
  margin-bottom: 0.5rem;
}

.back {
  display: inline-block;
  margin-bottom: 1.25rem;
  color: #777;
  text-decoration: none;
  font-size: 0.88rem;
}

.back:hover { color: #bbb; }

.warning {
  margin: 1.25rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid #755;
  border-radius: 10px;
  background: rgba(90, 60, 0, 0.22);
  text-align: left;
  font-size: 0.88rem;
}

.warning strong {
  display: block;
  margin-bottom: 0.3rem;
  color: #fca;
}

.sound-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0 0.5rem;
  font-size: 0.88rem;
  opacity: 0.75;
  cursor: pointer;
}

.color-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin: 0.75rem 0 1rem;
  font-size: 0.88rem;
  opacity: 0.75;
}

.color-opt select {
  width: 100%;
  max-width: 280px;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  background: #1a1a24;
  color: #eee;
  border: 1px solid #333;
  border-radius: 8px;
  cursor: pointer;
}

button {
  margin-top: 0.75rem;
  padding: 0.9rem 2.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #000;
  background: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

button:hover { opacity: 0.88; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
}

.btn-link {
  color: #777;
  font-size: 0.88rem;
  text-decoration: none;
}

.btn-link:hover { color: #aaa; }

/* ── Ready countdown ── */
.ready-box {
  text-align: center;
}

.ready-label {
  font-size: 1.1rem;
  opacity: 0.7;
  margin-bottom: 0.5rem;
}

.ready-num {
  display: block;
  font-size: 6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ready-hint {
  margin-top: 1rem;
  opacity: 0.55;
  font-size: 0.95rem;
}

/* ── Fixation point + progress ring ── */
#fixation {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  pointer-events: none;
  z-index: 10;
}

#progress-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(#e74 0deg, transparent 0deg);
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
  opacity: 0.85;
}

#fixation-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f33;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.6), 0 0 8px rgba(255,50,50,0.5);
}

#phase-hint {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.88rem;
  opacity: 0.55;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}

#phase-hint.urgent {
  opacity: 1;
  font-size: 1rem;
  font-weight: 600;
  color: #faa;
}

/* ── Done flash overlay ── */
#flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.15s;
}

#flash.active {
  opacity: 1;
}

.done-panel {
  position: relative;
  z-index: 101;
}

@media (prefers-reduced-motion: reduce) {
  button#btn-start {
    opacity: 0.45;
    pointer-events: none;
  }
  .warning p::after {
    content: " (Movimiento reducido activo en tu dispositivo)";
  }
}
