/* QuizTest.es - estilos de la seccion Juegos. Se apoya en las variables de /styles.css (con valores de reserva).
   Identidad: «mesa de cartas». Cada juego es una carta con su color, su marca (FLAG, CAPI...) y su icono; el color llega por --jg-c. */
.jg-page {
  --jg-ink: var(--ink, #17202a);
  --jg-muted: var(--muted, #647284);
  --jg-line: var(--line, #d9e2ea);
  --jg-blue: var(--blue, #1f3a5f);
  --jg-blue2: var(--blue-2, #2b70a8);
  --jg-green: var(--green, #0f8b7c);
  --jg-gold: var(--gold, #ffd166);
  --jg-red: var(--red, #d64550);
  --jg-mint: var(--mint, #dcfce7);
  --jg-rose: var(--rose, #ffe4e6);
  /* color del juego (por defecto el azul de la marca) */
  --jg-c: #1f3a5f; --jg-c-on: #fff; --jg-c-ink: #1f3a5f; --jg-c-soft: #e8eef6;
  --jg-flag-h: clamp(108px, 19svh, 190px);
  display: grid;
  gap: 18px;
}
[data-game="banderas"] { --jg-c: #2b70a8; --jg-c-on: #fff; --jg-c-ink: #1f5f94; --jg-c-soft: #e0f2fe; }
[data-game="capitales"] { --jg-c: #0b6b5f; --jg-c-on: #fff; --jg-c-ink: #0b6b5f; --jg-c-soft: #dcfce7; }
[data-game="sinparar"] { --jg-c: #c4254b; --jg-c-on: #fff; --jg-c-ink: #b01f43; --jg-c-soft: #ffe4e6; }
[data-game="calculo"] { --jg-c: #ffd166; --jg-c-on: #17202a; --jg-c-ink: #7a5200; --jg-c-soft: #fff4d6; }
[data-game="repaso"] { --jg-c: #1f3a5f; --jg-c-on: #fff; --jg-c-ink: #1f3a5f; --jg-c-soft: #e8eef6; }
.jg-page--capitales { --jg-flag-h: clamp(64px, 10svh, 96px); }

.jg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* cabecera compacta: el juego tiene que verse sin bajar */
.jg-hero { display: flex; align-items: flex-start; gap: 14px; padding: 4px 2px 0; }
.jg-hero > div { min-width: 0; }
.jg-hero .eyebrow { margin-bottom: 4px; color: var(--jg-c-ink); }
.jg-hero h1 { margin: 0 0 6px; font-size: clamp(1.45rem, 5.2vw, 2.5rem); line-height: 1.1; }
.jg-hero p { margin: 0; max-width: 760px; color: var(--jg-muted); font-size: 1.02rem; }
.jg-herotile { flex: 0 0 auto; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 14px; color: var(--jg-c-on); background: var(--jg-c);
  box-shadow: 0 8px 18px rgba(31, 58, 95, 0.2), inset 0 0 0 3px rgba(255, 255, 255, 0.28); transform: rotate(-4deg); }
.jg-herotile svg { width: 40px; height: 40px; }
.jg-hero--hub { align-items: center; justify-content: space-between; }
.jg-fan { display: none; position: relative; flex: 0 0 auto; width: 250px; height: 92px; }
.jg-fan span { position: absolute; bottom: 0; display: grid; place-items: center; width: 62px; height: 82px; border-radius: 10px; color: var(--jg-c-on); background: var(--jg-c);
  box-shadow: 0 8px 16px rgba(31, 58, 95, 0.22), inset 0 0 0 3px rgba(255, 255, 255, 0.3); transform-origin: 50% 120%; }
.jg-fan svg { width: 34px; height: 34px; }
.jg-fan span:nth-child(1) { left: 0; transform: rotate(-16deg); }
.jg-fan span:nth-child(2) { left: 44px; transform: rotate(-8deg); }
.jg-fan span:nth-child(3) { left: 94px; transform: rotate(0deg); }
.jg-fan span:nth-child(4) { left: 144px; transform: rotate(8deg); }
.jg-fan span:nth-child(5) { left: 188px; transform: rotate(16deg); }
@media (min-width: 760px) { .jg-fan { display: block; } .jg-herotile { width: 76px; height: 76px; } .jg-herotile svg { width: 48px; height: 48px; } }

.jg-card {
  position: relative;
  border: 1px solid var(--jg-line);
  border-top: 6px solid var(--jg-c);
  border-radius: 8px;
  padding: clamp(14px, 3.5vw, 28px);
  background: linear-gradient(180deg, #fff, #f7fbf8);
  box-shadow: var(--shadow, 0 18px 42px rgba(31, 58, 95, 0.14));
  scroll-margin-top: 90px;
}
.jg-card::before { position: absolute; inset: 6px; border: 1px solid rgba(31, 58, 95, 0.07); border-radius: 5px; content: ""; pointer-events: none; }
.jg { position: relative; max-width: 640px; margin: 0 auto; color: var(--jg-ink); }
.jg [hidden] { display: none !important; }
.jg-loading { margin: 24px 0; text-align: center; color: var(--jg-muted); }
.jg-lbl { margin: 0 0 6px; color: var(--jg-muted); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.jg-lbl label { font: inherit; letter-spacing: inherit; text-transform: inherit; }
.jg-hint, .jg-record, .jg-sub { margin: 8px 0 0; color: var(--jg-muted); font-size: 0.95rem; }
.jg .btn { min-height: 52px; font-size: 1.05rem; padding: 0 14px; text-align: center; display: inline-flex; align-items: center; justify-content: center; }
.jg button:focus-visible, .jg a:focus-visible, .jg select:focus-visible, .jg-gamecard:focus-visible { outline: 3px solid var(--jg-blue2); outline-offset: 2px; }
.jg .btn.primary { background: var(--jg-c); border-color: var(--jg-c); color: var(--jg-c-on); }
.jg .btn.primary:hover { filter: brightness(0.93); }

/* ajustes */
.jg-setup { display: grid; gap: 4px; }
.jg-setup .jg-lbl:not(:first-child) { margin-top: 10px; }
.jg-chips[data-g="level"] .jg-chip, .jg-chips[data-g="cont"] .jg-chip { min-height: 44px; padding: 4px 10px; }
.jg-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.jg-chip {
  flex: 1 1 auto; min-height: 48px; padding: 6px 14px; border: 2px solid var(--jg-line); border-radius: 10px;
  color: var(--jg-ink); background: #fff; font: inherit; font-size: 1rem; font-weight: 800; line-height: 1.2; cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.jg-chip small { display: block; margin-top: 1px; font-size: 0.78rem; font-weight: 600; opacity: 0.85; }
.jg-chip:hover { border-color: var(--jg-c-ink); }
.jg-chip[aria-pressed="true"] { border-color: var(--jg-c); color: var(--jg-c-on); background: var(--jg-c); }
.jg-chips[data-g="mode"] .jg-chip { flex-basis: calc(50% - 4px); }
.jg-select {
  width: 100%; min-height: 48px; padding: 6px 12px; border: 2px solid var(--jg-line); border-radius: 10px; color: var(--jg-ink); background: #fff;
  font: inherit; font-size: 1rem; font-weight: 700;
}
.jg-done { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--jg-mint); font-size: 1.05rem; }
.jg-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.jg-actions .btn { flex: 1 1 150px; }
.jg-copied { flex-basis: 100%; margin: 8px 0 0; color: #0b6b5f; font-weight: 700; white-space: pre-line; }
.jg-empty { text-align: center; padding: 8px 0; }
.jg-empty-t { margin: 0 0 6px; font-size: 1.25rem; font-weight: 800; }
.jg-empty .jg-actions { justify-content: center; }
#jg-repaso-tools { max-width: 640px; margin: 0 auto; text-align: center; }
#jg-repaso-tools:not(:empty) { margin-top: 14px; }

/* partida */
.jg-hud { display: flex; justify-content: space-between; gap: 6px; }
.jg-stat { flex: 1; min-width: 0; text-align: center; }
.jg-stat .jg-lbl { display: block; margin: 0; font-size: 0.7rem; }
.jg-stat b { display: block; font-size: 1.35rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.jg-lives { color: var(--jg-red); letter-spacing: 2px; }
.jg-timer-w.jg-hit b { animation: jg-flash 0.5s; }
.jg-bar { height: 6px; margin: 8px 0 10px; border-radius: 6px; background: #e7eef5; overflow: hidden; }
.jg-bar i { display: block; width: 0; height: 100%; background: var(--jg-c); transition: width 0.25s; }
.jg-prompt { display: grid; gap: 8px; justify-items: center; text-align: center; }
.jg-media { display: grid; place-items: center; min-height: var(--jg-flag-h); }
.jg-media:empty { display: none; min-height: 0; }
.jg-flag {
  display: block; width: auto; height: var(--jg-flag-h); aspect-ratio: 4 / 3; max-width: 100%; object-fit: contain;
  border: 1px solid rgba(23, 32, 42, 0.3); border-radius: 6px; background: #fff; box-shadow: 0 6px 18px rgba(31, 58, 95, 0.2);
  animation: jg-in 0.25s ease-out;
}
.jg-q { margin: 0; font-size: clamp(1.15rem, 4.6vw, 1.45rem); font-weight: 800; line-height: 1.25; outline: none; }
.jg-page[data-game="calculo"] .jg-q { font-size: clamp(1.9rem, 9vw, 2.7rem); font-variant-numeric: tabular-nums; padding: 6px 0; }
.jg-page[data-game="sinparar"] .jg-q { font-size: clamp(1.1rem, 4.4vw, 1.4rem); }
.jg-options { display: grid; gap: 8px; margin-top: 12px; }
.jg-page[data-game="calculo"] .jg-options { grid-template-columns: 1fr 1fr; }
.jg-page[data-game="calculo"] .jg-opt { justify-content: center; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.jg-opt {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 14px;
  border: 2px solid var(--jg-line); border-radius: 10px; color: var(--jg-ink); background: #fff;
  font: inherit; font-size: 1.06rem; font-weight: 700; line-height: 1.3; text-align: left; cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, background 0.12s, opacity 0.2s;
}
.jg-opt:not(:disabled):hover { border-color: var(--jg-c-ink); background: #f4f9fd; }
.jg-opt:not(:disabled):active { transform: scale(0.985); }
.jg-opt:disabled { cursor: default; color: var(--jg-ink); }
.jg-key {
  flex: 0 0 auto; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  color: var(--jg-blue); background: #e8f0f8; font-size: 0.85rem; font-weight: 900;
}
.jg-opt.is-ok { border-color: #0b6b5f; background: var(--jg-mint); animation: jg-pop 0.3s ease-out; }
.jg-opt.is-ok .jg-key { color: #fff; background: #0b6b5f; }
.jg-opt.is-ko { border-color: var(--jg-red); background: var(--jg-rose); animation: jg-shake 0.35s; }
.jg-opt.is-ko .jg-key { color: #fff; background: var(--jg-red); }
.jg-opt.is-dim { opacity: 0.55; }
.jg-fb { min-height: 3.2em; margin: 10px 0 0; font-size: 1rem; line-height: 1.4; }
.jg-fb.is-ok { color: #0b6b5f; }
.jg-fb.is-ko { color: #a8323c; }
.jg-fb .jg-fb-t { color: var(--jg-ink); }
.jg-quizlink { display: block; margin-top: 6px; padding: 8px 0; color: var(--jg-c-ink); font-weight: 800; }
.jg-play .jg-actions { margin-top: 8px; }
.jg-play .jg-actions .btn.ghost { flex: 0 1 auto; min-height: 44px; }
@media (max-width: 700px) {
  .jg-play .jg-actions { position: sticky; bottom: 8px; z-index: 5; padding: 8px; margin-inline: -6px; border-radius: 12px; background: rgba(255, 255, 255, 0.94); box-shadow: 0 -4px 14px rgba(31, 58, 95, 0.14); }
  .jg-play .jg-actions .btn { min-height: 48px; }
}

/* fin de partida: sello con anillo, cifra que sube y confeti */
.jg-end { position: relative; overflow: hidden; text-align: center; scroll-margin-top: 80px; }
.jg-end.is-pop .jg-big b { animation: jg-pop 0.5s ease-out 0.2s; }
.jg-endtitle { margin: 0; outline: none; }
.jg-endtitle .jg-lbl { margin: 0; }
.jg-seal { position: relative; display: grid; place-items: center; width: 176px; height: 176px; margin: 6px auto 0; }
.jg-seal-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.jg-seal-bg { fill: var(--jg-c-soft); stroke: #e3eaf1; stroke-width: 10; }
.jg-seal-fg { fill: none; stroke: var(--jg-c); stroke-width: 10; stroke-linecap: round; stroke-dashoffset: var(--jg-c-off); animation: jg-ring 0.9s ease-out; }
.jg-seal.is-high::before { position: absolute; inset: 14px; border-radius: 50%; box-shadow: 0 0 26px 6px rgba(255, 209, 102, 0.75); content: ""; }
.jg-big { position: relative; margin: 0; line-height: 1; }
.jg-big b { display: block; font-size: clamp(2.8rem, 14vw, 3.9rem); line-height: 1; color: var(--jg-ink); font-variant-numeric: tabular-nums; }
.jg-big span { display: block; margin-top: 2px; font-size: 1rem; font-weight: 800; color: var(--jg-muted); }
.jg-msg { margin: 6px 0 0; font-size: 1.35rem; font-weight: 800; }
.jg-grid { margin: 12px 0 0; font-size: 1.3rem; line-height: 1.4; letter-spacing: 0; word-break: break-all; }
.jg-badge { display: inline-block; margin: 10px 0 0; padding: 6px 14px; border-radius: 999px; background: var(--jg-gold); color: #17202a; font-weight: 900; animation: jg-pop 0.5s ease-out 0.4s; }
.jg-errors { margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: #f3f7fb; text-align: left; }
.jg-errors h3 { margin: 0 0 6px; font-size: 1rem; }
.jg-errors ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.jg-errors li { display: flex; align-items: center; gap: 8px; font-size: 1rem; line-height: 1.35; }
.jg-errors a { color: var(--jg-c-ink); font-weight: 800; }
.jg-rv { display: block; }
.jg-rv a { display: inline-block; margin-left: 4px; padding: 4px 0; }
.jg-thumb { flex: 0 0 auto; width: 32px; height: 24px; border: 1px solid rgba(23, 32, 42, 0.14); border-radius: 3px; object-fit: contain; background: #fff; }
.jg-end .jg-actions { justify-content: center; }
.jg-confetti { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.jg-confetti i { position: absolute; top: -14px; left: var(--x); width: var(--w); height: calc(var(--w) * 1.6); border-radius: 2px; opacity: 0; animation: jg-fall var(--t) ease-in var(--d) 1 forwards; }
.jg-end > :not(.jg-confetti) { position: relative; z-index: 1; }

/* contenido editorial */
.jg-text h2 { margin: 26px 0 8px; font-size: 1.5rem; }
.jg-text h2:first-child { margin-top: 0; }
.jg-text p, .jg-text li { max-width: 760px; line-height: 1.7; }
.jg-text ul { padding-left: 1.2em; }
.jg-text a { color: var(--jg-blue2); font-weight: 700; }
.jg-text table { width: 100%; max-width: 760px; border-collapse: collapse; font-size: 1rem; }
.jg-text th, .jg-text td { padding: 8px 10px; border-bottom: 1px solid var(--jg-line); text-align: left; }
.jg-text td img { display: inline-block; width: 32px; height: 24px; margin-right: 8px; vertical-align: middle; border: 1px solid rgba(23, 32, 42, 0.14); border-radius: 3px; object-fit: contain; background: #fff; }
.jg-text details { margin: 8px 0; border: 1px solid var(--jg-line); border-radius: 8px; background: #fff; }
.jg-text summary { padding: 12px 14px; font-weight: 800; cursor: pointer; }
.jg-text details > div { padding: 0 14px 12px; overflow-x: auto; }
.jg-noscript { padding: 14px; border-radius: 8px; background: var(--jg-rose); }
.jg-tricks { display: grid; gap: 12px; padding: 0 !important; list-style: none; }
.jg-tricks li { padding: 12px 14px; border: 1px solid var(--jg-line); border-left: 6px solid var(--jg-c); border-radius: 8px; background: #fff; }
.jg-tricks b { display: block; }
.jg-tricks code { padding: 1px 6px; border-radius: 5px; background: var(--jg-c-soft); font-size: 0.98em; }
.jg-catlist { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0 !important; list-style: none; }
.jg-catlist a { display: inline-block; padding: 8px 12px; border: 1px solid var(--jg-line); border-radius: 999px; background: #fff; text-decoration: none; }

/* hub: cada juego es una carta */
.jg-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.jg-gamecard {
  position: relative; display: grid; grid-template-rows: auto 1fr; overflow: hidden; border: 1px solid rgba(31, 58, 95, 0.16); border-radius: 10px;
  color: inherit; background: linear-gradient(180deg, #fff, #fbfcfd); text-decoration: none; isolation: isolate;
  box-shadow: 0 6px 16px rgba(31, 58, 95, 0.1); transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.jg-gamecard::before { position: absolute; inset: 7px; z-index: -1; border: 1px solid rgba(31, 58, 95, 0.08); border-radius: 6px; content: ""; pointer-events: none; }
.jg-gamecard:hover { border-color: var(--jg-c-ink); box-shadow: 0 14px 28px rgba(31, 58, 95, 0.18); transform: translateY(-3px) rotate(-0.6deg); }
.jg-card-line { position: absolute; z-index: 2; inset: 0 0 auto; height: 6px; background: var(--jg-c); }
.jg-cv {
  position: relative; display: grid; place-items: center; min-height: 112px; overflow: hidden; color: var(--jg-c-on);
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.4), transparent 20%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.13) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.13) 1px, transparent 1px),
    var(--jg-c);
  background-size: auto, 24px 24px, 24px 24px, auto;
}
.jg-cv::after { position: absolute; right: -30px; bottom: 16px; width: 140px; height: 38px; background: rgba(255, 255, 255, 0.14); content: ""; transform: rotate(-18deg); }
.jg-mark { position: absolute; top: 14px; left: 14px; z-index: 1; padding: 2px 8px; border: 2px solid currentColor; border-radius: 6px; font-size: 0.78rem; font-weight: 900; letter-spacing: 0.08em; line-height: 1.4; }
.jg-tile {
  position: relative; z-index: 1; display: grid; place-items: center; width: 76px; height: 76px; border: 2px solid rgba(255, 255, 255, 0.7); border-radius: 14px;
  background: rgba(23, 32, 42, 0.18); box-shadow: 0 12px 24px rgba(23, 32, 42, 0.2); transform: rotate(-3deg); transition: transform 0.18s;
}
[data-game="calculo"] .jg-tile { background: rgba(255, 255, 255, 0.45); border-color: rgba(23, 32, 42, 0.45); }
.jg-tile svg { width: 46px; height: 46px; }
.jg-gamecard:hover .jg-tile { transform: rotate(2deg) scale(1.06); }
.jg-body { display: grid; align-content: start; gap: 8px; padding: 14px 16px 16px; }
.jg-gamecard h2 { margin: 0; font-size: 1.3rem; line-height: 1.2; }
.jg-gamecard p { margin: 0; color: var(--jg-muted); font-size: 0.98rem; line-height: 1.45; }
.jg-meta { display: grid; gap: 4px; }
.jg-status { display: inline-block; justify-self: start; padding: 3px 10px; border-radius: 999px; background: var(--jg-c-soft); color: var(--jg-ink); font-size: 0.92rem; font-weight: 800; min-height: 1.6em; }
.jg-status.is-done { background: var(--jg-mint); color: #0a5a50; }
.jg-status.is-done::before { content: "\2713\00a0"; }
.jg-status.is-todo { background: #fff1c9; color: #6b4600; }
.jg-status.is-todo::before { content: "\25cf\00a0"; font-size: 0.7em; vertical-align: 0.12em; }
.jg-rec { color: var(--jg-muted); font-size: 0.92rem; min-height: 1.3em; }
.jg-go { font-weight: 900; color: var(--jg-c-ink); }
.jg-gamecard--minor { grid-column: 1 / -1; grid-template-rows: none; grid-template-columns: 112px 1fr; }
.jg-gamecard--minor .jg-cv { min-height: 100%; }
.jg-gamecard--minor .jg-mark { display: none; }
@media (max-width: 559px) {
  .jg-cards { grid-template-columns: 1fr; gap: 12px; }
  .jg-gamecard, .jg-gamecard--minor { grid-template-rows: none; grid-template-columns: 96px 1fr; }
  .jg-cv { min-height: 100%; }
  .jg-mark { top: 8px; left: 8px; padding: 1px 6px; font-size: 0.7rem; }
  .jg-tile { width: 56px; height: 56px; border-radius: 12px; }
  .jg-tile svg { width: 36px; height: 36px; }
  .jg-hero { gap: 10px; }
  .jg-herotile { width: 52px; height: 52px; border-radius: 12px; }
  .jg-herotile svg { width: 34px; height: 34px; }
}

@keyframes jg-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes jg-pop { 0% { transform: scale(1); } 45% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes jg-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes jg-flash { 0%, 100% { color: inherit; } 30% { color: var(--jg-red); transform: scale(1.2); } }
@keyframes jg-ring { from { stroke-dashoffset: var(--jg-c-len); } }
@keyframes jg-fall { 0% { opacity: 1; transform: translateY(0) rotate(var(--r)); } 100% { opacity: 0; transform: translateY(440px) rotate(calc(var(--r) + 540deg)); } }

@media (hover: none) { .jg-key { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .jg-flag, .jg-opt.is-ok, .jg-opt.is-ko, .jg-badge, .jg-end.is-pop .jg-big b, .jg-timer-w.jg-hit b, .jg-seal-fg { animation: none !important; }
  .jg-confetti { display: none; }
  .jg-opt, .jg-chip, .jg-bar i, .jg-gamecard, .jg-tile { transition: none !important; }
  .jg-gamecard:hover, .jg-gamecard:hover .jg-tile { transform: none; }
}
