:root {
  --bg: #121630; --panel: #1d2252; --line: #323a7a; --ink: #f4ead8;
  --celeste: #6cc3f2; --sol: #f5c12b; --tinta: #2a1d2c;
  --display: "Silkscreen", "Courier New", monospace;
  --body: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}
#game.smooth { image-rendering: auto; }

/* Gurí del juego (hoja de sprites de 32 px por cuadro) */
.portrait {
  background-image: url(assets/guri.png);
  background-repeat: no-repeat;
  image-rendering: pixelated;
  flex: none;
}
.portrait.s2 { width: 64px; height: 64px; background-size: 1536px 64px; background-position: 0 0; }
.portrait.s4 { width: 128px; height: 128px; background-size: 3072px 128px; }
.portrait.win { background-position: -1920px 0; }   /* cuadro 15: salta con el brazo arriba */

#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: calc(env(safe-area-inset-left, 0px) + 10px);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  background: rgba(29, 34, 82, .82);
  border: 3px solid var(--line);
  box-shadow: 0 3px 0 var(--tinta);
  border-radius: 10px;
  pointer-events: none;
}
.info { font-family: var(--display); line-height: 1.15; text-shadow: 0 2px 0 var(--tinta); }
#lap { font-size: 12px; color: var(--celeste); }
#time { font-size: 22px; color: var(--sol); font-variant-numeric: tabular-nums; }
#speed { font-size: 12px; }
#place { font-size: 9px; opacity: .75; margin-top: 2px; }

#msg {
  position: fixed;
  top: 24%;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--display);
  font-size: 96px;
  font-weight: 700;
  color: var(--sol);
  text-shadow: 0 6px 0 var(--tinta), 4px 0 0 var(--tinta), -4px 0 0 var(--tinta), 0 -4px 0 var(--tinta);
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
}
#msg.show { opacity: 1; }
#msg.pop { animation: pop .38s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(1.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Barra de carga del derrape */
#driftbar {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 118px);
  transform: translateX(-50%);
  width: 160px; height: 14px;
  background: rgba(29, 34, 82, .85);
  border: 3px solid var(--tinta);
  border-radius: 8px;
  overflow: hidden;
  opacity: 0; transition: opacity .12s;
  pointer-events: none;
}
#driftbar.on { opacity: 1; }
#driftfill { display: block; height: 100%; width: 0; background: var(--celeste); }
#driftfill.s1 { background: var(--celeste); box-shadow: inset 0 0 0 2px #bfe3f7; }
#driftfill.s2 { background: var(--sol); box-shadow: inset 0 0 0 2px #fff3c4; }

