/* Juegos del libro de letras (/libro-letras/juegos/) */
.jg { --c: var(--sea); }
.jg [lang="ar"] { font-family: var(--naskh); font-weight: 700; }
.jg .jg-bi { display: inline-flex; flex-wrap: wrap; gap: .1rem .45rem; align-items: baseline; justify-content: center; }
.jg .jg-bi [lang="ar"] { font-size: 1.12em; }

/* ---------- índice ---------- */
.jg-sec { padding: 1rem 0 1.5rem; }
.jg-sec h2 { font-size: 1.6rem; margin: 0 0 1rem; }
.jg-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.jg-card {
  display: grid; grid-template-rows: auto auto 1fr auto; gap: .45rem; padding: 1rem; border-radius: 1.2rem;
  background: var(--white); color: var(--ink); text-decoration: none; box-shadow: 0 6px 16px rgba(23, 32, 51, .08);
  border: 2px solid transparent; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.jg-card:hover, .jg-card:focus-visible { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(23, 32, 51, .14); border-color: var(--sea); }
.jg-icon { display: grid; place-items: center; height: 6.5rem; border-radius: .9rem; background: var(--sea-soft); overflow: hidden; }
.jg-icon img { width: 6rem; height: 6rem; object-fit: contain; mix-blend-mode: multiply; }
.jg-icon-t { font-size: 2.6rem; line-height: 1.2; color: var(--sea-deep); }
.jg-card-t { display: grid; gap: .1rem; font-weight: 700; font-size: 1.1rem; }
.jg-card-t [lang="ar"] { font-size: 1.15rem; color: var(--sea-deep); }
.jg-card-d { display: grid; gap: .3rem; align-content: start; color: var(--muted); font-size: .92rem; line-height: 1.45; }
.jg-card-d [lang="ar"] { font-size: 1rem; font-weight: 400; font-family: var(--arabic); }
.jg-card-go { font-weight: 700; color: var(--sea-deep); }

/* ---------- página de juego ---------- */
.jg-head { padding: .6rem 0 .4rem; }
.jg-head > * { max-width: 52rem; }
.jg-head h1 { font-size: clamp(1.6rem, 4.5vw, 2.5rem); margin: .2rem 0 .5rem; }
.jg-origin { display: inline-block; margin: 0; padding: .2rem .7rem; border-radius: 999px; font-weight: 600; font-size: .85rem; background: var(--sea-soft); color: var(--sea-deep); }
.jg-o-nuevo { background: #fde9c9; color: #8a4b00; }
.jg-ins { display: grid; gap: .2rem; margin: 0; font-size: 1.05rem; }
.jg-ins [lang="ar"] { font-size: 1.15rem; }
.jg-board {
  margin-top: .8rem; padding: 1rem; border-radius: 1.4rem; background: var(--white);
  box-shadow: 0 6px 18px rgba(23, 32, 51, .07); min-height: 18rem; touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.jg-loading { color: var(--muted); text-align: center; }
.jg-status { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: .2rem 1.2rem; min-height: 2.4rem; margin-top: .7rem; font-weight: 700; font-size: 1.1rem; text-align: center; }
.jg-status.is-ok { color: #1b7a3a; }
.jg-status.is-bad { color: #b3541e; }
.jg-status [lang="ar"] { font-size: 1.15em; }

.jg-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.jg-pips { display: flex; gap: .35rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.jg-pips li { width: .9rem; height: .9rem; border-radius: 50%; background: var(--line); }
.jg-pips li.now { background: var(--yellow); box-shadow: 0 0 0 2px #e0c800 inset; }
.jg-pips li.done { background: var(--sea); }
.jg-stars { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.jg-stage { display: grid; gap: 1rem; justify-items: center; }

.jg-q { display: grid; justify-items: center; gap: .4rem; text-align: center; }
.jg-pic { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.jg-pic-big { width: min(13rem, 55vw); height: min(13rem, 55vw); }
.jg-cap { display: inline-flex; gap: .2rem .9rem; flex-wrap: wrap; justify-content: center; font-weight: 600; color: var(--muted); }
.jg-cap [lang="ar"] { color: var(--ink); font-size: 1.15em; }
.jg-word { margin: 0; font-size: 2.4rem; line-height: 1.5; color: var(--sea-deep); }
.jg-missing { display: inline-flex; align-items: center; direction: rtl; }
.jg-gap { display: inline-grid; place-items: center; min-width: 2.6rem; height: 3rem; margin-inline-end: .15rem; border: 3px dashed #c9a400; border-radius: .6rem; color: #c9a400; font-size: 1.7rem; }
.jg-missing.is-full { color: #1b7a3a; }
.jg-ask { display: grid; gap: .15rem; margin: .2rem 0; font-weight: 600; font-size: 1.1rem; }
.jg-ask [lang="ar"] { font-size: 1.2rem; }

.jg-glyph { font-family: var(--naskh); font-weight: 700; font-size: 3rem; line-height: 1.35; }
.jg-glyph-big { font-size: 5.5rem; line-height: 1.3; color: var(--c); filter: brightness(.8) saturate(1.2); }
.jg-glyph-huge { font-size: 8rem; line-height: 1.3; color: var(--sea-deep); }

.jg-opts { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; }
.jg-opt {
  position: relative; display: grid; place-items: center; min-width: 5.5rem; min-height: 5.5rem; padding: .3rem .7rem;
  border: 0; border-radius: 1.1rem; background: var(--paper); color: var(--ink); cursor: pointer;
  box-shadow: 0 0 0 3px var(--line) inset, 0 4px 0 rgba(23, 32, 51, .12); transition: transform .12s ease, box-shadow .12s ease, opacity .2s;
}
.jg-opt:hover { transform: translateY(-2px); }
.jg-opt:active { transform: translateY(2px); }
.jg-opt:focus-visible, .jg-mi:focus-visible, .jg-tile:focus-visible, .jg-drop:focus-visible, .jg-card-m:focus-visible { outline: 3px solid var(--sea); outline-offset: 3px; }
.jg-opt.is-ok { background: #dff5e3; box-shadow: 0 0 0 4px #2f9e55 inset; animation: jg-pop .45s ease; }
.jg-opt.is-ok::after { content: "✓"; position: absolute; top: -.6rem; inset-inline-end: -.6rem; width: 1.7rem; height: 1.7rem; display: grid; place-items: center; border-radius: 50%; background: #2f9e55; color: #fff; font-weight: 700; }
.jg-opt.is-bad { opacity: .45; }
.jg-opt:disabled { cursor: default; }
.jg-opts-num .jg-opt { min-width: 5rem; gap: .2rem; }
.jg-dots { display: flex; gap: .3rem; min-height: 1.1rem; align-items: center; }
.jg-dots i { width: .9rem; height: .9rem; border-radius: 50%; background: var(--ink); }
.jg-zero { color: var(--muted); }
.jg-num { display: inline-flex; gap: .7rem; font-weight: 700; font-size: 1.25rem; }

.jg-opt-pic { width: 100%; aspect-ratio: 1; padding: .5rem; align-content: center; gap: .2rem; background: var(--white); }
.jg-opt-pic .jg-pic { height: auto; aspect-ratio: 1; max-height: 9rem; }
.jg-grid3, .jg-grid4, .jg-grid6 { display: grid; gap: .8rem; width: 100%; max-width: 40rem; }
.jg-grid3 { grid-template-columns: repeat(3, 1fr); }
.jg-grid4 { grid-template-columns: repeat(2, 1fr); max-width: 30rem; }
.jg-grid6 { grid-template-columns: repeat(3, 1fr); }
.jg-gray .jg-pic { filter: grayscale(1) contrast(.8) brightness(1.15); opacity: .7; transition: filter .4s ease, opacity .4s ease; }
.jg-tag { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 0 .6rem; font-size: .85rem; font-weight: 600; color: #8a4b00; }

.jg-target { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .3rem 1rem; padding: .3rem 1rem; border-radius: 1.2rem; background: color-mix(in srgb, var(--c) 14%, white); }
.jg-fam { display: flex; align-items: center; gap: .8rem; padding: .3rem 1rem; border-radius: 1.2rem; background: color-mix(in srgb, var(--c) 14%, white); font-weight: 600; }
.jg-chips { display: flex; gap: .4rem; }
.jg-chip { font-size: 2.4rem; color: var(--c); filter: brightness(.8); }
.ll-btn.jg-listen { padding: .6rem 1.1rem; }
.ll-btn.jg-listen-big, .ll-btn.jg-start { font-size: 1.3rem; padding: 1.1rem 2rem; background: var(--sea); color: #fff; box-shadow: 0 6px 0 var(--sea-deep); }
.ll-btn.jg-listen-big:hover, .ll-btn.jg-start:hover { box-shadow: 0 6px 0 var(--sea-deep); }

/* une */
.jg-match { position: relative; display: grid; gap: 2.4rem; width: 100%; max-width: 40rem; padding: .2rem 0; }
.jg-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.jg-lines line { stroke-width: 5; stroke-linecap: round; }
.jg-mrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.jg-mi {
  display: grid; place-items: center; min-height: 4.5rem; padding: .3rem; border: 0; border-radius: 1rem; cursor: pointer;
  background: var(--paper); box-shadow: 0 0 0 3px var(--line) inset; position: relative; z-index: 1;
}
.jg-mrow0 .jg-mi { aspect-ratio: 1; background: var(--white); }
.jg-mrow0 .jg-pic { max-width: 6.5rem; }
.jg-mi .jg-glyph { font-size: 2.6rem; }
.jg-mw { font-size: 1.5rem; }
.jg-mi.is-sel { box-shadow: 0 0 0 4px #e0c800 inset; background: #fffbd1; transform: translateY(-2px); }
.jg-mi.is-linked { box-shadow: 0 0 0 4px var(--k) inset; }
.jg-mi.is-full { background: color-mix(in srgb, var(--k) 14%, white); }

/* memoria */
.jg-mem { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; max-width: 36rem; margin: 0 auto; }
.jg-card-m { position: relative; aspect-ratio: 1; border: 0; padding: 0; background: none; cursor: pointer; perspective: 600px; }
.jg-face { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 1rem; backface-visibility: hidden; transition: transform .35s ease; }
.jg-back { background: var(--sea); color: #fff; font-size: 2.2rem; font-family: var(--naskh); box-shadow: 0 4px 0 var(--sea-deep); }
.jg-front { background: var(--white); box-shadow: 0 0 0 3px var(--line) inset; transform: rotateY(180deg); padding: .4rem; }
.jg-front .jg-glyph { font-size: 2.8rem; color: var(--sea-deep); }
.jg-card-m.is-open .jg-back { transform: rotateY(180deg); }
.jg-card-m.is-open .jg-front { transform: rotateY(360deg); }
.jg-card-m.is-match .jg-front { box-shadow: 0 0 0 4px #2f9e55 inset; background: #effaf1; }

/* arrastra y ordena */
.jg-drops { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; width: 100%; max-width: 34rem; }
.jg-drop { display: grid; justify-items: center; gap: .3rem; padding: .5rem; border: 0; border-radius: 1rem; background: var(--white); box-shadow: 0 0 0 3px var(--line) inset; cursor: pointer; }
.jg-drop .jg-pic { aspect-ratio: 1; height: auto; max-width: 8rem; }
.jg-slot { display: grid; place-items: center; width: 3.4rem; height: 3.4rem; border: 3px dashed #c9a400; border-radius: .8rem; font-family: var(--naskh); font-weight: 700; font-size: 2rem; color: #c9a400; }
.jg-drop.is-over { box-shadow: 0 0 0 4px #e0c800 inset; background: #fffbd1; }
.jg-drop.is-ok { box-shadow: 0 0 0 4px #2f9e55 inset; background: #effaf1; }
.jg-drop.is-ok .jg-slot { border-style: solid; border-color: #2f9e55; color: #1b7a3a; }
.jg-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; min-height: 5.5rem; }
.jg-tile {
  display: grid; place-items: center; width: 5rem; height: 5rem; border: 0; border-radius: 1rem; cursor: grab; touch-action: none;
  background: #fde9c9; color: #6b3a00; box-shadow: 0 5px 0 #e0b26b; position: relative; z-index: 2;
}
.jg-tile .jg-glyph { font-size: 2.8rem; }
.jg-tile.is-drag { cursor: grabbing; z-index: 20; box-shadow: 0 12px 24px rgba(23, 32, 51, .25); transition: none; }
.jg-tile.is-sel { box-shadow: 0 0 0 4px #e0c800, 0 5px 0 #e0b26b; }
.jg-abc { display: flex; flex-wrap: wrap; justify-content: center; gap: .15rem .35rem; font-size: 1.3rem; color: #b8c0cc; }
.jg-abc .on { color: var(--sea); }
.jg-slots { display: flex; gap: .6rem; align-items: center; }
.jg-slot-prev { font-size: 2.2rem; color: var(--muted); padding: 0 .3rem; }
.jg-slotbox { display: grid; place-items: center; width: 4.2rem; height: 4.6rem; border: 3px dashed #c9a400; border-radius: .9rem; font-family: var(--naskh); font-weight: 700; font-size: 2.6rem; }
.jg-slotbox.is-ok { border-style: solid; border-color: #2f9e55; background: #effaf1; color: #1b7a3a; animation: jg-pop .4s ease; }

/* sopa */
.jg-swords { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-bottom: .8rem; }
.jg-sw { display: grid; justify-items: center; width: 5.5rem; padding: .3rem; border-radius: .9rem; background: var(--paper); font-size: 1.25rem; }
.jg-sw .jg-pic { width: 3.6rem; height: 3.6rem; }
.jg-sw.is-found { background: color-mix(in srgb, var(--k) 22%, white); box-shadow: 0 0 0 3px var(--k) inset; }
.jg-sw.is-found [lang="ar"] { text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: var(--k); }
.jg-sopa { display: grid; gap: .3rem; width: min(100%, 26rem); margin: 0 auto; touch-action: none; }
.jg-sc { display: grid; place-items: center; aspect-ratio: 1; border-radius: .6rem; background: var(--paper); font-size: clamp(1.4rem, 6vw, 2rem); cursor: pointer; line-height: 1; }
.jg-sc.is-sel { background: #fff3a0; box-shadow: 0 0 0 3px #e0c800 inset; }
.jg-sc.is-found { background: color-mix(in srgb, var(--k) 35%, white); }
.jg-hint { display: grid; gap: .1rem; margin: .8rem 0 0; text-align: center; color: var(--muted); font-size: .95rem; }

/* dibuja y colorea */
.jg-tools { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: center; margin: .6rem 0; }
.jg-palette { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; }
.jg-swatch { width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 3px solid var(--white); box-shadow: 0 0 0 2px var(--line); cursor: pointer; font-size: 1.2rem; background: var(--paper); }
.jg-swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.12); }
.jg-sizes { display: flex; gap: .4rem; }
.jg-size { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border: 0; border-radius: .7rem; background: var(--paper); cursor: pointer; }
.jg-size i { display: block; border-radius: 50%; background: var(--ink); }
.jg-size[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink) inset; }
.jg-canvas { display: block; margin: 0 auto; border-radius: 1rem; background: #fff; box-shadow: 0 0 0 3px var(--line); touch-action: none; cursor: crosshair; max-width: 100%; }
.jg-color { width: min(100%, 34rem); height: auto; aspect-ratio: 1; cursor: pointer; }
.jg-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-top: .8rem; }
.ll-btn.jg-tb { padding: .55rem 1rem; font-size: .98rem; }
.jg-ideas { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .8rem; margin: .4rem 0; }
.jg-ideas[hidden] { display: none; }
.jg-idea { display: grid; justify-items: center; font-size: 1.2rem; }
.jg-idea .jg-pic { width: 4.5rem; height: 4.5rem; }
.jg-gal-t { font-size: 1.15rem; margin: 1.4rem 0 .6rem; text-align: center; }
.jg-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr)); gap: .5rem; }
.jg-thumb { aspect-ratio: 1; padding: .25rem; border: 0; border-radius: .8rem; background: #fff; box-shadow: 0 0 0 2px var(--line) inset; cursor: pointer; }
.jg-thumb img { width: 100%; height: 100%; object-fit: contain; }
.jg-thumb.is-sel { box-shadow: 0 0 0 3px var(--sea) inset; }

/* final */
.jg-end { display: grid; justify-items: center; gap: .3rem; padding: 1rem; text-align: center; }
.jg-end p { margin: 0; }
.jg-end-big { font-size: 3.5rem; animation: jg-pop .6s ease; }
.jg-end-t { font-size: 1.8rem; font-weight: 700; font-family: var(--display); }
.jg-end-d { display: grid; gap: .2rem; color: var(--muted); font-size: 1.05rem; }
.jg-end-row { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; margin-top: .7rem; }
.jg-end .ll-btn { text-decoration: none; }

/* animaciones */
.is-shake { animation: jg-shake .45s ease; }
@keyframes jg-shake { 0%, 100% { translate: 0; } 20% { translate: -8px; } 40% { translate: 7px; } 60% { translate: -5px; } 80% { translate: 3px; } }
@keyframes jg-pop { 0% { scale: .85; } 60% { scale: 1.08; } 100% { scale: 1; } }
.jg-burst { position: absolute; width: 0; height: 0; pointer-events: none; z-index: 50; }
.jg-burst i { position: absolute; width: 11px; height: 11px; border-radius: 3px; animation: jg-fly .85s ease-out forwards; }
@keyframes jg-fly { from { transform: translate(0, 0) rotate(0); opacity: 1; } to { transform: translate(var(--x), var(--y)) rotate(200deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .is-shake, .jg-opt.is-ok, .jg-end-big, .jg-slotbox.is-ok { animation: none; }
  .jg-face { transition: none; }
}

@media (max-width: 560px) {
  .jg-board { padding: .7rem; border-radius: 1rem; }
  .jg-opt { min-width: 4.6rem; min-height: 4.6rem; }
  .jg-glyph { font-size: 2.6rem; }
  .jg-glyph-big { font-size: 4.4rem; }
  .jg-glyph-huge { font-size: 6.5rem; }
  .jg-mem { grid-template-columns: repeat(3, 1fr); }
  .jg-mrow { gap: .35rem; }
  .jg-mi .jg-glyph { font-size: 2.1rem; }
  .jg-mw { font-size: 1.15rem; }
  .jg-match { gap: 1.8rem; }
  .jg-tile { width: 4.3rem; height: 4.3rem; }
  .jg-word { font-size: 2rem; }
  .jg-grid6 { gap: .5rem; }
  .jg-swatch { width: 2.3rem; height: 2.3rem; }
}
