/* =============================================================================
   Componentes en px del lienzo. Modales viven en #game-modal-root (dentro del stage).
   ============================================================================= */

.btn {
  appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  vertical-align: middle;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  min-height: 48px;
  cursor: pointer;
  color: var(--text);
  background: transparent;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: var(--type-body);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

/* Ícono dentro de un botón: alineado por la base del texto */
.btn .ui-icon {
  vertical-align: 0;
  margin: 0;
}

.btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.btn-cta {
  min-height: var(--vu-button, 80px);
  padding: 0 28px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.btn-primary {
  color: #05060f;
  background: linear-gradient(90deg, var(--cyan), #7af7ff);
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.28);
}

.btn-ghost {
  border-color: var(--line);
  background: rgba(12, 14, 28, 0.55);
}

.btn-ghost:hover {
  border-color: var(--line-strong);
}

.btn-magenta {
  border-color: rgba(255, 43, 214, 0.45);
  color: #ffd6f5;
  background: rgba(255, 43, 214, 0.08);
}

.btn-danger {
  border-color: rgba(255, 77, 109, 0.4);
  color: #ffd6dc;
}

.sound-toggle {
  min-width: 48px;
  padding-inline: 12px;
}

.sound-toggle svg {
  width: 22px;
  height: 22px;
  stroke: var(--cyan);
}

.sound-toggle.is-muted svg {
  stroke: var(--text-muted);
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  padding: 0 24px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-panel);
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.card-media {
  position: relative;
  z-index: 1;
  margin: 0 -24px 16px;
  aspect-ratio: 16 / 9;
  background: #05060f;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  pointer-events: none;
}

.card-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: 0 16px 40px rgba(0, 240, 255, 0.12);
}

.card-glow {
  position: absolute;
  inset: auto -20% -40% auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.22), transparent 70%);
  pointer-events: none;
}

.game-card[data-accent="magenta"] .card-glow {
  background: radial-gradient(circle, rgba(255, 43, 214, 0.22), transparent 70%);
}

.game-card[data-accent="violet"] .card-glow {
  background: radial-gradient(circle, rgba(123, 92, 255, 0.28), transparent 70%);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 20px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.badge.live {
  color: var(--ok);
  border-color: rgba(61, 255, 176, 0.35);
}

.game-card h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: var(--type-meta);
}

.game-card p {
  margin: 0 0 18px;
  color: var(--text-muted);
  flex: 1;
  font-size: var(--type-body);
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 12, 0.72);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal,
.drawer {
  position: absolute;
  z-index: 50;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.modal {
  width: var(--vu-panel-w, 600px);
  min-height: var(--vu-panel-h, 400px);
  max-height: calc(var(--game-virtual-h, 1080px) * 0.86);
  box-sizing: border-box;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  border-radius: 22px;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  overflow: auto;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.modal.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.drawer {
  top: 0;
  right: 0;
  height: 100%;
  width: 480px;
  padding: 24px;
  transform: translateX(110%);
  transition: transform 0.25s ease;
  pointer-events: none;
}

.drawer.is-open {
  transform: translateX(0);
  pointer-events: auto;
}

.modal-head,
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h2,
.drawer-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--type-meta);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--vu-icon, 64px);
  height: var(--vu-icon, 64px);
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: var(--type-title);
}

.icon-btn .ui-icon {
  display: block;
  width: 28px;
  height: 28px;
}

.ui-icon {
  display: inline-block;
  vertical-align: -0.2em;
  object-fit: contain;
  flex-shrink: 0;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  text-align: center;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 8px;
  min-height: 48px;
  cursor: pointer;
  font-size: var(--type-body);
}

.tab.is-active {
  color: #05060f;
  background: var(--cyan);
  border-color: var(--cyan);
}

.auth-hint {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: var(--type-body);
}

.google-wrap {
  margin-top: 12px;
}

.form-stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: var(--type-body);
  color: var(--text-muted);
}

input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(5, 6, 15, 0.7);
  color: var(--text);
  padding: 11px 12px;
  min-height: 48px;
  font-size: var(--type-body);
}

input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.12);
}

.form-error,
.form-ok {
  min-height: 1.2em;
  margin: 4px 0 0;
  font-size: var(--type-body);
}

