* { box-sizing: border-box; }
:root {
  --cream: #f6e8c3; --paper: #fbf1d6; --red: #d7263d; --gold: #f4b63f; --coral: #f46036; --teal: #1b6f6a; --ink: #1b1b3a;
  --pink: #e71d73; --sky: #2e86ab;
  --font: "Baloo 2", "Nunito", system-ui, "Noto Sans", sans-serif;
  --print: 4px 4px 0 var(--ink);
}
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #120f26; color: var(--ink); font-family: var(--font);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none;
}
#viewport { position: fixed; inset: 0; }
#stage { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 1280px; height: 720px; display: block; touch-action: none; }
button, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- screen-printed poster paper */
.card, .pill, .btn, .toast, .rbtn {
  background-color: var(--paper);
  background-image: radial-gradient(rgba(27,27,58,.08) 1px, transparent 1.3px), linear-gradient(180deg, #fff6df, #f3e2b8);
  background-size: 6px 6px, 100% 100%;
}
.card {
  position: relative; width: 580px; max-width: 92%; padding: 26px 32px 22px; border-radius: 6px;
  border: 4px solid var(--ink); box-shadow: 10px 10px 0 var(--red), 10px 10px 0 4px var(--ink);
  animation: cardIn .35s cubic-bezier(.2,1.6,.4,1) both;
}
.card::before { /* poster corner stripe */
  content: ''; position: absolute; left: -4px; right: -4px; top: -4px; height: 12px;
  background: repeating-linear-gradient(90deg, var(--red) 0 28px, var(--gold) 28px 56px); border-bottom: 3px solid var(--ink);
}
.card.wide { width: 960px; }
.card.narrow { width: 380px; }
.card h2 { margin: 6px 0 6px; font-size: 40px; line-height: 1.05; color: var(--red); text-shadow: 3px 3px 0 var(--gold); overflow-wrap: anywhere; text-transform: uppercase; letter-spacing: .5px; }
.card .sub { margin: 4px 0 12px; font-size: 19px; font-weight: 700; color: #4a4466; line-height: 1.3; }
.card .sub.small { font-size: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
@keyframes cardIn { from { transform: translateY(40px) rotate(-3deg) scale(.8); opacity: 0; } }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.overlay.dim { background: rgba(18,15,38,.6); }

/* ---------------------------------------------------------------- buttons */
.btn {
  position: relative; border: 3px solid var(--ink); cursor: pointer; padding: 10px 26px; min-height: 58px; border-radius: 6px;
  font-size: 24px; font-weight: 800; color: var(--ink); box-shadow: var(--print); transition: transform .08s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; line-height: 1.1; text-align: center; text-transform: uppercase;
}
.btn:hover { transform: translate(-1px, -2px) rotate(-.6deg); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.play { background: var(--red); color: var(--cream); text-shadow: 2px 2px 0 var(--ink); }
.btn.daily { background: var(--teal); color: var(--cream); flex-direction: column; gap: 0; text-shadow: 2px 2px 0 var(--ink); }
.btn.daily small { font-size: 15px; opacity: .95; font-weight: 700; text-transform: none; }
.btn.ghost { background: rgba(251,241,214,.75); }
.btn.small { font-size: 19px; min-height: 50px; padding: 8px 16px; }
.btn .em { font-size: 24px; }
.btn[disabled] { filter: grayscale(.8); opacity: .6; cursor: default; }
.rbtn {
  width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--ink); cursor: pointer; font-size: 20px; font-weight: 800;
  box-shadow: 3px 3px 0 var(--ink); display: grid; place-items: center;
}
.rbtn:active { transform: translate(2px, 2px); box-shadow: none; }
.badge {
  position: absolute; top: -10px; right: -10px; min-width: 26px; height: 26px; border-radius: 13px; background: var(--red);
  color: #fff; font-style: normal; font-size: 15px; line-height: 22px; border: 2px solid var(--ink); animation: bob 1s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-4px); } }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 8px; border-radius: 22px; border: 3px solid var(--ink);
  font-weight: 800; font-size: 22px; box-shadow: 3px 3px 0 var(--ink);
}
.pill.big { height: 50px; font-size: 26px; }
.pill.daily { background: var(--teal); color: var(--cream); padding: 0 14px; font-size: 18px; }
.pill.streakp { color: var(--red); font-size: 18px; padding: 0 14px; }
.ico-coin { display: inline-block; width: 30px; height: 30px; background: url(assets/items.webp) 0 50% / auto 100% no-repeat; }
body.noart .ico-coin { background: radial-gradient(circle, var(--gold) 55%, #b77d12 57%, transparent 62%); }
.ico-tower { display: inline-block; width: 24px; height: 30px; background:
  linear-gradient(var(--red), var(--red)) 3px 0 / 18px 8px no-repeat, linear-gradient(var(--teal), var(--teal)) 1px 10px / 22px 9px no-repeat,
  linear-gradient(var(--gold), var(--gold)) 4px 21px / 16px 9px no-repeat; }

/* ---------------------------------------------------------------- HUD */
#hud { position: absolute; left: 0; right: 0; top: 0; height: 120px; pointer-events: none; }
.hud-left { position: absolute; left: 18px; top: 16px; display: flex; gap: 10px; flex-wrap: wrap; max-width: 380px; }
.hud-right { position: absolute; right: 18px; top: 16px; pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; }
.pill.tower.pop, .pill.tips.pop { animation: pop .3s cubic-bezier(.2,2,.4,1); }
.hud-dist { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); text-align: center; white-space: nowrap; }
#hud-m {
  display: inline-block; font-size: 74px; line-height: 1; color: var(--cream); font-weight: 800;
  text-shadow: 4px 4px 0 var(--red), 7px 7px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink), 0 -2px 0 var(--ink);
}
.hud-dist .unit { font-size: 34px; font-weight: 800; color: var(--gold); margin-left: 4px; text-shadow: 2px 2px 0 var(--ink); }
.streak { margin-top: 0; font-size: 22px; font-weight: 800; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); animation: pop .25s cubic-bezier(.2,2,.4,1); }
@keyframes pop { 0% { transform: scale(1.45) rotate(-4deg); } 100% { transform: scale(1); } }
.powers { display: flex; gap: 8px; }
.pw { position: relative; width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--ink); background: var(--paper); box-shadow: 3px 3px 0 var(--ink); display: grid; place-items: center; }
.pw i { display: block; }
.pw b { position: absolute; bottom: -8px; right: -6px; font-size: 14px; background: var(--ink); color: var(--cream); border-radius: 8px; padding: 0 5px; }
.pw.low { animation: blink .4s ease-in-out infinite; }

