@font-face { font-family: 'Lilita One'; src: url('lilita-one.woff2') format('woff2'); font-display: swap; }
:root {
  --cream: #fff4dc;
  --sack: #8a5a2b;
  --ink: #3a2214;
  --pink: #e0447a;
  --teal: #1f9e89;
  --gold: #ffcf3f;
  --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: #cfe9e6 url('bg.svg') center bottom / cover no-repeat; }
#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: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.hud { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 6px; background: #fff4dcdd; border: 3px solid var(--sack); border-radius: 16px; }
.stat { display: flex; flex-direction: column; line-height: 1.1; min-width: 56px; }
.hud .next canvas { width: 32px; height: 32px; }
.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(--sack); }
.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: #fff4dccc; border-radius: 12px; display: flex; align-items: center; gap: 8px; }
.mission-line:empty { display: none; }
.mission-line .bar, .missions .bar { flex: 1; height: 8px; background: #3a221420; 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: #fff4dcee; border: 4px solid var(--sack); border-radius: 20px; padding: 12px 14px; box-shadow: 0 6px 0 #3a221433; }
.panel h3 { margin: 0 0 8px; font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--sack); }
.panel h3 small { font-family: system-ui, sans-serif; font-size: 12px; font-weight: 800; color: var(--ink); opacity: .7; }
.stats { display: flex; justify-content: space-around; }
.stats .value { font-size: 34px; }
.next-panel { display: flex; flex-direction: column; align-items: center; }
.next-panel canvas { width: 84px; height: 84px; }
.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 .bar i { background: var(--teal); }
.missions li.done::before { content: '✔ '; }
.rank { margin: 10px 0 0; font-size: 13px; font-weight: 800; color: var(--pink); }
.buttons-panel { display: flex; justify-content: center; gap: 10px; }
.collection { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 6px; }
.collection li { display: flex; align-items: center; gap: 4px; min-width: 0; font-size: 12px; font-weight: 700; }
.collection li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side { container-type: inline-size; }
@container (max-width: 239px) {
  .collection { grid-template-columns: repeat(4, minmax(0, 1fr)); justify-items: center; gap: 4px; }
  .collection li span { display: none; }
  .collection li canvas { width: 34px; height: 34px; }
}
.collection li canvas { width: 26px; height: 26px; flex: none; }
.collection li.locked { opacity: .55; }
.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(--sack); font: 800 12px system-ui, sans-serif; text-align: center; }

.skip { position: absolute; right: 10px; bottom: 74px; z-index: 3; padding: 6px 14px; border-radius: 12px; background: #fff; box-shadow: inset 0 -3px 0 #0002, 0 0 0 2px var(--sack); font-weight: 800; }
.toast { position: absolute; left: 50%; top: 32%; z-index: 4; transform: translateX(-50%); width: min(300px, 90%); padding: 10px 14px; border-radius: 16px; background: var(--cream); border: 3px solid var(--sack); box-shadow: 0 6px 0 #3a221433; 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(--pink); }
.toast span { display: block; font-size: 13px; font-weight: 600; margin-top: 2px; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: #2b1d1466; z-index: 5; animation: fade .2s ease-out; }
.hidden { display: none !important; }
.card { background: var(--cream); border: 4px solid var(--sack); border-radius: 26px; padding: 24px 22px; width: min(340px, 90%); max-height: 94%; overflow: auto; text-align: center; box-shadow: 0 10px 0 #3a221444; }
.card h1 { margin: 0 0 8px; font-family: var(--display); font-weight: 400; font-size: 50px; line-height: .9; color: var(--sack); text-shadow: 0 3px 0 #3a221422; }
.card h1 span { color: var(--pink); font-size: 66px; }
.card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 32px; color: var(--sack); }
.card p { margin: 10px 0; }
.card .missions { margin: 10px 0; }
.meta { font-size: 13px; font-weight: 800; color: var(--sack); }
.big { font-family: var(--display); font-size: 60px; line-height: 1; font-variant-numeric: tabular-nums; }
.record { color: var(--pink); font-weight: 900; animation: pop .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(--pink); 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; }
.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: el costal 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 / 612; }
  .hud, .mission-line { display: none; }
  .side { display: flex; flex-direction: column; gap: 14px; width: clamp(190px, calc((100vw - (100vh - 32px) * 360 / 612 - 80px) / 2), 280px); }
  .skip { bottom: 16px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 70% { transform: translateX(-50%) scale(1.06); } }
.record { animation-name: popc; }
@keyframes popc { 0% { transform: scale(.4); } 70% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .overlay, .record, .toast { animation: none; } }