.form-error {
  color: var(--danger);
}

.form-ok {
  color: var(--ok);
}

.hidden {
  display: none !important;
}

.leaderboard-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: var(--type-body);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.chip.is-active {
  color: var(--cyan);
  border-color: var(--line-strong);
}

/* Sub-label dentro de los chips (e.g. nombres de juegos del mes) */
.chip-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.01em;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(5, 6, 15, 0.55);
  border: 1px solid rgba(123, 92, 255, 0.16);
}

.leaderboard-list li > span:nth-child(2) {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rank {
  font-family: var(--font-display);
  color: var(--cyan);
}

.score-value {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* =============================================================================
   Medallas
   ============================================================================= */

/* Colores por tier en los items del leaderboard */
.leaderboard-list li.medal-gold   { border-color: rgba(255, 209, 102, 0.45); background: rgba(255, 209, 102, 0.05); }
.leaderboard-list li.medal-silver { border-color: rgba(180, 195, 220, 0.45); background: rgba(180, 195, 220, 0.04); }
.leaderboard-list li.medal-bronze { border-color: rgba(200, 130, 60, 0.45); background: rgba(200, 130, 60, 0.04); }
.leaderboard-list li.medal-crystal { border-color: rgba(0, 240, 255, 0.30); }
.leaderboard-list li.medal-nebula  { border-color: rgba(123, 92, 255, 0.22); }

/* Número de rango coloreado por tier */
.rank.medal-gold   { color: #ffd166; text-shadow: 0 0 8px rgba(255, 209, 102, 0.7); }
.rank.medal-silver { color: #b4c3dc; text-shadow: 0 0 8px rgba(180, 195, 220, 0.6); }
.rank.medal-bronze { color: #c8823c; text-shadow: 0 0 8px rgba(200, 130, 60, 0.6); }
.rank.medal-crystal { color: var(--cyan); }
.rank.medal-nebula  { color: var(--violet); }

/* Ícono de medalla en el profile chip */
.medal-row {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  flex-shrink: 0;
}

.medal-row img {
  display: block;
  width: 24px;
  height: 24px;
}

/* Cabecera del leaderboard mensual */
.board-month-label {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(123, 92, 255, 0.08);
  border: 1px solid rgba(123, 92, 255, 0.18);
}

/* Banda del banner del desafío mensual */
.board-month-banner {
  margin: 0 0 10px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(123, 92, 255, 0.18);
}

.board-month-banner img {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: cover;
  object-position: center;
}

/* Detalle de scores individuales en el mensual */
.board-game-detail {
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state,
.loading-state {
  color: var(--text-muted);
  text-align: center;
  padding: 28px 8px;
}

.toast-stack,
#game-toast-root {
  display: grid;
  align-content: end;
  justify-items: end;
  gap: 8px;
  padding: 18px;
}

.toast {
  min-width: 280px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(12, 14, 28, 0.94);
  box-shadow: var(--shadow);
  font-size: var(--type-body);
}

.toast.error {
  border-color: rgba(255, 77, 109, 0.45);
}

.toast.ok {
  border-color: rgba(61, 255, 176, 0.4);
}

.game-shell[data-layout="mobile"] .modal {
  width: auto;
  height: auto;
  left: 12px;
  right: 12px;
  top: 12px;
  bottom: auto;
  max-height: calc(100% - 24px);
  transform: none;
  padding: 16px;
  overflow: auto;
}

.game-shell[data-layout="mobile"] .modal.is-open {
  transform: none;
}

.game-shell[data-layout="mobile"] .drawer {
  width: 100%;
  overflow: auto;
  padding: 16px;
}

/* Recuadro de controles a la derecha del lienzo */
.game-play-row {
  display: flex;
  align-items: stretch;
  gap: 20px;
}

.game-play-row > [class$="-stage"] {
  flex: 0 0 auto;
}

.controls-panel {
  box-sizing: border-box;
  width: 248px;
  flex-shrink: 0;
  padding: 22px 18px 20px;
  border-radius: 22px;
  border: 1px solid rgba(0, 240, 255, 0.32);
  background: linear-gradient(180deg, rgba(12, 14, 28, 0.94), rgba(5, 6, 15, 0.92));
  box-shadow: 0 0 28px rgba(0, 240, 255, 0.1);
  color: var(--text-muted);
  overflow: auto;
}

.controls-panel h2 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: var(--type-meta);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  text-shadow: 0 0 14px rgba(0, 240, 255, 0.45);
}

.controls-panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.controls-panel li {
  display: grid;
  gap: 4px;
  font-size: var(--type-body);
  line-height: 1.25;
}

.controls-panel .controls-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.controls-panel kbd {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(0, 240, 255, 0.08);
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.04em;
}

.game-shell[data-layout="mobile"] .game-play-row {
  flex-direction: column;
  width: 100%;
  gap: 12px;
}

.controls-panel .controls-touch {
  display: none;
}

.controls-btn {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0, 240, 255, 0.45);
  background: rgba(8, 10, 24, 0.82);
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.game-shell[data-layout="mobile"] .controls-panel,
.game-shell[data-input="touch"] .controls-panel {
  display: none;
}

.play-orient-note {
  display: none;
  margin: 0 0 12px;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.04em;
  line-height: 1.35;
}

/* ============================================================
   Página de nueva contraseña
   ============================================================ */

.reset-panel {
  width: var(--vu-panel-w, 640px);
  max-width: 100%;
  box-sizing: border-box;
  margin: 48px auto;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  border-radius: 22px;
  padding: 24px;
}

.reset-panel h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: var(--type-meta);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.link-btn {
  justify-self: start;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--cyan);
  font-family: var(--font-body);
  font-size: var(--type-body);
  cursor: pointer;
  text-align: left;
}

.link-btn:hover,
.link-btn:focus-visible {
  text-decoration: underline;
}

/* ============================================================
   Páginas legales
   ============================================================ */

.legal-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 40px 24px;
}

.legal-page {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 48px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  border-radius: 22px;
  color: var(--text);
  line-height: 1.6;
  overflow-y: auto;
  max-height: calc(var(--game-virtual-h, 1080px) - var(--vu-hud-h, 100px) - 140px);
  scrollbar-width: thin;
  scrollbar-color: var(--cyan) var(--bg-deep);
}

.legal-page h1,
.legal-page h2 {
  font-family: var(--font-display);
}

.legal-page h1 {
  margin: 0 0 8px;
  font-size: var(--type-title);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legal-page h2 {
  margin-top: 32px;
  font-size: var(--type-meta);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
}

.legal-updated {
  margin: 0 0 20px;
  font-size: var(--type-meta);
  color: var(--text-muted);
}

.legal-page p {
  margin: 0 0 16px;
}

.legal-page ul {
  margin: 0 0 16px;
  padding-left: 24px;
}

.legal-page li {
  margin: 0 0 8px;
}

.legal-page a,
.legal-links a,
.legal-note a {
  color: var(--cyan);
}

.legal-page a:hover,
.legal-links a:hover,
.legal-note a:hover {
  text-decoration: underline;
}

.legal-links {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text-muted);
  font-size: var(--type-body);
}

.legal-note {
  margin: 8px 0 0;
  font-size: var(--type-meta);
  color: var(--text-muted);
}

/* Casilla de edad mínima del registro (docs/prompts/42_EDAD_MINIMA.md). */
.age-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.age-check[hidden] {
  display: none;
}

.age-check input {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--cyan);
}

/* ============================================================
   Página 404
   ============================================================ */

.notfound-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 40px 24px;
}