#btn-duck {
  position: absolute; left: 22px; bottom: 22px; width: 150px; height: 120px; border-radius: 24px; border: 4px solid rgba(27,27,58,.8);
  background: rgba(251,241,214,.55); color: var(--ink); font-size: 24px; font-weight: 800; display: flex; flex-direction: column;
  align-items: center; justify-content: center; box-shadow: 4px 4px 0 rgba(27,27,58,.6); text-transform: uppercase; touch-action: none;
}
#btn-duck .arrow { font-size: 42px; line-height: 1; }
#btn-duck.on { background: rgba(244,182,63,.85); transform: translate(3px, 3px); box-shadow: none; }

/* big callouts */
#calls { position: absolute; left: 0; right: 0; top: 118px; display: flex; flex-direction: column; align-items: center; pointer-events: none; gap: 6px; }
.call {
  font-size: 50px; font-weight: 800; color: var(--cream); padding: 0 30px; max-width: 1040px; text-align: center; line-height: 1.1;
  text-shadow: 4px 4px 0 var(--red), 7px 7px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink); text-transform: uppercase;
  animation: callIn 1.6s cubic-bezier(.2,1.6,.4,1) both;
}
.call.gold { color: var(--gold); }
.call.teal { text-shadow: 4px 4px 0 var(--teal), 7px 7px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink); }
.call.banner {
  font-size: 38px; color: var(--cream); text-shadow: 2px 2px 0 var(--ink); padding: 8px 48px; background: var(--red); border: 4px solid var(--ink);
  clip-path: polygon(0 0, 100% 0, 96% 50%, 100% 100%, 0 100%, 4% 50%); animation: bannerIn 2.4s cubic-bezier(.2,1.4,.4,1) both;
}
.call.rain { background: var(--sky); }
.call.medal { display: flex; align-items: center; gap: 12px; }
.call.medal i { width: 90px; height: 90px; background: url(assets/medals.webp) 0 0 / auto 100% no-repeat; animation: stampIn .5s cubic-bezier(.2,2,.4,1) both; }
@keyframes callIn { 0% { transform: scale(.3) rotate(-10deg); opacity: 0; } 12% { transform: scale(1.15) rotate(3deg); opacity: 1; } 22% { transform: scale(1); } 80% { opacity: 1; } 100% { transform: translateY(-30px); opacity: 0; } }
@keyframes bannerIn { 0% { transform: translateY(-120px) rotate(-6deg); } 15% { transform: translateY(0) rotate(2deg); } 85% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-120px); opacity: 0; } }
@keyframes stampIn { 0% { transform: scale(3) rotate(-30deg); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.hint {
  position: absolute; left: 50%; top: 250px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px;
  font-size: 30px; font-weight: 800; color: var(--cream); text-shadow: 3px 3px 0 var(--ink), 0 0 12px rgba(0,0,0,.5);
  pointer-events: none; white-space: nowrap; max-width: 1180px;
}
.hint .hand { font-size: 44px; animation: tap .9s ease-in-out infinite; }
@keyframes tap { 50% { transform: translateY(12px) scale(.9); } }

.toast {
  position: absolute; left: 50%; bottom: 36px; transform: translateX(-50%); padding: 12px 28px; border-radius: 6px; border: 3px solid var(--ink);
  font-size: 22px; font-weight: 800; box-shadow: var(--print); animation: cardIn .3s both; max-width: 80%; text-align: center; pointer-events: none;
}

/* ---------------------------------------------------------------- menu */
#menu { justify-content: flex-start; padding-top: 70px; background: linear-gradient(90deg, rgba(18,15,38,.62), rgba(18,15,38,.05) 62%); align-items: flex-start; padding-left: 70px; }
.menu-top { position: absolute; top: 18px; right: 20px; display: flex; gap: 12px; align-items: center; }
.logo h1 { margin: 0; line-height: .9; transform: rotate(-4deg); animation: logoBob 3s ease-in-out infinite; max-width: 720px; }
.logo .l1 { display: inline-block; font-size: 66px; color: var(--gold); background: var(--red); padding: 4px 18px 0; border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); text-transform: uppercase; }
.logo .l2 { display: block; width: max-content; max-width: none; white-space: nowrap; margin-top: 10px; font-size: 92px; color: var(--cream); text-transform: uppercase;
  text-shadow: 5px 5px 0 var(--red), 9px 9px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 -3px 0 var(--ink); }
.logo p { margin: 22px 0 0 6px; font-size: 28px; font-weight: 800; color: var(--gold); text-shadow: 3px 3px 0 var(--ink); max-width: 640px; }
@keyframes logoBob { 50% { transform: rotate(-3deg) translateY(-6px); } }
.menu-main { display: flex; flex-direction: column; gap: 14px; margin-top: 26px; width: 380px; }
.menu-main .btn { width: 100%; }
#btn-play { font-size: 42px; min-height: 84px; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04) rotate(-1deg); } }
.menu-row { display: flex; gap: 10px; margin-top: 14px; width: 480px; }
.menu-row .btn { flex: 1; padding: 8px 8px; font-size: 17px; }
.menu-foot { margin-top: 18px; font-size: 22px; font-weight: 800; color: var(--cream); text-shadow: 2px 2px 0 var(--ink); display: flex; gap: 16px; align-items: center; }
.medal-row { display: flex; gap: 8px; }
.medal-row span { display: inline-flex; align-items: center; gap: 2px; font-size: 18px; }
.medal-row i { width: 36px; height: 36px; background: url(assets/medals.webp) 0 0 / auto 100% no-repeat; }
.medal-row .off { filter: grayscale(1) brightness(.6); opacity: .6; }

/* ---------------------------------------------------------------- daily */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: rgba(27,111,106,.14); border: 2px solid rgba(27,27,58,.2); border-radius: 6px; padding: 8px 12px; font-size: 20px; font-weight: 800; }

