/* Página del minijuego: bajo la cabecera crema, todo es oscuro y pixelado. */
@font-face {
  font-family: 'Pixelify Sans';
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/pixelify-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Pixelify Sans';
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/pixelify-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.retro {
  --noche: #262E42;
  --fondo-hondo: #171C29;
  --pizarra: #333D56;
  --trazo: #4C5876;
  --hueso: #EFE8D6;
  --niebla: #AEB7CB;
  --capa: #E5584B;
  --billete: #9BE36D;
  --pixel: 'Pixelify Sans', ui-monospace, Menlo, monospace;
  background: var(--noche);
}
/* Sobre fondo oscuro, la cabecera translúcida se ensuciaría. */
.retro .site-header { background: var(--bg); }

.retro main, .retro .site-footer { font-family: var(--pixel); color: var(--hueso); }
.retro main a, .retro .site-footer a { color: var(--hueso); }
.retro main :focus-visible, .retro .site-footer :focus-visible { outline-color: var(--hueso); }

/* El crema de la cabecera se deshace en píxeles antes de llegar al fondo. */
.trama {
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='12' shape-rendering='crispEdges'%3E%3Cpath fill='%23F7F5F0' d='M0 0h4v4H0zM8 0h8v4H8zM4 4h4v4H4zM12 4h4v4h-4zM0 8h4v4H0z'/%3E%3C/svg%3E") repeat-x;
}

/* En pantallas bajas la columna se estrecha para que el juego quepa entero sin desplazarse. */
.juego { max-width: clamp(640px, calc((100dvh - 190px) * 16 / 9), 1120px); padding-top: 30px; padding-bottom: 72px; }

.juego-cabecera { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.juego-cabecera h1 { margin: 0; font-family: var(--pixel); font-size: clamp(34px, 6vw, 56px); font-weight: 700; line-height: .95; text-wrap: balance; }
.juego-entrada { margin: 12px 0 20px; max-width: 46ch; font-size: 18px; line-height: 1.45; color: var(--niebla); text-wrap: pretty; }
/* El perro se sienta sobre el marco, igual que en la portada se sienta sobre el pie. */
.juego-perro { flex: none; display: block; width: clamp(72px, 11vw, 112px); height: auto; margin-bottom: -4px; image-rendering: pixelated; }

/* Borde de cuatro sombras: deja las esquinas melladas, como un píxel de más. */
.juego-marco {
  position: relative;
  margin: 4px;
  background: var(--fondo-hondo);
  box-shadow: 0 -4px 0 var(--fondo-hondo), 0 4px 0 var(--fondo-hondo), -4px 0 0 var(--fondo-hondo), 4px 0 0 var(--fondo-hondo);
}
.juego-escena { position: relative; display: grid; }
#juego, #juego-panel { grid-area: 1 / 1; }
#juego {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  align-self: start;
  image-rendering: pixelated;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}
/* El panel ocupa la misma celda que el canvas; si su contenido no cabe (móvil), el marco crece. */
#juego-panel { display: grid; pointer-events: none; }
.decision {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: clamp(14px, 3.4vw, 32px);
  background: rgba(23, 28, 41, .95);
  animation: retro-entra .2s var(--ease-out);
}
.decision__title { margin: 0; font-family: var(--pixel); font-size: clamp(20px, 3.6vw, 30px); font-weight: 600; line-height: 1.1; }
.decision__money { color: var(--billete); }
.decision__lead { margin: 0; font-size: 18px; color: var(--niebla); }
.decision__options { display: grid; gap: 8px; grid-template-columns: repeat(3, 1fr); animation: retro-entra .2s var(--ease-out); }
.decision__options button {
  min-height: 46px;
  padding: 8px 12px;
  border: 2px solid var(--trazo);
  border-radius: 0;
  background: var(--pizarra);
  color: var(--hueso);
  font: inherit;
  font-size: 15px;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s, transform .12s var(--ease-out);
}
.decision__options button[data-choice="quedarselo"] { border-color: var(--capa); }
.decision__options button:active:not(:disabled) { transform: translateY(2px); }
.decision__options button:disabled { opacity: .45; cursor: default; }
.decision__stats { animation: retro-entra .2s var(--ease-out); }
.decision__stats p { margin: 0 0 8px; font-size: 16px; color: var(--niebla); }
.decision__row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) 4ch; gap: 10px; align-items: center; padding: 3px 0; font-size: 15px; }
.decision__row b { font-weight: 600; text-align: right; }
.decision__row--mine { color: var(--billete); }
.decision__bar { height: 10px; background: var(--pizarra); overflow: hidden; }
.decision__bar i { display: block; height: 100%; background: currentColor; }
.decision__again {
  align-self: flex-start;
  min-height: 46px;
  padding: 8px 20px;
  border: 0;
  border-radius: 0;
  background: var(--hueso);
  color: var(--fondo-hondo);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--capa);
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out);
  animation: retro-entra .2s var(--ease-out);
}
.decision__again:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--capa); }
@keyframes retro-entra { from { opacity: 0; transform: translateY(6px); } }

.juego-salir {
  position: absolute; top: 8px; left: 50%; z-index: 2;
  transform: translateX(-50%);
  min-width: 44px; min-height: 32px;
  padding: 3px 12px;
  border: 2px solid var(--trazo);
  border-radius: 0;
  background: rgba(23, 28, 41, .8);
  color: var(--hueso);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  animation: retro-entra .2s var(--ease-out);
}
.juego-completa {
  display: block;
  min-height: 48px;
  margin: 20px 0 0 4px;
  padding: 8px 20px;
  border: 0;
  border-radius: 0;
  background: var(--hueso);
  color: var(--fondo-hondo);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--capa);
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out);
}
.juego-completa:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--capa); }
.juego-gira { display: none; }