.notfound-panel {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 48px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  border-radius: 22px;
  text-align: center;
}

.notfound-code {
  font-family: var(--font-display);
  font-size: 180px;
  line-height: 1;
  margin: 0;
  color: var(--cyan);
  text-shadow: 0 0 24px rgba(0, 240, 255, 0.6), 0 0 48px rgba(255, 43, 214, 0.35);
}

.notfound-panel h1 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.notfound-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 24px;
}

/* ============================================================
   Móvil: overlays de juego, modal/drawer y 404
   ============================================================ */

.game-shell[data-layout="mobile"] .overlay-panel {
  padding: 12px 16px;
  align-content: safe center;
  overflow-y: auto;
}

.game-shell[data-layout="mobile"] .overlay-panel h1,
.game-shell[data-layout="mobile"] .overlay-panel h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.game-shell[data-layout="mobile"] .overlay-panel .kicker {
  font-size: 14px;
  margin-bottom: 4px;
}

.game-shell[data-layout="mobile"] .overlay-panel p {
  font-size: 15px;
  line-height: 1.3;
  margin-bottom: 8px;
}

.game-shell[data-layout="mobile"] .play-orient-note,
.game-shell[data-input="touch"] .play-orient-note {
  display: block;
}

.game-shell[data-layout="mobile"]:not([data-play="on"]) .game-stage-body {
  display: flex;
  flex-direction: column;
}

