/* =========================================================
   YATZEE XTREME · Neón pixel-art
   Organización:
     1. Variables y base          8. Partida: barra, jugadores, turno
     2. Fondo                     9. Tabla y estados de casilla
     3. Botones                  10. Camino al bonus
     4. Logo y dados 3D          11. Bandeja de dados y jugadas posibles
     5. Paneles y formularios    12. Modales y apuntado rápido
     6. Configurar partida       13. Resultados
     7. Modos y editor           14. Efectos y aviso
                                 15. Diseño adaptable de la partida
                                 16. Modo ahorro
                                 17. Nueva partida, menú principal y temas
   Rendimiento: las animaciones continuas solo cambian opacity/transform (las hace la GPU sin repintar).
   Tipografías: --px (Pixelify Sans) para títulos y botones; --num (Chakra Petch)
   para texto y números; --logo (Press Start 2P) solo para logo y banners.
   ========================================================= */

/* ---------- 1. Variables y base ---------- */
:root {
  --bg: #07000f;
  --panel: rgba(20, 6, 46, .88);
  --cyan: #00f0ff; --pink: #ff2bd6; --yellow: #ffe600; --green: #39ff14;
  --orange: #ff8a00; --purple: #a64dff; --red: #ff3d6e;
  --adv: #39ff14; --dis: #ff4d6d;
  --text: #ece6ff; --dim: #8f84bd;
  --px: 'Pixelify Sans', system-ui, sans-serif;
  --num: 'Chakra Petch', system-ui, sans-serif;
  --logo: 'Press Start 2P', monospace;
  /* Igualan el tamaño visual de cada fuente (altura de mayúsculas) */
  --px-adj: cap-height 1;
  --num-adj: cap-height 0.6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse 120% 60% at 50% -5%, #3b0b6e 0%, #16022e 45%, var(--bg) 75%) fixed, var(--bg);
  color: var(--text); font-family: var(--num); font-size-adjust: var(--num-adj); font-size: 23px; font-weight: 500; line-height: 1.2;
  min-height: 100dvh; overflow-x: hidden; overscroll-behavior-y: none;
}
body.modal-open { overflow: hidden; }
button { font: inherit; color: inherit; }
::selection { background: var(--pink); color: #000; }

#app {
  position: relative; z-index: 10; max-width: 980px; margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}