/* Pantalla de carga con el Gurí caminando */
#loading {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(#2d3478 0%, #d9837a 65%, #f3c98a 100%);
  transition: opacity .45s;
  text-align: center;
  padding: 12px;
}
#loading.hide { opacity: 0; pointer-events: none; }
#loading h1 {
  margin: 0; font-family: var(--display); font-size: 30px; color: var(--sol);
  text-shadow: 0 4px 0 var(--tinta), 3px 0 0 var(--tinta), -3px 0 0 var(--tinta);
}
#bar { width: min(260px, 70vw); height: 16px; background: rgba(29, 34, 82, .85); border: 3px solid var(--tinta); border-radius: 8px; overflow: hidden; }
#barfill { display: block; height: 100%; width: 0; background: var(--sol); transition: width .25s; }
#bar.done #barfill { background: #7cc576; }
#loadMsg { margin: 0; font-family: var(--display); font-size: 12px; color: var(--ink); text-shadow: 0 2px 0 var(--tinta); }
#start {
  font-family: var(--display); font-weight: 700; font-size: 17px;
  color: var(--tinta); background: var(--sol);
  border: 4px solid var(--tinta); border-radius: 14px; box-shadow: 0 5px 0 var(--tinta);
  padding: 12px 22px;
  animation: blink 1s steps(2) infinite;
}
#start:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--tinta); }
@keyframes blink { 50% { filter: brightness(1.12); } }
.tip { margin: 4px 0 0; font-size: 13px; font-weight: 700; color: #fff; text-shadow: 0 2px 0 var(--tinta); max-width: 340px; }
.portrait.walk { animation: walk .9s steps(10) infinite; }
@keyframes walk { from { background-position: 0 0; } to { background-position: -1280px 0; } }

#controls {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 calc(env(safe-area-inset-right, 0px) + 18px) calc(env(safe-area-inset-bottom, 0px) + 16px) calc(env(safe-area-inset-left, 0px) + 18px);
  pointer-events: none;
}
.pad { display: flex; gap: 14px; align-items: flex-end; }
.pad button {
  pointer-events: auto;
  font-family: var(--display);
  font-weight: 700;
  font-size: 28px;
  color: var(--tinta);
  background: var(--celeste);
  border: 4px solid var(--tinta);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--tinta);
  width: 88px; height: 88px;
  touch-action: none;
  opacity: .88;
}
.pad button.big { width: 118px; height: 108px; font-size: 22px; background: #7cc576; }
.pad button.small { width: 80px; height: 76px; font-size: 13px; background: #e8434f; color: #fff; }
.pad button.on { transform: translateY(4px); box-shadow: 0 1px 0 var(--tinta); opacity: 1; }

#result {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(18, 22, 48, .6);
}
#result.hidden { display: none; }
.card {
  background: var(--panel);
  border: 4px solid var(--line);
  box-shadow: 0 6px 0 var(--tinta);
  border-radius: 14px;
  padding: 10px 26px 18px;
  text-align: center;
  min-width: 280px;
  max-width: 92vw;
  display: flex; flex-direction: column; align-items: center;
}
.card h2 { margin: 0 0 6px; font-family: var(--display); font-size: 26px; color: var(--sol); text-shadow: 0 3px 0 var(--tinta); }
.card p { margin: 3px 0; font-size: 17px; font-weight: 700; }
.card button {
  margin-top: 12px;
  font-family: var(--display); font-weight: 700; font-size: 15px;
  color: var(--tinta); background: var(--celeste);
  border: 4px solid var(--tinta); border-radius: 12px;
  box-shadow: 0 4px 0 var(--tinta);
  padding: 10px 18px;
}
.card button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--tinta); }

#rotate {
  position: fixed; top: 10px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.7); color: #fff;
  padding: 8px 14px; border-radius: 20px;
  font-size: 14px; display: none;
  pointer-events: none;
}
@media (orientation: portrait) { #rotate { display: block; } }

/* Posición y sonido (arriba a la derecha) */
#topright {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  z-index: 5;
}
#pos {
  font-family: var(--display); font-weight: 700;
  background: rgba(29, 34, 82, .82);
  border: 3px solid var(--line); box-shadow: 0 3px 0 var(--tinta);
  border-radius: 10px; padding: 2px 12px 4px;
  text-shadow: 0 3px 0 var(--tinta);
  pointer-events: none;
}
#pos b { font-size: 34px; color: var(--sol); }
#pos span { font-size: 14px; color: var(--celeste); margin-left: 2px; }
#snd { display: flex; gap: 6px; }
#snd button {
  width: 40px; height: 40px; font-size: 18px; line-height: 1;
  color: var(--blanco, #fff); background: rgba(29, 34, 82, .85);
  border: 3px solid var(--line); border-radius: 10px;
  box-shadow: 0 3px 0 var(--tinta);
  touch-action: manipulation;
}
#snd button.off { opacity: .45; text-decoration: line-through; }
#snd button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--tinta); }

/* Botón del poder */
#itembtn {
  position: fixed; z-index: 4;
  right: calc(env(safe-area-inset-right, 0px) + 40px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 150px);
  width: 76px; height: 76px; border-radius: 50%;
  font-family: var(--display); font-weight: 700; font-size: 11px;
  color: var(--tinta); background: rgba(108, 195, 242, .45);
  border: 4px solid var(--tinta); box-shadow: 0 5px 0 var(--tinta);
  opacity: .55; touch-action: none; user-select: none;
}
#itembtn.has { opacity: 1; background: var(--sol); font-size: 34px; animation: itempop .35s cubic-bezier(.2, 1.6, .4, 1); }
#itembtn.on { transform: translateY(4px); box-shadow: 0 1px 0 var(--tinta); }
@keyframes itempop { from { transform: scale(.4); } to { transform: scale(1); } }

