/* Cuida tu Kaiju - prototipo Mundo 1. Paleta del GDD seccion 2 (low-poly pastel). */
:root {
  --ink: #1b1b22;
  --sky: #b6def3;
  --sky2: #dceff8;
  --grass: #8bd448;
  --grass-d: #5e9e2f;
  --water: #5bb8e8;
  --mud: #8a5a34;
  --gold: #e8c65a;
  --red: #e53935;
  --teal: #3dbfae;
  --orange: #f0a93a;
  --purple: #8e86b8;
  --bar: #1e2330;
  --cream: #fff6d6;
  --paper: #f4f1ea;
  --ok: #6cc24a;
  --warn: #f0a93a;
  --crit: #e53935;
  --font-title: "Arial Black", "Segoe UI Black", "Arial Rounded MT Bold", Impact, system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --font-body: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #12151c;
  color: var(--ink);
  font-family: var(--font-body);
  display: grid;
  place-items: center;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid #1b6fe8; outline-offset: 2px; }
#app {
  position: relative;
  width: min(100vw, 440px);
  height: min(100dvh, 920px);
  background: var(--sky);
  overflow: hidden;
  box-shadow: 0 10px 60px rgba(0, 0, 0, 0.55);
}
@media (min-width: 460px) and (min-height: 700px) { #app { border-radius: 22px; } }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.on { display: flex; }

/* ---------- tipografia del juego: titulo negro grueso y cinta roja ---------- */
.big-title {
  font-family: var(--font-title);
  font-weight: 900;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1;
  letter-spacing: 0.01em;
  text-shadow: 2px 0 #fff, -2px 0 #fff, 0 2px #fff, 0 -2px #fff, 2px 2px #fff, -2px -2px #fff, 2px -2px #fff, -2px 2px #fff;
}
.ribbon {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.32em 0.8em;
  transform: rotate(-1.4deg);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.22);
  letter-spacing: 0.02em;
}
.btn {
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 0.7em 1em;
  font-family: var(--font-title);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 15px;
  background: var(--teal);
  color: #fff;
  text-shadow: 1.5px 1.5px 0 rgba(0, 0, 0, 0.45);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  min-height: 48px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.btn.orange { background: var(--orange); }
.btn.purple { background: var(--purple); }
.btn.red { background: var(--red); }
.btn.ghost { background: #fff; color: var(--ink); text-shadow: none; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.6); }
.btn.sm { font-size: 12px; min-height: 40px; padding: 0.5em 0.7em; border-width: 2.5px; border-radius: 12px; }
.coin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: #f5b82e; border: 2px solid #b8791a; vertical-align: -2px; box-shadow: inset -1.5px -1.5px 0 rgba(0, 0, 0, 0.15); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- seleccion de personaje ---------- */
#screen-select { background: linear-gradient(#b6def3 0%, #dceff8 45%, #8bd448 45.2%, #7ec63c 100%); align-items: center; justify-content: space-evenly; padding: 18px 16px 16px; gap: 8px; }
#screen-select .big-title { font-size: 40px; text-align: center; }
#screen-select .ribbon { font-size: 12px; }
#screen-select .mascot { width: 100%; height: 150px; }
#screen-select h2 { margin: 6px 0 0; font-size: 15px; font-family: var(--font-mono); text-transform: uppercase; background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 4px 12px; }
.chars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; flex: 0 0 auto; }
.char {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px 10px;
  gap: 4px;
  text-align: center;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
  min-height: 0;
}
.char canvas { width: 100%; height: 190px; flex: none; }
.char b { font-family: var(--font-title); font-size: 17px; text-transform: uppercase; }
.char .sw { width: 100%; height: 10px; border-radius: 6px; border: 2px solid var(--ink); }
.char small { font-size: 11px; line-height: 1.2; color: #444; }
.char[aria-checked="true"] { outline: 4px solid var(--red); }
.char:active { transform: translateY(3px); }
#screen-select .hint { font-size: 11px; color: #1b1b22; background: rgba(255, 255, 255, 0.85); padding: 3px 8px; border-radius: 8px; text-align: center; }

/* ---------- mapa ---------- */
#screen-map { background: linear-gradient(#b6def3 0, #dceff8 22%, #8bd448 22.2%, #7ec63c 100%); }
.topline { display: flex; align-items: center; gap: 8px; background: var(--bar); color: #fff; padding: 8px 10px; }
.topline .who { display: flex; align-items: center; gap: 6px; color: #fff; }
.topline .who canvas { width: 28px; height: 36px; background: rgba(255, 255, 255, 0.12); border-radius: 8px; }
.topline .who small { display: block; font-size: 10px; opacity: 0.7; font-family: var(--font-mono); text-transform: uppercase; }
.topline .who b { font-family: var(--font-title); font-size: 14px; text-transform: uppercase; }
.topline .fichas { margin-left: auto; background: var(--cream); color: var(--ink); border-radius: 18px; padding: 5px 12px; font-family: var(--font-mono); font-weight: 800; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.maphead { padding: 8px 14px 0; text-align: center; }
.maphead .ribbon { font-size: 11px; }
.maphead .big-title { font-size: 27px; margin-top: 8px; }
.maphead .mascot { width: 100%; height: 86px; }
.levels { flex: 1; overflow: auto; padding: 4px 14px 10px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.lvl {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 9px 12px;
  text-align: left;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
}
.lvl .num { width: 48px; height: 48px; border-radius: 50%; background: var(--teal); border: 3px solid var(--ink); color: #fff; font-family: var(--font-title); font-size: 24px; display: grid; place-items: center; text-shadow: 1.5px 1.5px 0 rgba(0, 0, 0, 0.4); }
.lvl .nm { font-family: var(--font-title); font-weight: 900; font-size: 15px; text-transform: uppercase; line-height: 1.1; }
.lvl .meta { font-family: var(--font-mono); font-size: 11px; color: #555; margin-top: 3px; }
.lvl .stars { font-size: 22px; letter-spacing: 1px; color: #d9d9d9; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); white-space: nowrap; }
.lvl .stars .f { color: #f5b82e; }
.lvl .rank { display: inline-block; margin-left: 6px; background: var(--ink); color: #fff; border-radius: 6px; padding: 0 6px; font-weight: 800; }
.lvl.locked { background: #e5e5e5; color: #777; }
.lvl.locked .num { background: #999; }
.lvl:not(.locked):active { transform: translateY(3px); }
.lvl .lock { grid-column: 3; justify-self: end; font-family: var(--font-mono); font-size: 11px; }
.banner { background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 12px; text-align: center; font-family: var(--font-mono); font-size: 12px; }
.banner b { display: block; font-family: var(--font-title); font-size: 18px; color: var(--gold); text-transform: uppercase; }

/* ---------- escena (cinematica) ---------- */
#screen-scene { background: var(--ink); color: #fff; align-items: center; }
#screen-scene .frame { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; padding: 8px 8px 0; }
#screen-scene img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; border: 3px solid #000; background: #fff; animation: scenein 0.5s ease-out; }
@keyframes scenein { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }
#screen-scene .caption { width: 100%; padding: 10px 16px 6px; }
#screen-scene .tag { font-family: var(--font-mono); font-size: 11px; background: #000; display: inline-block; padding: 2px 8px; border-radius: 6px; margin-bottom: 4px; }
#screen-scene .narr { font-size: 17px; line-height: 1.3; margin: 0; color: #fff; }
#screen-scene .remate { font-family: var(--font-title); font-weight: 900; font-size: 25px; color: var(--gold); display: block; margin-top: 6px; text-transform: uppercase; }
#screen-scene .row { display: flex; gap: 10px; padding: 8px 16px 14px; width: 100%; }
#screen-scene .row .btn { flex: 1; }

/* ---------- briefing ---------- */
#screen-brief { background: linear-gradient(#b6def3, #dceff8 30%, var(--paper) 30.2%); padding: 14px 14px 14px; gap: 10px; overflow: auto; }
#screen-brief .big-title { font-size: 31px; text-align: center; margin-top: 2px; }
#screen-brief .center { text-align: center; }
#screen-brief .ribbon { font-size: 11px; }
.card { background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 10px 12px; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18); }
.card h3 { margin: 0 0 4px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: #555; }
.card p { margin: 0; font-size: 14px; line-height: 1.3; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.two .card.win h3 { color: #2e7d32; }
.two .card.lose h3 { color: #b71c1c; }
.starlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.starlist b { color: #c98a00; font-family: var(--font-mono); margin-right: 6px; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips span { background: var(--cream); border: 2px solid var(--ink); border-radius: 12px; font-family: var(--font-mono); font-weight: 800; font-size: 12px; padding: 2px 8px; }
#screen-brief .row { display: flex; gap: 10px; margin-top: auto; }
#screen-brief .row .btn { flex: 1; }

/* ---------- pantalla de juego ---------- */
#screen-play { background: var(--sky); }
.topbar { display: flex; align-items: center; gap: 6px; background: var(--bar); color: #fff; padding: 6px 8px; min-height: 46px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; background: rgba(255, 255, 255, 0.14); border: 0; display: grid; place-items: center; color: #fff; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.topbar .ttl { flex: 1; min-width: 0; font-family: var(--font-title); font-size: 13px; text-transform: uppercase; line-height: 1.05; }
.topbar .ttl small { display: block; font-family: var(--font-mono); font-size: 10px; opacity: 0.7; font-weight: 700; }
.chip { background: var(--cream); color: var(--ink); border-radius: 16px; padding: 4px 10px; font-family: var(--font-mono); font-weight: 800; font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.chip small { font-weight: 600; opacity: 0.6; }
.hud { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 6px; background: #fff; border-bottom: 3px solid var(--ink); padding: 6px 8px 7px; }
.m { display: grid; grid-template-columns: 24px 1fr; gap: 0 6px; align-items: center; min-width: 0; }
.m.wide { grid-column: 1 / -1; }
.m svg.mi { width: 24px; height: 24px; }
.m .mt { font-family: var(--font-mono); font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em; color: #333; display: flex; justify-content: space-between; gap: 4px; white-space: nowrap; }
.m .mt em { font-style: normal; font-weight: 800; }
.bar { position: relative; height: 10px; background: #e2e2e2; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--ok); transition: width 0.15s linear; }
.bar u { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed rgba(0, 0, 0, 0.55); }
.bar.ok i { background: var(--ok); }
.bar.warn i { background: var(--warn); }
.bar.crit i { background: var(--crit); }
.bar.pink i { background: #f27ca0; }
.bar.purple i { background: #8e6be0; }
.bar.green i { background: #7cc24a; }
.m .sub { font-family: var(--font-mono); font-size: 9.5px; color: #444; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m .val { font-family: var(--font-mono); font-weight: 800; }
.m .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.st-ok { color: #2e7d32; }
.st-warn { color: #b26a00; }
.st-crit { color: #c62828; }
.forecast { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 9.5px; align-items: center; }
.forecast b { white-space: nowrap; }
.forecast span { padding: 1px 5px; border-radius: 6px; border: 2px solid var(--ink); background: #fff; font-weight: 800; white-space: nowrap; }
.forecast span.ok { background: #d8f0c8; }
.forecast span.warn { background: #ffe7b0; }
.forecast span.crit { background: #ffc9c6; }
.alert { display: flex; align-items: center; gap: 8px; margin: 5px 8px 0; padding: 4px 8px; border: 2px solid var(--ink); border-radius: 8px; font-family: var(--font-mono); font-weight: 800; font-size: 11.5px; text-transform: uppercase; min-height: 28px; background: #e8f0f6; }
.alert .ic { width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 12px; background: var(--ink); color: #fff; }
.alert.warn { background: #ffd84d; }
.alert.warn .ic { border-radius: 4px; background: var(--ink); clip-path: polygon(50% 0, 100% 100%, 0 100%); padding-top: 5px; font-size: 10px; }
.alert.crit { background: var(--red); color: #fff; animation: blink 0.9s steps(2) infinite; }
.alert.crit .ic { background: #fff; color: var(--red); border-radius: 4px; clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
@keyframes blink { 50% { background: #b71c1c; } }
.stage { position: relative; flex: 1; min-height: 120px; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.toast { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); background: rgba(27, 27, 34, 0.92); color: #fff; font-family: var(--font-mono); font-weight: 800; font-size: 12px; padding: 5px 12px; border-radius: 14px; pointer-events: none; opacity: 0; transition: opacity 0.2s; white-space: nowrap; z-index: 3; }
.toast.on { opacity: 1; }
.dock { background: var(--paper); border-top: 3px solid var(--ink); padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); display: grid; gap: 6px; }
.palette { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.pcard { background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 2px 2px 4px; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.pcard canvas { width: 100%; height: 44px; }
.pcard b { font-family: var(--font-title); font-size: 10px; text-transform: uppercase; line-height: 1; }
.pcard small { font-family: var(--font-mono); font-size: 10px; font-weight: 800; display: flex; align-items: center; gap: 3px; }
.pcard[aria-pressed="true"] { border-color: var(--red); box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.35); }
.pcard[disabled] { opacity: 0.4; }
.pbar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.pbar .info { flex: 1; font-size: 12px; line-height: 1.2; min-width: 0; }
.pbar .info b { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; }
.pbar .info .bad { color: #c62828; font-weight: 800; }
.pbar .info .good { color: #2e7d32; font-weight: 800; }
.actions { display: grid; grid-template-columns: auto 1.25fr auto 1.25fr; gap: 6px; }
.actions .btn { padding: 0.45em 0.5em; font-size: 12.5px; min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 5px; }
.actions .btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- overlays: titulo grande + cinta roja (Pilar 3), quiz, pausa ---------- */
#fx { position: absolute; inset: 0; pointer-events: none; display: grid; place-items: center; z-index: 5; }
.fx { text-align: center; animation: fxpop 2.6s ease-out forwards; padding: 0 12px; }
.fx .big-title { font-size: 46px; display: block; }
.fx .ribbon { font-size: 13px; margin-top: 8px; }
@keyframes fxpop { 0% { opacity: 0; transform: scale(0.6); } 12% { opacity: 1; transform: scale(1.08); } 20% { transform: scale(1); } 82% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.modal { position: absolute; inset: 0; background: rgba(15, 18, 28, 0.66); display: grid; place-items: center; z-index: 8; padding: 16px; }
.modal .box { width: 100%; background: #fff; border: 4px solid var(--ink); border-radius: 20px; padding: 14px; display: grid; gap: 10px; box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3); }
.modal .kick { font-family: var(--font-mono); font-size: 11px; font-weight: 800; text-transform: uppercase; color: #555; }
.modal h3 { margin: 0; font-family: var(--font-title); font-size: 20px; line-height: 1.15; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; border: 3px solid var(--ink); border-radius: 14px; background: var(--cream); padding: 10px 12px; font-size: 15px; font-weight: 700; min-height: 48px; display: flex; align-items: center; gap: 10px; }
.opt .l { width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-family: var(--font-mono); font-size: 13px; }
.opt.right { background: #c9efb5; }
.opt.wrong { background: #ffc9c6; }
.opt.dim { opacity: 0.55; }
.explain { font-size: 14px; line-height: 1.3; background: #eef4f8; border-radius: 12px; padding: 8px 10px; }
.explain b.good { color: #2e7d32; }
.explain b.bad { color: #c62828; }
.pause-menu { display: grid; gap: 10px; }
.pause-menu .big-title { font-size: 34px; text-align: center; }

/* ---------- resultado ---------- */
#screen-result { background: linear-gradient(#b6def3, #dceff8 28%, var(--paper) 28.2%); padding: 16px 14px 14px; gap: 10px; overflow: auto; align-items: stretch; }
#screen-result .big-title { font-size: 33px; text-align: center; }
#screen-result .center { text-align: center; }
#screen-result .ribbon { font-size: 12px; }
.starrow { display: flex; justify-content: center; gap: 6px; font-size: 54px; line-height: 1; }
.starrow span { color: #cfcfcf; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
.starrow span.f { color: #f5b82e; animation: starpop 0.5s ease-out backwards; }
.starrow span.f:nth-child(2) { animation-delay: 0.25s; }
.starrow span.f:nth-child(3) { animation-delay: 0.5s; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }
.score { display: flex; align-items: center; justify-content: center; gap: 12px; }
.score .p { font-family: var(--font-title); font-size: 40px; }
.score .rk { width: 56px; height: 56px; border-radius: 14px; border: 3px solid var(--ink); background: var(--gold); display: grid; place-items: center; font-family: var(--font-title); font-size: 34px; }
.score .rk.A { background: #9bd6ff; }
.score .rk.B { background: #cfcfcf; }
.obj { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 13.5px; }
.obj li { display: grid; grid-template-columns: 24px 1fr; gap: 6px; align-items: start; }
.obj .ck { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 13px; border: 2px solid var(--ink); }
.obj .ck.y { background: #b7e5a0; }
.obj .ck.n { background: #ffc9c6; }
.brk { font-family: var(--font-mono); font-size: 11px; color: #444; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.reason { text-align: center; font-size: 15px; font-weight: 700; }
#screen-result .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; }
#screen-result .row .btn.full { grid-column: 1 / -1; }

@media (prefers-reduced-motion: reduce) {
  .fx, .starrow span.f, #screen-scene img, .alert.crit { animation: none; }
  .fx { opacity: 1; }
}
