/* Pantalla completa, sin scroll: pensado para 1920×1080 en Fire TV. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
body * {
  touch-action: pan-x pan-y;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #070b16;
  color: #f4f7ff;
  font-family: "Segoe UI", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body:focus {
  outline: none;
}

body {
  /* Night mode suave: centro un poco más claro, bordes oscuros. */
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, #1a2744 0%, rgba(26, 39, 68, 0) 70%),
    radial-gradient(ellipse 120% 90% at 50% 100%, #12182b 0%, #070b16 72%);
}

/* Estrellas fijas de fondo, solo CSS, para que la pantalla no esté vacía. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, rgba(255, 255, 255, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 68%, rgba(255, 255, 255, 0.35) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 46% 18%, rgba(255, 255, 255, 0.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 42%, rgba(255, 255, 255, 0.3) 50%, transparent 51%),
    radial-gradient(2px 2px at 74% 76%, rgba(255, 255, 255, 0.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 28%, rgba(255, 255, 255, 0.35) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 18% 84%, rgba(255, 255, 255, 0.28) 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 88%, rgba(255, 255, 255, 0.32) 50%, transparent 51%);
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: 8vh;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: min(40rem, 92vw);
  margin: 0;
  padding: 0.7rem 1.2rem;
  border-radius: 1.2rem;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(244, 247, 255, 0.72);
  font-size: clamp(1.05rem, 2.4vw, 2rem);
  letter-spacing: 0.02em;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.hint-sub {
  font-size: 0.62em;
  line-height: 1.35;
  color: rgba(244, 247, 255, 0.5);
}

.hint.is-hidden {
  opacity: 0;
}

/* Figura instanciada en cada pulsación. El JS fija posición, tamaño y color. */
.burst {
  position: absolute;
  width: var(--size);
  height: var(--size);
  margin: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  will-change: transform, opacity;
  animation: pop-fade var(--life, 2.6s) ease-out forwards;
}

.burst.shape {
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.82), var(--color) 46%);
  box-shadow: 0 0 28px var(--color);
}

.burst.circle {
  border-radius: 50%;
}

.burst.square {
  border-radius: 18%;
}

.burst.triangle {
  /* El degradado se recorta con la misma silueta. */
  clip-path: polygon(50% 6%, 96% 94%, 4% 94%);
}

.burst.star {
  clip-path: polygon(
    50% 0%,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
}

.burst.emoji {
  font-size: calc(var(--size) * 0.86);
  line-height: 1;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
}

/* La sorpresa: una cara que se sacude más que el resto. */
.burst.silly {
  z-index: 2;
  font-size: calc(var(--size) * 0.94);
  animation-name: silly-pop;
}

/* El nombre ocupa más ancho que alto: es una pegatina, no un cuadrado. */
.burst.name {
  width: calc(var(--size) * 2.4);
  height: calc(var(--size) * 1.05);
  background: none;
  box-shadow: none;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.32)) drop-shadow(0 0 18px var(--color));
}

.burst.name svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Foto con marco suave. El recorte prioriza la cara. */
.burst.photo {
  width: calc(var(--size) * 0.86);
  height: calc(var(--size) * 1.12);
  padding: 7px;
  border-radius: 22%;
  background: #fff;
  box-shadow: 0 14px 22px rgba(0, 0, 0, 0.35), 0 0 22px rgba(255, 255, 255, 0.2);
}

.burst.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  border-radius: 16%;
  pointer-events: none;
}

/*
  Entrada con “pop”, giro suave y desvanecimiento.
  La figura permanece visible la mayor parte del tiempo y se va entre 2 y 3 s.
*/
@keyframes pop-fade {
  0% {
    transform: translate(-50%, -50%) scale(0.12) rotate(calc(var(--spin) * -0.6));
    opacity: 0;
  }

  14% {
    transform: translate(-50%, -50%) scale(1.14) rotate(0deg);
    opacity: 1;
  }

  26% {
    transform: translate(-50%, -50%) scale(1) rotate(calc(var(--spin) * 0.35));
    opacity: 1;
  }

  70% {
    transform: translate(-50%, -50%) scale(1) rotate(var(--spin));
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(0.8) rotate(calc(var(--spin) * 1.35));
    opacity: 0;
  }
}

@keyframes silly-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.05) rotate(-18deg);
    opacity: 0;
  }

  12% {
    transform: translate(-50%, -50%) scale(1.28) rotate(14deg);
    opacity: 1;
  }

  24% {
    transform: translate(-50%, -50%) scale(0.9) rotate(-12deg);
    opacity: 1;
  }

  36% {
    transform: translate(-50%, -50%) scale(1.1) rotate(8deg);
    opacity: 1;
  }

  50% {
    transform: translate(-50%, -50%) scale(1) rotate(-4deg);
    opacity: 1;
  }

  74% {
    transform: translate(-50%, -50%) scale(1.04) rotate(3deg);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(0.75) rotate(-8deg);
    opacity: 0;
  }
}