/* Líneas de velocidad en el turbo */
#speedlines {
  position: fixed; inset: 0; pointer-events: none; opacity: 0;
  transition: opacity .18s;
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,0) 0deg 5deg, rgba(255,255,255,.55) 5deg 5.6deg, rgba(255,255,255,0) 5.6deg 11deg);
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 42%, #000 92%);
  mask-image: radial-gradient(ellipse at center, transparent 42%, #000 92%);
  animation: spinlines .5s steps(4) infinite;
}
@keyframes spinlines { to { transform: rotate(11deg) scale(1.05); } }

/* La posición rebota cuando cambia */
#posN { display: inline-block; }
#posN.bump { animation: posbump .5s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes posbump { 0% { transform: scale(1.9) rotate(-8deg); } 100% { transform: scale(1) rotate(0); } }

#levels { display: flex; gap: 8px; }
#levels button {
  font-family: var(--display); font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(29, 34, 82, .85); border: 3px solid var(--tinta); border-radius: 10px; padding: 7px 10px;
}
#levels button.on { background: var(--sol); color: var(--tinta); }

#minimap { width: 96px; height: 96px; background: rgba(29, 34, 82, .72); border: 3px solid var(--line); border-radius: 12px; box-shadow: 0 3px 0 var(--tinta); pointer-events: none; }
#pause { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(20, 16, 40, .66); }
#pause.hidden { display: none; }
#pause .card { display: flex; flex-direction: column; gap: 10px; align-items: stretch; min-width: 220px; padding: 16px; background: rgba(29, 34, 82, .95); border: 4px solid var(--tinta); border-radius: 16px; }
#pause h2 { margin: 0; text-align: center; font-family: var(--display); font-size: 26px; color: var(--sol); text-shadow: 0 3px 0 var(--tinta); }
#pause button { font-family: var(--display); font-weight: 700; font-size: 14px; color: var(--tinta); background: var(--sol); border: 3px solid var(--tinta); border-radius: 12px; box-shadow: 0 4px 0 var(--tinta); padding: 10px; touch-action: manipulation; }
#pause button[data-lv] { background: #fff; }

/* ---- Pantalla ordenada: arriba a la izquierda el tiempo, arriba al centro los botones,
   arriba a la derecha posición y minimapa, abajo al centro el ítem ---- */
#snd {
  position: fixed; z-index: 5;
  top: calc(env(safe-area-inset-top, 0px) + 8px); left: 50%; transform: translateX(-50%);
}
#snd button { width: 34px; height: 34px; font-size: 15px; border-width: 2px; border-radius: 9px; }
#itembtn {
  right: auto; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  width: 70px; height: 70px;
}
#itembtn.on { transform: translateX(-50%) translateY(4px); }
@keyframes itempop { from { transform: translateX(-50%) scale(.4); } to { transform: translateX(-50%) scale(1); } }
#driftbar { bottom: calc(env(safe-area-inset-bottom, 0px) + 100px); }
#minimap { width: 84px; height: 84px; }
#pos { padding: 0 10px 2px; }
#pos b { font-size: 26px; }
#hud { padding: 4px 10px 4px 4px; gap: 6px; }
#avatar { zoom: .6; }
#time { font-size: 18px; }
#place { display: none; }
@media (max-height: 520px) {
  .pad button { width: 72px; height: 72px; font-size: 22px; }
  .pad button.big { width: 98px; height: 88px; font-size: 18px; }
  .pad button.small { width: 66px; height: 62px; font-size: 11px; }
  .pad { gap: 10px; }
  #controls { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); }
  #itembtn { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
  #driftbar { bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); }
}