/* ---------------------------------------------------------------- garage */
.tabs { display: flex; gap: 6px; }
.tab { border: 3px solid var(--ink); background: var(--paper); border-radius: 6px; padding: 4px 16px; font-weight: 800; font-size: 19px; cursor: pointer; }
.tab.on { background: var(--gold); box-shadow: 3px 3px 0 var(--ink); }
.skin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.skin {
  position: relative; border: 3px solid rgba(27,27,58,.25); border-radius: 6px; padding: 8px 6px 10px; cursor: pointer; background: rgba(27,27,58,.05);
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 196px; transition: transform .1s;
}
.skin:hover { transform: translateY(-3px) rotate(-1deg); }
.skin.on { background: rgba(215,38,61,.14); border-color: var(--red); box-shadow: 4px 4px 0 var(--ink); }
.skin .pic { height: 96px; display: flex; align-items: flex-end; justify-content: center; }
.skin .pic div { max-width: 190px; transform-origin: bottom center; }
.skin:hover .pic div { animation: wiggle .4s ease-in-out infinite; }
@keyframes wiggle { 50% { transform: rotate(3deg) scale(1.05); } }
.skin.locked .pic div { filter: brightness(0) opacity(.35); }
.skin .nm { font-size: 19px; font-weight: 800; line-height: 1.1; text-align: center; }
.skin .ds { font-size: 14px; font-weight: 700; color: #4a4466; line-height: 1.15; text-align: center; min-height: 32px; }
.skin .tag { font-size: 16px; font-weight: 800; padding: 2px 10px; border-radius: 6px; background: var(--cream); display: inline-flex; align-items: center; gap: 2px; border: 2px solid var(--ink); }
.skin .tag .ico-coin { width: 22px; height: 22px; }
.skin .tag.buy { background: var(--gold); }
.skin .tag.use { background: var(--teal); color: var(--cream); }
.skin .tag.req { font-size: 12px; background: transparent; border: 0; color: #4a4466; text-align: center; }

/* ---------------------------------------------------------------- album */
.album-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 6px; }
.cargo { border: 3px solid rgba(27,27,58,.25); border-radius: 6px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; background: rgba(27,27,58,.05); }
.cargo .pic { height: 100px; display: flex; align-items: flex-end; justify-content: center; }
.cargo.unseen .pic div { filter: brightness(0) opacity(.3); }
.cargo .nm { font-size: 18px; font-weight: 800; text-align: center; line-height: 1.1; }
.cargo .ds { font-size: 14px; font-weight: 700; color: #4a4466; text-align: center; line-height: 1.15; min-height: 32px; }
.cargo .ct { font-size: 15px; font-weight: 800; background: var(--gold); border: 2px solid var(--ink); border-radius: 6px; padding: 0 8px; }
.cargo.unseen .ct { background: var(--cream); }

/* ---------------------------------------------------------------- missions */
.mission-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.mission { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; background: rgba(27,27,58,.06); border: 2px solid rgba(27,27,58,.2); padding: 10px 14px; border-radius: 6px; }
.mission .txt { font-size: 20px; font-weight: 800; line-height: 1.15; }
.mission .bar { grid-column: 1; height: 10px; border-radius: 2px; background: rgba(27,27,58,.15); overflow: hidden; }
.mission .bar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--red) 0 10px, var(--coral) 10px 20px); }
.mission .btn { grid-row: 1 / span 2; grid-column: 2; min-height: 46px; font-size: 18px; padding: 6px 14px; }
.mission.done .txt { color: var(--teal); }