/* Pantalla completa: el marco tapa la página y toda su superficie es táctil (izquierda agacha, derecha salta). */
.juego-inmersivo { overflow: hidden; overscroll-behavior: none; }
.juego-marco.inmersivo {
  position: fixed; inset: 0; z-index: 100;
  margin: 0;
  box-shadow: none;
  background: #0E121B;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.inmersivo .juego-escena {
  position: absolute; top: 50%; left: 50%;
  width: min(100vw, 100vh * 16 / 9); width: min(100dvw, 100dvh * 16 / 9);
  aspect-ratio: 16 / 9;
  grid-template: 100% / 100%;
  transform: translate(-50%, -50%);
}
/* Móvil en vertical sin giro automático: el juego se dibuja tumbado y es el jugador quien gira el teléfono. */
.inmersivo[data-giro="90"] .juego-escena {
  width: min(100vh, 100vw * 16 / 9); width: min(100dvh, 100dvw * 16 / 9);
  transform: translate(-50%, -50%) rotate(90deg);
}
.inmersivo #juego { height: 100%; }
.inmersivo #juego-panel { min-height: 0; }
.inmersivo .decision { overflow-y: auto; padding: 16px 24px; gap: 10px; }
.inmersivo .decision__options { grid-template-columns: repeat(3, 1fr); }
.inmersivo[data-giro="90"] .juego-gira {
  display: block;
  position: absolute; top: 50%; left: 50%; z-index: 3;
  margin: 0;
  padding: 10px 16px;
  background: var(--hueso);
  color: var(--fondo-hondo);
  font-family: var(--pixel);
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: gira-aviso 2.6s var(--ease-out) forwards;
}
@keyframes gira-aviso { 0% { opacity: 0; } 8%, 75% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

.juego-controles { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 18px 0 0; padding: 0; list-style: none; font-size: 15px; color: var(--niebla); }
.juego-controles kbd {
  display: inline-block;
  min-width: 26px;
  margin-right: 6px;
  padding: 2px 7px;
  border: 2px solid var(--trazo);
  border-bottom-width: 4px;
  background: var(--pizarra);
  color: var(--hueso);
  font: inherit;
  font-size: 14px;
  text-align: center;
}
.juego-controles--tacto { display: none; }
@media (hover: none) and (pointer: coarse) {
  .juego-controles--teclado { display: none; }
  .juego-controles--tacto { display: flex; }
}

/* Lo que hacen los jugadores con el dinero */
.reparto { margin-top: 64px; }
.reparto h2 { margin: 0; font-family: var(--pixel); font-size: clamp(24px, 3.6vw, 34px); font-weight: 600; line-height: 1.1; text-wrap: balance; }
.reparto-nota { margin: 8px 0 0; min-height: 1.4em; font-size: 17px; line-height: 1.4; color: var(--niebla); }
.reparto-lista { margin: 22px 0 0; padding: 0; list-style: none; animation: retro-entra .22s var(--ease-out); }
.reparto-fila {
  display: grid;
  grid-template-columns: 6ch minmax(0, 1fr) minmax(120px, 30%) 5ch;
  gap: 4px 16px;
  align-items: center;
  padding: 11px 0;
  border-top: 2px dotted var(--trazo);
  --color: var(--billete);
}
.reparto-fila:first-child { border-top: 0; }
.reparto-fila[data-choice="quedarselo"] { --color: var(--capa); }
.reparto-numero { font-size: 30px; font-weight: 700; line-height: 1; text-align: right; color: var(--color); font-variant-numeric: tabular-nums; }
.reparto-frase { font-size: 18px; line-height: 1.3; text-wrap: pretty; }
.reparto-porcentaje { font-size: 16px; text-align: right; color: var(--niebla); font-variant-numeric: tabular-nums; }
/* Barra de bloques: seis píxeles de color y dos de hueco. */
.reparto-barra { height: 12px; color: var(--pizarra); background: repeating-linear-gradient(90deg, currentColor 0 6px, transparent 6px 8px); }
.reparto-barra i { display: block; width: 0; height: 100%; color: var(--color); background: repeating-linear-gradient(90deg, currentColor 0 6px, transparent 6px 8px); transition: width .28s steps(7, end); }

.retro .site-footer { border-top: 2px dotted var(--trazo); }
.retro .footer-inner { color: var(--niebla); }

@media (hover: hover) {
  .decision__options button:hover:not(:disabled) { background: var(--hueso); border-color: var(--hueso); color: var(--fondo-hondo); }
}

@media (max-width: 640px) {
  .juego { padding-top: 24px; padding-bottom: 56px; }
  .juego-entrada { font-size: 16px; margin-bottom: 18px; }
  .decision__options { grid-template-columns: 1fr 1fr; }
  .decision__options button { font-size: 14px; padding: 6px 9px; }
  .decision__row { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 4ch; font-size: 14px; }
  .reparto { margin-top: 48px; }
  .reparto-fila { grid-template-columns: 5ch minmax(0, 1fr) 5ch; }
  .reparto-numero { font-size: 26px; grid-row: span 2; align-self: start; }
  .reparto-frase { font-size: 16px; }
  .reparto-barra { grid-column: 2 / 4; grid-row: 2; }
  .reparto-porcentaje { grid-column: 3; grid-row: 1; }
}

/* Una vez elegido, la pregunta sobra: el juego solo oculta las opciones. */
.decision:has(.decision__options[hidden]) .decision__lead { display: none; }