.screen.enter { animation: screenIn .4s steps(8) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
body.shake #app { animation: shake .45s steps(9); }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translate(-6px, 3px); } 40% { transform: translate(5px, -4px); } 60% { transform: translate(-4px, -2px); } 80% { transform: translate(4px, 3px); } }
@keyframes flicker { 0%,18%,22%,60%,64%,100% { opacity: 1; } 20%,62% { opacity: .35; } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes fadeIn { from { opacity: 0; } }

.hint { color: var(--dim); font-size: 22px; font-weight: 500; line-height: 1.3; margin: 8px 0; }
.center { text-align: center; }

/* ---------- 2. Fondo ---------- */
#bg, #fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
#bg { z-index: 0; }
#fx { z-index: 50; }
.sun {
  position: fixed; left: 50%; bottom: 30vh; width: 46vmin; height: 46vmin; transform: translateX(-50%);
  z-index: 0; pointer-events: none; opacity: .35;
  background: repeating-linear-gradient(to bottom, transparent 0 55%, var(--bg) 55% 60%, transparent 60% 68%, var(--bg) 68% 72%, transparent 72% 80%, var(--bg) 80% 83%, transparent 83%),
              linear-gradient(to bottom, var(--yellow), var(--pink) 70%);
  border-radius: 50%; filter: blur(.5px) drop-shadow(0 0 30px var(--pink)); will-change: transform; /* capa propia: el filtro se rasteriza una vez */
  -webkit-mask-image: linear-gradient(#000 0 70%, transparent 100%); mask-image: linear-gradient(#000 0 70%, transparent 100%);
}
.grid-floor {
  position: fixed; left: -60%; right: -60%; bottom: 0; height: 32vh; z-index: 0; pointer-events: none; overflow: hidden;
  transform: perspective(260px) rotateX(62deg); transform-origin: bottom center; opacity: .35;
  -webkit-mask-image: linear-gradient(to top, #000 15%, transparent 95%); mask-image: linear-gradient(to top, #000 15%, transparent 95%);
}
/* La rejilla avanza moviendo una capa (transform), sin repintar */
.grid-floor::before {
  content: ''; position: absolute; left: 0; right: 0; top: -48px; bottom: 0; will-change: transform;
  background-image: linear-gradient(var(--pink) 2px, transparent 2px), linear-gradient(90deg, var(--pink) 2px, transparent 2px);
  background-size: 64px 48px; animation: gridmove 1.6s linear infinite;
}
@keyframes gridmove { from { transform: translateY(0); } to { transform: translateY(48px); } }
.sun, .grid-floor { transition: opacity .6s ease; }
body:not([data-bg="neon"]) .sun, body:not([data-bg="neon"]) .grid-floor { opacity: 0; }
body:not([data-bg="neon"]) .grid-floor::before { animation-play-state: paused; }
.scanlines {
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .22) 0 1px, transparent 1px 3px);
}

/* ---------- 3. Botones pixel 3D ---------- */
.btn {
  --c: var(--pink);
  --d: color-mix(in srgb, var(--c) 45%, #000);
  font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 14px; font-weight: 700; letter-spacing: 1px; line-height: 1.4;
  color: #0b0016; background: var(--c); border: 0; padding: 13px 16px; cursor: pointer;
  position: relative; text-transform: uppercase; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, .45), inset 0 -4px 0 rgba(0, 0, 0, .28),
    inset 4px 0 0 rgba(255, 255, 255, .18), inset -4px 0 0 rgba(0, 0, 0, .18),
    0 6px 0 0 var(--d), 0 6px 0 4px #000, 0 0 22px color-mix(in srgb, var(--c) 55%, transparent);
  transform: translateY(-3px); transition: transform .06s steps(2), box-shadow .06s steps(2), filter .15s;
  margin: 4px 4px 10px;
}
.btn:hover { filter: brightness(1.12); }
.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: inset 0 4px 0 rgba(0, 0, 0, .25), inset 0 -4px 0 rgba(255, 255, 255, .25), 0 0 0 0 var(--d), 0 0 0 4px #000, 0 0 30px var(--c);
}
.btn:disabled { filter: grayscale(.9) brightness(.55); cursor: not-allowed; }
/* Foco visible al navegar con teclado */
.btn:focus-visible, .mode-card:focus-visible, .choice:focus-visible, .qface:focus-visible, .qbtn:focus-visible, .play:focus-visible { outline: 3px dashed #fff; outline-offset: 4px; }
td.cell:focus-visible { outline: 3px dashed #fff; outline-offset: -6px; }
.die-wrap[role="button"]:focus-visible { outline: 3px dashed #fff; outline-offset: 6px; }
.btn small { display: block; font-family: var(--num); font-size-adjust: var(--num-adj); font-size: 21px; text-transform: none; letter-spacing: 0; margin-top: 6px; opacity: .8; }
.btn.big { display: flex; flex-direction: column; width: 100%; font-size: 17px; padding: 18px 16px; margin: 6px 0 16px; }
.btn.huge { display: flex; width: 100%; font-size: 22px; padding: 22px 16px; margin: 14px 0 18px; }
.btn.wide { display: flex; width: calc(100% - 8px); }
.btn.small { font-size: 12px; padding: 9px 11px; }
.btn.icon { width: 44px; height: 44px; padding: 0; font-size: 20px; font-family: system-ui, sans-serif; font-size-adjust: none; font-weight: 900; }
.btn.icon.s { width: 34px; height: 34px; font-size: 15px; margin: 2px 3px 8px; }
.btn.grow { flex: 1; }
.btn.ghost { --c: #2a1650; color: var(--text); box-shadow: inset 0 0 0 3px var(--dim), 0 6px 0 0 #120626, 0 6px 0 4px #000; }

/* ---------- 4. Logo y dados 3D ---------- */
.logo-wrap { perspective: 700px; display: flex; justify-content: center; margin: 26px 0 10px; }
.logo { font-family: var(--logo); font-size-adjust: none; text-align: center; transform-style: preserve-3d; animation: logoFloat 7s ease-in-out infinite; }
.logo .l1 {
  display: block; font-size: clamp(32px, 11vw, 78px); color: #fff; letter-spacing: 3px;
  text-shadow: 0 0 6px #fff, 0 0 16px var(--cyan), 0 0 34px var(--cyan),
    3px 3px 0 var(--pink), 6px 6px 0 #c4169f, 9px 9px 0 #7a0b66, 12px 12px 0 #3a0034, 14px 14px 18px #000;
}
.logo .l2 {
  display: block; margin-top: 18px; font-size: clamp(18px, 6.5vw, 44px); color: var(--yellow); letter-spacing: 8px;
  text-shadow: 0 0 10px var(--orange), 0 0 24px var(--orange), 3px 3px 0 var(--pink), 6px 6px 0 #6a0a5a;
  animation: flicker 5s infinite;
}
@keyframes logoFloat { 0%,100% { transform: rotateX(14deg) rotateY(-12deg); } 50% { transform: rotateX(-8deg) rotateY(12deg); } }

.die-wrap { --s: 56px; width: var(--s); height: var(--s); perspective: 420px; flex: none; }
.die { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.25, 1.45, .45, 1); }
.face {
  position: absolute; inset: 0; background: #1a0838; border: 3px solid var(--dc, var(--cyan));
  box-shadow: inset 0 0 12px color-mix(in srgb, var(--dc, var(--cyan)) 45%, transparent), 0 0 10px color-mix(in srgb, var(--dc, var(--cyan)) 40%, transparent);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 15%; gap: 9%;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.face i { display: block; }
.face i.on { background: var(--pip, var(--pink)); box-shadow: 0 0 6px var(--pip, var(--pink)); }
.f1 { transform: translateZ(calc(var(--s) / 2)); }
.f2 { transform: rotateY(90deg) translateZ(calc(var(--s) / 2)); }
.f3 { transform: rotateX(90deg) translateZ(calc(var(--s) / 2)); }
.f4 { transform: rotateX(-90deg) translateZ(calc(var(--s) / 2)); }
.f5 { transform: rotateY(-90deg) translateZ(calc(var(--s) / 2)); }
.f6 { transform: rotateY(180deg) translateZ(calc(var(--s) / 2)); }
/* Cara en miniatura (botones de número) */
.mface { display: inline-grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 30px; height: 30px; gap: 2px; vertical-align: middle; }
.mface i.on { background: var(--pc, var(--pink)); box-shadow: 0 0 4px var(--pc, var(--pink)); }
/* Iconos de jugada (SVG) */
.dice-ic { display: inline-block; vertical-align: middle; flex: none; filter: drop-shadow(0 0 3px rgba(0, 240, 255, .35)); }

/* Portada */
.dice-show { display: flex; justify-content: center; gap: clamp(10px, 4vw, 26px); margin: 26px 0 34px; }
.dice-show .die-wrap { --s: clamp(40px, 11vw, 64px); animation: bob 2.4s ease-in-out infinite; }
.dice-show .die { animation: spin 7s linear infinite; }
.dice-show .d1 { --dc: var(--pink); --pip: var(--cyan); animation-delay: -.4s; } .dice-show .d1 .die { animation-duration: 8s; animation-direction: reverse; }
.dice-show .d2 { --dc: var(--yellow); --pip: var(--pink); animation-delay: -.8s; } .dice-show .d2 .die { animation-duration: 6s; }
.dice-show .d3 { --dc: var(--green); --pip: var(--yellow); animation-delay: -1.2s; } .dice-show .d3 .die { animation-duration: 9s; animation-direction: reverse; }
.dice-show .d4 { --dc: var(--purple); --pip: var(--green); animation-delay: -1.6s; } .dice-show .d4 .die { animation-duration: 7.5s; }
@keyframes spin { from { transform: rotateX(0) rotateY(0) rotateZ(0); } to { transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg); } }
.home .menu { max-width: 440px; margin: 0 auto; }
.home-foot { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ---------- 5. Paneles y formularios ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  margin: 0 -16px 12px; padding: max(4px, env(safe-area-inset-top)) 16px 2px;
  background: linear-gradient(var(--bg) 65%, rgba(7, 0, 15, 0));
}
.topbar .btn.icon { margin: 4px 2px 8px; }
.topbar h1 { flex: 1; text-align: center; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: clamp(15px, 4.6vw, 22px); font-weight: 700; margin: 0; color: #fff; text-shadow: 0 0 10px var(--pink), 3px 3px 0 var(--pink); }
.stitle { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 14px; font-weight: 700; color: var(--dim); margin: 22px 0 10px; letter-spacing: 2px; }

.panel {
  --c: var(--cyan);
  position: relative; background: var(--panel); border: 4px solid var(--c); padding: 18px 14px 12px; margin: 0 0 22px;
  box-shadow: 0 0 0 4px #000, 0 0 26px color-mix(in srgb, var(--c) 40%, transparent), inset 0 0 30px color-mix(in srgb, var(--c) 12%, transparent);
}
.panel::before, .panel::after { content: ''; position: absolute; width: 8px; height: 8px; background: #000; }
.panel::before { top: -4px; left: -4px; } .panel::after { bottom: -4px; right: -4px; }
.ptitle { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 15px; font-weight: 700; color: var(--c); margin: 0 0 14px; text-shadow: 0 0 10px var(--c); display: flex; justify-content: space-between; align-items: baseline; }

/* Etiquetas en mayúsculas con la fuente de texto */
.ptitle span, .fld > span, .ce-type, .turn span, .kdisp span {
  font-family: var(--num); font-size-adjust: var(--num-adj); font-size: 21px; letter-spacing: .5px; text-transform: uppercase; color: var(--dim);
}
.ptitle span { text-shadow: none; }

.inp {
  width: 100%; background: #0b0219; color: var(--text); border: 3px solid #3a2670; padding: 10px 12px;
  font-family: var(--num); font-size-adjust: var(--num-adj); font-size: 25px; border-radius: 0; outline: none; transition: border-color .15s, box-shadow .15s;
}
.inp:focus { border-color: var(--cyan); box-shadow: 0 0 14px color-mix(in srgb, var(--cyan) 50%, transparent); }
select.inp { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%), linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 30px; }
textarea.inp { resize: vertical; }
.inp.code { font-size: 18px; word-break: break-all; }
.fld { display: block; margin-bottom: 10px; }
.fld > span { display: block; margin-bottom: 6px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 0 10px; }

.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 10px 0 6px; font-size: 23px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .tg { flex: none; width: 52px; height: 28px; background: #0b0219; border: 3px solid #3a2670; position: relative; transition: all .15s steps(3); }
.toggle .tg::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: var(--dim); transition: all .15s steps(3); }
.toggle input:checked + .tg { border-color: var(--green); box-shadow: 0 0 12px var(--green); }
.toggle input:checked + .tg::after { left: 27px; background: var(--green); }
.toggle input:focus-visible + .tg { outline: 3px dashed #fff; outline-offset: 3px; }
.toggle b { color: var(--green); }

/* ---------- 6. Configurar partida ---------- */
.plist { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.prow { display: flex; align-items: center; gap: 8px; }
.prow .inp { flex: 1; min-width: 0; border-color: color-mix(in srgb, var(--pc) 60%, #000); }
.prow .lvl { flex: 0 0 auto; width: 118px; font-size: 21px; padding: 10px 26px 10px 8px; border-color: color-mix(in srgb, var(--pc) 60%, #000); }
.prow .btn { margin: 0 2px 6px; }
.swatch {
  flex: none; width: 48px; height: 48px; border: 0; background: var(--pc); cursor: pointer; position: relative;
  box-shadow: inset 0 4px 0 rgba(255,255,255,.45), inset 0 -4px 0 rgba(0,0,0,.3), 0 0 0 3px #000, 0 0 16px var(--pc);
}
.swatch span { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 20px; color: #0b0016; }
.prow.is-bot .swatch span { font-family: system-ui, sans-serif; font-size: 24px; }
.mrow { display: flex; gap: 6px; }
.mrow .btn { margin-bottom: 10px; }

.choice2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  background: #0d0320; border: 3px solid #36246a; padding: 14px 10px; cursor: pointer; text-align: left; color: var(--text);
  display: flex; flex-direction: column; gap: 8px; transition: transform .15s, border-color .15s, box-shadow .15s;
}
.choice b { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 13px; font-weight: 700; color: #fff; }
.choice span { font-size: 20px; color: var(--dim); line-height: 1.1; }
.choice.sel { border-color: var(--yellow); transform: translateY(-3px); box-shadow: 0 0 0 3px #000, 0 0 22px color-mix(in srgb, var(--yellow) 55%, transparent); }
.choice.sel b { color: var(--yellow); text-shadow: 0 0 8px var(--yellow); }

/* Tarjetas de modo */
.modes-pick, .mlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 12px; }
.mode-card {
  background: #0d0320; border: 3px solid #36246a; padding: 12px; cursor: default; position: relative;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.mode-card[data-act] { cursor: pointer; }
.mode-card[data-act]:hover { transform: translateY(-3px) rotateX(4deg); border-color: var(--pink); }
.mode-card.sel { border-color: var(--pink); box-shadow: 0 0 0 3px #000, 0 0 24px color-mix(in srgb, var(--pink) 60%, transparent), inset 0 0 22px color-mix(in srgb, var(--pink) 18%, transparent); transform: translateY(-3px); }
.mc-head { display: flex; align-items: center; gap: 8px; }
.mc-head b { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 14px; font-weight: 700; color: #fff; flex: 1; }
.mode-card.sel .mc-head b { color: var(--pink); text-shadow: 0 0 8px var(--pink); }
.badge { font-family: var(--num); font-size-adjust: var(--num-adj); font-size: 18px; padding: 0 6px; background: #2a1650; color: var(--cyan); }
.badge.own { color: var(--yellow); }
.tick { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 15px; color: var(--green); text-shadow: 0 0 8px var(--green); }
.mode-card p { font-size: 22px; font-weight: 500; line-height: 1.3; color: var(--dim); margin: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 20px; padding: 1px 6px; background: rgba(0, 240, 255, .08); border: 2px solid rgba(0, 240, 255, .25); color: var(--text); white-space: nowrap; }
.chip b { color: var(--cyan); }
.chip .dice-ic { margin: -2px 2px 0 0; filter: none; }
.chip.c-dim { color: var(--dim); border-color: #36246a; background: none; }
.chip.c-y { border-color: rgba(255, 230, 0, .35); } .chip.c-y b { color: var(--yellow); }
.chip.c-p { border-color: rgba(255, 43, 214, .35); } .chip.c-p b { color: var(--pink); }
.chip.c-g { border-color: rgba(57, 255, 20, .4); color: var(--green); }
.chip.c-d { border-color: rgba(255, 138, 0, .5); color: var(--orange); }
.mc-actions { display: flex; flex-wrap: wrap; margin-top: 10px; }

/* ---------- 7. Editor de modos ---------- */
.cat-list { display: flex; flex-direction: column; gap: 12px; }
.cat-ed { border: 3px solid #36246a; border-left: 6px solid var(--pink); background: #0d0320; padding: 10px 10px 4px; }
.cat-ed.upper { border-left-color: var(--cyan); }
.cat-ed.flash { animation: flash 1s steps(4); }
@keyframes flash { 0%,50% { box-shadow: 0 0 24px var(--green); border-color: var(--green); } }
.ce-icon { line-height: 0; margin-bottom: 6px; }
.ce-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.ce-type { line-height: 1.5; }
.ce-btns { display: flex; flex: none; }
.ce-prev { margin: 0 0 8px; color: var(--yellow); font-size: 22px; }
.warn { font-style: normal; color: var(--orange); }
.addrow { display: flex; gap: 6px; align-items: flex-start; margin-top: 16px; }
.addrow .inp { flex: 1; min-width: 0; }
.addrow .btn { margin-top: 2px; }
.savebar {
  position: sticky; bottom: 0; z-index: 5; display: flex; gap: 6px; padding: 12px 0 calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}

/* ---------- 8. Partida: barra, jugadores, turno ---------- */
.gbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.gbar .btn { margin: 2px 2px 10px; }
.gtitle { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.gturn { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 14px; font-weight: 700; color: var(--pc); text-shadow: 0 0 8px var(--pc); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gmode { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 15px; font-weight: 700; color: #fff; text-shadow: 0 0 10px var(--cyan), 2px 2px 0 var(--pink); }
.ground { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 12px; font-weight: 700; color: var(--yellow); }

/* Avatar del jugador (cuadrado con su inicial) */
.av {
  width: 30px; height: 30px; display: inline-grid; place-items: center; flex: none; background: var(--pc);
  color: #0b0016; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 15px; box-shadow: inset 0 3px 0 rgba(255,255,255,.45), inset 0 -3px 0 rgba(0,0,0,.3);
}
/* Nombres de jugador */
.pchip .pn, th.ph .nm, .pod .pn, .rinfo b, .sm-who { font-family: var(--num); font-size-adjust: var(--num-adj); font-size: 23px; letter-spacing: .5px; }

.pstrip { display: flex; gap: 10px; overflow-x: auto; padding: 14px 16px 10px; margin: 0 -16px; scrollbar-width: none; perspective: 500px; }
.pstrip::-webkit-scrollbar { display: none; }
.pchip {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; cursor: pointer; position: relative;
  background: #0d0320; border: 3px solid color-mix(in srgb, var(--pc) 45%, #000); color: var(--text);
  transition: transform .2s, box-shadow .2s;
}
.pchip .pn { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pchip .pt { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--pc); min-width: 28px; text-align: right; }
.pchip.on { border-color: var(--pc); transform: translateY(-6px) rotateX(10deg) scale(1.05); box-shadow: 0 10px 0 -2px color-mix(in srgb, var(--pc) 40%, #000), 0 0 22px var(--pc); }
.crown { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); color: var(--yellow); font-size: 22px; text-shadow: 0 0 8px var(--yellow); animation: bob 1.6s ease-in-out infinite; line-height: 1; }

.turn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; padding: 10px 14px;
  border: 4px solid var(--pc); background: color-mix(in srgb, var(--pc) 12%, #0a0018);
  box-shadow: 0 0 0 4px #000, 0 0 24px color-mix(in srgb, var(--pc) 45%, transparent);
}
.turn span { display: block; margin-bottom: 2px; }
.turn b { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: clamp(16px, 4.8vw, 22px); font-weight: 700; color: var(--pc); text-shadow: 0 0 10px var(--pc); word-break: break-word; }
.turn small { font-size: 21px; color: var(--dim); }
.turn .btn { margin: 0 0 6px; }

/* Leyenda de estados de casilla */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -4px 0 10px; font-size: 18px; color: var(--dim); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .lg {
  display: inline-grid; place-items: center; width: 34px; height: 24px; font-style: normal; font-size: 15px; font-weight: 700;
  background: rgba(10, 0, 30, .72); border: 2px solid rgba(255, 255, 255, .06);
}
.legend .lg.filled {
  background: color-mix(in srgb, var(--pc) 20%, #0a0018); border-color: color-mix(in srgb, var(--pc) 45%, transparent);
  color: color-mix(in srgb, var(--pc) 18%, #fff);
  text-shadow: 0 0 3px var(--pc), 0 0 10px var(--pc), 0 0 20px color-mix(in srgb, var(--pc) 55%, transparent);
}
.legend .lg.open { background: #07000f; border: 3px dashed var(--pc); }
.legend .lg.open::after { content: '+'; color: var(--pc); opacity: .7; }
.legend .lg.can {
  border: 3px dashed var(--pc); color: rgba(255, 255, 255, .6);
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--pc) 16%, #07000f) 0 4px, #07000f 4px 8px);
}
.legend .lg.zero { color: #6b6290; background: rgba(10, 0, 30, .45); }
.legend .lg.par-up { width: auto; padding: 0 4px; color: var(--adv); font-size: 14px; background: none; border-color: transparent; }
.modal .legend { margin: 0 0 14px; }

/* ---------- 9. Tabla y estados de casilla ---------- */
/* Todo el tablero se dimensiona con --row-h, que calcula fitBoard() (app.js)
   para que el tablero completo quepa en la pantalla. */
.board-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch; }
.board {
  --row-h: 44px; --cat-w: clamp(150px, 48vw, 220px);
  --ic-h: clamp(12px, calc(var(--row-h) * .62), 28px);
  border-collapse: separate; border-spacing: 2px; width: 100%;
}
.board th, .board td { padding: 0; }
.board td { text-align: center; }
.board .corner, .board th.cat { position: sticky; left: 0; z-index: 2; background: #12052a; text-align: left; }
.board .corner { font-family: var(--num); font-size-adjust: var(--num-adj); font-size: 15px; color: var(--dim); padding: 4px 8px; vertical-align: bottom; }

/* Con menos jugadores, la columna de jugadas aprovecha el ancho libre */
@media (max-width: 759px) {
  .board.p1, .board.p2 { --cat-w: clamp(150px, 62vw, 300px); }
  .board.p4 { --cat-w: clamp(130px, 40vw, 200px); }
}
/* Columna de jugadas: icono de dados grande y nombre en una sola línea */
th.cat {
  width: var(--cat-w); max-width: var(--cat-w); height: var(--row-h);
  font-family: var(--num); font-size-adjust: var(--num-adj); font-size: clamp(14px, calc(var(--row-h) * .66), 26px); font-weight: normal; line-height: 1;
  padding: 0 6px; border-left: 4px solid var(--purple);
}
.catin { display: flex; align-items: center; gap: 6px; min-width: 0; }
th.cat .ci { flex: none; line-height: 0; }
th.cat .ci .dice-ic { height: var(--ic-h); width: auto; }
th.cat.up .ci .dice-ic { height: clamp(14px, calc(var(--row-h) * .78), 34px); }
th.cat .cn { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th.cat .cs { flex: none; font-size: .72em; color: var(--yellow); line-height: 1; padding: 1px 4px; background: rgba(255, 230, 0, .12); border: 1px solid rgba(255, 230, 0, .4); }

/* Cabecera de jugador */
th.ph { padding: 4px 3px 5px; min-width: 48px; max-width: 120px; color: var(--pc); border-bottom: 3px solid var(--pc); background: rgba(0, 0, 0, .45); vertical-align: bottom; }
th.ph .av { width: 22px; height: 22px; font-size: 12px; margin-bottom: 3px; }
th.ph .nm { display: block; font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th.ph .lead { font-style: normal; color: var(--yellow); text-shadow: 0 0 6px var(--yellow); margin-right: 2px; }
th.ph.cur { background: color-mix(in srgb, var(--pc) 25%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--pc) 60%, transparent); }

/* Casilla base: números y marcas escalan con la fila */
td.cell {
  height: var(--row-h); font-size: calc(var(--row-h) * .74); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1;
  background: rgba(10, 0, 30, .72); border: 2px solid rgba(255, 255, 255, .06); opacity: 1;
  cursor: pointer; position: relative; isolation: isolate; transition: transform .1s, background .15s; user-select: none;
}
/* Halo animado: capa aparte que solo cambia de opacidad (no obliga a repintar la casilla) */
@keyframes glowPulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
td.cell:hover { background: color-mix(in srgb, var(--pc) 15%, rgba(10, 0, 30, .75)); }
td.cell:active { transform: scale(.94); }
td.cell.cur { background: rgba(10, 0, 30, .72); }
td.cell small { font-size: .55em; color: var(--dim); margin-right: 3px; }
td.cell.pop { animation: cellPop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes cellPop { 0% { transform: scale(1.6) rotate(-6deg); background: var(--pc); color: #000; } 100% { transform: none; } }

/* Sin anotar (otro jugador) */
td.cell.empty { background: rgba(10, 0, 30, .45); }

/* Anotada: número casi blanco con halo de neón que respira */
td.cell.filled {
  background: color-mix(in srgb, var(--pc) 20%, #0a0018);
  border: 2px solid color-mix(in srgb, var(--pc) 45%, transparent);
  color: color-mix(in srgb, var(--pc) 18%, #fff);
  text-shadow: 0 0 3px var(--pc), 0 0 10px var(--pc), 0 0 18px color-mix(in srgb, var(--pc) 50%, transparent);
}
/* El halo que "respira" detrás del número */
td.cell.filled::after {
  content: ''; position: absolute; inset: 8% 14%; z-index: -1; pointer-events: none; border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--pc) 50%, transparent), transparent);
  animation: glowPulse 4.5s ease-in-out infinite;
}

/* Tachada */
td.cell.zero { background: rgba(10, 0, 30, .45); color: #6b6290; text-shadow: none; }

/* Pendiente (jugador en turno): marco discontinuo y pulso suave */
td.cell.open { background: #07000f; border: 3px dashed var(--pc); opacity: 1; box-shadow: none; transform: none; }
/* Pulso suave de la casilla pendiente (capa aparte, solo opacidad) */
td.cell.open::before {
  content: ''; position: absolute; inset: -3px; z-index: -1; pointer-events: none;
  box-shadow: inset 0 0 14px color-mix(in srgb, var(--pc) 30%, transparent), 0 0 12px color-mix(in srgb, var(--pc) 35%, transparent);
  opacity: 0; animation: glowPulse 2.8s ease-in-out infinite;
}
td.cell.open::after { content: '+'; color: var(--pc); opacity: .6; font-size: .8em; animation: plusFade 2.8s ease-in-out infinite; }
@keyframes plusFade { 0%, 100% { opacity: .35; } 50% { opacity: .8; } }

/* Con tirada: valor posible ("ghost") en vez del "+" */
td.cell .ghost { display: inline-block; position: relative; line-height: 1; }
td.cell.open.has-ghost::after, td.cell.open.has-ghost::before { content: none; }

/* …que no puntúa */
td.cell.open.cant { animation: none; opacity: .35; border: 3px dashed color-mix(in srgb, var(--pc) 85%, transparent); }
td.cell.open.cant .ghost { color: #8a80b0; font-size: .55em; font-weight: 600; opacity: .45; text-shadow: none; }

/* …que puntúa: rayas, valor tenue y centrado ("+" fuera del centro) */
td.cell.open.can {
  border: 3px dashed var(--pc);
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--pc) 16%, #07000f) 0 5px, #07000f 5px 11px);
  box-shadow: 0 0 6px color-mix(in srgb, var(--pc) 25%, transparent);
}
/* Brillo que late en las jugadas posibles (capa aparte, solo opacidad) */
td.cell.open.can::after {
  content: ''; position: absolute; inset: -3px; z-index: -1; pointer-events: none;
  box-shadow: 0 0 16px color-mix(in srgb, var(--pc) 50%, transparent);
  animation: glowPulse 3.2s ease-in-out infinite;
}
td.cell.open.can .ghost {
  color: #fff; font-size: .68em; font-weight: 600; font-style: normal;
  text-shadow: 0 0 6px var(--pc); opacity: .55; animation: ghostFade 3.2s ease-in-out infinite;
}
td.cell.open.can .ghost::before { content: '+'; position: absolute; right: 100%; padding-right: 1px; font-size: .8em; top: .1em; }
td.cell.open.best::before { content: '★'; position: absolute; top: 1px; right: 2px; font-size: max(10px, .36em); color: var(--yellow); text-shadow: 0 0 6px var(--yellow); }
@keyframes ghostFade { 0%, 100% { opacity: .4; } 50% { opacity: .7; } }

/* Elegida para anotar */
td.cell.open.picked { background: var(--pc); border: 3px solid #fff; box-shadow: 0 0 18px var(--pc); animation: none; }
td.cell.open.picked::after { content: none; }
td.cell.open.picked .ghost { color: #0b0016; font-size: .72em; font-weight: 700; opacity: 1; text-shadow: none; animation: none; }
td.cell.open.picked.can .ghost { font-size: .68em; }

/* Filas de sección y totales */
tr.sec td { text-align: left; padding: 0; height: 16px; vertical-align: bottom; }
tr.sec td span { position: sticky; left: 0; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 10px; color: var(--dim); letter-spacing: 2px; }
tr.sum td, tr.bonus td { height: var(--row-h); font-size: calc(var(--row-h) * .6); color: var(--text); background: rgba(0, 0, 0, .35); }
tr.sum th.cat, tr.bonus th.cat { border-left-color: var(--cyan); }
tr.yb th.cat { border-left-color: var(--pink); }
tr.total th.cat { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: clamp(11px, calc(var(--row-h) * .36), 15px); font-weight: 700; border-left-color: var(--yellow); color: var(--yellow); background: #1d0838; }
tr.total td {
  height: var(--row-h); font-size: calc(var(--row-h) * .82); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; color: var(--pc);
  text-shadow: 0 0 10px var(--pc), 2px 2px 0 #000; background: color-mix(in srgb, var(--pc) 14%, #0a0018); border-top: 3px solid var(--pc);
}

/* ---------- 10. Camino al bonus: ventaja (verde) / desventaja (rojo) ---------- */
.par {
  position: absolute; right: 3px; bottom: 2px; line-height: 1;
  font-family: var(--num); font-size-adjust: var(--num-adj); font-size: .5em; font-weight: 700; font-style: normal;
  text-shadow: none; animation: none; letter-spacing: 0;
}
.par.up { color: var(--adv); }
.par.down { color: var(--dis); }
.par.even { color: var(--dim); opacity: .55; }
td.cell.zero .par { opacity: .9; }
/* Número y ventaja: apilados si la fila es alta, en línea si es compacta */
.cstack { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1; vertical-align: middle; }
.cstack .cv { line-height: 1; }
.cstack .par { position: static; display: block; margin: 0; font-size: .5em; }
.board.compact .cstack { flex-direction: row; align-items: baseline; gap: 3px; }
.board.compact .cstack .par { font-size: .55em; }
td.cell.open.can .par.pre { opacity: .75; }
td.cell.open.can:has(.par.pre) .ghost { margin-top: 2px; }
.board.compact td.cell.open.can:has(.par.pre) .ghost { margin-top: 0; }
td.cell.open.picked .par.pre { color: #0b0016; opacity: .8; }

tr.bonus td { vertical-align: middle; position: relative; }
tr.bonus .bstate { display: block; font-size: 1.1em; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
tr.bonus .need { display: block; font-size: .7em; color: var(--dim); margin-top: 2px; }
tr.bonus .bar { display: block; height: 4px; margin: 2px 6px 0; background: #2a1650; }
tr.bonus .bar i { display: block; height: 100%; background: var(--pc); box-shadow: 0 0 6px var(--pc); }
.board.compact tr.bonus .bstate, .board.compact tr.bonus .need { display: inline; }
.board.compact tr.bonus .need { margin: 0 0 0 4px; font-size: .62em; }
.board.compact tr.bonus .bar { position: absolute; left: 4px; right: 4px; bottom: 2px; height: 3px; margin: 0; }
tr.bonus td.bal.up .bstate { color: var(--adv); text-shadow: 0 0 10px color-mix(in srgb, var(--adv) 60%, transparent); }
tr.bonus td.bal.down .bstate { color: var(--dis); text-shadow: 0 0 10px color-mix(in srgb, var(--dis) 60%, transparent); }
tr.bonus td.bal.even .bstate { color: var(--text); }
tr.bonus td.got { background: color-mix(in srgb, var(--adv) 14%, #0a0018); color: var(--green); text-shadow: 0 0 8px var(--green); }
tr.bonus td.got .bstate { color: color-mix(in srgb, var(--adv) 25%, #fff); font-size: .9em; text-shadow: 0 0 10px var(--adv), 0 0 22px var(--adv); }
tr.bonus td.lost { background: rgba(255, 77, 109, .08); }
tr.bonus td.lost .bstate { color: var(--dis); font-size: .9em; }

/* ---------- 11. Bandeja de dados y jugadas posibles ---------- */
/* Móvil: barra fija abajo, compacta (dados y botón en una fila, jugadas debajo).
   Escritorio: dentro del panel lateral (ver sección 15). */
body.has-tray #app { padding-bottom: calc(var(--tray-h, 120px) + 8px); }
body.has-tray #toast { bottom: calc(var(--tray-h, 120px) + 12px); }
.tray {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: linear-gradient(rgba(14, 3, 36, .97), #090016); border-top: 3px solid var(--pc);
  box-shadow: 0 -3px 0 #000, 0 -10px 34px color-mix(in srgb, var(--pc) 35%, transparent);
  padding: 4px 12px calc(6px + env(safe-area-inset-bottom));
  animation: trayIn .35s cubic-bezier(.2, 1.3, .4, 1);
}
.tray.no-in { animation: none; }
@keyframes trayIn { from { transform: translateY(100%); } }
.tray > * { max-width: 640px; margin-left: auto; margin-right: auto; }
.tray-head { display: none; justify-content: space-between; align-items: center; gap: 10px; }
.tray-who { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 13px; font-weight: 700; color: var(--pc); text-shadow: 0 0 8px var(--pc); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray.is-bot .tray-who::after { content: ' ▮'; animation: flicker 1s steps(2) infinite; }
.rolls { display: flex; gap: 6px; align-items: center; flex: none; }
.rolls i { width: 12px; height: 12px; background: var(--pc); box-shadow: 0 0 8px var(--pc); }
.rolls i.used { background: #2a1650; box-shadow: none; }

.tray-row { display: flex; align-items: center; gap: 8px; }
.tray-dice { flex: 1; min-width: 0; display: flex; justify-content: space-around; gap: 4px; padding: 10px 0 12px; }
.tray-dice .die-wrap { --s: clamp(30px, calc((100vw - 170px) / 5), 46px); cursor: pointer; position: relative; transition: transform .2s, opacity .2s; }
.tray-dice.n6 .die-wrap { --s: clamp(28px, calc((100vw - 170px) / 6), 44px); }
.tray-dice.idle .die-wrap { opacity: .3; }
.tray.is-bot .die-wrap { cursor: default; }
.tdie.held { --dc: var(--yellow); --pip: var(--yellow); transform: translateY(-5px); }
.tdie.held::after { content: ''; position: absolute; left: 15%; right: 15%; bottom: -8px; height: 3px; background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.tray-dice .die-wrap.rolling { animation: hop .7s cubic-bezier(.3, 1.6, .5, 1) both; }
.tdie.held.rolling { animation: none; }
@keyframes hop { 0% { transform: translateY(0); } 35% { transform: translateY(-34px); } 70% { transform: translateY(4px); } 100% { transform: translateY(0); } }

.tray-act { flex: none; display: flex; gap: 4px; }
.tray-act .btn { margin: 2px 0 8px; padding: 10px 9px; font-size: 12px; }
.tray-roll .lbl.opt { display: none; }   /* móvil: "🎲 2" basta tras la primera tirada */
/* Tiradas restantes: fuente de números (la pixel confunde el 2 con un 8 a este tamaño) */
.tray-roll em {
  font-style: normal; display: inline-grid; place-items: center; min-width: 24px; height: 24px; margin-left: 6px; padding: 0 4px;
  font-family: var(--num); font-size-adjust: var(--num-adj); font-size: 22px; font-weight: 700; line-height: 1; letter-spacing: 0;
  background: #0b0016; color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5);
}
.tray-hint { display: none; text-align: center; color: var(--dim); font-size: 20px; font-weight: 500; line-height: 1.3; margin: 2px 0 0; }

.plays { display: flex; gap: 6px; overflow-x: auto; padding: 0 2px 4px; min-height: 40px; scrollbar-width: none; scroll-snap-type: x proximity; }
.plays::-webkit-scrollbar { display: none; }
.plays.empty { display: block; text-align: center; color: var(--dim); font-size: 17px; line-height: 1.2; padding: 8px 0 4px; }
.play {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; cursor: pointer; scroll-snap-align: start;
  background: #120530; border: 2px solid color-mix(in srgb, var(--pc) 55%, #000); color: var(--text);
  font-family: var(--num); font-size: 18px; font-weight: 600; box-shadow: 0 4px 0 #000; transition: transform .06s, box-shadow .15s;
}
.play b { color: var(--pc); font-size: 20px; font-variant-numeric: tabular-nums; }
.play em { font-style: normal; font-size: 13px; color: #0b0016; background: var(--green); padding: 0 4px; }
.play .dice-ic { filter: none; height: 15px; width: auto; }
.play.best { border-color: var(--yellow); }
.play.best b::after { content: ' ★'; color: var(--yellow); }
.play.on { background: var(--pc); border-color: #fff; color: #0b0016; box-shadow: 0 4px 0 #000, 0 0 16px var(--pc); }
.play.on b { color: #0b0016; }
.play:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.play:disabled { cursor: default; }

/* ---------- 12. Modales y apuntado rápido ---------- */
#modal-root { position: fixed; inset: 0; z-index: 40; display: none; }
#modal-root.open { display: flex; align-items: flex-end; justify-content: center; }
.modal-bg { position: absolute; inset: 0; background: rgba(5, 0, 15, .86); animation: fadeIn .2s; }
.modal {
  position: relative; width: 100%; max-width: 520px; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain;
  background: linear-gradient(#170733, #0c0220); border: 4px solid var(--pc); border-bottom: 0;
  padding: 20px 16px calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 0 0 4px #000, 0 0 50px color-mix(in srgb, var(--pc) 45%, transparent);
  animation: sheetIn .35s cubic-bezier(.2, 1.25, .4, 1);
}
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
@media (min-width: 700px) {
  #modal-root.open { align-items: center; }
  .modal { border-bottom: 4px solid var(--pc); padding-bottom: 18px; animation: popIn .35s cubic-bezier(.2, 1.4, .4, 1); }
  @keyframes popIn { from { transform: perspective(600px) rotateX(-25deg) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
}
.xclose { position: absolute; top: 8px; right: 8px; width: 38px; height: 38px; background: none; border: 0; color: var(--dim); font-size: 23px; font-size-adjust: none; cursor: pointer; }
.xclose:hover { color: #fff; }
.mtitle { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 17px; font-weight: 700; color: var(--pc); text-shadow: 0 0 10px var(--pc); margin: 4px 40px 14px 0; line-height: 1.4; }
.mtext { font-size: 23px; margin: 0 0 14px; }
.mmenu { display: flex; flex-direction: column; }
.sm-foot { display: flex; gap: 6px; margin-top: 14px; align-items: stretch; }
.sm-foot .btn { margin: 4px 0 10px; }

.sm-head { padding-right: 36px; }
.sm-who { display: flex; align-items: center; gap: 8px; font-size: 24px; color: var(--pc); }
.sm-who .av { --pc: inherit; background: var(--pc); width: 26px; height: 26px; font-size: 13px; }
.sm-icon { margin: 12px 0 -2px; line-height: 0; }
.sm-head h3 { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: clamp(19px, 5.8vw, 26px); font-weight: 700; margin: 12px 0 8px; color: #fff; text-shadow: 0 0 10px var(--pc), 3px 3px 0 color-mix(in srgb, var(--pc) 60%, #000); }
.sm-rule { margin: 0; color: var(--yellow); font-size: 22px; font-weight: 500; line-height: 1.3; }
.sm-cur { margin: 6px 0 0; font-size: 22px; color: var(--dim); }
.sm-cur b { color: var(--pc); }
.link { background: none; border: 0; color: var(--cyan); text-decoration: underline; cursor: pointer; font-size: 22px; padding: 0; }

.tabs { display: flex; gap: 0; margin: 16px 0 14px; border-bottom: 3px solid #36246a; }
.tab { flex: 1; background: none; border: 0; padding: 10px 4px; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 13px; font-weight: 700; color: var(--dim); cursor: pointer; border-bottom: 4px solid transparent; margin-bottom: -3px; }
.tab.on { color: var(--pc); border-bottom-color: var(--pc); text-shadow: 0 0 8px var(--pc); }

/* Pestaña "Con dados" */
.dice-row { display: flex; justify-content: center; gap: clamp(8px, 3vw, 16px); padding: 18px 0 14px; }
.dice-row .die-wrap { --s: clamp(46px, 13vw, 62px); cursor: pointer; transition: transform .15s; position: relative; }
.dice-row.n6 { gap: clamp(6px, 2.4vw, 14px); }
.dice-row.n6 .die-wrap { --s: clamp(38px, 10.5vw, 56px); }
.dice-row .die-wrap.sel { transform: translateY(-10px); --dc: var(--pc); }
.dice-row .die-wrap.sel::after { content: ''; position: absolute; left: 50%; bottom: -16px; width: 10px; height: 6px; transform: translateX(-50%); background: var(--pc); box-shadow: 0 0 8px var(--pc); }
.dice-row .die-wrap.rolling { animation: hop .6s cubic-bezier(.3, 1.6, .5, 1) both; }
.facepad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 6px 0; }
.fbtn { aspect-ratio: 1; background: #0d0320; border: 3px solid #36246a; cursor: pointer; padding: 5px; max-height: 60px; display: grid; place-items: center; transition: border-color .1s, transform .06s; }
.fbtn:hover { border-color: var(--pc); }
.fbtn:active { transform: scale(.9); border-color: var(--pc); box-shadow: 0 0 14px var(--pc); }
.dice-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dice-tools .hint { font-size: 21px; margin: 0; }
.dice-tools .btn { margin: 6px 4px 10px; }
.preview { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; margin-top: 8px; border: 3px solid; }
.preview span { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 13px; font-weight: 700; }
.preview b { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.preview.ok { border-color: var(--green); color: var(--green); background: rgba(57, 255, 20, .07); box-shadow: 0 0 16px rgba(57, 255, 20, .35); }
.preview.ok b { text-shadow: 0 0 10px var(--green); }
.preview.bad { border-color: #4d2a5e; color: #a07aa8; }
.ybn { text-align: center; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 13px; color: var(--pink); text-shadow: 0 0 10px var(--pink); animation: flicker 1s infinite; margin: 10px 0 0; }

/* Pestaña "Rápido" */
.qlabel { font-size: 23px; margin: 4px 0 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qcount { font-style: normal; font-weight: 700; color: var(--yellow); margin-left: auto; }
.qgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.qgrid.n7 { grid-template-columns: repeat(4, 1fr); }
.qbtn {
  background: #0d0320; border: 3px solid color-mix(in srgb, var(--pc) 50%, #000); padding: 12px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .08s, box-shadow .15s;
  box-shadow: 0 5px 0 #000;
}
.qbtn b { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 20px; font-weight: 700; color: var(--pc); }
.qbtn span { font-size: 23px; color: var(--text); }
.qbtn:hover { border-color: var(--pc); box-shadow: 0 5px 0 #000, 0 0 16px color-mix(in srgb, var(--pc) 50%, transparent); }
.qbtn:active { transform: translateY(4px); box-shadow: 0 1px 0 #000, 0 0 22px var(--pc); }
.fgrid6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 12px; }
.qface {
  background: #0d0320; border: 3px solid color-mix(in srgb, var(--pc) 45%, #000); padding: 8px 2px 6px; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 5px 0 #000; transition: transform .06s, box-shadow .15s;
}
.qface .mface { width: clamp(28px, 8vw, 40px); height: clamp(28px, 8vw, 40px); }
.qface span { font-size: 24px; line-height: 1; color: var(--pc); min-height: 22px; }
.qface:hover { border-color: var(--pc); }
.qface:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #000, 0 0 18px var(--pc); }
.qface.on { background: color-mix(in srgb, var(--pc) 30%, #0d0320); border-color: var(--pc); box-shadow: 0 5px 0 #000, 0 0 16px var(--pc); }
.qface.on span { color: #fff; }
.qface:disabled { opacity: .25; cursor: not-allowed; }
.qrowg .qlabel { color: var(--pc); }
.qrowg .mface i.on { background: var(--pc); box-shadow: 0 0 4px var(--pc); }
.qsets .btn { margin: 4px 4px 12px; }
.kdisp { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 6px 12px; border: 3px solid var(--pc); background: #08011a; margin-bottom: 10px; }
.kdisp span { flex-basis: 100%; }
.kdisp > b { font-size: 50px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--pc); text-shadow: 0 0 10px var(--pc); line-height: 1; }
.kdisp em { font-style: normal; font-size: 30px; color: var(--yellow); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key { background: #1a0a38; border: 0; padding: 10px; font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; color: var(--text); box-shadow: inset 0 3px 0 rgba(255,255,255,.12), 0 5px 0 #000; transition: transform .05s; }
.key:active { transform: translateY(4px); box-shadow: 0 1px 0 #000; background: color-mix(in srgb, var(--pc) 40%, #1a0a38); }

/* Opciones */
.opt-sec { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 11px; font-weight: 700; letter-spacing: 2px; color: var(--dim); margin: 18px 0 2px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 2px dotted #36246a; }
.opt-txt { flex: 1; min-width: 0; }
.opt-txt b { display: block; font-size: 22px; font-weight: 700; color: var(--text); }
.opt-txt span { display: block; font-size: 18px; line-height: 1.25; color: var(--dim); margin-top: 2px; }
.opt-txt em { font-style: normal; color: var(--yellow); }
.opt.off .opt-txt b { color: var(--dim); }
.opt .toggle { margin: 0; flex: none; }
.toggle input:disabled + .tg { opacity: .35; cursor: not-allowed; }
.seg { display: flex; flex: none; border: 2px solid #36246a; }
.segb {
  background: #0d0320; border: 0; padding: 8px 8px; cursor: pointer; color: var(--dim);
  font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 10px; font-weight: 700; letter-spacing: .5px;
}
.segb + .segb { border-left: 2px solid #36246a; }
.segb.on { background: var(--cyan); color: #0b0016; box-shadow: 0 0 12px color-mix(in srgb, var(--cyan) 60%, transparent); }
.segb:focus-visible { outline: 3px dashed #fff; outline-offset: 2px; }
.modal.options .btn.wide { margin-top: 12px; }
@media (max-width: 380px) { .opt { flex-wrap: wrap; } .seg { width: 100%; } .segb { flex: 1; } }

/* Otros modales */
.stepper { display: flex; justify-content: center; align-items: center; gap: 22px; margin: 10px 0; }
.stepper b { font-size: 64px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--pc); text-shadow: 0 0 12px var(--pc); min-width: 60px; text-align: center; }
.rules { list-style: none; padding: 0; margin: 0 0 16px; }
.rules li { display: flex; gap: 10px; justify-content: space-between; padding: 7px 0; border-bottom: 2px dotted #36246a; font-size: 22px; }
.rules li b { display: flex; align-items: center; gap: 8px; font-family: var(--num); font-size-adjust: var(--num-adj); font-size: 22px; color: var(--cyan); flex: none; padding-top: 0; }
.rules li span { text-align: right; color: var(--text); }
.rules li.hl b { color: var(--yellow); }

/* ---------- 13. Resultados ---------- */
.res-title { text-align: center; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: clamp(16px, 5vw, 26px); font-weight: 700; color: #fff; text-shadow: 0 0 12px var(--cyan), 3px 3px 0 var(--pink); margin: 18px 0 14px; }
.winner { text-align: center; margin-bottom: 18px; }
.winner span { display: block; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 13px; color: var(--yellow); margin-bottom: 10px; animation: flicker 2s infinite; }
.winner b { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: clamp(18px, 6vw, 32px); font-weight: 700; color: var(--pc); text-shadow: 0 0 14px var(--pc), 3px 3px 0 #000; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 30px 0 26px; perspective: 600px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 30%; max-width: 150px; position: relative; animation: rise .9s cubic-bezier(.2, 1.3, .4, 1) both; }
.pod.r1 { animation-delay: .5s; } .pod.r2 { animation-delay: .25s; }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
.pod .av { width: 40px; height: 40px; font-size: 20px; box-shadow: 0 0 18px var(--pc); }
.pod .crown { top: -24px; font-size: 30px; }
.pod .pn { color: var(--pc); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pts { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; text-shadow: 0 0 10px var(--pc); line-height: 1; }
.pod .block {
  width: 100%; display: grid; place-items: center; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 25px; color: #0b0016;
  background: linear-gradient(var(--pc), color-mix(in srgb, var(--pc) 50%, #000));
  box-shadow: inset 0 6px 0 rgba(255,255,255,.4), 0 0 0 4px #000, 0 0 30px color-mix(in srgb, var(--pc) 60%, transparent);
  transform: rotateX(8deg); transform-origin: bottom;
}
.pod.r1 .block { height: 130px; } .pod.r2 .block { height: 90px; } .pod.r3 .block { height: 60px; }
.pod:not(.r1):not(.r2):not(.r3) .block { height: 40px; }
.rank-list { padding: 8px 12px; }
.rrow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 2px dotted #36246a; }
.rrow:last-child { border-bottom: 0; }
.rk { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 14px; color: var(--dim); width: 30px; }
.rinfo { flex: 1; min-width: 0; }
.rinfo b { display: block; color: var(--pc); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; }
.rinfo small { font-size: 22px; font-weight: 500; line-height: 1.3; color: var(--dim); }
.rt { font-size: 38px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--pc); text-shadow: 0 0 8px var(--pc); }
.res-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 0 6px; }
.res-btns .big { grid-column: 1 / -1; }
.res-btns .btn { margin: 4px 0 12px; }

/* ---------- 14. Efectos, aviso, adaptación ---------- */
.float-text {
  position: fixed; z-index: 55; pointer-events: none; transform: translate(-50%, -50%);
  font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 20px; font-weight: 700; color: var(--c); white-space: nowrap;
  text-shadow: 0 0 10px var(--c), 2px 2px 0 #000; animation: floatUp 1.4s steps(14) forwards;
}
.float-text.big { font-size: 30px; }
@keyframes floatUp { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; } 15% { transform: translate(-50%, -70%) scale(1.25); opacity: 1; } 100% { transform: translate(-50%, -260%) scale(1); opacity: 0; } }
.banner { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; pointer-events: none; perspective: 700px; }
.b-in { text-align: center; animation: bannerIn 1.9s cubic-bezier(.2, 1.3, .4, 1) forwards; padding: 0 10px; }
.b-in b { display: block; font-family: var(--logo); font-size-adjust: none; font-size: clamp(28px, 10vw, 72px); color: #fff;
  text-shadow: 0 0 10px #fff, 0 0 26px var(--c), 0 0 50px var(--c), 4px 4px 0 var(--c), 8px 8px 0 color-mix(in srgb, var(--c) 45%, #000), 12px 12px 0 #000; }
.b-in span { display: block; margin-top: 16px; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: clamp(14px, 4.5vw, 26px); font-weight: 700; color: var(--c); text-shadow: 0 0 12px var(--c), 3px 3px 0 #000; }
@keyframes bannerIn {
  0% { transform: rotateX(80deg) scale(.2); opacity: 0; }
  20% { transform: rotateX(-10deg) scale(1.15); opacity: 1; }
  30% { transform: none; }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6) rotateX(-40deg); opacity: 0; }
}
.sweep {
  position: fixed; left: 0; right: 0; top: 42%; z-index: 55; pointer-events: none; height: 64px; display: grid; place-items: center;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--c) 85%, #000) 15%, color-mix(in srgb, var(--c) 85%, #000) 85%, transparent);
  box-shadow: 0 0 40px var(--c); animation: sweep 1.3s cubic-bezier(.7, 0, .3, 1) forwards;
}
.sweep span { font-family: var(--px); font-size-adjust: var(--px-adj); font-size: clamp(13px, 4.5vw, 22px); font-weight: 700; color: #0b0016; text-shadow: 2px 2px 0 rgba(255,255,255,.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 92vw; }
@keyframes sweep { 0% { transform: translateX(-110%) skewX(-20deg); } 30%,70% { transform: none; } 100% { transform: translateX(110%) skewX(-20deg); } }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 70; transform: translate(-50%, calc(100% + 80px)); opacity: 0;
  background: #0b0016; border: 3px solid var(--cyan); padding: 10px 16px; font-size: 23px; max-width: 90vw;
  box-shadow: 0 0 0 3px #000, 0 0 20px rgba(0, 240, 255, .5); transition: transform .3s cubic-bezier(.2, 1.4, .4, 1); pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- 15. Diseño adaptable de la partida ---------- */
/* Móvil y tablet: barra compacta con el turno; el tablero ocupa el resto de la pantalla.
   Los jugadores y la leyenda están en la cabecera del tablero y en Menú ▸ Reglas y leyenda. */
body[data-screen="game"] #app { padding-top: max(6px, env(safe-area-inset-top)); }
body[data-screen="game"]:not(.has-tray) #app { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
body[data-screen="game"].has-tray #app { padding-bottom: calc(var(--tray-h, 120px) + 4px); }
.game .pstrip, .game .turn, .game .legend { display: none; }
.game .turn.done { display: flex; }
.game .gbar { margin-bottom: 2px; }
.game .gbar .btn.icon { width: 38px; height: 38px; font-size: 17px; margin: 0 2px 6px; }

/* Pantallas bajas: se recorta lo prescindible para que el tablero quepa entero */
.board.tight th.ph .av { display: none; }
.board.tight tr.sec td { height: 3px; }
.board.tight tr.sec td span { display: none; }
body.board-tight .game .gtitle { flex-direction: row; justify-content: center; align-items: baseline; gap: 10px; }
body.board-tight .game .gmode { font-size: 12px; white-space: nowrap; flex: none; }
body.board-tight .game .gturn { font-size: 13px; min-width: 0; }
body.board-tight .game .gbar .btn.icon { width: 34px; height: 34px; font-size: 15px; margin-bottom: 5px; }

@media (min-width: 760px) {
  body { font-size: 24px; }
  .board { --cat-w: 270px; }
  .board-wrap { margin: 0; padding: 0; }
  .pstrip { margin: 0; padding-left: 4px; padding-right: 4px; }
  th.ph .nm { font-size: 20px; }
  .tray-dice .die-wrap, .tray-dice.n6 .die-wrap { --s: 48px; }
  .tray-roll .lbl.opt { display: inline; }
}

/* Escritorio: tablero a la izquierda a toda altura, panel lateral con jugadores, turno, leyenda y dados */
@media (min-width: 1024px) {
  body[data-screen="game"] #app { max-width: 1600px; padding: 16px 24px; }
  .screen.game { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 24px; align-items: start; }
  .g-main { grid-column: 1; grid-row: 1; min-width: 0; }
  .g-side {
    grid-column: 2; grid-row: 1; position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow-y: auto;
    display: flex; flex-direction: column; gap: 12px; padding: 4px 8px 8px 4px; scrollbar-width: thin;
  }
  .board { --cat-w: 320px; --ic-h: clamp(14px, calc(var(--row-h) * .8), 32px); }
  .game .gturn { display: none; }
  .game .gbar { margin: 0; }
  .game .pstrip { display: flex; flex-direction: column; gap: 8px; overflow: visible; margin: 0; padding: 0; perspective: none; }
  .game .pchip { width: 100%; }
  .game .pchip .pn { max-width: none; flex: 1; text-align: left; }
  .game .pchip.on { transform: translateX(-6px); }
  .game .pchip .crown { position: static; transform: none; animation: none; order: 3; }
  .game .turn, .game .legend { display: flex; margin: 0; }
  #side-tray:empty { display: none; }
  #side-tray .tray {
    position: static; border: 4px solid var(--pc); padding: 10px 12px 12px; animation: none;
    box-shadow: 0 0 0 4px #000, 0 0 24px color-mix(in srgb, var(--pc) 40%, transparent);
  }
  #side-tray .tray-head { display: flex; margin-bottom: 2px; }
  #side-tray .tray-row { flex-wrap: wrap; }
  #side-tray .tray-dice { flex-basis: 100%; justify-content: space-between; }
  #side-tray .tray-dice .die-wrap { --s: 46px; }
  #side-tray .tray-act { flex: 1; }
  #side-tray .tray-act .btn { flex: 1; padding: 12px 10px; font-size: 13px; }
  #side-tray .plays { flex-wrap: wrap; overflow: visible; }
  #side-tray .tray-hint { display: block; }
}
/* Móviles estrechos */
@media (max-width: 380px) {
  .board { --cat-w: 46vw; }
  th.ph { min-width: 46px; }
}
/* ---------- 17. Nueva partida, menú principal y temas ---------- */
body[data-screen="setup"] #app, body[data-screen="results"] #app, body[data-screen="modes"] #app, body[data-screen="editor"] #app { padding-top: 0; }
.setup .topbar { margin-bottom: 8px; }
.setup .panel { margin-bottom: 10px; padding: 12px 12px 4px; }
.setup .ptitle { margin-bottom: 8px; }
.setup .plist { gap: 7px; margin-bottom: 6px; }
.setup .mrow .btn { margin: 2px 2px 8px; padding: 11px 10px; }
.setup .pick-row { margin-bottom: 6px; padding: 7px 10px; }
.setup .prow .inp { padding: 7px 10px; }
.setup .prow .btn.icon { width: 40px; height: 40px; }
.swatch { width: 44px; height: 44px; }
.sw-th { position: absolute; right: -6px; bottom: -6px; font-style: normal; font-size: 16px; line-height: 1; filter: drop-shadow(0 0 2px #000); }
.hint.mini { font-size: 18px; margin: 6px 0 0; }
.pick-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; margin-bottom: 8px; text-align: left; color: var(--text);
  background: #0d0320; border: 3px solid #36246a; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
button.pick-row:hover, button.pick-row:focus-visible { border-color: var(--pink); box-shadow: 0 0 14px color-mix(in srgb, var(--pink) 45%, transparent); outline: none; }
.pick-row.static { cursor: default; }
.pk-l { flex: none; width: 56px; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 11px; font-weight: 700; color: var(--dim); letter-spacing: 1px; }
.pk-v { flex: 1; min-width: 0; }
.pk-v b { display: block; font-family: var(--px); font-size-adjust: var(--px-adj); font-size: 16px; font-weight: 700; color: #fff; }
.pk-v small { display: block; font-size: 18px; color: var(--dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-go { flex: none; font-size: 22px; color: var(--pink); }
.dice-seg { flex: 1; }
.dice-seg .segb { flex: 1; padding: 10px 4px; font-size: 11px; }
.startbar {
  position: sticky; bottom: 0; z-index: 15; margin: 0 -16px; padding: 6px 16px calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(7, 0, 15, 0), var(--bg) 35%);
}
.startbar .btn.huge { margin: 4px 0 8px; padding: 16px 16px; }

/* Ventana de elegir modo */
.modes-pick.in-modal { grid-template-columns: 1fr; margin-bottom: 4px; }

/* Color y fondo del jugador */
.modal.pstyle .sm-who { margin-bottom: 4px; }
.opt-sec small { font-family: var(--num); font-size-adjust: var(--num-adj); font-size: 16px; letter-spacing: 0; font-weight: 500; text-transform: none; }
.cgrid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px; margin: 8px 0 4px; }
.cswatch {
  aspect-ratio: 1; background: var(--sw); border: 3px solid #000; cursor: pointer; position: relative;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -3px 0 rgba(0,0,0,.25);
}
.cswatch.used::after { content: ''; position: absolute; inset: 35%; background: rgba(0, 0, 0, .55); }
.cswatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--sw), 0 0 14px var(--sw); transform: scale(1.08); }
.cswatch:focus-visible, .tcard:focus-visible, .pick-row:focus-visible { outline: 3px dashed #fff; outline-offset: 2px; }
.tgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0 4px; }
.tcard {
  display: flex; flex-direction: column; gap: 4px; padding: 5px; cursor: pointer; text-align: left; position: relative;
  background: #0d0320; border: 3px solid #36246a; color: var(--text); font-size: 19px; font-weight: 600;
}
.tcard canvas { width: 100%; height: auto; aspect-ratio: 72 / 44; image-rendering: pixelated; display: block; }
.tcard i { position: absolute; top: 8px; right: 8px; font-style: normal; font-size: 14px; padding: 0 4px; background: rgba(0, 0, 0, .7); color: var(--dim); }
.tcard.on { border-color: var(--pc); box-shadow: 0 0 16px color-mix(in srgb, var(--pc) 60%, transparent); }
.tcard.on span { color: var(--pc); }
@media (min-width: 560px) { .tgrid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 380px) { .cgrid { grid-template-columns: repeat(6, 1fr); } }

/* Jugador en escritorio: emoji de su fondo */
.pchip .pth { font-style: normal; font-size: 16px; }

/* Resultados más compactos */
.results .winner { margin-bottom: 8px; }
.results .podium { margin: 18px 0 14px; }
.pod.r1 .block { height: clamp(70px, 14vh, 130px); } .pod.r2 .block { height: clamp(48px, 9vh, 90px); } .pod.r3 .block { height: clamp(34px, 6vh, 60px); }
.results .rank-list { margin-bottom: 10px; }
.results .rrow { padding: 6px 0; }
.res-btns { position: sticky; bottom: 0; z-index: 15; margin: 0 -16px; padding: 4px 16px calc(4px + env(safe-area-inset-bottom)); background: linear-gradient(rgba(7, 0, 15, 0), var(--bg) 30%); }

/* Portada: cabe sin desplazar en pantallas bajas */
@media (max-height: 720px) {
  .logo-wrap { margin: 10px 0 4px; }
  .logo .l2 { margin-top: 10px; }
  .dice-show { margin: 14px 0 18px; }
  .dice-show .die-wrap { --s: clamp(34px, 9vw, 52px); }
  .home .btn.big { padding: 13px 16px; margin: 4px 0 12px; }
}

/* ---------- 16. Modo ahorro ----------
   Se activa solo si el dispositivo no llega a ~40 fps (o desde Menú ▸ Efectos).
   Quita los movimientos decorativos continuos; el juego y los efectos al anotar se mantienen. */
body.lite .grid-floor::before, body.lite .logo, body.lite .logo .l2, body.lite .dice-show .die-wrap, body.lite .dice-show .die,
body.lite td.cell::before, body.lite td.cell::after, body.lite td.cell .ghost, body.lite .crown,
body.lite .tray.is-bot .tray-who::after, body.lite .winner span { animation: none !important; }
body.lite td.cell.open::before { opacity: 0; }
body.lite td.cell.open.can::after { opacity: .7; }
body.lite td.cell.filled::after { opacity: .6; }
body.lite td.cell.open.can .ghost { opacity: .55; }
body.lite .scanlines { display: none; }

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