@font-face {
  font-family: Baloo;
  src: url("/assets/baloo-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: Baloo, "Trebuchet MS", sans-serif;
  color: #fff7fd;
  background: #38154e;
  --ink: #4b2263;
  --plum: #6a267c;
  --paper: #fff4e9;
  --gold: #ffda56;
  --catch-line: 88%;
  --belt-line: 27%;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100svh;
  padding: 0 max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 14% 10%, #85296e, transparent 58%), radial-gradient(ellipse at 100% 95%, #254c83, transparent 52%), #38154e;
}

h1, h2, p { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #ffe87a; outline-offset: 4px; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.topbar, main { max-width: 1200px; margin-inline: auto; }
.topbar, .topbar nav, .identity, .wallet, .control {
  display: flex;
  align-items: center;
}
.topbar {
  justify-content: space-between;
  padding-block: max(14px, env(safe-area-inset-top)) 8px;
}
.topbar nav { gap: 8px; }
.control {
  min-width: 44px;
  min-height: 44px;
  gap: 7px;
  justify-content: center;
  padding: 0 13px;
  color: #fff5ff;
  border: 1px solid #ffffff55;
  border-radius: 15px;
  text-decoration: none;
  background: #592963;
}
.control svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.control:focus-visible, .control:hover:not(:disabled) { background: #7b347f; }
#sound { padding: 0 10px; }
#sound[aria-pressed="false"] .sound-on, #sound[aria-pressed="true"] .sound-off { display: none; }
.identity {
  justify-content: space-between;
  gap: 12px;
  padding-block: 10px 17px;
}
h1 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 .36em;
  color: #fff5fe;
  font: 400 clamp(26px, 4.2vw, 54px)/.98 "Luckiest Guy", Baloo, sans-serif;
  letter-spacing: -.02em;
  text-shadow: 0 4px #572152;
}
h1 strong { font: inherit; color: #ffdc68; font-size: 1.22em; text-shadow: 0 4px #a53368, 0 6px #572152; }
.wallet {
  flex: none;
  gap: 7px;
  padding: 6px 12px 6px 7px;
  color: #ffedbc;
  border-radius: 50px;
  background: #2b1646;
  box-shadow: inset 0 1px 2px #21072ea0;
  font-size: 15px;
}
.wallet strong { font-size: 20px; color: white; line-height: 1; }
.coin {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  color: #9f460c;
  background: #ffdc55;
  border: 2px solid #ffed9a;
  border-radius: 50%;
  box-shadow: inset 0 -3px #ec9939;
}

.cabinet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(238px, 23vw, 288px);
  grid-template-areas: "play console";
  align-items: start;
  gap: 18px;
}
.play { grid-area: play; min-width: 0; }
.console { grid-area: console; min-width: 0; align-self: start; }
.mission {
  display: grid;
  justify-items: center;
  padding: 16px 16px 15px;
  border-radius: 18px;
  border: 2px solid #fff3fb;
  background: radial-gradient(ellipse at 50% 8%, #fff9ee 5%, transparent 60%), #ffd8ec;
  color: var(--ink);
  text-align: center;
  box-shadow: 0 5px 0 #aa4d96, 0 9px 24px #270c435c;
}
.mission-icon { width: 80px; height: 80px; object-fit: contain; filter: drop-shadow(0 4px 4px #86216a37); }
.listen { position: relative; display: grid; place-items: center; min-width: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; border-radius: 12px; }
.listen svg { position: absolute; bottom: 0; right: -2px; width: 25px; height: 25px; padding: 4px; border-radius: 50%; background: var(--plum); fill: none; stroke: white; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.listen:focus-visible { outline-color: var(--plum); }
.listen:disabled svg { display: none; }
.label { color: #782765; font-size: 15px; line-height: 1.25; }
.mission h2 { margin-block: 5px; font-size: clamp(22px, 2.25vw, 32px); line-height: .98; text-wrap: balance; }
#mission-description { font-size: 16px; line-height: 1.15; text-wrap: pretty; }
.mission-meter { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 13px; }
.mission-meter strong { min-width: max-content; color: #8b286e; font-size: 19px; }
progress { flex: 1; display: block; width: 100%; min-width: 0; appearance: none; height: 11px; border: 0; border-radius: 20px; background: #ebacd3; }
progress::-webkit-progress-bar { border-radius: 20px; background: #ebacd3; }
progress::-webkit-progress-value { border-radius: 20px; background: #a437a7; }
progress::-moz-progress-bar { border-radius: 20px; background: #a437a7; }
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 17px; }
.meter { padding: 7px 11px; border-radius: 13px; background: #2d174a; box-shadow: inset 0 1px 2px #190d36; }
.meter span { display: block; color: #ffd6ed; font-size: 14px; }
.meter strong { color: #fff3fd; font-size: clamp(22px, 2.5vw, 32px); line-height: 1; font-variant-numeric: tabular-nums; }
.meter .urgent { color: #ffda62; }
#instructions { margin: 17px 4px 0; color: #fff1fc; line-height: 1.25; }
.giant-tip { display: flex; gap: 8px; align-items: center; margin: 10px 4px 0; color: #ffe998; font-size: 14px; line-height: 1.15; }
.giant-tip img { flex: none; }

.field {
  --basket-width: 20%;
  container-type: size;
  position: relative;
  isolation: isolate;
  width: 100%;
  height: clamp(390px, 61svh, 640px);
  overflow: hidden;
  border: 3px solid #fff2fb;
  border-radius: 24px;
  background: #41c9ed url("./art/maquina.webp") center / 100% 100% no-repeat;
  box-shadow: 0 6px 0 #b13d91, 0 12px 28px #24163891;
  touch-action: pan-y;
  user-select: none;
}
.field[data-state="playing"] { cursor: ew-resize; touch-action: none; }
.route {
  position: absolute;
  z-index: 4;
  top: 10px;
  left: 10px;
  padding: 3px 12px;
  color: var(--ink);
  background: #fff6ee;
  border: 2px solid #ffffff;
  border-radius: 24px;
  box-shadow: 0 2px #9c3f8366;
  font-size: 14px;
  white-space: nowrap;
}
.machine-glow {
  position: absolute;
  left: 50%;
  top: 21%;
  width: 33%;
  height: 22%;
  opacity: .22;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 0%, #fff6a6, transparent 67%);
}
.field[data-state="playing"][data-route="rain"] .machine-glow { animation: glow 1.65s ease-in-out infinite alternate; }
@keyframes glow { to { opacity: .95; transform: translateX(-50%) scaleX(1.25); } }
.belt {
  display: none;
  position: absolute;
  top: calc(var(--belt-line) + clamp(17px, 4.2cqh, 28px));
  left: 0;
  width: 100%;
  height: clamp(13px, 3.3cqh, 23px);
  border-block: 3px solid #d78cdf;
  background: repeating-linear-gradient(108deg, #81448f 0 16px, #b867b4 17px 26px);
  box-shadow: 0 3px 0 #57215d, 0 5px 7px #4a20605a;
}
.field[data-route="belt"] .belt { display: block; }
.field[data-state="playing"] .belt { animation: rollers .9s linear infinite; }
.field[data-state="playing"] .belt.reverse { animation-direction: reverse; }
@keyframes rollers { to { background-position-x: 28px; } }
#pieces, #effects { position: absolute; inset: 0; pointer-events: none; }
#effects { z-index: 6; }
.piece {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: clamp(48px, 13.2%, 78px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
}
.piece img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 2px #3a267b57);
  animation: float-toy 1.15s ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
}
.piece.goal img {
  filter: drop-shadow(1px 0 1px #fff8a1) drop-shadow(-1px 0 1px #fff8a1) drop-shadow(0 0 5px #fff59d) drop-shadow(0 4px 2px #3a267b57);
}
.piece.goal::after {
  content: "✦";
  position: absolute;
  top: 1%;
  right: 0;
  color: #fffddd;
  line-height: .85;
  font-size: clamp(13px, 2.6vw, 23px);
  text-shadow: 0 1px 3px #9c5a21;
}
.piece.giant { width: clamp(76px, 20%, 130px); }
.piece.giant img { filter: drop-shadow(0 0 8px #ffe75e) drop-shadow(0 5px 4px #a75138a1); }
.piece.giant::before {
  content: "";
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(circle, #fffaba 6%, #ffd76fa8 38%, transparent 68%);
  animation: giant-aura .72s ease-in-out infinite alternate;
}
.piece.giant img { position: relative; }
.field:is([data-state="paused"], [data-state="briefing"]) .piece img, .field:is([data-state="paused"], [data-state="briefing"]) .piece.giant::before { animation-play-state: paused; }
@keyframes float-toy { from { transform: rotate(-9deg) scale(.97, 1.03); } to { transform: rotate(9deg) scale(1.04, .97); } }
@keyframes giant-aura { from { transform: scale(.8); opacity: .45; } to { opacity: .95; } }

.catcher {
  position: absolute;
  z-index: 5;
  left: var(--x, 50%);
  top: var(--catch-line);
  width: var(--basket-width);
  transform: translateX(-50%);
  pointer-events: none;
}
.basket { position: relative; top: -4px; display: block; width: 100%; height: min(11.5cqh, 70px); filter: drop-shadow(0 4px 3px #5c226b63); }
.yoyi {
  position: absolute;
  right: 76%;
  top: 0;
  width: auto;
  height: clamp(63px, 26cqh, 154px);
  transform: translateY(-64%);
  filter: drop-shadow(0 4px 3px #5c226b46);
}
.catcher[data-side="right"] .yoyi { left: 76%; right: auto; transform: translateY(-64%) scaleX(-1); }

.game-controls { display: grid; grid-template-columns: 64px auto 64px; justify-content: center; gap: 10px; margin-top: 16px; }
.direction { touch-action: none; }
.direction svg { width: 25px; height: 25px; }
.game-controls .control { min-height: 46px; background: #722b79; box-shadow: 0 3px 0 #301141; }
.game-controls .control:disabled { color: #e4b7e7; background: #572664; }
.game-controls .control:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 #301141; }

.round-panel {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 47%;
  width: min(calc(100% - 28px), 360px);
  padding: 14px 16px;
  transform: translate(-50%, -50%);
  border: 2px solid white;
  border-radius: 21px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  user-select: auto;
  box-shadow: 0 5px 0 #d65ca6, 0 12px 30px #512b8573;
}
.panel-title { font: 400 clamp(24px, 3.25vw, 35px)/1.02 "Luckiest Guy", Baloo, sans-serif; color: #912170; letter-spacing: -.025em; text-wrap: balance; }
.briefing-pieces { display: none; justify-content: center; margin: 0 auto 4px; }
.briefing-pieces img { width: clamp(44px, 15cqh, 76px); height: auto; object-fit: contain; }
.field[data-state="briefing"] .briefing-pieces { display: flex; }
#panel-message { margin: 6px 0 10px; font-size: 16px; line-height: 1.06; }
fieldset { display: flex; justify-content: center; gap: 6px; padding: 0; margin: 0 0 10px; border: 0; }
.mode { cursor: pointer; position: relative; }
.mode input { position: absolute; opacity: 0; }
.mode span { display: flex; min-height: 44px; align-items: center; padding-inline: 12px; border-radius: 12px; border: 2px solid #efb2d1; color: var(--plum); background: #fffafe; }
.mode input:checked + span { background: #ffd8ee; border-color: #9b3d8c; }
.mode input:focus-visible + span { outline: 3px solid #6a267c; outline-offset: 2px; }
.primary {
  min-width: min(100%, 174px);
  min-height: 46px;
  padding: 4px 14px 2px;
  border: 2px solid #fbec9b;
  border-radius: 15px;
  background: linear-gradient(#ffec8b, #ffc750);
  color: #572256;
  box-shadow: 0 3px 0 #c9763a;
  font-size: 23px;
  line-height: 1.05;
}
.primary:hover { background: #ffdd67; }
.primary::before { content: ""; display: inline-block; margin-right: 8px; border-block: .3em solid transparent; border-left: .45em solid currentColor; }
.primary:focus-visible { outline-color: var(--plum); }
.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #c9763a; }
.round-reward { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.round-reward span { border-radius: 8px; padding: 4px 7px; background: #ffdcf0; color: #782765; line-height: 1; }
.unlock { display: flex; justify-content: center; align-items: center; gap: 5px; margin: -4px 0 8px; color: #8b286e; line-height: 1; }

.pop, .particle { position: absolute; left: var(--x); top: var(--y); }
.pop {
  transform: translate(-50%, -55%);
  white-space: nowrap;
  border-radius: 30px;
  padding: 2px 10px;
  background: #fff5c5;
  color: #81265e;
  box-shadow: 0 3px 0 #7b40915e;
  font-size: clamp(17px, 2.6vw, 24px);
  animation: pop-feedback .8s ease-out both;
}
.pop[data-kind="wrong"], .pop[data-kind="miss"] { background: #fff0f8; }
.pop[data-kind="bonus"] { background: #ffdc61; color: #6b2c39; }
@keyframes pop-feedback {
  0% { transform: translate(-50%, -10%) scale(.78); opacity: 0; }
  22% { transform: translate(-50%, -75%) scale(1.08); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -175%); opacity: 0; }
}
.particle {
  color: var(--c);
  text-shadow: 0 1px 2px #6532908f;
  font-size: 22px;
  animation: burst .63s cubic-bezier(.1,.68,.38,1) both;
}
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(150deg) scale(.22); opacity: 0; } }

dialog {
  width: min(calc(100% - 22px), 545px);
  max-height: calc(100% - 26px);
  padding: 18px;
  border: 3px solid #fff9f1;
  border-radius: 20px;
  background: #fff2f8;
  color: var(--ink);
  box-shadow: 0 6px 0 #c454a6, 0 20px 60px #290e43a6;
}
dialog::backdrop { background: #23143bc9; }
.album-header { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.album-header h2 { font: 400 clamp(25px, 5vw, 38px)/1 "Luckiest Guy", Baloo, sans-serif; color: #912170; }
.album-header p { font-size: 15px; line-height: 1.15; }
#collection { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px; padding: 0; margin: 14px 0 0; list-style: none; }
#collection li { display: grid; justify-items: center; align-content: start; padding: 8px 4px; border-radius: 13px; text-align: center; line-height: 1.03; background: #ffdcf0; }
#collection li.locked { background: #f0ddf7; color: #633474; }
#collection img, .album-unknown { width: 60px; height: 60px; object-fit: contain; }
.album-unknown { display: grid; place-items: center; color: #84559a; font-size: 40px; }

@media (max-width: 730px) {
  .cabinet { grid-template-columns: minmax(0, 1fr); grid-template-areas: "console" "play"; gap: 10px; }
  .console { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 8px; }
  .mission { grid-template-columns: auto minmax(0, 1fr); justify-items: start; align-items: center; gap: 1px 8px; padding: 7px 8px 5px; border-radius: 13px; text-align: left; box-shadow: 0 3px 0 #aa4d96; }
  .mission-icon { width: clamp(35px, 9vw, 60px); height: auto; }
  .mission-meter { grid-column: 1 / -1; margin-top: 0; }
  .mission-meter strong { font-size: 15px; }
  .mission h2 { font-size: clamp(17px, 4.4vw, 24px); margin-block: 1px; text-wrap: initial; }
  .label { font-size: 12px; }
  #mission-description { font-size: clamp(12px, 3.3vw, 15px); }
  progress { height: 7px; }
  .meters { grid-template-columns: 1fr; margin: 0; gap: 4px; }
  .meter { min-width: 66px; padding: 3px 8px; border-radius: 9px; }
  .meter span { font-size: 11px; line-height: 1.02; }
  .meter strong { font-size: 21px; }
  #instructions { grid-column: 1 / -1; margin: 0 0 1px; font-size: 13px; }
  .giant-tip { display: none; }
  .field { height: clamp(298px, 53svh, 505px); border-radius: 18px; background-size: max(147%, 1.56 * 53svh) 100%; }
  .game-controls { margin-top: 12px; }
}

@media (max-width: 420px) {
  body { padding-inline: max(9px, env(safe-area-inset-left)) max(9px, env(safe-area-inset-right)); }
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 5px; }
  .identity { padding: 6px 0 11px; }
  h1 { font-size: clamp(20px, 5.4vw, 28px); }
  .wallet { gap: 4px; padding: 4px 8px 4px 4px; }
  .wallet span:last-child { display: none; }
  .coin { width: 24px; height: 24px; font-size: 13px; }
  .route { font-size: 12px; padding-inline: 7px; left: 6px; top: 6px; }
}

.field[data-reduced-motion="true"][data-state] :is(.piece img, .belt.reverse, .belt, .machine-glow, .pop, .particle) { animation: none; }
.field[data-reduced-motion="true"] .piece.giant::before { animation: none; }
.field[data-reduced-motion="true"] .particle { display: none; }

@media (orientation: landscape) and (max-height: 520px) and (min-width: 600px) {
  .topbar { padding-block: max(3px, env(safe-area-inset-top)) 0; }
  .identity { padding-block: 1px 6px; }
  h1 { font-size: 27px; }
  .cabinet { grid-template-columns: minmax(0, 1fr) 195px; grid-template-areas: "play console"; gap: 10px; }
  .console { display: block; }
  .mission { grid-template-columns: auto minmax(0, 1fr); justify-items: start; gap: 3px 7px; padding: 8px; text-align: left; }
  .mission-icon { width: 43px; height: auto; }
  .mission h2 { font-size: 18px; }
  #mission-description { font-size: 13px; }
  .mission-meter { grid-column: 1 / -1; margin-top: 2px; }
  .meters { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 8px; }
  .meter { padding: 4px 8px; }
  .meter strong { font-size: 23px; }
  #instructions { margin: 7px 3px 0; font-size: 13px; }
  .giant-tip { display: none; }
  .field { height: max(191px, calc(100svh - 145px)); background-size: 100% 100%; }
  .piece { width: clamp(44px, 17cqh, 65px); }
  .piece.giant { width: clamp(62px, 23cqh, 90px); }
  .game-controls { margin-top: 9px; }
  .round-panel { top: 51%; padding-block: 8px; }
  .panel-title { font-size: 23px; }
  #panel-message { margin: 3px 0 5px; font-size: 14px; }
  .round-reward, fieldset { margin-bottom: 5px; }
  .unlock { margin: 0; }
  .unlock img { width: 30px; height: 30px; }
}
