/* ========================================================
   VIOLÍN CON PIANO - PLAY ESCOLA DE MÚSICA
   ======================================================== */

:root {
  /* Movimiento */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-press: 140ms;
  --dur-ui: 240ms;
  /* Tonos para texto o fondos con texto blanco: cumplen contraste WCAG AA (4.5:1) */
  --orange-ink: #9a3f1c;
  --theme-ink: #9a3f1c;
  --ok-ink: #15803d;
  --correct-ink: #15803d;
  --orange: #a8502a;
  --orange-dark: #7a3214;
  --orange-soft: #f8ece4;
  --ink: #1d1410;
  --muted: #6a564c;
  --line: #ecdcd2;
  --ok: #16a34a;
  --ok-soft: #e7f6ec;
  --ko: #dc2626;
  --ko-soft: #fdecec;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 10px 30px rgba(120, 50, 10, 0.12);
  --shadow-sm: 0 3px 10px rgba(120, 50, 10, 0.12);
  --font: "Outfit", "Outfit Local", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--orange);
  color: #ffffff;
  font-family: var(--font);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  outline: none;
}

button:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

.icon {
  width: 1.15em; height: 1.15em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}

.app { position: relative; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- Pantallas ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: scale(0.985);
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out), visibility 0s linear 0.25s;
}

.screen.active {
  opacity: 1; visibility: visible; pointer-events: auto; transform: scale(1);
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out), visibility 0s;
}

/* ---------- Botones ---------- */
.btn {
  min-height: 58px; padding: 0 24px; border-radius: 16px;
  font-size: clamp(17px, 2vw, 21px); font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 0.12s, filter 0.2s, opacity 0.2s;
}

