/* ============================================================
   AMANE LETRAS — Estilos
   ============================================================ */

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

:root {
  /* Respaldo por si game.json no carga. Lo normal es que juego-comun.js
     los reescriba con el color de la tarjeta del juego en el selector.
     Nombres neutros porque aquí puede acabar cualquier tono. */
  --acento:        #e91e8c;
  --acento-claro: #f0d0e8;
  --acento-suave:  #fce4ec;
  --acento-fuerte: #c2176e;
  --acento-medio:    #f48fb1;
  --bg:          #fff5f9;
  --card:        #ffffff;
  --text:        #3a1a2e;
  --correct-bg:  #e8f5e9;
  --correct-bd:  #66bb6a;
  --wrong-bg:    #ffebee;
  --wrong-bd:    #ef5350;
  --shadow:      0 6px 24px rgba(233,30,140,0.15);
  --radius:      20px;
}

/* Las opciones son un hiragana suelto, así que se agrandan: lo de serie
   está calculado para juegos que meten "murcielago" en un botón. Las
   clases len-* que pone game.js siguen mandando por encima, así que una
   opción larga se encoge igual.

   AQUÍ NO VA UN `--tam-elemento`, Y NO ES UN OLVIDO. Lo hubo —
   `min(52cqh, 55cqw)`, con un comentario que decía «aquí lo que se enseña
   es UNA letra»—, y ese supuesto ya era falso al escribirlo: la última
   fase de este juego son PALABRAS, de "mama" a "botella". La cáscara
   dimensiona por longitud con su tabla `data-largo`, pero la escribe en
   `--auto-tam`, que es sólo el RESPALDO de `--tam-elemento`:

       font-size: var(--tam-elemento, var(--auto-tam, min(30cqh, 24cqw)));

   O sea que fijar `--tam-elemento` no ajusta el tamaño: APAGA el ajuste.
   Toda palabra de 4 letras o más se pintaba al cuerpo de una letra suelta
   —201px en un iPhone, 339px en un iPad— y se partía en dos o tres
   líneas, con la última cayendo por detrás de los botones. Lo avisó un
   padre el 29 de agosto de 2026, y llevaba roto desde que el juego tiene
   fase de palabras. En horizontal no se veía: ahí sobra ancho.

   Quitarlo no encoge nada de lo que decía proteger, y eso está medido con
   estas hojas: una letra suelta sale EXACTAMENTE igual (201px en iPhone,
   339px en iPad, 123px tumbado), porque la fila `data-largo="1"` de la
   tabla es justo `min(52cqh, 55cqw)`. Era redundante para su caso y
   destructivo para el resto.

   Si algún día hay que agrandar algo de aquí, la perilla es esa tabla, o
   una clase len-* puesta desde game.js —como hace minusculas-mayusculas—,
   nunca este atajo. */
:root {
  --tam-opcion:   clamp(2rem, 9.5vw, 3.6rem);
}


body {
  font-family: 'Nunito', 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(24px, 4vh) 16px 32px;
}

#app {
  width: 100%;
  max-width: 560px;
  position: relative;
}

/* ── GAME SCREEN ─────────────────────────────────────────── */
#game-screen {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
header {
  text-align: center;
}

h1 {
  font-size: 2rem;
  font-weight: 900;
  color: var(--acento);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

#level-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#phase-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #999;
  font-weight: 700;
}

#level-row {
  width: 100%;
  max-width: 320px;
}

#level-text {
  display: block;
  text-align: center;
  font-size: 0.88rem;
  color: #777;
  margin-bottom: 5px;
}

#level-bar-bg {
  background: var(--acento-suave);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}

#level-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--acento-medio), var(--acento));
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(.34,1.56,.64,1);
}

#accuracy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

#accuracy-bar-bg {
  flex: 1;
  background: #f0f0f0;
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}

#accuracy-bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: #ccc;
  transition: width 0.5s ease, background 0.5s ease;
}

#accuracy-pct {
  font-size: 0.72rem;
  color: #bbb;
  font-weight: 700;
  min-width: 2.8em;
  text-align: right;
}

