/* ==========================================================================
   ¡SOMBRA, SOMBRA! · El Gran Desafío de las Siluetas
   PlayLab Games · style.css
   Índice:
   1. Tokens y base        6. Zona de juego (objetos / sombras)
   2. Botones y chips      7. Efectos (toast, chispas, mano, splash)
   3. Fondo y logo         8. Ranking
   4. Menú principal       9. Modales (cómo se juega / resultados)
   5. Selector de niveles  10. Responsive y accesibilidad
   ========================================================================== */

/* ---------- 1. TOKENS Y BASE ---------- */
:root {
  --navy: #14235b;
  --ink: #1c2350;
  --yellow: #ffd23f;
  --orange: #ff8a1f;
  --green: #35c759;
  --blue: #3b8bff;
  --sky: #5ec8ff;
  --pink: #ff5fa2;
  --red: #ff4d5e;
  --purple: #7b4de8;
  --bg1: #162b80;
  --bg2: #3a1d8f;
  --card: #fff6dc;
  --text: #1c2350;
  --text-inv: #ffffff;
  --font: 'Fredoka', 'Baloo 2', 'Nunito', 'Trebuchet MS', 'Comic Sans MS', system-ui, sans-serif;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
/* El juego tiene su propia identidad nocturna; en modo oscuro solo se profundiza un poco. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg1: #0f1c5c; --bg2: #2a1470; --card: #fff1cf; }
}
:root[data-theme="dark"] { --bg1: #0f1c5c; --bg2: #2a1470; --card: #fff1cf; }

*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }

html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-inv);
  background:
    radial-gradient(circle at 15% 8%, #3f62e0 0, transparent 42%),
    radial-gradient(circle at 88% 92%, #8a45f0 0, transparent 46%),
    linear-gradient(160deg, var(--bg1), var(--bg2) 65%, #40208f);
  background-color: var(--bg1);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
#app { position: relative; width: 100%; height: 100%; overflow: hidden; }
button, input { font-family: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.screen {
  position: absolute; inset: 0; z-index: 2;
  display: none; flex-direction: column;
  padding: 12px clamp(10px, 3vw, 28px) 14px;
  overflow-x: hidden; overflow-y: auto;
}
.screen.active { display: flex; animation: screenIn .45s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes screenIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- 2. BOTONES Y CHIPS ---------- */
.btn {
  --c1: #ffb52e; --c2: #ff8a1f; --edge: #b85a00;
  appearance: none; border: 0; cursor: pointer;
  min-height: 56px; padding: 12px 26px;
  border-radius: 999px;
  font-weight: 700; font-size: clamp(18px, 4.4vw, 26px); letter-spacing: .01em;
  color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .22);
  background: linear-gradient(var(--c1), var(--c2));
  box-shadow: 0 6px 0 var(--edge), 0 12px 20px rgba(0, 0, 0, .28), inset 0 2px 0 rgba(255, 255, 255, .45);
  transition: transform .1s, box-shadow .1s, filter .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--edge), 0 4px 10px rgba(0, 0, 0, .25), inset 0 2px 0 rgba(255, 255, 255, .35); }