.game-shell[data-layout="mobile"]:not([data-play="on"]) main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  padding: 0;
  place-items: stretch;
}

.game-shell[data-layout="mobile"]:not([data-play="on"]) .game-play-row {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.game-shell[data-layout="mobile"]:not([data-play="on"]) .game-play-row > [class$="-stage"] {
  flex: 0 1 auto;
  width: 100%;
  height: auto;
  max-height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  overflow: auto;
}

.game-shell[data-layout="mobile"]:not([data-play="on"]) #game {
  display: none;
}

.game-shell[data-layout="mobile"] #overlay-menu.is-open {
  position: relative;
  inset: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  height: auto;
  max-height: 100%;
  padding: 20px 16px 16px;
  text-align: center;
  background: rgba(7, 8, 18, 0.98);
}

.game-shell[data-layout="mobile"] #overlay-menu.is-open::before {
  content: none;
}

.game-shell[data-layout="mobile"] #overlay-menu > p:not(.kicker):not(.play-orient-note) {
  flex: 0 1 auto;
  min-height: 0;
  max-height: none;
  margin-bottom: 12px;
  overflow: visible;
}

.game-shell[data-layout="mobile"] #overlay-menu .play-orient-note {
  margin-bottom: 14px;
}

.game-shell[data-layout="mobile"] #overlay-menu .overlay-actions {
  flex: 0 0 auto;
  flex-direction: column;
  align-items: stretch;
  margin-top: 0;
}

.game-shell[data-layout="mobile"] #overlay-menu .overlay-actions .btn {
  width: 100%;
}

.game-shell:is([data-layout="mobile"], [data-input="touch"])[data-play="on"] .site-header {
  visibility: hidden;
}

.game-shell:is([data-layout="mobile"], [data-input="touch"])[data-play="on"] .game-play-row > [class$="-stage"]:fullscreen {
  inset: 0;
  width: 100%;
  height: 100%;
  transform: none;
}

.game-shell:is([data-layout="mobile"], [data-input="touch"])[data-play="on"] .game-play-row > [class$="-stage"] {
  position: fixed;
  z-index: 90;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #05060f;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
  touch-action: none;
}

.game-shell:is([data-layout="mobile"], [data-input="touch"])[data-play="on"] #game {
  position: relative;
  inset: auto;
  flex: 0 0 auto;
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: auto;
  max-height: 100%;
  aspect-ratio: 16 / 9;
}

.game-shell:is([data-layout="mobile"], [data-input="touch"])[data-play="on"] .touch-bar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  width: auto;
  margin: 0;
}

.game-shell:is([data-layout="mobile"], [data-input="touch"])[data-play="on"] .tetra-stage:has(#touch-bar:not([hidden])) {
  padding-bottom: 72px;
  box-sizing: border-box;
}

.game-shell[data-layout="mobile"] .overlay-panel .final-score strong {
  font-size: 32px;
}

.game-shell[data-layout="mobile"] .overlay-actions {
  gap: 8px;
}

.game-shell[data-layout="mobile"] .overlay-panel .btn,
.game-shell[data-layout="mobile"] .overlay-panel .btn-cta {
  min-height: 44px;
  padding: 8px 20px;
  font-size: 17px;
}

.game-shell:is([data-layout="mobile"], [data-input="touch"]) [class$="-stage"]:has(> .overlay-panel.is-open) .touch-actions,
.game-shell:is([data-layout="mobile"], [data-input="touch"]) [class$="-stage"]:has(> .overlay-panel.is-open) .touch-pad {
  display: none;
}