/* Element card */
#element-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 44px 24px 36px;
  text-align: center;
  position: relative;
}

#element-text {
  font-size: 5.5rem;
  font-weight: 900;
  color: var(--acento);
  line-height: 1.1;
  user-select: none;
  transition: transform 0.2s;
}

#element-text.pop {
  animation: pop 0.35s ease-out;
}

@keyframes pop {
  0%   { transform: scale(0.4); opacity: 0; }
  70%  { transform: scale(1.12); }
  100% { transform: scale(1);   opacity: 1; }
}

#audio-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background: var(--acento-suave);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  display: none; /* oculto mientras la voz esté deshabilitada en código */
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
}

#audio-btn:hover  { background: var(--acento-suave); transform: scale(1.15); }
#audio-btn:active { transform: scale(0.95); }

/* Options grid */
#options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

.option-btn {
  background: var(--card);
  border: 3px solid var(--acento-suave);
  border-radius: 16px;
  font-size: 2.8rem;
  font-family: 'Hiragino Sans', 'Meiryo', sans-serif;
  padding: 22px 12px;
  cursor: pointer;
  min-height: 90px;
  transition: border-color 0.15s, background 0.15s, transform 0.12s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(233,30,140,0.07);
  user-select: none;
  line-height: 1;
}

@media (hover: hover) {
  .option-btn:hover:not(.disabled) {
    background: var(--bg);
    border-color: var(--acento-medio);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(233,30,140,0.15);
  }
}

.option-btn:active:not(.disabled) {
  transform: translateY(1px);
}

.option-btn.correct {
  background: var(--correct-bg);
  border-color: var(--correct-bd);
  animation: correct-flash 0.35s ease-out;
}

@keyframes correct-flash {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.option-btn.wrong {
  background: var(--wrong-bg);
  border-color: var(--wrong-bd);
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-7px); }
  40%     { transform: translateX(7px); }
  60%     { transform: translateX(-5px); }
  80%     { transform: translateX(5px); }
}

.option-btn.disabled {
  cursor: default;
  pointer-events: none;
}

.option-btn.disabled:not(.correct):not(.wrong) {
  opacity: 0.35;
}

/* Feedback */
#feedback {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  min-height: 1.8em;
  transition: opacity 0.2s;
}

.fb-correct { color: #2e7d32; }
.fb-wrong   { color: #c62828; }

/* ── OVERLAYS ─────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 240, 250, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.overlay.hidden { display: none; }

/* Video screen */
#video-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 680px;
  text-align: center;
}

#video-box h2 {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--acento);
}

#youtube-player {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
}

#youtube-player iframe {
  width: 100% !important;
  height: 100% !important;
  display: block;
}


/* Shared buttons */
#skip-btn {
  background: var(--acento);
  color: #fff;
  border: none;
  border-radius: 99px;
  padding: 14px 38px;
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  box-shadow: 0 4px 14px rgba(233,30,140,0.3);
}

#skip-btn:hover {
  background: var(--acento);
  transform: scale(1.04);
}

#skip-btn:active {
  transform: scale(0.97);
}

/* ── RESPONSIVE ───────────────────────────────────────────── */

/* iPad (768 px+) */
@media (min-width: 768px) {
  body           { padding: max(40px, 6vh) 32px 40px; }
  #app           { max-width: 660px; }
  h1             { font-size: 2.4rem; }
  #game-screen   { gap: 32px; }
  #element-card  { padding: 56px 40px 48px; }
  #element-text  { font-size: 7rem; }
  #options-grid  { gap: 20px; margin-top: 12px; }
  .option-btn    { font-size: 3.2rem; min-height: 110px; padding: 28px 16px; }
  #feedback      { font-size: 1.3rem; }
  #level-row     { max-width: 400px; }
  #accuracy-row  { max-width: 400px; }
}

/* iPhone pequeño */
@media (max-width: 420px) {
  h1               { font-size: 1.5rem; }
  #element-text    { font-size: 4rem; }
  .option-btn      { font-size: 2.2rem; padding: 16px 8px; min-height: 78px; }
  #video-box h2    { font-size: 1.3rem; }
}