.btn:focus-visible, .level-card:focus-visible, .chip-btn:focus-visible, .avatar:focus-visible, .obj:focus-visible, input:focus-visible {
  outline: 4px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 7px var(--navy);
}
.btn[disabled] { filter: grayscale(.8) brightness(.9); opacity: .7; cursor: not-allowed; }
.btn-play { --c1: #6be36b; --c2: #26b44a; --edge: #16803a; }
.btn-rank { --c1: #ffd23f; --c2: #ffab1f; --edge: #b87400; color: #4a2a00; text-shadow: 0 2px 0 rgba(255, 255, 255, .4); }
.btn-how  { --c1: #62c8ff; --c2: #2f7bff; --edge: #1a4fb8; }
.btn-sound { --c1: #ff7eb6; --c2: #e83e8c; --edge: #a5205f; }
.btn-hint { --c1: #ffe36b; --c2: #ffb400; --edge: #b87f00; color: #4a2a00; text-shadow: 0 2px 0 rgba(255, 255, 255, .45); }
.btn-save { --c1: #6be36b; --c2: #26b44a; --edge: #16803a; }
.btn-ghost { --c1: rgba(255, 255, 255, .22); --c2: rgba(255, 255, 255, .12); --edge: rgba(0, 0, 0, .3); box-shadow: 0 5px 0 var(--edge), inset 0 2px 0 rgba(255, 255, 255, .3); }
.btn-small { min-height: 48px; padding: 8px 18px; font-size: clamp(15px, 3.6vw, 20px); }
.btn-icon { min-height: 52px; min-width: 52px; padding: 0; font-size: 26px; --c1: #62c8ff; --c2: #2f7bff; --edge: #1a4fb8; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 42px; padding: 4px 14px 4px 10px;
  border-radius: 999px; background: #fff; color: var(--ink);
  font-size: clamp(16px, 3.8vw, 22px); font-weight: 700;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip .ico { font-size: 1.15em; }
.chip.bump { animation: chipBump .5s cubic-bezier(.2, 1.8, .4, 1); }
.chip-score { background: linear-gradient(#fff9d6, #ffe680); }
.chip-combo { background: linear-gradient(#ffe0c2, #ffb37a); }
.chip-combo.hot { animation: hotPulse .6s ease-in-out infinite alternate; }
.chip-time.urgent { background: #ffd6d6; color: #a1121f; animation: hotPulse .5s ease-in-out infinite alternate; }
@keyframes chipBump { 0% { transform: scale(1); } 40% { transform: scale(1.28) rotate(-3deg); } 100% { transform: scale(1); } }
@keyframes hotPulse { from { transform: scale(1); } to { transform: scale(1.09); } }

/* ---------- 3. FONDO Y LOGO ---------- */
#bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bubble {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .5), rgba(255, 255, 255, .06) 60%);
  animation: rise linear infinite;
}
@keyframes rise { from { transform: translateY(20px); opacity: 0; } 10% { opacity: 1; } 90% { opacity: .9; } to { transform: translateY(-115vh); opacity: 0; } }
.floaty {
  position: absolute; width: var(--s); height: var(--s);
  opacity: .9; filter: drop-shadow(0 8px 0 rgba(0, 0, 0, .18));
  animation: floatY var(--t) ease-in-out infinite alternate;
  animation-delay: var(--dl);
}
.floaty svg { width: 100%; height: 100%; overflow: visible; }
@keyframes floatY { from { transform: translateY(-10px) rotate(var(--r0)); } to { transform: translateY(14px) rotate(var(--r1)); } }

.brand {
  position: fixed; z-index: 30; pointer-events: none;
  top: calc(env(safe-area-inset-top, 0px) + 6px); left: 8px;
}
.brand img { display: block; width: clamp(96px, 15vw, 150px); height: auto; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35)); }
body[data-screen="game"] .brand { display: none; }

/* ---------- 4. MENÚ PRINCIPAL ---------- */
#screen-menu { align-items: center; justify-content: center; }
.menu-wrap { width: min(680px, 100%); display: flex; flex-direction: column; align-items: center; gap: clamp(14px, 3vh, 28px); padding-top: clamp(50px, 9vh, 90px); }
.title-block { position: relative; text-align: center; }
.title { margin: 0; line-height: .95; font-size: clamp(46px, 13vw, 104px); font-weight: 700; display: flex; flex-direction: column; align-items: center; }
.title-line { display: block; white-space: nowrap; }
.tl {
  display: inline-block; color: var(--c);
  -webkit-text-stroke: .13em var(--navy); paint-order: stroke fill;
  text-shadow: 0 .07em 0 rgba(10, 15, 60, .55);
  transform: rotate(var(--r)); animation: letterBob 2.6s ease-in-out infinite; animation-delay: var(--d);
}
@keyframes letterBob { 0%, 100% { transform: translateY(0) rotate(var(--r)); } 50% { transform: translateY(-.08em) rotate(calc(var(--r) * -1)); } }
.subtitle {
  display: inline-block; margin: 12px 0 0; padding: 6px 20px;
  background: linear-gradient(#fff6dc, #ffe39a); color: var(--ink);
  border-radius: 999px; font-weight: 700; font-size: clamp(16px, 4vw, 26px);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .28);
}
.mascot { position: absolute; width: clamp(64px, 13vw, 110px); right: -2%; top: -6%; animation: mascotBob 3s ease-in-out infinite; z-index: 3; }
.mascot svg { width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .25)); }
.mascot .pupil { animation: look 4.5s ease-in-out infinite; }
@keyframes mascotBob { 0%, 100% { transform: translateY(0) rotate(6deg); } 50% { transform: translateY(-10px) rotate(-4deg); } }
@keyframes look { 0%, 100% { transform: translate(0, 0); } 30% { transform: translate(-3px, 1px); } 65% { transform: translate(3px, -1px); } }

.menu-buttons { width: min(420px, 100%); display: grid; gap: 14px; }
.menu-buttons .btn { width: 100%; }
.menu-buttons .btn-play { font-size: clamp(26px, 6.5vw, 38px); min-height: 76px; animation: playPulse 1.6s ease-in-out infinite; }
@keyframes playPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.menu-levels { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.mini-level {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 20px; color: #fff;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  box-shadow: 0 4px 0 rgba(0, 0, 0, .3), inset 0 2px 0 rgba(255, 255, 255, .4);
  border: 3px solid #fff;
}
.mini-level.locked { filter: grayscale(1); opacity: .65; border-style: dashed; }

/* ---------- 5. SELECTOR DE NIVELES ---------- */
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: clamp(40px, 8vh, 60px); margin-bottom: 8px; }
.screen-head h2 { margin: 0; font-size: clamp(26px, 6vw, 44px); text-shadow: 0 4px 0 rgba(0, 0, 0, .3); text-align: center; flex: 1; }
.head-spacer { width: 100px; flex: none; }
.btn-back { flex: none; }
@media (max-width: 520px) { .head-spacer { width: 0; } }

.theme-picker { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 6px 0 4px; }
.chip-btn {
  appearance: none; border: 0; cursor: pointer; min-height: 48px; padding: 6px 16px;
  border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--ink);
  font-weight: 700; font-size: clamp(15px, 3.6vw, 19px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .28); transition: transform .12s;
}
.chip-btn[aria-pressed="true"] { background: linear-gradient(#ffe36b, #ffb400); box-shadow: 0 4px 0 #b87f00; transform: translateY(-2px); }
.chip-btn[aria-pressed="true"]::after { content: " ✓"; }
.chip-btn:active { transform: translateY(2px); }
.theme-note { text-align: center; margin: 2px 0 10px; font-size: 15px; opacity: .9; min-height: 1.3em; }

.level-grid {
  width: min(1000px, 100%); margin: 0 auto;
  display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr));
  padding: 6px 4px 10px;
}
.level-card {
  position: relative; appearance: none; border: 0; text-align: left; cursor: pointer; font: inherit;
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center;
  padding: 14px 16px; min-height: 120px; border-radius: 28px; color: #fff;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  box-shadow: 0 8px 0 var(--edge), 0 14px 22px rgba(0, 0, 0, .3), inset 0 3px 0 rgba(255, 255, 255, .4);
  transition: transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.level-card:hover { transform: translateY(-3px) rotate(-.6deg); }
.level-card:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--edge); }
.lc-num {
  grid-row: span 3; width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center; font-size: 38px; font-weight: 700;
  background: rgba(255, 255, 255, .95); color: var(--edge);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .25);
}
.lc-emoji { position: absolute; right: 14px; top: 8px; font-size: 34px; }
.lc-name { font-weight: 700; font-size: clamp(19px, 4.2vw, 23px); line-height: 1.1; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); padding-right: 40px; }
.lc-meta { font-size: 15px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 4px 10px; opacity: .97; }
.lc-best { font-size: 15px; font-weight: 700; background: rgba(0, 0, 0, .25); padding: 2px 10px; border-radius: 999px; justify-self: start; }
.level-card.locked { filter: grayscale(.85) brightness(.85); cursor: not-allowed; }
.level-card.locked:hover { transform: none; }
.lc-lock { position: absolute; inset: 0; border-radius: 28px; display: grid; place-content: center; text-align: center; background: rgba(10, 15, 50, .55); font-weight: 700; font-size: 17px; }
.lc-lock span { font-size: 40px; display: block; }
.level-card.shake { animation: shake .45s; }

.levels-foot { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: center; margin-top: 10px; padding-bottom: 8px; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; cursor: pointer; min-height: 48px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-box { width: 56px; height: 32px; border-radius: 999px; background: rgba(255, 255, 255, .3); position: relative; box-shadow: inset 0 3px 0 rgba(0, 0, 0, .25); transition: background .2s; flex: none; }
.switch-box::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.switch input:checked + .switch-box { background: var(--green); }
.switch input:checked + .switch-box::after { transform: translateX(24px); }
.switch input:focus-visible + .switch-box { outline: 4px solid #fff; outline-offset: 3px; }

/* ---------- 6. ZONA DE JUEGO ---------- */
#screen-game { overflow: hidden; padding: 8px clamp(8px, 2vw, 22px) 10px; gap: 8px; touch-action: none; }
.game-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: none; }
.game-logo { height: 46px; width: auto; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .3)); }
.game-title { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; margin-right: auto; }
.gt-num { font-weight: 700; font-size: 14px; letter-spacing: .06em; opacity: .9; }
.gt-name { font-weight: 700; font-size: clamp(17px, 3.6vw, 26px); text-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.hud { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.board {
  position: relative; flex: 1 1 0; min-height: 0;
  display: flex; flex-direction: column; gap: 12px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.zone { position: relative; border-radius: 30px; min-height: 0; }
.zone-tray {
  flex: 38 1 0; z-index: 3;
  background: linear-gradient(180deg, #fff3bd, #ffd67a);
  box-shadow: 0 8px 0 #c98a1b, 0 14px 22px rgba(0, 0, 0, .3), inset 0 4px 0 rgba(255, 255, 255, .55);
}
.zone-shadows {
  flex: 62 1 0; z-index: 1;
  background: linear-gradient(180deg, #eaf6ff, #c6dbff);
  box-shadow: 0 8px 0 #6f8fd6, 0 14px 22px rgba(0, 0, 0, .3), inset 0 4px 0 rgba(255, 255, 255, .7);
}
.zone-label {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 1;
  padding: 2px 16px; border-radius: 999px; white-space: nowrap;
  font-weight: 700; font-size: clamp(13px, 3vw, 17px); color: var(--ink);
  background: rgba(255, 255, 255, .8);
}
.zone-shadows .zone-label { background: var(--navy); color: #fff; animation: labelPulse 2.4s ease-in-out infinite; }
@keyframes labelPulse { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.06); } }

.grid {
  position: absolute; left: 8px; right: 8px; top: 34px; bottom: 8px;
  display: grid; justify-content: center; align-content: center;
  grid-template-columns: repeat(var(--cols, 1), var(--cell, 80px));
  grid-auto-rows: var(--cell, 80px);
  gap: var(--gap, 6px);
}

/* Objetos arrastrables (parte superior) */
.obj {
  position: relative; width: var(--cell); height: var(--cell);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  will-change: transform; z-index: 1; border-radius: 24px;
}
.obj.dragging { z-index: 60; cursor: grabbing; transition: none !important; }
.obj.returning { z-index: 40; }
.obj-art {
  position: absolute; inset: 5%;
  transform: translate(var(--jx, 0%), var(--jy, 0%));
  filter: drop-shadow(0 5px 0 rgba(120, 70, 0, .22));
  pointer-events: none;
}
.obj-art svg { width: 100%; height: 100%; overflow: visible; display: block; animation: bob 3s ease-in-out infinite; animation-delay: var(--d, 0s); }
.obj.dragging .obj-art { filter: drop-shadow(0 18px 10px rgba(30, 20, 80, .4)); }
.obj.dragging .obj-art svg { animation: none; }
.obj.selected .obj-art { filter: drop-shadow(0 0 0 #fff) drop-shadow(0 0 10px #fff) drop-shadow(0 0 6px var(--orange)); }
.obj.selected .obj-art svg { animation: wiggle .5s ease-in-out infinite; }
.obj.hint .obj-art svg { animation: hintBounce .5s ease-in-out infinite; }
.obj.placed { pointer-events: none; }
.obj.placed .obj-art { visibility: hidden; }
.obj.placed::after {
  content: "✔"; position: absolute; inset: 22%; display: grid; place-items: center;
  border-radius: 50%; font-size: clamp(18px, 3.5vw, 30px); font-weight: 700; color: #1f8a3c;
  background: rgba(255, 255, 255, .5); border: 3px dashed rgba(31, 138, 60, .55);
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4%); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) scale(1.05); } }
@keyframes hintBounce { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-12%) scale(1.12); } }

/* Sombras (parte inferior) */
.slot { position: relative; width: var(--cell); height: var(--cell); }
.slot-pad {
  position: absolute; inset: 5%; border-radius: 28%;
  background: rgba(255, 255, 255, .6); box-shadow: inset 0 0 0 3px rgba(60, 80, 160, .14);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.slot-art {
  position: absolute; inset: 12%;
  transform: translate(var(--jx, 0%), var(--jy, 0%)) rotate(var(--rot, 0deg)) scale(var(--sc, 1));
}
.slot-art svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.slot-art .sh { filter: brightness(0); opacity: .82; transition: opacity .25s; }
.slot-art .co { opacity: 0; transform: scale(.5); transition: opacity .25s, transform .4s cubic-bezier(.2, 1.9, .4, 1); }
.slot.filled .slot-art .sh { opacity: 0; }
.slot.filled .slot-art .co { opacity: 1; transform: scale(1); }
.slot.filled .slot-pad {
  background: linear-gradient(#e2ffe0, #a8f5a2);
  box-shadow: 0 0 0 4px #2fb34f, 0 0 22px 4px rgba(60, 220, 90, .65);
}
.slot.filled::after {
  content: "✔"; position: absolute; right: 6%; top: 6%; width: 28%; max-width: 30px; aspect-ratio: 1; display: grid; place-items: center;
  border-radius: 50%; background: #2fb34f; color: #fff; font-weight: 700; font-size: 14px; border: 2px solid #fff;
  animation: popIn .4s cubic-bezier(.2, 2, .4, 1);
}
.slot.near .slot-pad { background: #fff; transform: scale(1.08); box-shadow: 0 0 0 4px var(--orange), 0 0 22px 6px rgba(255, 170, 40, .8); }
.slot.near-good .slot-pad { background: #fff; transform: scale(1.1); box-shadow: 0 0 0 4px #2fb34f, 0 0 26px 8px rgba(60, 220, 90, .85); }
.slot.hint .slot-pad { animation: hintGlow .55s ease-in-out infinite alternate; }
.slot.shake { animation: shake .45s; }
@keyframes hintGlow { from { background: #fff; box-shadow: 0 0 0 4px #ffd23f, 0 0 10px 2px rgba(255, 210, 63, .6); } to { background: #fff9d0; box-shadow: 0 0 0 6px #ffb400, 0 0 30px 10px rgba(255, 190, 0, .95); transform: scale(1.1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px) rotate(-2deg); } 40% { transform: translateX(8px) rotate(2deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }

.game-foot { display: flex; justify-content: center; flex: none; padding-top: 2px; }
.game-foot .btn { min-width: min(320px, 70vw); }

/* ---------- 7. EFECTOS ---------- */
.toast {
  position: absolute; left: 50%; top: 38%; z-index: 80; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transform: translate(-50%, -50%) scale(.5); opacity: 0; text-align: center;
  font-weight: 700; white-space: nowrap;
}
.toast .t-main {
  font-size: clamp(30px, 8vw, 64px); color: #fff; line-height: 1;
  -webkit-text-stroke: .13em var(--navy); paint-order: stroke fill;
  text-shadow: 0 .06em 0 rgba(0, 0, 0, .4);
}
.toast .t-sub { font-size: clamp(18px, 4vw, 28px); color: var(--yellow); -webkit-text-stroke: .16em var(--navy); paint-order: stroke fill; }
.toast.good .t-main { color: #fff27a; }
.toast.oops .t-main { color: #b9e4ff; }
.toast.show { animation: toastPop 1.05s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes toastPop {
  0% { transform: translate(-50%, -50%) scale(.4) rotate(-6deg); opacity: 0; }
  18% { transform: translate(-50%, -50%) scale(1.15) rotate(3deg); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  80% { transform: translate(-50%, -62%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(.9); opacity: 0; }
}
.float-score {
  position: absolute; z-index: 75; pointer-events: none; font-weight: 700; font-size: clamp(22px, 5vw, 34px);
  transform: translate(-50%, -50%); color: #fff; -webkit-text-stroke: .14em var(--navy); paint-order: stroke fill;
  animation: floatUp 1.1s ease-out forwards;
}
.float-score.minus { color: #ffb3bb; }
@keyframes floatUp { from { transform: translate(-50%, -50%) scale(.7); opacity: 1; } to { transform: translate(-50%, -190%) scale(1.1); opacity: 0; } }
.spark {
  position: absolute; z-index: 74; pointer-events: none; font-size: 22px; line-height: 1; color: var(--c, #ffd23f);
  transform: translate(-50%, -50%); animation: sparkFly .8s ease-out forwards; text-shadow: 0 0 6px rgba(255, 255, 255, .8);
}
@keyframes sparkFly { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2) rotate(180deg); opacity: 0; } }

.hand { position: absolute; z-index: 70; left: 0; top: 0; font-size: 56px; pointer-events: none; filter: drop-shadow(0 6px 4px rgba(0, 0, 0, .35)); animation: handMove 2.4s ease-in-out infinite; }
@keyframes handMove {
  0% { transform: translate(var(--x0), var(--y0)) scale(1); opacity: 0; }
  10% { opacity: 1; transform: translate(var(--x0), var(--y0)) scale(.9); }
  25% { transform: translate(var(--x0), var(--y0)) scale(.8); }
  75% { transform: translate(var(--x1), var(--y1)) scale(.8); opacity: 1; }
  90% { transform: translate(var(--x1), var(--y1)) scale(1); opacity: 0; }
  100% { transform: translate(var(--x1), var(--y1)) scale(1); opacity: 0; }
}

.splash { position: absolute; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(15, 20, 70, .55); border-radius: 30px; animation: fadeIn .2s; }
.splash.out { animation: fadeOut .35s forwards; }
.splash-card {
  text-align: center; padding: 22px 34px; border-radius: 34px; max-width: 92%;
  background: linear-gradient(#fff6dc, #ffe39a); color: var(--ink);
  box-shadow: 0 10px 0 rgba(0, 0, 0, .28); animation: cardIn .5s cubic-bezier(.2, 1.6, .4, 1);
}
.splash-emoji { font-size: clamp(50px, 12vw, 84px); line-height: 1; animation: mascotBob 1.4s ease-in-out infinite; }
.splash-num { font-weight: 700; font-size: 18px; letter-spacing: .08em; margin-top: 4px; }
.splash-name { font-weight: 700; font-size: clamp(26px, 7vw, 44px); line-height: 1.05; }
.splash-tip { margin-top: 8px; font-size: clamp(16px, 3.6vw, 22px); font-weight: 600; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 200; pointer-events: none; }

/* ---------- 8. RANKING ---------- */
.rank-filters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 6px 0 12px; }
.rank-card { width: min(720px, 100%); margin: 0 auto; background: var(--card); color: var(--ink); border-radius: 28px; padding: 10px 12px 12px; box-shadow: 0 8px 0 rgba(0, 0, 0, .28); }
.rank-row { display: grid; grid-template-columns: 76px 1fr 96px 60px; gap: 8px; align-items: center; padding: 9px 10px; border-radius: 16px; font-weight: 700; font-size: clamp(16px, 3.8vw, 21px); }
.rank-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.rank-row .lvl { text-align: center; }
.rank-head { font-size: 14px; opacity: .75; border-bottom: 3px dashed rgba(28, 35, 80, .15); border-radius: 0; }
.rank-list .rank-row:nth-child(odd) { background: rgba(255, 210, 63, .22); }
.rank-row.me { background: linear-gradient(90deg, #c9ffc9, #eaffd0) !important; outline: 3px solid #2fb34f; }
.rank-pos { font-size: 1.15em; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-empty { text-align: center; padding: 26px 10px; font-weight: 600; }
.rank-foot { text-align: center; font-size: 14px; opacity: .85; margin: 12px auto 4px; max-width: 520px; }

/* ---------- 9. MODALES ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  background: rgba(10, 14, 60, .68); overflow-y: auto;
}
.modal.open { display: flex; animation: fadeIn .25s; }
.card {
  width: min(560px, 100%); max-height: 100%; overflow-y: auto; margin: auto;
  background: var(--card); color: var(--ink); border-radius: 34px; padding: clamp(16px, 4vw, 26px);
  box-shadow: 0 10px 0 rgba(0, 0, 0, .28), 0 24px 40px rgba(0, 0, 0, .4);
  animation: cardIn .5s cubic-bezier(.2, 1.5, .4, 1);
}
@keyframes cardIn { from { transform: scale(.7) translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.card h2 { margin: 0 0 10px; font-size: clamp(26px, 6.5vw, 38px); text-align: center; line-height: 1.05; }

.how-demo { position: relative; height: 130px; margin: 6px auto 12px; max-width: 360px; border-radius: 22px; background: linear-gradient(#eaf6ff, #c6dbff); overflow: hidden; }
.how-demo svg { width: 100%; height: 100%; display: block; overflow: visible; }
.demo-shadow { position: absolute; right: 16%; top: 18%; width: 74px; height: 74px; }
.demo-shadow svg { filter: brightness(0); opacity: .8; }
.demo-obj { position: absolute; left: 14%; top: 18%; width: 74px; height: 74px; animation: demoMove 3.2s ease-in-out infinite; }
.demo-hand { position: absolute; left: 14%; top: 45%; font-size: 40px; animation: demoMove 3.2s ease-in-out infinite; filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .3)); }
@keyframes demoMove { 0%, 15% { transform: translateX(0) scale(1); } 60%, 85% { transform: translateX(190px) scale(1.1); } 100% { transform: translateX(0) scale(1); } }
@media (max-width: 420px) { @keyframes demoMove { 0%, 15% { transform: translateX(0) scale(1); } 60%, 85% { transform: translateX(150px) scale(1.1); } 100% { transform: translateX(0) scale(1); } } }
.how-steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.how-steps li { display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: center; font-size: clamp(16px, 3.8vw, 19px); font-weight: 600; background: rgba(255, 210, 63, .28); border-radius: 18px; padding: 8px 12px; }
.hs-ico { font-size: 30px; text-align: center; }
.how-card .btn { width: 100%; }

.res-stars { display: flex; justify-content: center; gap: 4px; font-size: clamp(44px, 12vw, 64px); line-height: 1; margin-bottom: 4px; }
.res-stars span { display: inline-block; animation: starIn .6s cubic-bezier(.2, 2, .4, 1) backwards; }
.res-stars .off { filter: grayscale(1) opacity(.35); }
.res-stars span:nth-child(1) { animation-delay: .1s; } .res-stars span:nth-child(2) { animation-delay: .35s; margin-top: -10px; } .res-stars span:nth-child(3) { animation-delay: .6s; }
@keyframes starIn { from { transform: scale(0) rotate(-200deg); } to { transform: none; } }
.res-sub { text-align: center; margin: 0 0 6px; font-weight: 600; }
.res-score { text-align: center; font-size: clamp(22px, 5vw, 30px); font-weight: 700; }
.res-score b { font-size: clamp(38px, 10vw, 58px); color: #e8590c; font-variant-numeric: tabular-nums; }
.res-new { text-align: center; margin: 2px 0 6px; font-weight: 700; color: #b34700; background: #fff0b8; border-radius: 999px; padding: 4px 12px; animation: hotPulse .6s ease-in-out infinite alternate; }
.res-grid { list-style: none; margin: 10px 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.res-grid li { display: flex; flex-direction: column; align-items: center; background: #fff; border-radius: 18px; padding: 8px 4px; box-shadow: 0 4px 0 rgba(0, 0, 0, .12); }
.res-grid li span { font-size: 22px; }
.res-grid li b { font-size: clamp(20px, 5vw, 26px); font-variant-numeric: tabular-nums; }
.res-grid li small { font-size: 12px; font-weight: 600; opacity: .8; text-align: center; }
.res-bonus { text-align: center; font-size: 15px; font-weight: 600; margin: 2px 0; min-height: 1.2em; }
.res-msg { text-align: center; font-size: clamp(20px, 5vw, 26px); font-weight: 700; margin: 6px 0 12px; }
.save-box { background: #fff; border-radius: 22px; padding: 12px; margin-bottom: 14px; box-shadow: inset 0 0 0 3px rgba(60, 80, 160, .12); }
.save-box label { display: block; font-weight: 700; text-align: center; margin-bottom: 8px; }
.avatars { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 8px; }
.avatar { appearance: none; border: 3px solid transparent; background: #f0f3ff; border-radius: 16px; width: 48px; height: 48px; font-size: 26px; cursor: pointer; }
.avatar[aria-checked="true"] { border-color: var(--green); background: #d9ffdf; transform: scale(1.12); }
.save-row { display: flex; gap: 8px; }
.save-row input { flex: 1; min-width: 0; min-height: 56px; border-radius: 999px; border: 3px solid #b5c3f2; padding: 0 18px; font-size: 22px; font-weight: 600; color: var(--ink); background: #fff; }
.save-row .btn { min-height: 56px; padding: 8px 20px; font-size: 20px; }
.save-help { display: block; margin-top: 8px; font-size: 13px; opacity: .8; text-align: center; }
.save-status { margin: 6px 0 0; text-align: center; font-weight: 700; min-height: 1.3em; }
.save-status.ok { color: #16803a; }
.save-status.warn { color: #b34700; }
.res-actions { display: grid; gap: 10px; }
.res-actions .btn { width: 100%; font-size: clamp(18px, 4.5vw, 22px); min-height: 56px; }
.res-actions .btn-ghost { --c1: #dfe5ff; --c2: #c5cff8; --edge: #8a99d6; color: var(--ink); text-shadow: none; }
.card .btn-ghost { box-shadow: 0 5px 0 var(--edge); }

/* ---------- 10. RESPONSIVE Y ACCESIBILIDAD ---------- */
@media (max-width: 720px) {
  .game-logo { display: none; }
  .game-head { gap: 6px; }
  .hud { order: 5; width: 100%; justify-content: space-between; gap: 5px; }
  .chip { padding: 3px 9px 3px 7px; min-height: 38px; gap: 4px; font-size: 16px; }
  .btn-icon { min-height: 46px; min-width: 46px; font-size: 22px; }
  .zone { border-radius: 24px; }
  .board { gap: 10px; }
  .brand img { width: 84px; }
  .mascot { right: -6%; top: -14%; }
  .rank-row { grid-template-columns: 62px 1fr 78px 44px; gap: 4px; padding: 8px 6px; }
  .res-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Móviles en horizontal: objetos a la izquierda, sombras a la derecha */
@media (orientation: landscape) and (max-height: 560px) {
  #screen-game { padding-top: 4px; padding-bottom: 6px; gap: 4px; }
  .board { flex-direction: row; gap: 10px; }
  .zone-tray { flex: 40 1 0; }
  .zone-shadows { flex: 60 1 0; }
  .game-logo { display: none; }
  .hud { order: 0; width: auto; }
  .btn-icon, .chip { min-height: 40px; }
  .game-foot .btn { min-height: 46px; padding: 4px 18px; font-size: 18px; }
  .gt-num { display: none; }
  .menu-wrap { padding-top: 8px; gap: 10px; }
  .title { font-size: clamp(34px, 9vh, 60px); }
  .menu-buttons { grid-template-columns: 1fr 1fr; width: min(640px, 100%); }
  .menu-buttons .btn-play { min-height: 60px; }
  .brand img { width: 70px; }
}
@media (min-width: 1100px) { .zone-label { font-size: 18px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .bubble, .floaty { display: none; }
}

/* Extras */
.obj.oops .obj-art svg { animation: shake .45s; }
@media (prefers-reduced-motion: reduce) {
  .toast.show { animation: none !important; opacity: 1; transform: translate(-50%, -50%) scale(1); }
  .float-score, .spark { display: none; }
}

/* Apodo y guardado */
.head-nick { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; }
.nick-card { text-align: center; }
.nick-emoji { font-size: 56px; line-height: 1; animation: mascotBob 2s ease-in-out infinite; }
.nick-input { width: 100%; min-height: 60px; border-radius: 999px; border: 3px solid #b5c3f2; padding: 0 20px; margin: 6px 0 2px; font-size: 26px; font-weight: 700; letter-spacing: .06em; text-align: center; color: var(--ink); background: #fff; }
.nick-card .btn { width: 100%; margin-top: 12px; }
.save-box { text-align: center; }
.save-box .btn { margin-top: 8px; }
