/* Ballzooka — the look of an ad game, minus the ad: fat type, candy colours,
   buttons that bounce. The field is a canvas; everything here sits on it. */
:root {
  --bg: #1a1238; --ink: #fff; --dim: #c9c2ea; --line: rgba(255,255,255,.14);
  --card: rgba(30,22,66,.92); --card2: rgba(44,32,92,.96);
  --pri: #ffd23f; --pri-ink: #2a1a00; --pink: #ff5d8f; --good: #2fd67a; --bad: #ff4d5e; --blue: #3fa9ff;
  --safeT: env(safe-area-inset-top, 0px); --safeB: env(safe-area-inset-bottom, 0px);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.35 var(--font); overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#overlay { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: var(--pri); }
.ico { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.noscript { position: fixed; inset: 40% 0 auto; text-align: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 16px; background: var(--card2); border: 2px solid var(--line); font-weight: 800; letter-spacing: .02em; box-shadow: 0 4px 0 rgba(0,0,0,.35); transition: transform .08s; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.btn:disabled { opacity: .5; cursor: default; }
.btn small { font-weight: 600; opacity: .8; font-size: 12px; display: block; }
.btn span { display: inline-flex; align-items: center; gap: 4px; flex-direction: column; }
.btn.primary { background: linear-gradient(#ffe36a, #ffb800); color: var(--pri-ink); border-color: #fff3b0; box-shadow: 0 5px 0 #b36b00; }
.btn.danger { background: #5a1a2a; border-color: #ff6b7a; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 12px; }
.btn.small .ico { width: 16px; height: 16px; }
.btn.small span { flex-direction: row; }
.btn.big { padding: 16px 26px; font-size: 22px; font-weight: 900; border-radius: 22px; }
.btn.big .ico { width: 26px; height: 26px; }
.btn.pulse { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }
.ibtn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 14px; background: var(--card); border: 2px solid var(--line); }
.ibtn.small { width: 30px; height: 30px; border-radius: 10px; }
.ibtn.off { opacity: .45; }
.info { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: var(--dim); vertical-align: middle; }
.info .ico { width: 18px; height: 18px; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 8px; font-weight: 900; white-space: nowrap; }
.chip.coin .ico { color: var(--pri); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; margin: 0 auto; max-width: 480px; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: none; }
#hud button { pointer-events: auto; }
.hud-top { position: absolute; top: calc(8px + var(--safeT)); left: 8px; right: 8px; display: flex; align-items: center; gap: 8px; }
.lvl { flex: 1; text-align: center; font-weight: 900; font-size: 14px; letter-spacing: .08em; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
.prog { position: relative; height: 10px; margin: 4px auto 0; max-width: 260px; background: rgba(0,0,0,.45); border-radius: 6px; border: 2px solid var(--line); overflow: visible; }
.prog > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--good), #9cff6b); border-radius: 4px; transition: width .2s; }
.prog .skull { display: none; position: absolute; right: -12px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border-radius: 50%; background: var(--bad); place-items: center; border: 2px solid #fff; }
.prog .skull .ico { width: 14px; height: 14px; }
.prog.boss .skull { display: grid; }
.hud-row { position: absolute; top: calc(58px + var(--safeT)); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: center; }
#hearts { display: flex; gap: 2px; }
#hearts span .ico { width: 22px; height: 22px; filter: drop-shadow(0 2px 0 rgba(0,0,0,.5)); }
#hearts .on { color: #ff3d5e; } #hearts .on .ico { fill: #ff3d5e; }
#hearts .off { color: rgba(255,255,255,.3); }
#scoreTxt { font-weight: 900; font-size: 18px; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
#buffs { position: absolute; top: calc(86px + var(--safeT)); left: 10px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.buff { font-size: 11px; font-weight: 900; padding: 2px 8px; border-radius: 999px; background: var(--c); color: #1a1238; }
.hud-bot { position: absolute; bottom: calc(6px + var(--safeB)); left: 8px; right: 8px; display: flex; align-items: flex-end; gap: 10px; }
.balls { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; text-shadow: 0 2px 0 rgba(0,0,0,.6); }
.balls b { font-size: 26px; font-weight: 900; }
.balls small { font-size: 11px; font-weight: 800; opacity: .8; letter-spacing: .1em; text-transform: uppercase; }
.meters { flex: 1; display: flex; flex-direction: column; gap: 4px; max-width: 220px; margin-left: auto; }
.fever { position: relative; height: 14px; border-radius: 8px; background: rgba(0,0,0,.45); border: 2px solid var(--line); overflow: hidden; }
.fever i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #ff5df0, #ffd23f); transition: width .15s; }
.fever span { position: relative; display: block; text-align: center; font-size: 9px; font-weight: 900; letter-spacing: .2em; line-height: 10px; }
#hud.fever .fever i { animation: rainbow .5s linear infinite; }
@keyframes rainbow { to { filter: hue-rotate(360deg); } }
.xp { height: 5px; border-radius: 3px; background: rgba(0,0,0,.45); overflow: hidden; }
.xp i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .15s; }

/* ---------- screens ---------- */
#screen { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: calc(10px + var(--safeT)) 12px calc(10px + var(--safeB)); overflow-y: auto; }
#screen.s-title { background: radial-gradient(ellipse at 50% 30%, rgba(26,18,56,.15), rgba(26,18,56,.7)); }
#screen.s-shop, #screen.s-skins, #screen.s-trophies, #screen.s-settings { background: rgba(14,9,32,.88); align-items: flex-start; }
#screen.s-draft, #screen.s-pause, #screen.s-won, #screen.s-lost { background: rgba(14,9,32,.72); }

.title { width: min(440px, 100%); min-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.topbar { width: 100%; display: flex; align-items: center; }
.grow { flex: 1; }
.ad-ribbon { background: var(--bad); color: #fff; font-weight: 900; font-size: 12px; letter-spacing: .08em; padding: 5px 14px; border-radius: 6px; transform: rotate(-3deg); box-shadow: 0 3px 0 #8a1020; animation: wiggle 2.4s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(2deg) scale(1.05); } }
.logo { margin: 14px 0 0; line-height: .82; font-weight: 900; font-style: italic; letter-spacing: -.02em; }
.logo span { display: block; text-shadow: 0 5px 0 #b3006b, 0 10px 18px rgba(0,0,0,.4); }
.logo .l1 { font-size: 72px; color: #fff; animation: bob 2s ease-in-out infinite; }
.logo .l2 { font-size: 62px; background: linear-gradient(#ffe36a, #ff8a00); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; filter: drop-shadow(0 5px 0 #b3006b); animation: bob 2s ease-in-out .25s infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-1deg); } }
.tag { margin: 0; color: var(--dim); font-weight: 700; }
.playwrap { margin-top: auto; }
.modes { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.modes .btn { min-width: 132px; }
.dock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.dock .btn { flex-direction: column; padding: 10px 4px; font-size: 12px; border-radius: 14px; }
.dock .btn .ico { width: 24px; height: 24px; }
.noads { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 12px; margin: 0; }
.noads .ico { color: var(--good); width: 16px; height: 16px; }

.panel { width: min(520px, 100%); padding-bottom: 20px; }
.head { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; padding: 4px 0 8px; background: linear-gradient(rgba(14,9,32,.98) 70%, rgba(14,9,32,0)); z-index: 1; }
.head h2 { flex: 1; margin: 0; font-size: 24px; font-weight: 900; font-style: italic; }
.panel h3 { margin: 18px 0 8px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.sub { color: var(--dim); margin: 2px 0 10px; }
.sub.small { font-size: 12px; margin: 0; }
.list { display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 2px solid var(--line); border-radius: 16px; }
.item.dim { opacity: .5; }
.item .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.08); color: var(--pri); flex: none; }
.item .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item .txt small { color: var(--dim); }
.item .txt b small { color: var(--pri); font-weight: 800; }
.maxed { color: var(--good); }
.stats { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.stats span { display: flex; flex-direction: column; align-items: center; min-width: 88px; padding: 8px 10px; background: var(--card); border-radius: 14px; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.stats b { font-size: 20px; color: #fff; letter-spacing: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.skin { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; background: var(--card); border: 2px solid var(--line); border-radius: 16px; }
.skin.on { border-color: var(--pri); box-shadow: 0 0 0 2px var(--pri) inset; }
.skin[data-poor] { opacity: .55; }
.skin small { display: inline-flex; align-items: center; gap: 3px; color: var(--dim); font-size: 11px; font-weight: 700; }
.skin small .ico { width: 13px; height: 13px; }
.sw { width: 44px; height: 30px; border-radius: 10px; border: 4px solid; display: block; }
.sw.ball { width: 26px; height: 26px; border-radius: 50%; border: 0; margin: 2px 0; }
.switch { width: 50px; height: 30px; border-radius: 15px; background: rgba(255,255,255,.15); position: relative; flex: none; transition: background .15s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--good); }
.switch.on i { transform: translateX(20px); }

/* ---------- modals ---------- */
.modal { width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 18px 14px; background: var(--card); border: 2px solid var(--line); border-radius: 26px; animation: popin .3s cubic-bezier(.3,1.6,.6,1); }
@keyframes popin { from { transform: scale(.6); opacity: 0; } }
.modal h2 { margin: 0; font-size: 32px; font-weight: 900; font-style: italic; line-height: 1; }
.modal h2.win { color: var(--pri); text-shadow: 0 4px 0 #b36b00; }
.modal h2.lose { color: var(--bad); text-shadow: 0 4px 0 #6b0010; }
.col { display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: stretch; }
.row { display: flex; gap: 8px; align-items: center; }
.perks { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.perk { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; background: rgba(255,255,255,.08); border-radius: 999px; padding: 3px 9px 3px 5px; }
.perk .ico { width: 15px; height: 15px; color: var(--pri); }
.stars { display: flex; gap: 6px; }
.star .ico { width: 54px; height: 54px; color: rgba(255,255,255,.2); fill: rgba(255,255,255,.12); }
.star.on .ico { color: #fff3b0; fill: var(--pri); filter: drop-shadow(0 3px 0 #b36b00); animation: starpop .5s cubic-bezier(.3,1.8,.6,1) both; animation-delay: calc(var(--i) * .25s + .2s); }
@keyframes starpop { from { transform: scale(0) rotate(-90deg); } }
.earn { display: flex; align-items: center; gap: 6px; font-size: 34px; font-weight: 900; color: var(--pri); text-shadow: 0 3px 0 rgba(0,0,0,.4); }
.earn .ico { width: 34px; height: 34px; }
.score { display: flex; flex-direction: column; }
.score b { font-size: 40px; font-weight: 900; }
.score small { color: var(--pri); font-weight: 800; }
.wheel { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; border-radius: 14px; overflow: hidden; border: 3px solid #fff; }
.wheel span { padding: 10px 0; font-weight: 900; font-size: 18px; background: #3f2f8a; }
.wheel span:nth-child(2), .wheel span:nth-child(4) { background: #6a3fd0; }
.wheel span.hot { background: var(--pink); }
.wheel i { position: absolute; top: -2px; bottom: -2px; width: 6px; margin-left: -3px; left: 0; background: #fff; box-shadow: 0 0 10px #fff; border-radius: 3px; }

.draft { width: min(560px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.draft h2 { margin: 0; font-size: 38px; font-weight: 900; font-style: italic; color: var(--pri); text-shadow: 0 4px 0 #b36b00; animation: popin .35s cubic-bezier(.3,1.6,.6,1); }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; background: linear-gradient(#3a2a80, #251a58); border: 3px solid #8f7bff; border-radius: 20px; box-shadow: 0 5px 0 #120a30; animation: deal .4s cubic-bezier(.3,1.5,.6,1) both; animation-delay: calc(var(--i) * .08s); }
.card:active { transform: translateY(3px); }
@keyframes deal { from { transform: translateY(40px) scale(.7) rotate(-6deg); opacity: 0; } }
.card .ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: rgba(255,255,255,.1); color: var(--pri); }
.card .ic .ico { width: 30px; height: 30px; }
.card b { font-size: 15px; font-weight: 900; }
.card small { color: var(--dim); font-size: 12px; }
.pips { display: flex; gap: 3px; margin-top: auto; }
.pips i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.18); }
.pips i.on { background: var(--pri); }
.pips i.new { background: var(--good); box-shadow: 0 0 6px var(--good); }
@media (max-width: 380px) { .cards { grid-template-columns: 1fr; } .card { flex-direction: row; text-align: left; } .card .pips { margin: 0 0 0 auto; } }

/* ---------- toast, info sheet, update bar ---------- */
#toast { position: fixed; left: 50%; top: calc(96px + var(--safeT)); pointer-events: none; transform: translateX(-50%); z-index: 30; background: var(--card2); border: 2px solid var(--pri); border-radius: 999px; padding: 8px 16px; font-weight: 700; max-width: calc(100vw - 24px); text-align: center; }
#toast.in { animation: toastin .35s cubic-bezier(.3,1.6,.6,1); }
@keyframes toastin { from { transform: translate(-50%, -20px) scale(.8); opacity: 0; } }
#info-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
#info-sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(560px, 100vw); max-height: 78vh; overflow-y: auto; background: #241a52; border: 2px solid var(--line); border-radius: 22px 22px 0 0; padding: 4px 18px calc(18px + var(--safeB)); z-index: 41; user-select: text; -webkit-user-select: text; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #241a52; padding: 12px 0 4px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 900; }
#info-body p, #info-body li { color: #e4def8; line-height: 1.5; }
#info-body ul { padding-left: 18px; }
#info-body b { color: var(--pri); }
#update-bar { position: fixed; top: calc(8px + var(--safeT)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: var(--card2); border: 2px solid var(--blue); border-radius: 999px; padding: 6px 8px 6px 14px; z-index: 50; font-size: 13px; font-weight: 700; max-width: calc(100vw - 16px); }

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