.game-shell[data-layout="mobile"] .modal-head .icon-btn,
.game-shell[data-layout="mobile"] .drawer-head .icon-btn {
  width: 48px;
  height: 48px;
}

.game-shell[data-layout="mobile"] .tab {
  font-size: 17px;
  white-space: nowrap;
}

.game-shell[data-layout="mobile"] .notfound-stage {
  padding: 16px;
}

.game-shell[data-layout="mobile"] .notfound-panel {
  padding: 24px 16px;
}

.game-shell[data-layout="mobile"] .notfound-code {
  font-size: 110px;
}

.game-shell[data-layout="mobile"] .notfound-actions {
  flex-wrap: wrap;
  gap: 12px;
}

.game-shell[data-layout="mobile"] .reset-panel {
  width: auto;
  margin: 16px;
  padding: 16px;
}

.game-shell[data-layout="mobile"] .reset-panel .btn {
  width: 100%;
}

.game-shell[data-layout="mobile"] .legal-stage,
.game-shell[data-layout="mobile"] .legal-page {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.game-shell[data-layout="mobile"] .legal-stage {
  justify-content: flex-start;
  padding: 12px;
}

.game-shell[data-layout="mobile"] .legal-page {
  padding: 16px;
  max-height: none;
  overflow: visible;
  font-size: 16px;
}

.game-shell[data-layout="mobile"] .legal-page h1 {
  font-size: 22px;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.game-shell[data-layout="mobile"] .legal-page h2,
.game-shell[data-layout="mobile"] .legal-updated {
  font-size: 18px;
}

.game-shell[data-layout="mobile"] .legal-page p,
.game-shell[data-layout="mobile"] .legal-page li {
  font-size: 16px;
}

.game-shell[data-layout="mobile"][data-orient="landscape"] .notfound-code {
  font-size: 72px;
}

.game-shell[data-layout="mobile"][data-orient="landscape"] .notfound-stage {
  padding: 8px 16px;
}

.game-shell[data-layout="mobile"][data-orient="landscape"] .notfound-panel h1 {
  font-size: 22px;
  margin: 8px 0;
}

.game-shell[data-layout="mobile"][data-orient="landscape"] .reset-panel {
  margin: 8px 16px;
}

.game-shell[data-layout="mobile"][data-orient="landscape"] .legal-stage {
  padding: 8px 12px;
}

/* ============================================================
   Historia: selector de niveles y nivel superado (js/ui/levelSelect.js)
   ============================================================ */

/* El overlay-panel usa place-content:center (pista del ancho del contenido):
   por eso el host pide un ancho fijo y se limita al panel */
.ls-host {
  width: 720px;
  max-width: 100%;
}

.level-select {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.ls-total {
  margin: 0;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 18px;
  text-align: center;
}

.ls-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.ls-cell {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  min-height: 88px;
  padding: 8px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font-display);
  cursor: pointer;
}

.ls-cell:hover:not(:disabled) {
  border-color: var(--cyan);
}

.ls-cell:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.ls-cell.is-current {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255, 209, 102, 0.35);
}

.ls-cell.is-locked {
  border-style: dashed;
  border-color: var(--line);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.ls-num {
  font-size: 24px;
  line-height: 1;
}

.ls-stars {
  display: inline-flex;
  gap: 3px;
}

/* Estrella dibujada con clip-path: sin imágenes ni emojis */
.ls-star {
  width: 14px;
  height: 14px;
  background: rgba(139, 147, 184, 0.35);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.ls-star.is-on {
  background: var(--gold);
}

.ls-stars-big {
  justify-content: center;
  gap: 8px;
  margin: 8px 0 12px;
}

.ls-stars-big .ls-star {
  width: 40px;
  height: 40px;
}

/* Candado dibujado con CSS: arco (::before) y cuerpo (::after) */
.ls-lock {
  position: relative;
  width: 14px;
  height: 16px;
}

.ls-lock::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0;
  width: 8px;
  height: 8px;
  box-sizing: border-box;
  border: 2px solid currentColor;
  border-bottom: none;
  border-radius: 5px 5px 0 0;
}

.ls-lock::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 14px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
}

.ls-actions {
  margin-top: 0;
}

.game-shell[data-layout="mobile"] .ls-host {
  width: 100%;
}

.game-shell[data-layout="mobile"] .level-select {
  gap: 8px;
}

.game-shell[data-layout="mobile"] .ls-total {
  font-size: 14px;
}

/* Móvil: 10 columnas x 2 filas para que la grilla entre en el lienzo 16:9 */
.game-shell[data-layout="mobile"] .ls-grid {
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
}

.game-shell[data-layout="mobile"] .ls-cell {
  min-height: 44px;
  gap: 2px;
  padding: 4px 2px;
  border-radius: 8px;
}

.game-shell[data-layout="mobile"] .ls-num {
  font-size: 15px;
}

.game-shell[data-layout="mobile"] .ls-stars {
  gap: 1px;
}

.game-shell[data-layout="mobile"] .ls-star {
  width: 7px;
  height: 7px;
}

.game-shell[data-layout="mobile"] .ls-stars-big {
  margin: 2px 0 4px;
}

.game-shell[data-layout="mobile"] .ls-stars-big .ls-star {
  width: 22px;
  height: 22px;
}

/* Móvil: el nombre del nivel no entra; ya se vio en la grilla */
.game-shell[data-layout="mobile"] .ls-clear-name {
  display: none;
}

.game-shell[data-layout="mobile"] .ls-lock {
  transform: scale(0.75);
}

/* Móvil: Siguiente / Repetir / Niveles en una sola fila */
.game-shell[data-layout="mobile"] .ls-clear-actions {
  flex-wrap: nowrap;
}

.game-shell[data-layout="mobile"] .ls-clear-actions .btn {
  padding: 8px 14px;
}

/* ============================================================
   Overlays de juego: tarjeta legible detrás del texto (36_RETOQUES_JUEGOS, RJ-A)
   La tarjeta es el ::before del overlay: ocupa todas las filas de la grilla
   (grid-row 1 / -1) y cada hijo va a su fila con nth-child. Así no se toca el
   HTML y siguen andando "#overlay-menu > p" y el contenido de levelClear.js.
   Tope: 12 hijos directos por overlay (lo valida tests/overlayCard.test.js).
   ============================================================ */

.overlay-panel {
  isolation: isolate;
  grid-template-rows: repeat(12, auto);
}

.overlay-panel > * {
  grid-column: 1;
}

.overlay-panel > :nth-child(1) { grid-row: 1; }
.overlay-panel > :nth-child(2) { grid-row: 2; }
.overlay-panel > :nth-child(3) { grid-row: 3; }
.overlay-panel > :nth-child(4) { grid-row: 4; }
.overlay-panel > :nth-child(5) { grid-row: 5; }
.overlay-panel > :nth-child(6) { grid-row: 6; }
.overlay-panel > :nth-child(7) { grid-row: 7; }
.overlay-panel > :nth-child(8) { grid-row: 8; }
.overlay-panel > :nth-child(9) { grid-row: 9; }
.overlay-panel > :nth-child(10) { grid-row: 10; }
.overlay-panel > :nth-child(11) { grid-row: 11; }
.overlay-panel > :nth-child(12) { grid-row: 12; }

.overlay-panel::before {
  content: "";
  grid-column: 1;
  grid-row: 1 / -1;
  z-index: -1;
  margin: -28px -40px;
  border-radius: 22px;
  border: 1px solid rgba(0, 240, 255, 0.32);
  background: linear-gradient(180deg, rgba(12, 14, 34, 0.86), rgba(6, 7, 18, 0.92));
  box-shadow:
    inset 0 0 0 1px rgba(255, 43, 214, 0.12),
    0 0 36px rgba(0, 240, 255, 0.16),
    0 18px 48px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}

.game-shell[data-layout="mobile"] .overlay-panel::before {
  margin: -8px -12px;
  border-radius: 16px;
}

/* Cuenta atrás al revivir. No se muestra mientras la publicidad esté apagada. */
.revive-countdown {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  background: rgba(5, 6, 15, 0.45);
  pointer-events: auto;
}

.revive-countdown p {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--type-meta);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan, #00f0ff);
}

.revive-countdown strong {
  font-family: var(--font-display);
  font-size: 160px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 28px #00f0ff;
}

.game-shell[data-layout="mobile"] .revive-countdown strong {
  font-size: 96px;
}