/* ---------------------------------------------------------------- settings */
.set-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.set { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; }
.toggle { min-width: 90px; height: 42px; border-radius: 6px; border: 3px solid var(--ink); cursor: pointer; font-weight: 800; background: #d9ccb0; box-shadow: 3px 3px 0 var(--ink); }
.toggle.on { background: var(--teal); color: var(--cream); }
select { height: 44px; border-radius: 6px; border: 3px solid var(--ink); background: var(--paper); font-size: 19px; font-weight: 700; padding: 0 8px; max-width: 260px; }

/* ---------------------------------------------------------------- results */
#result { background: radial-gradient(ellipse at center, rgba(18,15,38,.3), rgba(18,15,38,.65)); }
.card.result { width: 720px; text-align: center; }
.card.result h2 { font-size: 32px; text-transform: none; }
.res-body { display: grid; grid-template-columns: 140px 1fr 210px; gap: 16px; align-items: center; margin-top: 8px; }
.medal-slot { width: 130px; height: 130px; border-radius: 50%; background: rgba(27,27,58,.08); display: grid; place-items: center; }
.medal-slot i.none { filter: grayscale(1) brightness(1.4); opacity: .22; animation: none; }
.medal-slot i { width: 124px; height: 124px; background: url(assets/medals.webp) 0 0 / auto 100% no-repeat; animation: stampIn .45s .5s cubic-bezier(.2,2,.4,1) both; }
.res-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 22px; font-weight: 800; color: #4a4466; padding: 0 10px; gap: 10px; }
.res-line b { font-size: 48px; color: var(--ink); line-height: 1.1; white-space: nowrap; }
.newbest { display: inline-block; margin-top: 4px; font-size: 26px; font-weight: 800; color: var(--cream); background: var(--red); border: 3px solid var(--ink); padding: 2px 16px; transform: rotate(-4deg); animation: stampIn .4s .9s both, bob 1s 1.3s infinite; }
.res-side { display: flex; flex-direction: column; gap: 6px; }
.res-chip { display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 800; background: rgba(244,182,63,.3); border: 2px solid rgba(27,27,58,.2); border-radius: 6px; padding: 4px 10px; text-align: left; line-height: 1.15; }
.goal { margin: 12px 0 0; font-size: 21px; font-weight: 800; color: var(--teal); }
.res-missions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.res-missions span { font-size: 15px; font-weight: 800; background: var(--teal); color: var(--cream); padding: 3px 10px; border-radius: 6px; }
.retry-hint { margin: 10px 0 0; font-size: 16px; font-weight: 700; color: #6a6488; animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .4; } }

/* ---------------------------------------------------------------- loading / rotate */
#loading { background: #1b1b3a url(assets/cover.webp) center / cover no-repeat; }
.loader { text-align: center; color: var(--cream); font-size: 26px; font-weight: 800; background: rgba(27,27,58,.7); padding: 18px 30px; border-radius: 8px; }
.spin { width: 60px; height: 60px; margin: 0 auto 10px; border-radius: 50%; border: 6px solid rgba(246,232,195,.25); border-top-color: var(--red); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#rotate {
  display: none; position: fixed; inset: 0; z-index: 9; background: var(--ink); color: var(--cream); font-size: 22px; font-weight: 800;
  flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px;
}
#rotate span { font-size: 60px; animation: bob 1.2s infinite; }
@media (orientation: portrait) and (max-width: 700px) and (pointer: coarse) { body.touch #rotate { display: flex; } }

/* phones: the stage is scaled to ~50%, so small print gets bigger and flavour text goes */
@media (max-height: 500px), (max-width: 700px) {
  .skin .ds, .cargo .ds { display: none; }
  .skin { min-height: 160px; }
  .skin .nm, .cargo .nm { font-size: 22px; }
  .skin .tag { font-size: 20px; }
  .res-chip { font-size: 22px; }
  .retry-hint, .goal { font-size: 24px; }
  .mission .txt { font-size: 24px; }
  .card .sub { font-size: 22px; }
  .stat { font-size: 24px; }
  .btn.daily small { font-size: 18px; }
  .menu-foot { font-size: 26px; }
  .rbtn { width: 64px; height: 64px; font-size: 24px; }
  #btn-duck { width: 190px; height: 150px; font-size: 28px; }
  .hint { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
