:root {
  --orange: #f97316;
  --orange-dark: #ea580c;
  /* Naranja para texto pequeno y para fondos con texto blanco: 5,2:1. */
  --orange-ink: #c2410c;
  --orange-soft: #ffedd5;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --red: #e11d48;
  --red-soft: #ffe4e6;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --ink: #1f2937;
  --ink-soft: #4b5563;
  --muted: #6b7280;
  --line: #e5e7eb;
  --card: #ffffff;
  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --shadow: 0 10px 30px rgba(31,41,55,.10), 0 2px 6px rgba(31,41,55,.06);
  --shadow-sm: 0 4px 14px rgba(31,41,55,.08);
  --tap: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #fff7ed;
  background-image:
    radial-gradient(1100px 600px at 10% -10%, #ffe4c4 0%, rgba(255,228,196,0) 60%),
    radial-gradient(900px 600px at 100% 0%, #dbeafe 0%, rgba(219,234,254,0) 55%),
    linear-gradient(180deg, #fff7ed 0%, #f5f3ff 100%);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 16px 40px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { font-size: 38px; line-height: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,.15)); }

.brand-text h1 {
  margin: 0;
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 900;
  letter-spacing: -.5px;
  background: linear-gradient(90deg, var(--orange-dark), #d946ef);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text p { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
/* En el movil el nombre del nino, las estrellas y el reinicio no caben al
   lado del titulo: bajan a su propia fila en vez de taparlo. */
@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-right { margin-left: auto; }
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 2px solid var(--line); border-radius: 999px;
  padding: 10px 16px; font: inherit; font-weight: 900; font-size: 17px;
  color: var(--ink); box-shadow: var(--shadow-sm);
}
.chip.stars { border-color: #fcd34d; background: #fffbeb; }
.chip.ghost { cursor: pointer; min-width: 48px; justify-content: center; color: var(--muted); font-size: 20px; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.tab {
  flex: 1 1 118px;
  min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 10px;
  border: 2px solid transparent; border-radius: var(--r-md);
  background: rgba(255,255,255,.75);
  font: inherit; font-weight: 800; font-size: 15px;
  color: var(--ink-soft); cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, background .15s ease, color .15s ease;
}
.tab span { font-size: 20px; }
.tab:active { transform: scale(.96); }
.tab.active {
  background: linear-gradient(135deg, var(--orange-ink), #cc4a12);
  color: #fff; border-color: #fff;
  box-shadow: 0 8px 20px rgba(249,115,22,.4);
}

.settingsbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 16px; padding: 10px 12px;
  background: rgba(255,255,255,.7); border-radius: var(--r-md); box-shadow: var(--shadow-sm);
}
.settingsbar.hidden { display: none; }
.levels { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.levels .lvl-label { font-weight: 900; font-size: 14px; color: var(--muted); margin-right: 4px; }

.lvl {
  min-height: 46px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 999px;
  background: #fff; font: inherit; font-weight: 800; font-size: 15px;
  color: var(--ink-soft); cursor: pointer; white-space: nowrap;
}
.lvl b { display: block; font-size: 11px; font-weight: 800; color: var(--muted); }
.lvl.active { background: var(--purple); border-color: var(--purple); color: #fff; }
.lvl.active b { color: rgba(255,255,255,.85); }

.switches { display: flex; gap: 6px; flex-wrap: wrap; }
.toggle {
  min-height: 46px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 999px;
  background: #fff; font: inherit; font-weight: 800; font-size: 14px; color: var(--muted); cursor: pointer;
}
.toggle[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: #1e40af; }

.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 20px; font-weight: 900; }

.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 820px) {
  .split { grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); }
  .split .card { margin-bottom: 0; }
}

.muted { color: var(--muted); font-weight: 700; font-size: 14px; }
.nl { color: var(--orange-ink); font-weight: 900; font-style: normal; }

.clock-card { text-align: center; }
.clock-host { width: 100%; }
.clock {
  display: block; width: 100%; max-width: 400px; margin: 0 auto;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.clock.interactive { cursor: grab; }
.clock.interactive.dragging { cursor: grabbing; }
.clock.locked { pointer-events: none; opacity: .95; }
.clock .face { fill: #fff; stroke: #cbd5e1; stroke-width: 1.6; }
.clock .rim { fill: none; stroke: var(--orange); stroke-width: 4; opacity: .95; }
.clock .tick { stroke: #94a3b8; stroke-width: 1; stroke-linecap: round; }
.clock .tick5 { stroke: #334155; stroke-width: 2.6; stroke-linecap: round; }
.clock .hnum { fill: #1e293b; font-weight: 900; font-size: 15px; font-family: inherit; }
.clock .mnum { fill: var(--red); font-weight: 800; font-size: 7.5px; font-family: inherit; }
.clock .mnum.hide { display: none; }
.clock .hand-hour { stroke: var(--blue); stroke-width: 8.5; stroke-linecap: round; }
.clock .hand-min { stroke: var(--red); stroke-width: 5.5; stroke-linecap: round; }
.clock .hand-hit { stroke: transparent; stroke-width: 30; stroke-linecap: round; }
.clock .knob-hour { fill: var(--blue); }
.clock .knob-min { fill: var(--red); }
.clock .pin-outer { fill: #fff; stroke: #334155; stroke-width: 2; }
.clock .pin-inner { fill: #334155; }
.clock g.hand { transition: transform .18s cubic-bezier(.34,1.3,.64,1); }
.clock.dragging g.hand { transition: none; }

.hint { margin: 10px 0 12px; font-size: 14px; font-weight: 800; color: var(--muted); }

.ctrls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.ctrls button {
  min-height: var(--tap); border: 2px solid var(--line); border-radius: var(--r-md);
  background: #f8fafc; font: inherit; font-weight: 900; font-size: 16px; color: var(--ink); cursor: pointer;
}
.ctrls button:active { transform: scale(.96); background: var(--orange-soft); }
.ctrls button.soft { background: var(--purple-soft); border-color: #ddd6fe; color: #5b21b6; }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 12px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.legend .dot { display: inline-block; width: 14px; height: 6px; border-radius: 999px; vertical-align: middle; margin-right: 4px; }
.legend .dot.hour { background: var(--blue); width: 12px; height: 8px; }
.legend .dot.minute { background: var(--red); width: 22px; height: 5px; }

.digital {
  font-size: clamp(46px, 9vw, 68px); font-weight: 900; letter-spacing: -2px; line-height: 1;
  text-align: center; color: var(--ink); font-variant-numeric: tabular-nums;
}
.daypart { text-align: center; font-weight: 800; font-size: 14px; color: var(--muted); min-height: 20px; margin-top: 4px; }

.nl-phrase {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  margin: 14px 0 6px; padding: 16px;
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 2px dashed #fdba74; border-radius: var(--r-md);
}
.nl-phrase > span { font-size: clamp(24px, 4.6vw, 34px); font-weight: 900; color: var(--orange-dark); text-align: center; }

.speak {
  min-width: 52px; min-height: 52px; border: none; border-radius: 50%;
  background: var(--orange); color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: 0 6px 14px rgba(249,115,22,.4);
}
.speak:active { transform: scale(.93); }
.speak.big { min-width: 86px; min-height: 86px; font-size: 40px; }

.explain { margin-top: 12px; }
.ex-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); font-size: 16px; font-weight: 700; line-height: 1.45; }
.ex-tag { flex: 0 0 116px; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding-top: 3px; }
.ex-result { margin-top: 10px; padding: 12px; border-radius: var(--r-sm); background: var(--green-soft); color: #14532d; font-weight: 900; font-size: 19px; text-align: center; }
.ex-tip { margin-top: 10px; padding: 12px 14px; border-radius: var(--r-sm); background: #fef9c3; border-left: 6px solid #facc15; font-weight: 700; font-size: 15px; line-height: 1.5; }

.quiz-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 12px 16px; background: rgba(255,255,255,.85); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.progress { flex: 1 1 auto; height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #34d399, #10b981); transition: width .35s ease; }
.qcount, .streak { font-weight: 900; font-size: 15px; white-space: nowrap; color: var(--ink-soft); }
.streak { color: var(--orange-dark); }

.q { font-size: clamp(19px, 3vw, 24px); font-weight: 900; margin: 0 0 16px; line-height: 1.3; }
.prompt-nl {
  text-align: center; padding: 22px 16px;
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 2px dashed #fdba74; border-radius: var(--r-md);
  font-size: clamp(28px, 5.5vw, 44px); font-weight: 900; color: var(--orange-dark);
  margin-bottom: 14px; word-break: break-word;
}

.options { display: grid; gap: 10px; }
@media (min-width: 560px) { .options.two-col { grid-template-columns: 1fr 1fr; } }

.opt {
  min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border: 3px solid var(--line); border-radius: var(--r-md); background: #fff;
  font: inherit; font-weight: 800; font-size: clamp(18px, 2.6vw, 22px); color: var(--ink);
  text-align: left; cursor: pointer;
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.opt .letter { flex: 0 0 34px; height: 34px; border-radius: 10px; background: var(--purple-soft); color: #5b21b6; display: grid; place-items: center; font-weight: 900; font-size: 16px; }
.opt:active { transform: scale(.98); }
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--green); background: var(--green-soft); }
.opt.correct .letter { background: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.wrong .letter { background: var(--red); color: #fff; }
.opt.dim { opacity: .45; }

.feedback { margin-top: 16px; }
.feedback:empty { margin: 0; }
.fb-banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); font-weight: 900; font-size: 19px; margin-bottom: 12px; }
.fb-banner.ok { background: var(--green-soft); color: #14532d; }
.fb-banner.bad { background: var(--red-soft); color: #881337; }
.fb-banner .em { font-size: 28px; }

.btn-next {
  width: 100%; min-height: 62px; margin-top: 14px; border: none; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--orange), #fb923c); color: #fff;
  font: inherit; font-weight: 900; font-size: 20px; cursor: pointer; box-shadow: 0 8px 18px rgba(249,115,22,.35);
}
.btn-next:active { transform: scale(.98); }

.btn-check {
  width: 100%; min-height: 62px; margin-top: 6px; border: none; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--green), #22c55e); color: #fff;
  font: inherit; font-weight: 900; font-size: 20px; cursor: pointer; box-shadow: 0 8px 18px rgba(22,163,74,.3);
}
.btn-check:active { transform: scale(.98); }
.btn-check:disabled { background: #cbd5e1; box-shadow: none; }

.listen-box { text-align: center; padding: 10px 0 4px; }
.listen-box .again { margin-top: 12px; font-size: 14px; font-weight: 800; color: var(--muted); }
.reveal { margin-top: 14px; border: 2px solid var(--line); border-radius: var(--r-md); background: #f8fafc; padding: 12px; font: inherit; font-weight: 800; font-size: 15px; color: var(--muted); cursor: pointer; width: 100%; }
.novoice { margin-top: 12px; padding: 12px 14px; border-radius: var(--r-sm); background: #fef9c3; border-left: 6px solid #facc15; font-weight: 700; font-size: 14px; line-height: 1.5; }

.result-card { text-align: center; padding: 34px 20px; }
.result-card .big-emoji { font-size: 76px; line-height: 1; }
.result-card h2 { font-size: 30px; margin: 10px 0 4px; }
.result-card .score { font-size: 56px; font-weight: 900; color: var(--orange-dark); font-variant-numeric: tabular-nums; }
.result-card .stars-row { font-size: 46px; letter-spacing: 6px; margin: 6px 0 14px; }
.result-card .msg { font-weight: 800; color: var(--ink-soft); margin-bottom: 18px; font-size: 17px; }

.rule-card { border: 3px solid #fdba74; background: linear-gradient(135deg, #fffbeb, #fff7ed); }
.rule-card p { font-size: 17px; font-weight: 700; line-height: 1.6; margin: 8px 0; }
.rule-big { text-align: center; font-size: clamp(20px, 3.4vw, 28px) !important; font-weight: 900 !important; padding: 14px; background: #fff; border-radius: var(--r-md); }
.warn { background: var(--red-soft); border-left: 6px solid var(--red); padding: 12px 14px; border-radius: var(--r-sm); color: #881337; }

.words { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.word { border: 2px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; background: #fff; cursor: pointer; text-align: left; font: inherit; }
.word:active { background: var(--orange-soft); }
.word .w { font-size: 21px; font-weight: 900; color: var(--orange-dark); }
.word .p { font-size: 13px; font-weight: 700; color: var(--blue); }
.word .m { font-size: 14px; font-weight: 700; color: var(--ink-soft); margin-top: 3px; }

.cheat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.cheat-item { border: 2px solid var(--line); border-radius: var(--r-md); padding: 10px; background: #fff; text-align: center; cursor: pointer; font: inherit; }
.cheat-item:active { background: var(--orange-soft); }
.cheat-item .clock { max-width: 110px; }
.cheat-item .t { font-weight: 900; font-size: 17px; margin-top: 6px; }
.cheat-item .nlp { font-weight: 800; font-size: 13px; color: var(--orange-dark); line-height: 1.3; min-height: 34px; }

.toast {
  position: fixed; left: 50%; bottom: 26px;
  transform: translate(-50%, 160%); opacity: 0; pointer-events: none;
  background: #1f2937; color: #fff; font-weight: 800; padding: 14px 22px;
  border-radius: 999px; box-shadow: var(--shadow);
  transition: transform .3s cubic-bezier(.34,1.3,.64,1), opacity .2s ease;
  z-index: 50; max-width: 90vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti span { position: absolute; top: -40px; font-size: 24px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .2; } }

.pop { animation: pop .4s cubic-bezier(.34,1.5,.64,1); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

.shake { animation: shake .4s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }

.foot { text-align: center; margin-top: 26px; font-size: 13px; font-weight: 700; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
