@font-face { font-family: 'Lilita One'; src: url('lilita-one.woff2') format('woff2'); font-display: swap; }
:root {
  --cream: #fff6e0;
  --frame: #2f3440;
  --ink: #2a1f1a;
  --red: #d93b3b;
  --yellow: #f2c14e;
  --teal: #1f9e89;
  --display: 'Lilita One', ui-rounded, system-ui, sans-serif;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; color: var(--ink); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
body { background: linear-gradient(180deg, #9fd3e8 0%, #cfe6ec 45%, #f2e3c6 100%); }
#app { position: relative; display: flex; justify-content: center; gap: 18px; height: 100%; padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); }
#center { display: flex; flex-direction: column; width: 100%; max-width: 520px; min-height: 0; }
.side { display: none; }

.label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }
.value { font-family: var(--display); font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud { display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin-bottom: 6px; background: #fff6e0ee; border: 3px solid var(--frame); border-radius: 16px; }
.stat { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.hud .value { font-size: 19px; }
.hud .icon { width: 34px; height: 34px; border-radius: 10px; }
.hud .icon svg { width: 19px; height: 19px; }
.hud .buttons { gap: 4px; }
.hud .lives i { width: 11px; height: 11px; }
.aboard .bar { display: block; height: 6px; margin-top: 3px; background: #2a1f1a22; border-radius: 3px; overflow: hidden; }
.aboard .bar i { display: block; height: 100%; width: 0; background: var(--teal); border-radius: 3px; transition: width .2s ease-out, background-color .2s; }
.aboard.over .bar i { background: var(--red); }
.aboard.over .value { color: var(--red); }
.lives { display: inline-flex; gap: 3px; }
.lives i { width: 14px; height: 14px; border-radius: 4px; background: var(--yellow); box-shadow: inset 0 -2px 0 #0003, 0 0 0 2px var(--frame); }
.lives i.lost { background: #2a1f1a33; box-shadow: 0 0 0 2px #2a1f1a55; }
.buttons { margin-left: auto; display: flex; gap: 6px; }
button { font: inherit; cursor: pointer; border: 0; color: inherit; }
.icon { width: 40px; height: 40px; border-radius: 12px; background: #fff; box-shadow: inset 0 -3px 0 #0002, 0 0 0 2px var(--frame); }
.icon svg { width: 22px; height: 22px; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon .off, .icon[aria-pressed="true"] .on { display: none; }
.icon[aria-pressed="true"] .off { display: inline; }
.js-music[aria-pressed="true"] .off { display: none; }
.js-music[aria-pressed="false"] .off { display: inline; }
.js-music[aria-pressed="false"] svg { opacity: .55; }
.icon:hover { background: #fff8e8; }
.icon:active { transform: translateY(1px); }
.mission-line { min-height: 26px; margin: 0 4px 6px; padding: 3px 10px; font-size: 13px; font-weight: 800; background: #fff6e0dd; border-radius: 12px; display: flex; align-items: center; gap: 8px; }
.mission-line:empty { display: none; }
.rank-pill { padding: 1px 7px; border-radius: 8px; background: var(--red); color: #fff; font-size: 11px; white-space: nowrap; }
.mission-line .bar, .missions .bar { flex: 1; height: 8px; background: #2a1f1a20; border-radius: 4px; overflow: hidden; min-width: 40px; }
.mission-line .bar i, .missions .bar i { display: block; height: 100%; background: var(--teal); border-radius: 4px; transition: width .3s ease-out; }
#stage { flex: 1; position: relative; min-height: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.panel { background: #fff6e0ee; border: 4px solid var(--frame); border-radius: 20px; padding: 12px 14px; box-shadow: 0 6px 0 #2a1f1a33; }
.panel h3 { margin: 0 0 8px; font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--red); }
.panel .aboard { display: flex; flex-direction: column; }
.panel .aboard .value { font-size: 30px; }
.lives-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.stats { display: flex; justify-content: space-around; gap: 8px; }
.stats .value { font-size: 28px; }
.missions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.missions li { font-size: 14px; font-weight: 700; }
.missions li .row { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }
.missions li.done { color: var(--teal); }
.missions li.done::before { content: '✔ '; }
.rank { margin: 10px 0 0; font-size: 13px; font-weight: 800; color: var(--red); }
.buttons-panel { display: flex; justify-content: center; gap: 10px; }
.controls-panel p { margin: 6px 0; font-size: 13px; font-weight: 700; }
kbd { display: inline-block; min-width: 24px; padding: 2px 6px; margin-right: 2px; border-radius: 6px; background: #fff; box-shadow: inset 0 -2px 0 #0003, 0 0 0 1.5px var(--frame); font: 800 12px system-ui, sans-serif; text-align: center; }

.toast { position: absolute; left: 50%; top: 26%; z-index: 4; transform: translateX(-50%); width: min(300px, 90%); padding: 10px 14px; border-radius: 16px; background: var(--cream); border: 3px solid var(--frame); box-shadow: 0 6px 0 #2a1f1a33; text-align: center; animation: pop .45s ease-out; pointer-events: none; }
.toast strong { display: block; font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--red); }
.toast span { display: block; font-size: 13px; font-weight: 600; margin-top: 2px; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: #1d1a1866; z-index: 5; animation: fade .2s ease-out; }
.hidden { display: none !important; }
.card { background: var(--cream); border: 4px solid var(--frame); border-radius: 26px; padding: 24px 22px; width: min(340px, 90%); max-height: 94%; overflow: auto; text-align: center; box-shadow: 0 10px 0 #2a1f1a44; }
.card h1 { margin: 0 0 8px; font-family: var(--display); font-weight: 400; font-size: 54px; line-height: .9; color: var(--frame); text-shadow: 0 3px 0 #2a1f1a22; }
.card h1 span { color: var(--red); font-size: 70px; }
.card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 30px; color: var(--frame); }
.card p { margin: 10px 0; }
.card .missions { margin: 10px 0; }
.meta { font-size: 13px; font-weight: 800; color: var(--frame); }
.big { font-family: var(--display); font-size: 56px; line-height: 1; font-variant-numeric: tabular-nums; }
.record { color: var(--red); font-weight: 900; animation: popc .5s ease-out; }
.hint { font-size: 13px; opacity: .7; }
.primary, .reward { display: block; width: 100%; margin-top: 12px; padding: 14px 16px; border-radius: 16px; font-family: var(--display); font-size: 24px; box-shadow: inset 0 -5px 0 #0003; transition: transform .1s; }
.primary { background: var(--red); color: #fff; }
.reward { background: var(--teal); color: #fff; font-size: 18px; }
.primary:hover, .reward:hover { filter: brightness(1.06); }
.primary:active, .reward:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 #0003; }
.primary[disabled], .reward[disabled] { opacity: .45; cursor: default; }
.ad .bar { height: 8px; background: #0001; border-radius: 4px; overflow: hidden; margin-top: 12px; }
.ad .bar i { display: block; height: 100%; width: 0; background: var(--teal); }
.ad.running .bar i { width: 100%; transition: width 2s linear; }

/* Escritorio / apaisado: la pista ocupa la altura y los paneles van a los lados. */
@media (min-aspect-ratio: 1/1) and (min-width: 760px) {
  #app { gap: 22px; padding: 16px; align-items: center; }
  #center { height: 100%; width: auto; max-width: none; aspect-ratio: 360 / 640; }
  .hud, .mission-line { display: none; }
  .side { display: flex; flex-direction: column; gap: 14px; width: clamp(190px, calc((100vw - (100vh - 32px) * 360 / 640 - 80px) / 2), 280px); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 70% { transform: translateX(-50%) scale(1.06); } }
@keyframes popc { 0% { transform: scale(.4); } 70% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .overlay, .record, .toast { animation: none; } }
