@font-face { font-family: 'Fredoka'; src: url('../assets/fredoka-latin.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
:root {
  --ink: #3b2f5c; --ink-soft: #6b5d8f; --card: #fffaf2; --sun: #ffd35c; --sun-deep: #ffb52e; --mint: #5fd6a4; --mint-deep: #2fb47f;
  --sky: #8fd3ff; --pink: #ff8fc4; --lilac: #b9a7ff; --white: #fff; --shadow: 0 6px 0 rgba(59,47,92,.18), 0 10px 24px rgba(59,47,92,.18);
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd8ff; }
body { font-family: 'Fredoka', 'Nunito', 'Arial Rounded MT Bold', ui-rounded, system-ui, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
[hidden] { display: none !important; }

/* ---------- icons (inline SVG, no network) ---------- */
.i { display: inline-block; width: 1.2em; height: 1.2em; background: center / contain no-repeat; vertical-align: -0.22em; flex: none; }
.i-coin { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23ffc93c' stroke='%23e89a12' stroke-width='2'/%3E%3Cpath d='M12 6.5l1.6 3.4 3.6.4-2.7 2.4.8 3.6L12 14.4l-3.3 1.9.8-3.6-2.7-2.4 3.6-.4z' fill='%23fff3c4'/%3E%3C/svg%3E"); }
.i-play { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5.5c0-1.2 1.3-1.9 2.3-1.3l8.6 5.6c1 .6 1 2 0 2.6l-8.6 5.6c-1 .6-2.3-.1-2.3-1.3z' fill='%23fff'/%3E%3C/svg%3E"); }
.i-pause { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='5' width='4.5' height='14' rx='2' fill='%233b2f5c'/%3E%3Crect x='13.5' y='5' width='4.5' height='14' rx='2' fill='%233b2f5c'/%3E%3C/svg%3E"); }
.i-back { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14.5 5l-7 7 7 7' fill='none' stroke='%233b2f5c' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.i-home { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 11.5L12 4l8 7.5V20a1 1 0 0 1-1 1h-4.5v-5.5h-5V21H5a1 1 0 0 1-1-1z' fill='%233b2f5c'/%3E%3C/svg%3E"); }
.i-retry { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18.5 9A7 7 0 1 0 19 14' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M20 4v5.5h-5.5' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.i-shop { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9h16l-1.6 10.2a2 2 0 0 1-2 1.8H7.6a2 2 0 0 1-2-1.8z' fill='%23ff8fc4'/%3E%3Cpath d='M8 9a4 4 0 0 1 8 0' fill='none' stroke='%233b2f5c' stroke-width='2.4' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='14.5' r='2.4' fill='%23fff'/%3E%3C/svg%3E"); }
.i-hat { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 16c0-6 3.6-10 8-10s8 4 8 10z' fill='%23ffd35c'/%3E%3Cellipse cx='12' cy='16.5' rx='10' ry='3' fill='%23ffb52e'/%3E%3Ccircle cx='12' cy='5.5' r='2' fill='%23ff8fc4'/%3E%3C/svg%3E"); }
.i-trophy { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 4h10v5a5 5 0 0 1-10 0z' fill='%23ffc93c'/%3E%3Cpath d='M7 6H4a3 3 0 0 0 3 4M17 6h3a3 3 0 0 1-3 4' fill='none' stroke='%23ffb52e' stroke-width='2'/%3E%3Crect x='10.5' y='13' width='3' height='4' fill='%23ffb52e'/%3E%3Crect x='7.5' y='17' width='9' height='3' rx='1.4' fill='%235fd6a4'/%3E%3C/svg%3E"); }
.i-gear { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 9.5h3l4-4v13l-4-4H5z' fill='%235fb8ff'/%3E%3Cpath d='M15.5 9a4 4 0 0 1 0 6M18 6.5a7.5 7.5 0 0 1 0 11' fill='none' stroke='%233b2f5c' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.i-sound { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 9.5h3l4-4v13l-4-4H5z' fill='%235fb8ff'/%3E%3Cpath d='M15.5 9a4 4 0 0 1 0 6M18 6.5a7.5 7.5 0 0 1 0 11' fill='none' stroke='%233b2f5c' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.i-music { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 17V6l10-2v11' fill='none' stroke='%233b2f5c' stroke-width='2.2'/%3E%3Cellipse cx='6.5' cy='17.5' rx='3' ry='2.4' fill='%23ff8fc4'/%3E%3Cellipse cx='16.5' cy='15.5' rx='3' ry='2.4' fill='%23ff8fc4'/%3E%3C/svg%3E"); }
.i-pals { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4.5 21c0-5 3.3-8 7.5-8s7.5 3 7.5 8z' fill='%23ffd35c'/%3E%3Ccircle cx='12' cy='9' r='5.5' fill='%23ffd35c'/%3E%3Ccircle cx='12' cy='10' r='3.6' fill='%23ffe8c9'/%3E%3Ccircle cx='10.6' cy='9.6' r='.8' fill='%233b2f5c'/%3E%3Ccircle cx='13.4' cy='9.6' r='.8' fill='%233b2f5c'/%3E%3Cpath d='M10.8 11.6q1.2 1 2.4 0' fill='none' stroke='%233b2f5c' stroke-width='.9' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='4.6' r='1.9' fill='%23ffd35c'/%3E%3Ccircle cx='16' cy='4.6' r='1.9' fill='%23ffd35c'/%3E%3C/svg%3E"); }
.i-bubble { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='9' cy='13' r='6.5' fill='%23c9f0ff' stroke='%2378c8ff' stroke-width='1.6'/%3E%3Ccircle cx='17' cy='7' r='4' fill='%23ffe0f4' stroke='%23ff9fd0' stroke-width='1.4'/%3E%3Cpath d='M6.5 10.5a3.6 3.6 0 0 1 3-2' stroke='%23fff' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); }
.i-sprinkler { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3c3 4.5 5 7.5 5 10a5 5 0 0 1-10 0c0-2.5 2-5.5 5-10z' fill='%235fb8ff'/%3E%3Cpath d='M5 6c1.2 1.8 2 3 2 4a2 2 0 0 1-4 0c0-1 .8-2.2 2-4zM19 6c1.2 1.8 2 3 2 4a2 2 0 0 1-4 0c0-1 .8-2.2 2-4z' fill='%2394d4ff'/%3E%3C/svg%3E"); }
.i-confetti { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 20l4-12 8 8z' fill='%23ffb52e'/%3E%3Crect x='14' y='3' width='3' height='5' rx='1' fill='%23ff8fc4' transform='rotate(25 15 5)'/%3E%3Crect x='18' y='9' width='3' height='5' rx='1' fill='%235fd6a4' transform='rotate(-30 19 11)'/%3E%3Ccircle cx='11' cy='5' r='1.6' fill='%23b9a7ff'/%3E%3Ccircle cx='19' cy='17' r='1.6' fill='%235fb8ff'/%3E%3C/svg%3E"); }
.i-rainbow { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 18a10 10 0 0 1 20 0' fill='none' stroke='%23ff7b9c' stroke-width='2.6'/%3E%3Cpath d='M5 18a7 7 0 0 1 14 0' fill='none' stroke='%23ffd35c' stroke-width='2.6'/%3E%3Cpath d='M8 18a4 4 0 0 1 8 0' fill='none' stroke='%235fd6a4' stroke-width='2.6'/%3E%3C/svg%3E"); }
.i-zoom { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13 2L5 13.5h5.5L9 22l9-12h-6z' fill='%23ffb52e' stroke='%23fff' stroke-width='1' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.i-reach { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 12h15M14 7l5 5-5 5' fill='none' stroke='%235fb8ff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.i-twin { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='8' cy='12' r='5' fill='%23c9f0ff' stroke='%2378c8ff' stroke-width='1.6'/%3E%3Ccircle cx='16' cy='12' r='5' fill='%23c9f0ff' stroke='%2378c8ff' stroke-width='1.6'/%3E%3C/svg%3E"); }
.i-heart { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 20s-7.5-4.6-7.5-10A4.3 4.3 0 0 1 12 7.4 4.3 4.3 0 0 1 19.5 10C19.5 15.4 12 20 12 20z' fill='%23ff6fa8'/%3E%3C/svg%3E"); }
.i-heart-empty { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 20s-7.5-4.6-7.5-10A4.3 4.3 0 0 1 12 7.4 4.3 4.3 0 0 1 19.5 10C19.5 15.4 12 20 12 20z' fill='%23ffffff' fill-opacity='.55' stroke='%23ff9cc3' stroke-width='1.6'/%3E%3C/svg%3E"); }
.boss-face { display: inline-block; width: 34px; height: 26px; flex: none; background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 30'%3E%3Cpath d='M8 26a7 7 0 0 1-1-13.9A9 9 0 0 1 24 7a7 7 0 0 1 9 7 6 6 0 0 1-1 12z' fill='%2394a0b8'/%3E%3Cpath d='M14 15l4 1.6M26 15l-4 1.6' stroke='%233b2f5c' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='17' cy='18.5' r='1.5' fill='%233b2f5c'/%3E%3Ccircle cx='23' cy='18.5' r='1.5' fill='%233b2f5c'/%3E%3Cpath d='M18 23q2-1.5 4 0' fill='none' stroke='%233b2f5c' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E"); }
.boss-face.small { width: 26px; height: 20px; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: none; flex-direction: column; pointer-events: none; padding: calc(10px + var(--safe-top)) 14px calc(14px + var(--safe-bottom)); }
body[data-screen="home"] #screen-home, body[data-screen="play"] #screen-play, body[data-screen="shop"] #screen-shop,
body[data-screen="hats"] #screen-hats, body[data-screen="scores"] #screen-scores, body[data-screen="settings"] #screen-settings { display: flex; }
.screen > * { pointer-events: auto; }
#screen-play > * { pointer-events: none; }
#screen-play #pause-btn { pointer-events: auto; }
.screen.sub { background: linear-gradient(180deg, rgba(255,250,242,.94), rgba(255,244,228,.97)); overflow-y: auto; touch-action: pan-y; align-items: center; }
.screen.sub > * { width: 100%; max-width: 520px; }

.btn { font: inherit; color: var(--ink); border: 0; cursor: pointer; min-width: 48px; min-height: 48px; border-radius: 24px; background: var(--white); box-shadow: var(--shadow); display: inline-flex; align-items: center; justify-content: center; gap: .4em; padding: 0 18px; font-size: 18px; font-weight: 600; transition: transform .12s ease, box-shadow .12s ease, filter .12s; }
.btn:active { transform: translateY(3px) scale(.97); box-shadow: 0 2px 0 rgba(59,47,92,.18); }
.btn:focus-visible { outline: 4px solid #5fb8ff; outline-offset: 3px; }
.btn[disabled] { filter: grayscale(.7) opacity(.6); cursor: default; }
.btn-play { background: linear-gradient(180deg, #7ee6b4, var(--mint-deep)); color: #fff; font-size: 28px; font-weight: 700; min-height: 72px; padding: 0 34px; border-radius: 36px; text-shadow: 0 2px 0 rgba(0,0,0,.15); box-shadow: 0 7px 0 #1f8d61, 0 14px 30px rgba(47,180,127,.4); }
.btn-play .i { width: 1em; height: 1em; }
.btn-round { flex-direction: column; gap: 2px; width: 72px; height: 72px; border-radius: 26px; padding: 0; font-size: 13px; }
.btn-round .i { width: 30px; height: 30px; }
.btn-icon { width: 52px; height: 52px; padding: 0; border-radius: 18px; }
.btn-icon .i { width: 26px; height: 26px; }
.btn-small { min-height: 52px; font-size: 18px; background: #fff; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.92); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 18px; box-shadow: 0 3px 0 rgba(59,47,92,.12); min-height: 40px; }
.pill .i { width: 24px; height: 24px; }

/* Home */
#screen-home { align-items: center; justify-content: space-between; }
.home-top { width: 100%; display: flex; justify-content: flex-end; }
.logo { margin: 2vh 0 0; display: flex; flex-direction: column; align-items: center; line-height: .9; font-weight: 700; letter-spacing: 1px; filter: drop-shadow(0 6px 0 rgba(59,47,92,.2)); pointer-events: none; }
.logo span { font-size: clamp(48px, 15vw, 84px); -webkit-text-stroke: 3px #fff; paint-order: stroke fill; }
.logo-a { color: #5fb8ff; transform: rotate(-4deg); animation: bob 2.6s ease-in-out infinite; }
.logo-b { color: var(--sun-deep); transform: rotate(3deg); animation: bob 2.6s ease-in-out -1.3s infinite; }
@keyframes bob { 50% { translate: 0 -6px; } }
.home-mid { flex: 1; pointer-events: none; }
.home-bottom { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; }
#play-btn { min-width: 240px; font-size: 32px; animation: glow 1.8s ease-in-out infinite; }
#play-btn .i { width: 34px; height: 34px; }
@keyframes glow { 50% { box-shadow: 0 7px 0 #1f8d61, 0 14px 40px rgba(47,180,127,.75), 0 0 0 8px rgba(255,255,255,.35); } }
.home-nav { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* HUD */
#screen-play { padding-top: calc(8px + var(--safe-top)); }
.hud-top { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 560px; margin: 0 auto; }
.hud-top .pill { font-size: 17px; padding: 4px 12px; min-height: 44px; flex: none; }
/* pause stays a 48px touch target but sits level with the 44px pills */
.hud-top .btn-icon { width: 48px; height: 48px; min-height: 48px; border-radius: 16px; flex: none; align-self: center; }
.hud-progress { flex: 1; height: 14px; border-radius: 8px; background: rgba(255,255,255,.6); position: relative; overflow: hidden; box-shadow: inset 0 2px 0 rgba(0,0,0,.08); }
.hud-progress-fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: linear-gradient(90deg, #7ee6b4, #5fb8ff); border-radius: 8px; }
.hud-progress-boss { position: absolute; right: 2px; top: 1px; width: 12px; height: 12px; border-radius: 50%; background: #94a0b8; }
.hud-row2 { display: flex; gap: 8px; width: 100%; max-width: 560px; margin: 8px auto 0; align-items: center; }
.pill-squad { font-size: 22px; }
.pill-squad .i { width: 28px; height: 28px; }
.pill-kind .hearts { display: inline-flex; gap: 1px; }
.pill-kind .hearts .i { width: 18px; height: 18px; }
.pill-kind .helpers { font-size: 15px; color: #ff4f93; }
.i-helper { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4.5 21c0-5 3.3-8 7.5-8s7.5 3 7.5 8z' fill='%23ff9fd0'/%3E%3Ccircle cx='12' cy='9' r='5.5' fill='%23ff9fd0'/%3E%3Ccircle cx='12' cy='10' r='3.6' fill='%23ffe8c9'/%3E%3Ccircle cx='10.6' cy='9.6' r='.8' fill='%233b2f5c'/%3E%3Ccircle cx='13.4' cy='9.6' r='.8' fill='%233b2f5c'/%3E%3Cpath d='M10.8 11.6q1.2 1 2.4 0' fill='none' stroke='%233b2f5c' stroke-width='.9' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='4.6' r='1.9' fill='%23ff9fd0'/%3E%3Ccircle cx='16' cy='4.6' r='1.9' fill='%23ff9fd0'/%3E%3C/svg%3E"); }
.pill-kind .helpers { display: inline-flex; align-items: center; margin-left: 4px; }
.pill-kind .helpers .i { width: 20px; height: 20px; margin-left: -3px; }
.pill-blaster.off { visibility: hidden; }
.pill-blaster { margin-left: auto; }
.pill-blaster .i { width: 28px; height: 28px; }
.hud-boss { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 560px; margin: 10px auto 0; background: rgba(255,255,255,.9); border-radius: 18px; padding: 6px 12px; box-shadow: var(--shadow); }
.boss-bar { flex: 1; height: 16px; background: #e6e2f5; border-radius: 9px; overflow: hidden; }
.boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #94a0b8, #b9c3d8); border-radius: 9px; transition: width .12s linear; }
.boss-num { font-size: 22px; min-width: 3ch; text-align: right; }
.squash { animation: squash .25s ease; }
@keyframes squash { 40% { transform: scale(1.25, .85); } 70% { transform: scale(.92, 1.08); } }

/* Sub screens */
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sub-head h2 { margin: 0; font-size: 30px; }
.sub-note { color: #4f4372; font-size: 16px; text-align: center; margin: 8px 0 14px; }
.list { display: flex; flex-direction: column; gap: 12px; }
.upgrade { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 22px; padding: 12px 14px; box-shadow: 0 4px 0 rgba(59,47,92,.1); }
.upgrade .u-icon { width: 54px; height: 54px; border-radius: 16px; background: #fff4d6; display: grid; place-items: center; flex: none; }
.upgrade .u-icon .i { width: 36px; height: 36px; }
.upgrade .u-text { flex: 1; min-width: 0; }
.upgrade .u-name { font-weight: 700; font-size: 18px; }
.upgrade .u-what { color: #4f4372; font-size: 14px; }
.tiers { display: flex; gap: 4px; margin-top: 4px; }
.tiers i { width: 14px; height: 14px; border-radius: 50%; background: #e8e3f5; }
.tiers i.on { background: var(--mint); }
.upgrade .btn { min-width: 92px; background: linear-gradient(180deg, #ffe07a, var(--sun-deep)); color: var(--ink); font-size: 18px; padding: 0 12px; }
.upgrade .btn .price { color: var(--ink); font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.hat { flex-direction: column; min-height: 150px; border-radius: 24px; padding: 10px; gap: 4px; }
.hat canvas { width: 84px; height: 84px; }
.hat .h-name { font-size: 15px; }
.hat .h-price { font-size: 16px; display: inline-flex; gap: 4px; align-items: center; }
.hat.worn { background: #dcf7ea; outline: 4px solid var(--mint-deep); }
.hat.worn .h-price { background: var(--mint); color: var(--ink); border-radius: 999px; padding: 2px 12px 2px 8px; font-weight: 700; }
.hat.worn .h-price::before { content: ''; width: 18px; height: 18px; flex: none; background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%233b2f5c' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.tabs { display: flex; gap: 10px; margin: 12px 0; }
.tab { flex: 1; }
.tab[aria-selected="true"] { background: linear-gradient(180deg, #8fd3ff, #5fb8ff); color: #fff; }
.my-best { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.score-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.score-list li { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 16px; padding: 8px 14px; font-size: 18px; }
.score-list li .rank { width: 2.2em; font-weight: 700; color: var(--ink-soft); }
.score-list li .nm { flex: 1; }
.score-list li .val { font-weight: 700; }
.score-list li.me { background: #fff4c2; }
.score-list .note { justify-content: center; color: var(--ink-soft); background: transparent; text-align: center; }
.name-pick { margin: 16px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.name-title { font-weight: 700; }
.name-row { display: flex; gap: 8px; width: 100%; justify-content: center; }
select { font: inherit; font-size: 18px; min-height: 52px; border-radius: 16px; border: 3px solid #e8e3f5; padding: 0 12px; background: #fff; color: var(--ink); flex: 1; max-width: 190px; }
.toggle { justify-content: flex-start; gap: 12px; min-height: 64px; font-size: 20px; width: 100%; }
.toggle .i { width: 32px; height: 32px; }
.toggle .switch { margin-left: auto; width: 56px; height: 32px; border-radius: 16px; background: #d9d4ea; position: relative; transition: background .2s; }
.toggle .switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.toggle[aria-pressed="true"] .switch { background: var(--mint); }
.toggle[aria-pressed="true"] .switch::after { left: 28px; }

/* Cards */
.card { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(59,47,92,.28); z-index: 10; padding: 16px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.card-box { position: relative; width: min(92vw, 420px); background: var(--card); border-radius: 32px; padding: 24px 20px 20px; text-align: center; box-shadow: 0 10px 0 rgba(59,47,92,.2), 0 24px 50px rgba(59,47,92,.3); display: flex; flex-direction: column; align-items: center; gap: 12px; animation: pop .35s cubic-bezier(.3,1.6,.5,1); overflow: hidden; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.card-title { margin: 0; font-size: 36px; color: var(--ink); position: relative; }
.card-kicker { font-size: 16px; color: var(--ink-soft); font-weight: 600; }
.card-text { margin: 0; font-size: 19px; color: var(--ink-soft); line-height: 1.3; position: relative; }
.card-box .btn-play { min-width: 220px; position: relative; }
.card-box .btn-small { position: relative; }
#card-level { background: transparent; pointer-events: none; }
#card-level .card-box { pointer-events: auto; }
.win-stats { display: flex; gap: 10px; position: relative; }
.win-stats .pill { font-size: 22px; background: #fff4d6; }
.sun-burst { position: absolute; inset: -40%; background: repeating-conic-gradient(from 0deg, rgba(255,211,92,.32) 0 12deg, transparent 12deg 24deg); animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.meter { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.meter-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 4px 8px; text-align: left; }
.meter-row .meter-label { grid-column: 1; grid-row: 1; display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 16px; }
.meter-row b { grid-column: 2; grid-row: 1; font-size: 26px; line-height: 1; text-align: right; }
.meter-row .meter-bar { grid-column: 1 / -1; grid-row: 2; }
.meter-bar { height: 22px; border-radius: 12px; background: #ece7f8; overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 12px; transition: width .9s cubic-bezier(.2,.9,.3,1); }
.meter-row.you .meter-fill { background: linear-gradient(90deg, #7ee6b4, #2fb47f); }
.meter-row.boss .meter-fill { background: linear-gradient(90deg, #b9c3d8, #8c97b3); }
.stretch-pal { width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle at 50% 60%, #ffe8c9 0 28%, #ffd35c 29% 60%, transparent 61%), radial-gradient(circle at 26% 26%, #ffd35c 0 14%, transparent 15%), radial-gradient(circle at 74% 26%, #ffd35c 0 14%, transparent 15%); animation: stretch 1.6s ease-in-out infinite; }
@keyframes stretch { 50% { transform: scaleY(1.12) translateY(-6px); } }
.update-banner { position: fixed; left: 50%; bottom: calc(14px + var(--safe-bottom)); transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 26px; padding: 8px 8px 8px 18px; box-shadow: var(--shadow); font-weight: 600; white-space: nowrap; }
.update-banner .btn { background: linear-gradient(180deg, #8fd3ff, #5fb8ff); color: #fff; }
body[data-screen="home"] .update-banner { bottom: calc(190px + var(--safe-bottom)); }

@media (max-width: 380px) {
  .hud-top { gap: 6px; }
  .hud-top .pill { font-size: 15px; padding: 3px 9px; gap: 4px; min-height: 40px; }
  .hud-top .pill .i { width: 20px; height: 20px; }
  .pill-kind .hearts .i { width: 15px; height: 15px; }
  .pill-kind .helpers { font-size: 13px; }
}
@media (min-width: 900px) {
  .btn-round { width: 84px; height: 84px; font-size: 14px; }
}
@media (max-height: 700px) {
  .logo span { font-size: clamp(40px, 12vw, 64px); }
  .btn-play { min-height: 64px; }
}
/* ---------- round 2 ---------- */
/* A quick first tap while the level is still being prepared: the Play button breathes */
body.level-wait #play-btn, body.level-wait #next-btn, body.level-wait #retry-btn { animation: wait-pulse .6s ease-in-out infinite alternate; }
@keyframes wait-pulse { to { transform: scale(.95); filter: brightness(1.08); } }
/* Shop: a picture of the next run fills the space under the upgrades */
.shop-preview { margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; background: rgba(255,255,255,.9); border-radius: 26px; padding: 16px 14px 18px; box-shadow: var(--shadow); }
.sp-title { font-weight: 700; font-size: 20px; color: var(--ink); }
.sp-pals { display: flex; justify-content: center; align-items: flex-end; min-height: 92px; }
.sp-pals canvas { width: 64px; height: 84px; margin: 0 -8px; }
.sp-pals canvas:nth-child(even) { transform: translateY(-6px); }
.sp-chips { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.sp-chip { display: flex; align-items: center; gap: 6px; background: #fff4d6; border-radius: 18px; padding: 8px 14px; font-size: 20px; }
.sp-chip .i { width: 26px; height: 26px; }
/* Home: the attract parade runs through the middle; wide screens get how-to-play and bests at the sides */
.home-mid { position: relative; width: 100%; max-width: 1180px; display: flex; justify-content: space-between; align-items: center; }
.home-side { display: none; flex-direction: column; gap: 12px; pointer-events: none; }
.how-step, .best-card { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.92); border-radius: 22px; padding: 10px 18px 10px 12px; box-shadow: var(--shadow); font-weight: 700; font-size: 19px; }
.how-pic { width: 54px; height: 54px; flex: none; border-radius: 16px; background: #eaf7ff center / 70% no-repeat; }
.pic-drag { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 58'%3E%3Cpath d='M17 7a4.5 4.5 0 0 1 9 0v19l1.5-.8a4.3 4.3 0 0 1 5 1.3 4.3 4.3 0 0 1 5.5 1.4 4.3 4.3 0 0 1 5 3.6V44c0 7.5-5.6 12-12.5 12h-4.5c-5 0-8.6-2.2-11.4-6.2L6.4 37.5a4.6 4.6 0 0 1 7-5.8L17 35.5z' fill='%23fff' stroke='%233b2f5c' stroke-width='3.2' stroke-linejoin='round'/%3E%3Cpath d='M26 27v8M32.5 28.5v7M38 31v5' stroke='%23c9bfe6' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E"); background-size: 52%; }
.pic-hoop { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Crect x='5' y='6' width='38' height='36' rx='9' fill='%23c9f5e3' stroke='%232fd39a' stroke-width='4'/%3E%3Cpath d='M24 15v18M15 24h18' stroke='%231f8d61' stroke-width='5' stroke-linecap='round'/%3E%3Ccircle cx='10' cy='40' r='4' fill='%23c9f0ff' stroke='%2378c8ff' stroke-width='1.6'/%3E%3C/svg%3E"); background-color: #e7fbf2; }
.pic-cloud { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 40'%3E%3Cpath d='M10 34a8.5 8.5 0 0 1-1.2-16.9A11 11 0 0 1 29.5 10a8.5 8.5 0 0 1 11 8.5A7.6 7.6 0 0 1 39 34z' fill='%23ffd9ec' stroke='%23ff8fc4' stroke-width='2.4'/%3E%3Ccircle cx='19' cy='22' r='2' fill='%233b2f5c'/%3E%3Ccircle cx='29' cy='22' r='2' fill='%233b2f5c'/%3E%3Cpath d='M19.5 27q4.5 4 9 0' fill='none' stroke='%233b2f5c' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E"); background-color: #fff0f7; }
.best-card { flex-direction: column; align-items: flex-start; gap: 0; min-width: 190px; }
.best-card .i { width: 30px; height: 30px; }
.best-card .best-lbl { font-size: 15px; color: var(--ink-soft); }
.best-card b { font-size: 36px; line-height: 1.05; }
@media (min-width: 900px) and (min-aspect-ratio: 4/3) { .home-side { display: flex; } }

/* Level 1-2: an animated hand shows how to steer until the first drag */
.hint-drag { position: fixed; left: 50%; bottom: calc(27vh + var(--safe-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; z-index: 5; pointer-events: none; filter: drop-shadow(0 4px 0 rgba(59,47,92,.25)); }
.hint-hand { width: 64px; height: 76px; background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 58'%3E%3Cpath d='M17 7a4.5 4.5 0 0 1 9 0v19l1.5-.8a4.3 4.3 0 0 1 5 1.3 4.3 4.3 0 0 1 5.5 1.4 4.3 4.3 0 0 1 5 3.6V44c0 7.5-5.6 12-12.5 12h-4.5c-5 0-8.6-2.2-11.4-6.2L6.4 37.5a4.6 4.6 0 0 1 7-5.8L17 35.5z' fill='%23fff' stroke='%233b2f5c' stroke-width='3.2' stroke-linejoin='round'/%3E%3Cpath d='M26 27v8M32.5 28.5v7M38 31v5' stroke='%23c9bfe6' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E"); animation: hint-slide 1.6s ease-in-out infinite; }
.hint-arrow { width: 44px; height: 44px; border-radius: 50%; background: rgba(95,184,255,.92) center / 62% no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15 5l-7 7 7 7' fill='none' stroke='%23fff' stroke-width='4.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); animation: hint-blink 1.6s ease-in-out infinite; }
.hint-arrow.r { transform: scaleX(-1); animation-delay: -.8s; }
@keyframes hint-slide { 0%, 100% { translate: -38px 0; rotate: -10deg; } 50% { translate: 38px 0; rotate: 10deg; } }
@keyframes hint-blink { 0%, 100% { opacity: .35; } 25% { opacity: 1; } }

/* Squad check: an opaque card over a calm, dimmed pause; a pals-vs-cloud tug meter instead of numbers */
.card.card-solid { background: rgba(59,47,92,.5); animation: fade .15s ease; }
.card-solid .card-box { animation: pop-in .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop-in { from { transform: scale(.7); } }
.tug { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.tug-side { display: flex; align-items: center; justify-content: center; min-width: 64px; height: 56px; border-radius: 18px; }
.tug-side.you { background: #dcf7ea; padding: 0 8px; }
.tug-side.boss { background: #eceff6; }
.tug-side.boss .boss-face { width: 52px; height: 40px; }
.tug-pal { width: 26px; height: 32px; margin: 0 -4px; background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4.5 21c0-5 3.3-8 7.5-8s7.5 3 7.5 8z' fill='%23ffd35c'/%3E%3Ccircle cx='12' cy='9' r='5.5' fill='%23ffd35c'/%3E%3Ccircle cx='12' cy='10' r='3.6' fill='%23ffe8c9'/%3E%3Ccircle cx='10.6' cy='9.6' r='.8' fill='%233b2f5c'/%3E%3Ccircle cx='13.4' cy='9.6' r='.8' fill='%233b2f5c'/%3E%3Cpath d='M10.8 11.6q1.2 1 2.4 0' fill='none' stroke='%233b2f5c' stroke-width='.9' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='4.6' r='1.9' fill='%23ffd35c'/%3E%3Ccircle cx='16' cy='4.6' r='1.9' fill='%23ffd35c'/%3E%3C/svg%3E"); }
.tug-pal:nth-child(2) { transform: translateY(-5px) scale(1.15); position: relative; z-index: 1; }
.tug-bar { position: relative; height: 34px; border-radius: 18px; background: linear-gradient(90deg, #c3cad9, #94a0b8); overflow: hidden; box-shadow: inset 0 3px 0 rgba(0,0,0,.08); }
.tug-fill { position: absolute; inset: 0 auto 0 0; width: 50%; background: linear-gradient(90deg, #7ee6b4, #2fb47f); border-radius: 18px 0 0 18px; transition: width 1s cubic-bezier(.2,1.3,.4,1); }
.tug[data-state="measuring"] .tug-fill { animation: tug-wobble .45s ease-in-out infinite alternate; transition: none; }
@keyframes tug-wobble { from { width: 40%; } to { width: 60%; } }
.tug-sun { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; transform: translate(-50%, -50%); background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='6.5' fill='%23ffd35c' stroke='%23fff' stroke-width='2'/%3E%3Cg stroke='%23ffb52e' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M12 1.5v2.5M12 20v2.5M1.5 12h2.5M20 12h2.5M4.6 4.6l1.8 1.8M17.6 17.6l1.8 1.8M4.6 19.4l1.8-1.8M17.6 6.4l1.8-1.8'/%3E%3C/g%3E%3C/svg%3E"); }
.verdict { font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--ink); }
#card-check[data-win="true"] .verdict { color: var(--mint-deep); }
#card-check[data-win="false"] .verdict { color: #e0607e; }

/* Losing is a soft moment: the scene dims slowly and the card floats up */
.card.card-soft { background: rgba(143,211,255,.42); animation: fade .7s ease; }
.card-soft .card-box { animation: float-up .55s cubic-bezier(.2,1.2,.4,1) .15s backwards; }
@keyframes float-up { from { transform: translateY(60px) scale(.9); opacity: 0; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