.btn:not(:disabled):active { transform: scale(0.97); }
.btn-primary { background: var(--orange-ink); color: #ffffff; box-shadow: var(--shadow-sm); }
.btn-secondary { background: #ffffff; color: var(--orange-dark); box-shadow: inset 0 0 0 2.5px var(--orange); }
.btn-dark { background: var(--ink); color: #ffffff; box-shadow: var(--shadow-sm); }

.pill, .pill-btn {
  height: 38px; padding: 0 14px; border-radius: 19px;
  font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  color: #ffffff; font-variant-numeric: tabular-nums;
}

.pill { background: rgba(0, 0, 0, 0.18); }
.pill-btn { background: rgba(0, 0, 0, 0.2); border: 1.5px solid rgba(255, 255, 255, 0.55); }
.pill-btn:active { transform: scale(0.95); }
.score-ok { background: var(--ok-ink); }
.score-ko { background: var(--ko); }

.menu-link {
  position: absolute; top: calc(14px + var(--safe-top)); left: 16px;
  height: 38px; padding: 0 14px; border-radius: 19px;
  display: inline-flex; align-items: center; gap: 6px;
  color: #ffffff; font-size: 14px; font-weight: 700; text-decoration: none;
  background: rgba(0, 0, 0, 0.2); border: 1.5px solid rgba(255, 255, 255, 0.55);
  z-index: 5;
}

/* ---------- Pantalla 1: preparar ---------- */
.screen-setup {
  justify-content: safe center;
  gap: clamp(14px, 3vh, 26px);
  padding: calc(20px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  overflow-y: auto;
}

.brand-bar { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; }
.brand-logo { width: clamp(150px, 22vw, 230px); height: auto; display: block; }
.brand-title { font-size: clamp(30px, 5vw, 48px); font-weight: 900; letter-spacing: -1px; line-height: 1; }

.setup-card {
  width: 100%; max-width: 640px;
  background: #ffffff; color: var(--ink);
  border-radius: 24px; padding: clamp(18px, 3vw, 30px);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px; flex: none;
}

.setup-row { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.label { font-size: 14px; font-weight: 700; color: var(--muted); letter-spacing: 0.2px; }
.note { font-size: 14px; font-weight: 600; color: var(--muted); line-height: 1.4; }

.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px;
  border-radius: 16px; background: var(--orange-soft);
}

.segmented.seg-3 { grid-template-columns: repeat(3, 1fr); }
.segmented.seg-4 { grid-template-columns: repeat(4, 1fr); }

.seg-btn {
  min-height: 50px; padding: 4px 6px; border-radius: 12px;
  font-size: 17px; font-weight: 800; color: var(--orange-dark);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.1; text-align: center;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.seg-btn small { font-size: 12px; font-weight: 600; opacity: 0.8; }
.seg-btn.seg-big { font-size: 22px; font-variant-numeric: tabular-nums; }
.seg-btn.on { background: #ffffff; color: var(--orange-ink); box-shadow: var(--shadow-sm); }

#btn-start { margin-top: 4px; }

/* ---------- Pantalla 1: extras ---------- */
.intro { font-size: 17px; font-weight: 700; line-height: 1.35; }
.best { min-height: 1.2em; font-size: 15px; font-weight: 800; color: var(--orange-dark); }
.best:empty { display: none; }

/* ---------- Pantalla 2: juego ---------- */
.screen-play { padding: var(--safe-top) 0 var(--safe-bottom); }

.play-bar {
  width: 100%; height: 64px; padding: 0 16px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; flex: none;
}

.bar-left { display: flex; justify-content: flex-start; }
.bar-right { display: flex; justify-content: flex-end; }

.score-pill { font-size: 20px; font-weight: 900; padding: 0 18px; }
.score-pill small { font-size: 13px; font-weight: 700; opacity: 0.85; }

.pause-card { display: grid; gap: 12px; justify-items: center; }
.btn[hidden], .pill-btn[hidden] { display: none; }

@media (max-width: 600px) {
  /* Auditoría 12/11: en móvil «Velocidad» y «Cómo se toca» no caben juntas: una debajo de otra */
  .setup-grid { grid-template-columns: 1fr; gap: 12px; }
  .pill, .pill-btn { height: 34px; padding: 0 10px; font-size: 13px; }
  .score-pill { font-size: 17px; }
}

/* ---------- Pantalla 3: resultados ---------- */
.results-modal {
  background: rgba(40, 15, 0, 0.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  justify-content: center; padding: 16px; z-index: 100;
}

.results-card {
  width: 100%; max-width: 460px;
  background: #ffffff; color: var(--ink);
  border-radius: 24px; padding: 30px 26px 24px;
  text-align: center; box-shadow: 0 20px 50px rgba(40, 15, 0, 0.35);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}

.stars { display: flex; gap: 8px; margin-bottom: 4px; }
.star { width: 52px; height: 52px; fill: var(--line); }
.star.on { fill: #f5b301; }
.results-title { font-size: 32px; font-weight: 900; letter-spacing: -0.5px; color: var(--orange-ink); }
.results-score { font-size: 56px; font-weight: 900; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.results-score small { font-size: 18px; color: var(--muted); }
.results-best { font-size: 16px; font-weight: 800; color: var(--muted); }
.results-best.is-record { color: var(--ok-ink); font-size: 20px; }
.results-sub { font-size: 18px; font-weight: 600; color: var(--muted); }
.results-actions { width: 100%; display: grid; gap: 10px; margin-top: 12px; }


/* ---------- Revisión de accesibilidad ---------- */
/* Zonas táctiles de al menos 44 × 44 px */
.pill-btn, .menu-link { min-height: 44px; }
.step-btn { min-width: 44px; min-height: 44px; }
/* Foco visible también en enlaces */
a:focus-visible { outline: 3px solid #1d1410; outline-offset: 3px; }
.pill .icon-inline { width: 1em; height: 1em; }

/* ---------- Movimiento ----------
   Criterios: solo transform y opacity, curvas ease-out fuertes, interfaz por debajo de 300 ms,
   las salidas más rápidas que las entradas y escalonados de 40 ms en grupos. */
.screen {
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out), visibility 0s linear 160ms;
}
.screen.active {
  transition: opacity var(--dur-ui) var(--ease-out), transform var(--dur-ui) var(--ease-out), visibility 0s;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes correct-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

@keyframes wrong-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* Entrada de la tarjeta de opciones al abrir cada pantalla */
.screen.active .setup-card > * { animation: rise 280ms var(--ease-out) both; }
.screen.active .setup-card > :nth-child(2) { animation-delay: 40ms; }
.screen.active .setup-card > :nth-child(3) { animation-delay: 80ms; }
.screen.active .setup-card > :nth-child(4) { animation-delay: 120ms; }
.screen.active .setup-card > :nth-child(5) { animation-delay: 160ms; }
.screen.active .setup-card > :nth-child(n+6) { animation-delay: 200ms; }

/* Opciones de respuesta: aparecen escalonadas en cada pregunta */
.options > *, .options-grid > *, .def-answers > .action-btn {
  animation: rise 260ms var(--ease-out) both;
}
.options > :nth-child(2), .options-grid > :nth-child(2) { animation-delay: 40ms; }
.options > :nth-child(3), .options-grid > :nth-child(3) { animation-delay: 80ms; }
.options > :nth-child(4), .options-grid > :nth-child(4), .def-answers > .action-btn { animation-delay: 120ms; }

/* Respuesta correcta o incorrecta: respuesta breve y física */
.option.is-correct, .option-btn.is-correct, .choice.is-correct { animation: correct-pop 260ms var(--ease-out); }
.option.is-wrong, .option-btn.is-wrong, .choice.is-wrong { animation: wrong-shake 300ms var(--ease-in-out); }

/* Ventanas y resultados */
.results-modal.active .results-card, .modal:not([hidden]) .modal-card { animation: card-in 280ms var(--ease-out) both; }

/* Pulsación: respuesta inmediata al tocar */
.btn, .seg-btn, .chip, .pill-btn, .listen-btn, .reveal-btn, .step-btn, .menu-link {
  transition-property: transform, background-color, color, box-shadow, opacity, filter, border-color;
  transition-duration: var(--dur-press);
  transition-timing-function: var(--ease-out);
}
.btn:not(:disabled):active, .seg-btn:not(:disabled):active, .chip:not(:disabled):active,
.pill-btn:not(:disabled):active, .listen-btn:not(:disabled):active, .reveal-btn:active,
.step-btn:not(:disabled):active, .menu-link:active { transform: scale(0.97); }

/* Accesibilidad: con «reducir movimiento» se quitan desplazamientos y se mantienen los fundidos */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .screen, .screen.active { transform: none !important; }
}