/* Esquina para abrir ajustes. Un toque corto no juega; hay que mantenerla. */
.parent-gate {
  position: fixed;
  z-index: 6;
  top: 0;
  left: 0;
  width: 6.75rem;
  height: 6.75rem;
  margin: 0;
  padding: max(0.7rem, env(safe-area-inset-top)) 0 0 max(0.85rem, env(safe-area-inset-left));
  border: 0;
  background: transparent;
  color: rgba(244, 247, 255, 0.42);
  font: inherit;
  font-size: clamp(0.8rem, 1.5vw, 1.05rem);
  letter-spacing: 0.04em;
  text-align: left;
  touch-action: none;
  cursor: pointer;
}

.parent-gate.is-holding {
  color: rgba(255, 255, 255, 0.95);
}

.settings {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: max(1.2rem, env(safe-area-inset-top)) 1rem max(1.2rem, env(safe-area-inset-bottom));
  background: rgba(20, 28, 38, 0.42);
  font-family: Georgia, "Palatino Linotype", Palatino, "Iowan Old Style", "Noto Serif", serif;
}

.settings[hidden] {
  display: none;
}

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
  width: min(36rem, 100%);
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 1.4rem 1.3rem 1.2rem;
  border-radius: 0.35rem;
  background: #f7f1e6;
  color: #2a241c;
  border: 1px solid #e4d8c6;
  box-shadow: 0 14px 36px rgba(24, 18, 12, 0.28);
}

.settings-card h1,
.settings-card h2,
.settings-note,
.settings-label,
.settings-empty,
.settings-status,
.settings-help,
.settings-thanks {
  margin: 0;
}

.settings-card h1 {
  font-size: clamp(1.7rem, 3vw, 2.15rem);
  font-weight: 700;
  letter-spacing: 0;
}

.settings-note,
.settings-help,
.settings-empty,
.settings-status,
.settings-thanks {
  color: #5c5348;
  font-size: 0.98rem;
  line-height: 1.45;
}

.settings-note {
  padding: 0.75rem 0.85rem;
  border-radius: 0.2rem;
  background: #e7f4f8;
  color: #243848;
}

.settings-thanks {
  margin-top: 0.2rem;
  padding-top: 0.85rem;
  border-top: 1px solid #e4d8c6;
  color: #3d3428;
}

.settings-pair {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.settings-block {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0;
  padding: 0.95rem 0.9rem 1rem;
  background: #fffdf8;
  border: 1px solid #eadfce;
  border-radius: 0.3rem;
}

.settings-block-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  color: #163044;
}

.settings-label {
  display: block;
  font-size: 1.05rem;
}

.settings-row,
.settings-actions,
.icon-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.settings-row {
  justify-content: space-between;
  flex-wrap: wrap;
  min-height: 2.8rem;
}

.settings-row > span {
  flex: 1 1 8rem;
  line-height: 1.25;
}

.settings-actions {
  flex-wrap: wrap;
}

.settings-input,
.btn,
.switch {
  font: inherit;
  color: #2a241c;
}

.settings-input {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.2rem;
  border: 1px solid #d9cdb8;
  background: #fffdf8;
  font-size: 1.35rem;
  user-select: text;
  -webkit-user-select: text;
}

.btn {
  min-height: 3.25rem;
  padding: 0.65rem 1.15rem;
  border-radius: 0.35rem;
  border: 1px solid #d9cdb8;
  background: #fffdf8;
  font-size: 1.15rem;
  cursor: pointer;
}

.switch {
  position: relative;
  width: 3.8rem;
  height: 2.2rem;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #d7d0c4;
  cursor: pointer;
}

.switch-knob {
  position: absolute;
  top: 0.24rem;
  left: 0.24rem;
  width: 1.72rem;
  height: 1.72rem;
  border-radius: 50%;
  background: #f4f7ff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease;
}

.switch.is-on {
  background: #8fd4f2;
}

.switch.is-on .switch-knob {
  transform: translateX(1.58rem);
  background: #123044;
}

.btn-primary {
  background: #8fd4f2;
  border-color: #8fd4f2;
  color: #123044;
  font-weight: 700;
}

.btn-quiet {
  background: transparent;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.85rem;
  height: 2.85rem;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #e4d8c6;
  background: #fffdf8;
  color: #2a241c;
  cursor: pointer;
}

.icon-btn .icon {
  width: 1.35rem;
  height: 1.35rem;
  display: block;
}

.icon-btn.is-recording {
  background: #ff6b6b;
  color: #2a1010;
}

.icon-btn.is-playing {
  background: #8fd4f2;
  color: #123044;
}

.icon-btn.danger {
  margin-left: auto;
  background: transparent;
  border-color: transparent;
  color: #7a6d5e;
}

.btn:disabled {
  opacity: 0.45;
}

.settings button:focus,
.settings input:focus,
.settings select:focus {
  outline: 3px solid #8fd4f2;
  outline-offset: 3px;
}