#levels { flex-wrap: wrap; justify-content: center; max-width: 92vw; }
#levels button { font-size: 10px; padding: 6px 8px; }
@media (max-height: 520px) { #pause .card { gap: 6px; padding: 10px; } #pause button { padding: 6px; font-size: 12px; } }

/* Opciones: modo, dificultad y control */
.optbox { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.opts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.opts button {
  font-family: var(--display); font-size: 10px; font-weight: 700; color: #fff;
  background: rgba(29, 34, 82, .85); border: 3px solid var(--tinta); border-radius: 10px; padding: 6px 8px;
  touch-action: manipulation;
}
.opts button.on { background: var(--sol); color: var(--tinta); }
#pause .opts button { background: rgba(255, 255, 255, .12); font-size: 11px; box-shadow: none; padding: 7px 8px; }
#pause .opts button.on { background: var(--sol); color: var(--tinta); }
#pause .cols { display: flex; gap: 14px; align-items: flex-start; }
#pause .col { display: flex; flex-direction: column; gap: 8px; }
#pause .card { max-width: 94vw; }

/* Stick analógico */
#stick {
  display: none; position: fixed; z-index: 4;
  left: calc(env(safe-area-inset-left, 0px) + 36px); bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  width: 124px; height: 124px; border-radius: 50%;
  background: rgba(108, 195, 242, .35); border: 4px solid var(--tinta); box-shadow: 0 5px 0 var(--tinta);
  touch-action: none; user-select: none;
}
#stick i {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: var(--celeste); border: 4px solid var(--tinta); box-shadow: 0 3px 0 var(--tinta);
  transform: translate(0, 0);
}
body.stick #stick { display: block; }
body.stick #controls .pad.left { visibility: hidden; }
body.crono #pos { display: none; }
@media (max-height: 520px) {
  #loading { gap: 5px; }
  #loading .portrait { display: none; }
  #loading h1 { font-size: 24px; }
  .tip { display: none; }
  #stick { width: 108px; height: 108px; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); }
}

/* Stick flotante: la zona táctil es la mitad izquierda; el círculo aparece donde apoyás el dedo */
#stickzone { display: none; position: fixed; z-index: 3; left: 0; top: 18%; bottom: 0; width: 46%; touch-action: none; }
body.stick #stickzone { display: block; }
#stick { pointer-events: none; opacity: .3; transition: opacity .12s; }
#stick.live { opacity: 1; }

