 @font-face { font-family: Fredoka; font-style: normal; font-weight: 400 700; font-display: swap; src: url(../fonts/fredoka-latin.woff2) format('woff2'); }
:root {
  --f: Fredoka, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  --cream: #fff4dc;
  --brown: #5a3a1e;
  --brown-d: #3a2410;
  --orange: #f08a2b;
  --orange-d: #b9591a;
  --red: #d94a3a;
  --red-d: #8f2a20;
  --green: #6aa84f;
  --green-d: #3f6b2a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #4a7a3a; overscroll-behavior: none; }
body { font-family: var(--f); color: var(--brown); touch-action: none; position: fixed; inset: 0; width: 100%; }
#app { position: fixed; inset: 0; height: 100dvh; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  font: 700 22px/1 var(--f); color: #fff; background: var(--c, var(--orange));
  border: 0; border-radius: 22px; padding: 16px 28px; cursor: pointer;
  box-shadow: 0 6px 0 var(--cd, var(--orange-d)), 0 12px 18px rgba(60, 30, 5, .25);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .18); transition: transform .08s, box-shadow .08s, filter .15s;
  position: relative; top: 0;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--cd, var(--orange-d)), 0 4px 8px rgba(60, 30, 5, .25); }
.btn.big { font-size: 30px; padding: 18px 56px; border-radius: 28px; }
.btn.small { font-size: 17px; padding: 12px 16px; border-radius: 16px; }
.btn.alt { --c: var(--green); --cd: var(--green-d); }
.btn.danger { --c: var(--red); --cd: var(--red-d); }
.btn[disabled], .btn.off { filter: grayscale(.85) brightness(.9); opacity: .75; }
.roundbtn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; font: 700 22px var(--f); color: var(--brown);
  background: var(--cream); box-shadow: 0 4px 0 #d8b98a, 0 6px 10px rgba(0, 0, 0, .2); cursor: pointer; padding: 0;
  display: grid; place-items: center; pointer-events: auto;
}
.roundbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d8b98a; }
.pill {
  background: var(--cream); border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 20px;
  display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 4px 0 #d8b98a, 0 6px 10px rgba(0, 0, 0, .2); white-space: nowrap;
}
.pill i { font-style: normal; color: #3d8f2a; font-size: 15px; }
.pill.bump { animation: bump .3s; }
@keyframes bump { 50% { transform: scale(1.18); } }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.hud-top {
  position: absolute; top: calc(var(--safe-t) + 10px); left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 10px);
  display: flex; align-items: center; gap: 10px;
}
.prog { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--cream); border-radius: 999px; padding: 6px 12px; box-shadow: 0 4px 0 #d8b98a, 0 6px 10px rgba(0, 0, 0, .2); font-weight: 700; font-size: 14px; }
.bar { flex: 1; height: 14px; background: #ecd7ae; border-radius: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; background: linear-gradient(#ffb04d, #e8742a); border-radius: 9px; transition: width .25s; }
.combo { position: absolute; top: calc(var(--safe-t) + 70px); left: calc(var(--safe-l) + 14px); font-weight: 700; font-size: 22px; color: #fff; text-shadow: 0 2px 0 rgba(70, 35, 10, .8), 0 0 8px rgba(70, 35, 10, .5); opacity: 0; transition: opacity .2s; }
.combo.on { opacity: 1; }
.combo.pop { animation: bump .25s; }
.gust { position: absolute; top: calc(var(--safe-t) + 70px); right: calc(var(--safe-r) + 14px); background: #dff3ff; color: #2a6a9a; font-weight: 700; padding: 6px 12px; border-radius: 999px; box-shadow: 0 4px 0 #9cc9e6; animation: wob .5s infinite alternate; }
#gustArrow { display: inline-block; }
@keyframes wob { to { transform: translateX(3px) rotate(2deg); } }
.hint { position: absolute; left: 20px; right: 20px; bottom: calc(var(--safe-b) + 210px); text-align: center; color: #fff; font-weight: 600; font-size: 17px; text-shadow: 0 2px 0 rgba(70, 35, 10, .8), 0 0 10px rgba(70, 35, 10, .6); opacity: 0; transition: opacity .5s; }
.hint.on { opacity: 1; }

/* ---------- controls ---------- */
#controls { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#stickzone { position: absolute; left: 0; bottom: 0; width: 56%; top: 90px; pointer-events: auto; touch-action: none; }
#blowzone { position: absolute; right: 0; bottom: 0; width: 44%; top: 90px; pointer-events: auto; touch-action: none; }
#stick { position: absolute; width: 116px; height: 116px; margin: -58px 0 0 -58px; border-radius: 50%; background: rgba(255, 255, 255, .22); border: 3px solid rgba(255, 255, 255, .55); opacity: 0; transition: opacity .15s; pointer-events: none; }
#stick.on { opacity: 1; }
#knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 4px 0 rgba(0, 0, 0, .18); }
#stick.idle { opacity: .45; }
#blow {
  position: absolute; right: calc(var(--safe-r) + 22px); bottom: calc(var(--safe-b) + 34px);
  width: 118px; height: 118px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  --fuel: 100%; --ring: #ffe27a;
  background: conic-gradient(var(--ring) var(--fuel), rgba(0, 0, 0, .25) 0);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .25), 0 10px 16px rgba(0, 0, 0, .25);
  display: grid; place-items: center; transition: transform .08s; pointer-events: none;
}
#blow::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffb04d, var(--orange) 55%, var(--orange-d)); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .18); }
#blow .bi, #blow small { position: relative; z-index: 1; font-family: var(--f); }
#blow .bi { font-size: 38px; margin-top: -4px; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .2)); }
#blow small { font-weight: 700; font-size: 14px; letter-spacing: 1px; color: #fff; margin-top: -26px; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
#blow.down { transform: scale(.9); }
#blow.hot { --ring: #ff5a4a; animation: shk .25s infinite; }
#blow.hot::before { filter: grayscale(.8) brightness(.8); }
@keyframes shk { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; z-index: 10; padding: calc(var(--safe-t) + 10px) calc(var(--safe-l) + 14px) calc(var(--safe-b) + 14px) calc(var(--safe-r) + 14px); }
.screen.on { display: flex; animation: scrin .3s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes scrin { from { opacity: 0; transform: scale(.96); } }
#home { background: linear-gradient(#ffd9a0 0%, #ffb867 55%, #f08a2b 100%); }
#levels, #shop, #awards, #settings { background: linear-gradient(#ffe7bd, #ffc27a); }
.screen.overlay { background: rgba(50, 25, 5, .55); align-items: center; justify-content: center; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 20; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0 10px; position: relative; z-index: 2; }
.topbar.right { justify-content: flex-end; }
.topbar h2 { margin: 0; font-size: 28px; color: var(--brown-d); flex: 1; text-align: center; }

/* home */
.home-inner { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; position: relative; z-index: 2; min-height: 0; }
.logo { margin: 0; font-size: clamp(64px, 20vw, 104px); line-height: 1; letter-spacing: 2px; display: flex; }
.logo span { display: inline-block; color: #fff; -webkit-text-stroke: 7px var(--brown-d); paint-order: stroke fill; text-shadow: 0 8px 0 var(--brown-d); animation: logo 2.2s ease-in-out infinite; }
.logo span:nth-child(1) { color: #ffd34d; } .logo span:nth-child(2) { color: #ff9b3d; animation-delay: .1s; }
.logo span:nth-child(3) { color: #f06a3a; animation-delay: .2s; } .logo span:nth-child(4) { color: #e8493a; animation-delay: .3s; }
.logo span:nth-child(5) { color: #ffd34d; animation-delay: .4s; } .logo span:nth-child(6) { color: #ff9b3d; animation-delay: .5s; }
@keyframes logo { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-9px) rotate(2deg); } }
.tag { margin: -4px 0 0; font-weight: 600; font-size: 20px; color: var(--brown-d); text-align: center; }
#homePrev { width: min(78vw, 340px); height: auto; max-height: 34vh; object-fit: contain; }
.falling { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.falling i { position: absolute; top: -40px; border-radius: 0 100% 0 100%; opacity: .9; animation: fall linear infinite; box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .15); }
@keyframes fall { 0% { transform: translate3d(0, -40px, 0) rotate(0); } 50% { transform: translate3d(40px, 50vh, 0) rotate(260deg); } 100% { transform: translate3d(-20px, 110vh, 0) rotate(540deg); } }

/* lists */
.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 20px; }
.card-row {
  display: flex; align-items: center; gap: 12px; background: var(--cream); border-radius: 22px; padding: 12px 14px;
  box-shadow: 0 5px 0 #d8b98a, 0 8px 12px rgba(80, 40, 5, .18); cursor: pointer; animation: rowin .4s both; flex-shrink: 0;
}
.card-row:active { transform: translateY(3px); box-shadow: 0 2px 0 #d8b98a; }
.card-row.locked { filter: grayscale(.9); opacity: .6; cursor: default; }
@keyframes rowin { from { opacity: 0; transform: translateY(14px); } }
.badge { width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(#ffb04d, var(--orange)); display: grid; place-items: center; font-size: 30px; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15); flex-shrink: 0; }
.card-row .meta { flex: 1; min-width: 0; }
.card-row .meta b { display: block; font-size: 20px; color: var(--brown-d); }
.card-row .meta small { font-size: 14px; opacity: .8; font-weight: 600; }
.mini-stars { font-size: 20px; letter-spacing: 1px; color: #e0cfa6; white-space: nowrap; }
.mini-stars .f { color: #f5b50c; text-shadow: 0 1px 0 #a8730c; }
.flames { color: #d94a3a; font-size: 13px; letter-spacing: 1px; }

/* shop */
#shopPrev { width: 100%; max-height: 22vh; object-fit: contain; margin-bottom: 6px; }
.pips { display: flex; gap: 4px; margin: 4px 0 2px; }
.pips i { width: 20px; height: 8px; border-radius: 5px; background: #e0cfa6; }
.pips i.on { background: linear-gradient(#8cd65c, var(--green)); }
.buy { min-width: 92px; font-size: 18px; padding: 12px 12px; }
.buy.shake { animation: shk .3s; }
.tier { font-weight: 700; color: var(--orange-d); font-size: 15px; }

/* cards */
.card { background: var(--cream); border-radius: 30px; padding: 22px 20px; width: min(92vw, 380px); text-align: center; box-shadow: 0 8px 0 #d8b98a, 0 20px 40px rgba(0, 0, 0, .35); animation: scrin .4s cubic-bezier(.2, 1.5, .4, 1); display: flex; flex-direction: column; gap: 12px; align-items: center; max-height: 100%; overflow: auto; }
.card h2 { margin: 0; font-size: 34px; color: var(--brown-d); }
.card .sub { margin: -6px 0 4px; font-weight: 600; }
.stars { font-size: 60px; display: flex; gap: 6px; line-height: 1; }
.stars i { font-style: normal; color: #e0cfa6; transform: scale(.4); opacity: 0; }
.stars i.on { color: #f5b50c; text-shadow: 0 4px 0 #a8730c; animation: starin .55s cubic-bezier(.2, 1.8, .4, 1) forwards; }
.stars i.off { animation: starin .4s forwards; }
@keyframes starin { to { transform: scale(1); opacity: 1; } }
.rows { width: 100%; display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 18px; }
.rows div { display: flex; justify-content: space-between; animation: rowin .4s both; }
.total { display: flex; width: 100%; justify-content: space-between; align-items: center; font-size: 22px; font-weight: 700; border-top: 3px dashed #e0cfa6; padding-top: 10px; }
.total b { font-size: 34px; color: #3d8f2a; }
.unlock { margin: 0; color: var(--red); font-weight: 700; min-height: 1.2em; }
.row2 { display: flex; gap: 8px; width: 100%; justify-content: center; }
.leavebox { border-top: 3px dashed #e0cfa6; padding-top: 12px; width: 100%; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.leavebox p { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.35; }
.leavebox b.neg { color: var(--red); }

#toast { position: absolute; left: 50%; top: calc(var(--safe-t) + 80px); transform: translate(-50%, -20px); background: var(--brown-d); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: all .3s; z-index: 50; white-space: nowrap; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) and (min-height: 600px) {
  .screen:not(.overlay) { align-items: center; }
  .list, .topbar, #shopPrev { width: min(100%, 520px); }
}

/* strafe aim ring (touch) */
#aim { position: absolute; width: 96px; height: 96px; margin: -48px 0 0 -48px; border-radius: 50%; background: rgba(255, 190, 90, .2); border: 3px solid rgba(255, 210, 120, .7); opacity: 0; transition: opacity .15s; pointer-events: none; }
#aim.on { opacity: 1; }
#aimdot { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: rgba(255, 226, 122, .95); box-shadow: 0 3px 0 rgba(0, 0, 0, .18); }
button.pill { border: 0; font-family: var(--f); color: var(--brown); cursor: pointer; font-size: 15px; }
button.pill:active { transform: translateY(3px); }
.topbar.right { flex-wrap: wrap; }

/* ---------- v2 additions ---------- */
.btn.blue { --c: #3f7cac; --cd: #25506f; }
.cashpill.neg b, .pill.neg b { color: var(--red); }
.timer { position: absolute; top: calc(var(--safe-t) + 64px); left: 50%; transform: translateX(-50%); background: var(--cream); border-radius: 999px; padding: 4px 14px; font-weight: 700; font-size: 18px; box-shadow: 0 4px 0 #d8b98a; }
.timer.low { background: #ffd9d3; color: var(--red-d); animation: bump .5s infinite; }
.prog.danger .bar i { background: linear-gradient(#ff8a7a, var(--red)); }

.tabs { display: flex; gap: 8px; margin: 2px 0 8px; }
.tab { flex: 1; font: 700 17px var(--f); color: var(--brown); background: var(--cream); border: 0; border-radius: 14px; padding: 10px; box-shadow: 0 4px 0 #d8b98a; cursor: pointer; }
.tab.on { background: var(--orange); color: #fff; box-shadow: 0 4px 0 var(--orange-d); }
.debtnote { background: #ffd9d3; color: var(--red-d); border-radius: 14px; padding: 8px 12px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.sechead { font-weight: 700; font-size: 15px; opacity: .75; margin: 6px 4px 0; text-transform: uppercase; letter-spacing: 1px; }
.swatch { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.15); flex-shrink: 0; }
.card-row.mode { background: linear-gradient(135deg, #fff4dc, #ffe2a8); }
.gatetxt { color: var(--red); font-weight: 700; font-size: 14px; }
.card-row .meta small.sub2 { display: block; }

.award { cursor: default; }
.award.locked { filter: grayscale(1); opacity: .55; }

.setrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--cream); border-radius: 18px; padding: 12px 14px; box-shadow: 0 4px 0 #d8b98a; font-weight: 700; font-size: 18px; flex-shrink: 0; }
.setrow input[type=range] { flex: 1; max-width: 55%; accent-color: var(--orange); height: 28px; touch-action: pan-x; }
.fine { text-align: center; opacity: .6; font-size: 13px; font-weight: 600; }

.dbg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.dbg .btn { font-size: 15px; padding: 12px 8px; }
#fps { position: absolute; left: 6px; bottom: calc(var(--safe-b) + 4px); z-index: 60; font: 700 12px monospace; color: #fff; background: rgba(0,0,0,.55); padding: 2px 6px; border-radius: 6px; pointer-events: none; }

.tut { position: absolute; left: 0; right: 0; top: calc(var(--safe-t) + 84px); display: flex; justify-content: center; padding: 0 16px; pointer-events: none; }
.tut-card { background: var(--brown-d); color: #fff; border-radius: 18px; padding: 12px 16px; text-align: center; font-size: 17px; box-shadow: 0 6px 0 rgba(0,0,0,.25); max-width: 340px; animation: scrin .3s; pointer-events: auto; }
.tut-card button { display: block; margin: 8px auto 0; background: none; border: 0; color: #ffd9a0; font: 600 14px var(--f); text-decoration: underline; cursor: pointer; }
#tutstick { position: absolute; left: 22%; bottom: calc(var(--safe-b) + 150px); width: 110px; height: 110px; margin-left: -55px; border-radius: 50%; border: 3px dashed rgba(255,255,255,.8); background: rgba(255,255,255,.15); pointer-events: none; }
#tutstick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255,255,255,.9); animation: tutdrag 1.8s ease-in-out infinite; }
@keyframes tutdrag { 0%, 100% { transform: translate(0, 0); } 30% { transform: translate(30px, -26px); } 65% { transform: translate(-26px, -34px); } }
#blow.pulse::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 4px solid #fff; animation: ring 1s infinite; }
@keyframes ring { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }

#achToast { position: absolute; left: 50%; top: calc(var(--safe-t) + 10px); transform: translate(-50%, -140%); z-index: 70; display: flex; gap: 10px; align-items: center; background: var(--brown-d); color: #fff; border-radius: 18px; padding: 10px 16px; box-shadow: 0 6px 0 rgba(0,0,0,.25); transition: transform .45s cubic-bezier(.2, 1.4, .4, 1); pointer-events: none; }
#achToast.on { transform: translate(-50%, 0); }
#achToast span { font-size: 32px; } #achToast small { display: block; opacity: .7; font-size: 12px; font-weight: 600; } #achToast b { font-size: 18px; }

.tip { position: absolute; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 10px); background: var(--brown-d); color: #fff; border-radius: 16px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; z-index: 5; }
.tip button { background: none; border: 0; color: #ffd9a0; font-size: 20px; cursor: pointer; }

.stars.hide { display: none; }
.row2 { flex-wrap: wrap; }

/* reduced motion */
body.rm .logo span, body.rm .falling i, body.rm .gust, body.rm .btn, body.rm .pill.bump, body.rm .timer.low, body.rm #blow.hot { animation: none !important; }
body.rm .screen.on, body.rm .card, body.rm .card-row { animation-duration: .01s !important; }
@media (prefers-reduced-motion: reduce) { .falling i, .logo span { animation: none !important; } }