.language-select {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.65rem 2.4rem 0.65rem 0.9rem;
  border-radius: 0.2rem;
  border: 1px solid #d9cdb8;
  background-color: #fffdf8;
  background-image:
    linear-gradient(45deg, transparent 50%, #2a241c 50%),
    linear-gradient(135deg, #2a241c 50%, transparent 50%);
  background-position:
    calc(100% - 1.15rem) 55%,
    calc(100% - 0.75rem) 55%;
  background-size: 0.4rem 0.4rem, 0.4rem 0.4rem;
  background-repeat: no-repeat;
  font: inherit;
  font-size: 1.2rem;
  color: #2a241c;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.photo-list,
.phrase-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.photo-list:empty,
.phrase-list:empty {
  display: none;
}

.item-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.75rem;
  border-radius: 0.25rem;
  background: #fffdf8;
  border: 1px solid #eadfce;
}

.item-card img {
  width: 100%;
  height: 7.5rem;
  border-radius: 0.8rem;
  object-fit: cover;
  background: #070b16;
}

.item-card .settings-input {
  font-size: 1.25rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Panel discreto: no captura el foco ni el puntero. */
.debug {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  z-index: 5;
  min-width: 11rem;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 0.7rem;
  background: rgba(8, 12, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(244, 247, 255, 0.86);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  pointer-events: none;
  user-select: none;
}

.debug.is-hidden {
  display: none;
}

.debug p {
  margin: 0;
}

.debug-title {
  margin-bottom: 0.35rem;
  color: rgba(244, 247, 255, 0.5);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.debug strong {
  font-weight: 650;
  color: #fff;
}

.burst.face svg,
.burst.count {
  width: 100%;
  height: 100%;
}

.burst.count {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.08em;
}

.count-ball {
  width: 0.78em;
  height: 0.78em;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%, #fff 0 12%, transparent 13%),
    var(--ball, #ff8787);
  box-shadow: 0 0.12em 0 rgba(0, 0, 0, 0.18);
  font-size: calc(var(--size) * 0.34);
}

.age-gate {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: rgba(7, 11, 22, 0.72);
}

.age-gate[hidden] {
  display: none;
}

.age-card {
  width: min(42rem, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 1.4rem 1.2rem 1.2rem;
  border-radius: 1.2rem;
  background: #f7f1e6;
  color: #2a241c;
}

.age-card h1,
.age-help {
  margin: 0;
  text-align: center;
}

.age-card h1 {
  font-family: Georgia, "Palatino Linotype", Palatino, serif;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.age-help {
  margin-top: 0.45rem;
  color: #5c5348;
  font-size: 1.05rem;
  line-height: 1.35;
}

.age-langs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.age-lang {
  margin: 0;
  padding: 0.45rem 0.8rem;
  border: 2px solid #e4d8c6;
  border-radius: 999px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.age-lang.is-on {
  border-color: #163044;
  background: #163044;
  color: #fff;
}

.age-choices {
  display: grid;
  gap: 0.75rem;
  margin: 1.1rem 0 0.9rem;
}

.age-choice {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  margin: 0;
  padding: 0.95rem 1rem;
  border: 2px solid #e4d8c6;
  border-radius: 1rem;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.age-choice.is-holding,
.age-choice:focus {
  border-color: #3d7ea6;
  outline: none;
}

.age-choice-title {
  font-size: 1.35rem;
  font-weight: 700;
}

.age-choice-help {
  color: #5c5348;
  font-size: 1rem;
  line-height: 1.3;
}

.age-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.age-picks .btn.is-on {
  background: #163044;
  color: #fff;
}

.ask {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4vw;
  pointer-events: auto;
}

.ask[hidden] {
  display: none;
}

.ask-choice {
  width: min(28vh, 30vw);
  height: min(28vh, 30vw);
  margin: 0;
  padding: 0;
  border: 6px solid transparent;
  border-radius: 18%;
  background: rgba(255, 255, 255, 0.08);
  font-size: min(18vh, 16vw);
  line-height: 1;
  cursor: pointer;
}

.ask-choice:focus,
.ask-choice.is-focus {
  border-color: #fff;
  outline: none;
}

.ask-choice.is-right {
  border-color: #69db7c;
  background: rgba(105, 219, 124, 0.25);
}

.ask-choice.is-wrong {
  animation: ask-shake 0.35s ease;
}

.ask-shape {
  display: block;
  width: 68%;
  height: 68%;
  margin: 16% auto;
  background: var(--color);
}

.ask-shape.circle {
  border-radius: 50%;
}

.ask-shape.square {
  border-radius: 12%;
}

.ask-shape.triangle {
  background: transparent;
  border-radius: 0;
  clip-path: polygon(50% 6%, 96% 94%, 4% 94%);
  background: var(--color);
}

.ask-shape.star {
  background: var(--color);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.switch:disabled {
  opacity: 0.45;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  top: -16px;
  width: 12px;
  height: 18px;
  border-radius: 2px;
  animation: confetti-fall 1.35s ease-in forwards;
}

@keyframes confetti-fall {
  to {
    transform: translate(var(--drift, 0px), 108vh) rotate(220deg);
    opacity: 0.15;
  }
}

@keyframes ask-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

@media (prefers-reduced-motion: reduce) {
  .burst {
    animation-duration: 0.8s;
  }

  .switch-knob {
    transition: none;
  }
}