/* Elegir personaje */
.chars { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chars button {
  font-family: var(--display); font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(29, 34, 82, .85); border: 3px solid var(--tinta); border-radius: 10px; padding: 7px 9px;
}
.chars button[data-pj="guri"] { border-bottom: 6px solid #6cc3f2; }
.chars button[data-pj="gurisa"] { border-bottom: 6px solid #e8434f; }
.chars button[data-pj="carpincho"] { border-bottom: 6px solid #ff9d2e; }
.chars button[data-pj="chiqui"] { border-bottom: 6px solid #7cc576; }
.chars button.on { background: var(--sol); color: var(--tinta); }
#pause .chars button { font-size: 10px; padding: 6px 7px; }

@media (max-height: 520px) {
  .chars button { font-size: 9px; padding: 4px 7px; border-width: 2px; border-bottom-width: 5px; }
  #loading { overflow-y: auto; }
}

/* ---- Modo TOQUE: mitades de pantalla para girar, el kart acelera solo ---- */
.zone { display: none; position: fixed; top: 0; bottom: 0; width: 50%; z-index: 3; touch-action: none; -webkit-tap-highlight-color: transparent; }
#zone-left { left: 0; } #zone-right { right: 0; }
body.toque .zone { display: block; }
.hint {
  display: none; position: fixed; z-index: 3; pointer-events: none;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); font-size: 44px; color: #fff; opacity: .28;
  text-shadow: 0 3px 0 var(--tinta); transition: opacity .1s, transform .1s;
}
#hint-left { left: calc(env(safe-area-inset-left, 0px) + 30px); }
#hint-right { right: calc(env(safe-area-inset-right, 0px) + 30px); }
body.toque .hint { display: block; }
.hint.on { opacity: .95; transform: scale(1.25); }
body.toque #controls { display: none; }
#brakebtn {
  display: none; position: fixed; z-index: 4; left: calc(50% + 50px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  width: 62px; height: 62px; border-radius: 50%; font-family: var(--display); font-size: 10px; font-weight: 700;
  color: #fff; background: #e8434f; border: 3px solid var(--tinta); box-shadow: 0 4px 0 var(--tinta); opacity: .85;
  touch-action: none;
}
#brakebtn.on { transform: translateY(4px); box-shadow: 0 1px 0 var(--tinta); opacity: 1; }
body.toque #brakebtn { display: block; }

/* ---- Botón de personaje ---- */
.pjbtn {
  font-family: var(--display); font-size: 12px; font-weight: 700; color: var(--tinta);
  background: #fff; border: 3px solid var(--tinta); border-radius: 12px; box-shadow: 0 4px 0 var(--tinta); padding: 8px 12px;
  touch-action: manipulation;
}
.pjbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--tinta); }

/* ---- Pantalla de personajes ---- */
#select { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(20, 16, 40, .82); --pj: #6cc3f2; }
#select.hidden { display: none; }
.selcard {
  position: relative; display: flex; flex-direction: column; gap: 8px; align-items: stretch;
  width: min(94vw, 720px); max-height: 94vh; padding: 12px 14px 10px;
  background: rgba(29, 34, 82, .97); border: 4px solid var(--tinta); border-radius: 16px; box-shadow: 0 0 0 3px var(--pj);
}
.selx { position: absolute; top: 6px; right: 8px; width: 32px; height: 32px; font-size: 15px; font-weight: 700; color: #fff; background: #e8434f; border: 3px solid var(--tinta); border-radius: 9px; z-index: 2; }
.selbody { display: flex; gap: 12px; align-items: center; }
.selview { display: flex; align-items: center; gap: 4px; flex: 1.15; min-width: 0; }
#selCanvas { flex: 1; min-width: 0; width: 100%; height: auto; max-height: 46vh; aspect-ratio: 8 / 5; image-rendering: pixelated; background: radial-gradient(ellipse at 50% 70%, color-mix(in srgb, var(--pj) 38%, #1d2252), #1d2252 70%); border: 3px solid var(--tinta); border-radius: 12px; }
.arrow { flex: none; width: 34px; height: 54px; font-size: 18px; font-weight: 700; color: var(--tinta); background: var(--sol); border: 3px solid var(--tinta); border-radius: 10px; box-shadow: 0 3px 0 var(--tinta); }
.selinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; color: #fff; }
.selinfo h2 { margin: 0; font-family: var(--display); font-size: 22px; color: var(--pj); text-shadow: 0 2px 0 var(--tinta); }
.selinfo p { margin: 0 0 2px; font-size: 13px; font-weight: 700; line-height: 1.25; }
.stat { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--display); font-size: 10px; font-weight: 700; }
.stat b { display: flex; gap: 3px; }
.stat b i { width: 16px; height: 11px; background: rgba(255, 255, 255, .18); border: 2px solid var(--tinta); border-radius: 3px; }
.stat b i.on { background: var(--pj); }
.selbtns { display: flex; gap: 8px; margin-top: 4px; }
.selbtns button { font-family: var(--display); font-size: 12px; font-weight: 700; color: var(--tinta); background: #fff; border: 3px solid var(--tinta); border-radius: 12px; box-shadow: 0 4px 0 var(--tinta); padding: 9px 10px; touch-action: manipulation; }
#selPick { flex: 1; background: var(--sol); }
.chips { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.chips button { font-family: var(--display); font-size: 10px; font-weight: 700; color: #fff; background: rgba(255, 255, 255, .1); border: 3px solid var(--tinta); border-bottom: 6px solid var(--c); border-radius: 10px; padding: 6px 9px; }
.chips button.on { background: var(--sol); color: var(--tinta); }
@media (max-height: 520px) {
  .selcard { padding: 8px 12px 8px; gap: 6px; }
  .selinfo h2 { font-size: 18px; }
  .selinfo p { font-size: 11px; }
  .arrow { width: 28px; height: 44px; }
  #selCanvas { max-height: 62vh; }
  .stat b i { width: 13px; height: 9px; }
}

/* Retratos de Gurises: cada personaje con su hoja de sprites (mismo formato que la del Gurí) */
body.pj-gurisa .portrait { background-image: url(assets/gurisa.png); }
body.pj-chiqui .portrait { background-image: url(assets/chiqui.png); }
body.pj-carpincho .portrait { background-image: url(assets/carpincho.png); }
.selhead { display: flex; align-items: center; gap: 8px; }
.selhead .portrait { flex: none; }
#selPortrait { zoom: .9; }

/* ---- Pantalla final: encima de todo y sin controles de juego ---- */
#result { z-index: 15; }
.resrow { display: flex; gap: 8px; }
#result .card button { margin-top: 10px; }
#nextLevel { background: var(--sol) !important; }
.resrow button { flex: 1; font-size: 13px !important; padding: 9px 12px !important; }
body.finished .zone, body.finished .hint, body.finished #brakebtn, body.finished #controls,
body.finished #itembtn, body.finished #driftbar, body.finished #stickzone, body.finished #stick,
body.finished #snd { display: none !important; }
@media (max-height: 520px) {
  #result .card { padding: 6px 18px 10px; }
  #result .card p { font-size: 13px; margin: 1px 0; }
  #result .card h2 { font-size: 20px; margin-bottom: 2px; }
  #result .portrait { display: none; }
}

/* ---- Bizcochos, tienda e historia ---- */
#biz { font-size: 13px; color: var(--sol); }
.menurow { display: flex; gap: 8px; justify-content: center; }
.storytag { display: none; margin: 0; max-width: 90vw; text-align: center; font-family: var(--display); font-size: 11px; line-height: 1.35; color: #fff; text-shadow: 0 2px 0 var(--tinta); }
body.historia .storytag { display: block; }
body.historia #levels, body.historia #pause [data-lv], body.historia #again { display: none !important; }
#resBiz, #resStory { color: var(--sol); }
#resStory:empty, #resBiz:empty { display: none; }
#result .card { max-height: 94vh; overflow-y: auto; }
#shop { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(20, 16, 40, .82); }
#shop.hidden { display: none; }
.shopcard { width: min(94vw, 560px); }
.shophead { display: flex; align-items: center; gap: 10px; padding-right: 36px; color: #fff; }
.shophead h2 { margin: 0; flex: 1; font-family: var(--display); font-size: 17px; color: var(--sol); text-shadow: 0 2px 0 var(--tinta); }
.shophead b { font-family: var(--display); font-size: 18px; color: var(--sol); }
.shoprow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; margin-top: 6px; background: rgba(255, 255, 255, .08); border: 3px solid var(--tinta); border-radius: 12px; color: #fff; }
.shopinfo { display: flex; flex-direction: column; gap: 2px; }
.shopinfo b { font-family: var(--display); font-size: 13px; }
.shopinfo span { font-size: 12px; font-weight: 700; opacity: .85; }
.pips { display: flex; gap: 3px; margin-top: 2px; }
.pips i { width: 18px; height: 10px; background: rgba(255, 255, 255, .18); border: 2px solid var(--tinta); border-radius: 3px; }
.pips i.on { background: var(--sol); }
.shoprow button { min-width: 86px; font-family: var(--display); font-size: 13px; font-weight: 700; color: var(--tinta); background: var(--sol); border: 3px solid var(--tinta); border-radius: 12px; box-shadow: 0 4px 0 var(--tinta); padding: 9px 8px; touch-action: manipulation; }
.shoprow button:disabled { background: #8a87a0; color: #3b3850; box-shadow: none; opacity: .75; }
.shopnote { margin: 6px 2px 0; font-size: 11px; font-weight: 700; color: #cfd2f5; }
@media (max-height: 520px) {
  .shoprow { padding: 4px 8px; margin-top: 4px; }
  .shopnote { font-size: 10px; margin-top: 4px; }
  .menurow .pjbtn { font-size: 10px; padding: 6px 9px; }
  .storytag { font-size: 9px; }
}

/* Escenas */
.bizico { display: inline-block; width: 19px; height: 15px; background: url(assets/bizcocho.png) center/contain no-repeat; image-rendering: pixelated; vertical-align: -2px; }
#scene { position: fixed; inset: 0; z-index: 40; background: #000; display: flex; align-items: center; justify-content: center; }
#scene.hidden { display: none; }
#sceneCanvas { width: 100%; max-height: 100%; aspect-ratio: 16/9; image-rendering: pixelated; }
#sceneBox { position: absolute; left: 3%; right: 3%; bottom: 4%; padding: 10px 14px; background: rgba(20,16,40,.92); border: 3px solid #fff; border-radius: 10px; color: #fff; font-family: inherit; }
#sceneBox[hidden] { display: none; }
#sceneWho { display: block; font-size: 13px; margin-bottom: 4px; letter-spacing: 1px; }
#sceneWho[hidden] { display: none; }
#sceneText { margin: 0; font-size: 14px; line-height: 1.35; min-height: 38px; }
#sceneNext { position: absolute; right: 12px; bottom: 6px; animation: blink .8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
#sceneSkip, #sceneNever { position: absolute; top: 10px; font-size: 12px; padding: 7px 10px; color: #fff; background: #e8434f; border: 3px solid #2a1d2c; border-radius: 9px; font-weight: 700; }
#sceneSkip { right: 10px; }
#sceneNever { left: 10px; background: #4a4458; }
