/* Luckiest Guy by Astigmatic, Apache License 2.0 (see fonts/LuckiestGuy-LICENSE.txt). */
@font-face {
  font-family: 'Luckiest Guy';
  src: url('fonts/LuckiestGuy.woff2') format('woff2');
  font-display: swap;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #9fd3ee;
  font-family: 'Luckiest Guy', 'Arial Black', Impact, system-ui, sans-serif; letter-spacing: .5px;
  color: #fff; user-select: none; -webkit-user-select: none; touch-action: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
/* While YouTube has the game paused, every animation holds still. */
body.paused *, body.paused *::before, body.paused *::after { animation-play-state: paused !important; }
/* On YouTube the player uses YouTube's own mute button, so the game's is hidden. */
body.hostMute #btnMute { display: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 0 2px 0 #000, 0 0 6px rgba(0,0,0,.6); }
#hudLeft { position: absolute; left: 16px; top: 12px; }
#score { font-size: 38px; line-height: 1; color: #ffd83a; }
#combo { margin-top: 6px; font-size: 16px; color: #ff7a2a; }
#comboMult { font-size: 24px; color: #fff; }
#comboBar { width: 120px; height: 5px; background: rgba(0,0,0,.45); border-radius: 3px; margin-top: 3px; overflow: hidden; }
#comboBar i { display: block; height: 100%; width: 100%; background: #ff7a2a; transform-origin: left; }

#hudMid { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); width: min(38vw, 360px); text-align: center; }
#pctLabel { font-size: 13px; letter-spacing: 1px; }
#pctText { color: #ffd83a; }
#pctBar { height: 12px; background: rgba(0,0,0,.5); border: 2px solid #000; border-radius: 7px; margin-top: 4px; overflow: hidden; }
#pctFill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffb52a, #ff4a1e); transform: scaleX(0); transform-origin: left; transition: transform .25s; }

#hudRight { position: absolute; right: 12px; top: 10px; display: flex; gap: 8px; align-items: center; pointer-events: auto; }
#time { font-size: 20px; margin-right: 4px; }
#hudRight button { background: rgba(15,18,30,.75); border: 2px solid #000; border-radius: 8px; padding: 6px 10px; font-size: 11px; letter-spacing: 1px; }
#hudRight button:hover { background: #2a3050; }

/* The way back to the monster picker: bottom corner, only during a round. */
#btnMenu { display: none; position: fixed; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); background: rgba(15,18,30,.75); border: 2px solid #000; border-radius: 8px; padding: 6px 10px; font-size: 11px; letter-spacing: 1px; text-shadow: 0 2px 0 #000; touch-action: none; }
body.playing #btnMenu { display: block; }
#btnMenu:hover { background: #2a3050; }
#btnMenu.sure { background: #e2452c; }

#special { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); text-align: center; font-size: 12px; letter-spacing: 1px; }
#specialBar { width: 200px; height: 10px; background: rgba(0,0,0,.5); border: 2px solid #000; border-radius: 6px; margin-top: 3px; overflow: hidden; }
#specialFill { display: block; height: 100%; background: #4fd8ff; transform-origin: left; }
#specialFill.ready { background: #7dff6a; }
#hints { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font: 600 12px 'Segoe UI', system-ui, sans-serif; opacity: .85; }

/* ---------- Goals ---------- */
#goals { position: absolute; left: 16px; top: 92px; display: flex; flex-direction: column; gap: 4px; font: 800 12px 'Segoe UI', system-ui, sans-serif; letter-spacing: 0; }
#goals div { display: flex; align-items: center; gap: 6px; padding: 3px 9px 3px 5px; background: rgba(10,12,24,.55); border-radius: 9px; width: fit-content; max-width: 46vw; text-shadow: 0 1px 0 #000; }
#goals div::before { content: ''; width: 12px; height: 12px; flex: none; border: 2px solid #fff; border-radius: 4px; }
#goals .done { color: #7dff6a; }
#goals .done::before { background: #7dff6a; border-color: #7dff6a; }
#goals .lost { opacity: .45; text-decoration: line-through; }
#goals .done.fresh { animation: goalWon .7s ease-out; }
@keyframes goalWon { 0% { transform: scale(1.35); background: #2f9a48; } 100% { transform: scale(1); } }
body.touch #goals { top: 156px; } /* below the camera buttons */

#toast { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); padding: 7px 18px; background: linear-gradient(#3cc47a, #23803f); border: 3px solid #000; border-radius: 14px; font-size: clamp(13px, 2.6vw, 20px); white-space: nowrap; box-shadow: 0 4px 0 #000; opacity: 0; }
#toast.show { animation: toast 2.6s ease-out forwards; }
@keyframes toast {
  0% { opacity: 0; transform: translateX(-50%) translateY(-24px) scale(.7); }
  10% { opacity: 1; transform: translateX(-50%) scale(1.08); }
  16% { transform: translateX(-50%) scale(1); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ---------- Tutorial ---------- */
#tutorial { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; width: max-content; max-width: min(94vw, 720px); padding: 10px 12px 10px 16px; background: rgba(12,15,30,.9); border: 3px solid #ffd83a; border-radius: 16px; box-shadow: 0 5px 0 #000; font: 700 clamp(13px, 2.4vw, 18px) 'Segoe UI', system-ui, sans-serif; letter-spacing: 0; text-shadow: none; }
#tutorial b { color: #ffd83a; }
#tutorialCount { font: inherit; opacity: .6; font-size: .8em; }
#tutorialNice { display: none; font-family: 'Luckiest Guy', 'Arial Black', sans-serif; font-weight: normal; letter-spacing: 1px; color: #7dff6a !important; }
#tutorial.nice { border-color: #7dff6a; }
#tutorial.nice #tutorialNice { display: inline; }
#tutorial.nice #tutorialText { opacity: .45; }
#btnSkipTutorial { flex: none; background: #2a3050; border: 2px solid #000; border-radius: 9px; padding: 5px 10px; font-size: 11px; letter-spacing: 1px; }
/* On touch screens the tutorial sits clear of the buttons, and lets touches through to the stick. */
body.touch #tutorial { bottom: 236px; pointer-events: none; }
body.touch #btnSkipTutorial { pointer-events: auto; }
.tbtn.hint { animation: hint .7s ease-in-out infinite alternate; box-shadow: 0 0 0 4px #ffd83a, 0 0 26px 8px rgba(255,216,58,.9); }
@keyframes hint { to { transform: scale(1.12); } }
#btnHowTo { margin-top: 14px; font-size: 13px; padding: 9px 16px; }
#btnHowTo.armed { background: #23803f; }

/* ---------- Score popups ---------- */
#popups { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; left: 0; top: 0; font-size: 22px; color: #ffd83a; text-shadow: 0 2px 0 #000, 0 0 5px #000; white-space: nowrap; will-change: transform, opacity; }
.pop.hot { color: #ff7a2a; font-size: 28px; }
.pop.small { font-size: 15px; color: #fff; }

/* ---------- Touch controls ---------- */
#touch { display: none; position: fixed; inset: 0; pointer-events: none; }
body.touch.playing #touch { display: block; }
body.touch #hints { display: none; }
body.touch #special { bottom: auto; top: 54px; }
#stickZone { position: absolute; left: 0; bottom: 0; width: 50%; height: 70%; pointer-events: auto; touch-action: none; }
#stickBase { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255,255,255,.14); border: 2px solid rgba(255,255,255,.5); display: none; }
#stickBase.on { display: block; }
#stickKnob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.75); transform: translate(-50%, -50%); }
.tbtn { position: absolute; pointer-events: auto; touch-action: none; width: 84px; height: 84px; border-radius: 50%; border: 3px solid #000; font-size: 12px; letter-spacing: .5px; text-shadow: 0 1px 0 #000; opacity: .88; }
.tbtn:active { transform: scale(.92); opacity: 1; }
#tPunch { right: 20px; bottom: 28px; width: 100px; height: 100px; background: #e2452c; font-size: 14px; }
#tSpecial { right: 132px; bottom: 20px; background: #2f9be0; }
#tJump { right: 28px; bottom: 140px; background: #46b356; }
#tGrab { right: 124px; bottom: 116px; background: #9a5fe0; }
.tbtn.small { width: 52px; height: 52px; font-size: 24px; background: rgba(15,18,30,.75); top: 56px; }
#tCamL { left: 14px; }
#tCamR { right: 14px; }

/* ---------- Combo banner ---------- */
#banner { position: fixed; left: 0; right: 0; top: 22%; text-align: center; pointer-events: none; opacity: 0; --hot: #ffd83a; }
#banner.show { animation: bannerIn 2s cubic-bezier(.2, 1.3, .3, 1) forwards; }
/* Drawn cheaply for phones (measured on a Nothing Phone 2a): a 44px blurred glow and a text stroke
   on text this big froze the game for 120-220 ms each time the banner appeared. The outline is now
   four sharp shadows, and the glow is gone (it was barely visible over the city anyway). */
#bannerTitle {
  font-size: clamp(38px, 11vw, 112px); line-height: 1; color: var(--hot); letter-spacing: 3px;
  transform: rotate(-4deg);
  text-shadow: -3px -3px 0 #1a0d05, 3px -3px 0 #1a0d05, -3px 3px 0 #1a0d05, 3px 3px 0 #1a0d05, 0 6px 0 #7a2408, 0 11px 0 #000;
}
#banner.long #bannerTitle { font-size: clamp(26px, 6.6vw, 68px); }
#bannerBonus { margin-top: 10px; font-size: clamp(18px, 4vw, 38px); color: #fff; text-shadow: 0 3px 0 #000, 0 0 12px rgba(0,0,0,.7); }
@keyframes bannerIn {
  0% { opacity: 0; transform: scale(2.8); }
  11% { opacity: 1; transform: scale(.9); }
  19% { transform: scale(1.07); }
  27% { transform: scale(1); }
  76% { opacity: 1; transform: scale(1.03); }
  100% { opacity: 0; transform: scale(1.3) translateY(-34px); }
}

/* ---------- Loading screen ---------- */
#loading { background: linear-gradient(#3aa6e0, #1d4f8f); gap: 18px; z-index: 10; transition: opacity .35s; }
#loading.fade { opacity: 0; pointer-events: none; }
#loadBar { width: min(70vw, 420px); height: 22px; background: rgba(0,0,0,.45); border: 3px solid #000; border-radius: 13px; overflow: hidden; box-shadow: 0 5px 0 rgba(0,0,0,.5); }
#loadFill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffd83a, #ff6a1e); transform: scaleX(0); transform-origin: left; transition: transform .25s; }
#loadText { margin: 0; font-size: clamp(14px, 2.6vw, 20px); text-shadow: 0 2px 0 #000; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; background: rgba(8,10,22,.5); text-align: center; }
h1 { margin: 0; font-size: clamp(36px, 9vw, 84px); line-height: .95; color: #ffd83a; letter-spacing: 2px; text-shadow: 0 4px 0 #c2410c, 0 8px 0 #000, 0 0 30px rgba(0,0,0,.5); }
.sub { margin: 4px 0 14px; font: 700 clamp(14px, 2.4vw, 20px) 'Segoe UI', system-ui, sans-serif; text-shadow: 0 2px 0 #000; }
#cards, #cityCards { display: flex; gap: clamp(8px, 1.6vw, 18px); justify-content: center; width: 100%; max-width: 900px; }
#cards { max-width: 1080px; }
.card { flex: 1 1 0; min-width: 0; max-width: 260px; padding: 10px 10px 14px; background: linear-gradient(#262a44, #151828); border: 3px solid #000; border-radius: 16px; box-shadow: 0 6px 0 #000; transition: transform .12s, border-color .12s; }
.card:hover, .card:focus-visible { transform: translateY(-6px); border-color: #ffd83a; outline: none; }
.card img { width: 100%; aspect-ratio: 1 / 1.05; object-fit: contain; display: block; background: radial-gradient(circle at 50% 70%, #3a4170, transparent 70%); border-radius: 10px; }
.card h2 { margin: 8px 0 0; font-size: clamp(15px, 3vw, 26px); color: #ffd83a; text-shadow: 0 2px 0 #000; }
.card .kind { font: 700 clamp(10px, 1.6vw, 13px) 'Segoe UI', system-ui, sans-serif; opacity: .8; text-transform: uppercase; letter-spacing: 1px; }
.card .stat { display: flex; align-items: center; gap: 6px; margin-top: 6px; font: 700 clamp(9px, 1.4vw, 12px) 'Segoe UI', system-ui, sans-serif; text-align: left; }
.card .stat span { width: 42px; flex: none; opacity: .8; }
.card .pips { flex: 1; display: flex; gap: 3px; }
.card .pips i { flex: 1; height: 7px; border-radius: 2px; background: rgba(255,255,255,.15); }
.card .pips i.on { background: #ff7a2a; }
.card .move { margin-top: 9px; font: 700 clamp(10px, 1.5vw, 13px) 'Segoe UI', system-ui, sans-serif; color: #4fd8ff; }

.card .mini { display: flex; justify-content: center; gap: 3px; margin-top: 8px; }
.card .mini i { width: 16px; height: 16px; background: #333a55; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.card .mini i.on { background: linear-gradient(#fff8b8, #ffb52a); }
.card .blurb { margin-top: 6px; font: 700 clamp(10px, 1.6vw, 13px) 'Segoe UI', system-ui, sans-serif; opacity: .85; }
#btnBack { margin-top: 16px; }
/* ---------- Locked monsters and the unlock screen ---------- */
.card { position: relative; }
.card.locked { border-color: #7d58cc; background: linear-gradient(#2a2148, #130f24); }
.card.locked img { filter: brightness(0) drop-shadow(0 0 10px #a77bff); }
.card.locked .stat, .card.locked .move { visibility: hidden; }
/* A locked monster keeps its name secret until it is earned. */
.card.locked h2 { font-size: 0; }
.card.locked h2::after { content: '? ? ?'; font-size: clamp(15px, 3vw, 26px); }
.card.locked .kind { visibility: hidden; }
.card .lock { display: none; }
.card.locked .lock { display: flex; flex-direction: column; align-items: center; gap: 4px; position: absolute; left: 0; right: 0; top: 34%; font-size: clamp(11px, 1.8vw, 16px); color: #ffd83a; text-shadow: 0 2px 0 #000; }
.padlock { position: relative; width: 30px; height: 24px; margin-top: 16px; background: linear-gradient(#ffe27a, #ffb52a); border: 3px solid #000; border-radius: 6px; }
.padlock::before { content: ''; position: absolute; left: 4px; right: 4px; top: -17px; height: 16px; border: 4px solid #000; border-bottom: none; border-radius: 12px 12px 0 0; }

#unlock { background: radial-gradient(ellipse at center, rgba(40,20,80,.85), rgba(6,4,16,.96)); gap: clamp(6px, 1.4vh, 12px); overflow: hidden; z-index: 5; }
#unlock > * { position: relative; }
#unlockRays, #unlockFlash, #unlockConfetti { position: absolute !important; inset: 0; pointer-events: none; }
#unlockRays { inset: -60% !important; background: repeating-conic-gradient(from 0deg, rgba(125,255,176,.22) 0deg 8deg, transparent 8deg 20deg); opacity: 0; animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#unlockFlash { background: #d9fff0; opacity: 0; }
#unlockTitle { font-size: clamp(26px, 6.5vw, 62px); color: #c9a6ff; text-shadow: 0 4px 0 #3b1f7a, 0 8px 0 #000, 0 0 30px rgba(160,110,255,.8); }
#unlockImg { height: min(34vh, 300px); filter: brightness(0) drop-shadow(0 0 18px #a77bff); transition: filter .5s; }
#unlockName { font-size: clamp(22px, 5vw, 44px); color: #ffd83a; letter-spacing: 4px; text-shadow: 0 3px 0 #000; }
#unlockAlt { opacity: .8; margin: 0; }
#unlockText { margin: 0; max-width: 560px; }

#unlock.won #unlockRays { opacity: 1; transition: opacity .4s; }
#unlock.won #unlockFlash { animation: flash .6s ease-out; }
#unlock.won #unlockTitle { color: #7dffb0; text-shadow: 0 4px 0 #14613a, 0 8px 0 #000, 0 0 34px rgba(125,255,176,.9); animation: slam .75s cubic-bezier(.2, 1.4, .3, 1) both; }
#unlock.won #unlockImg { filter: drop-shadow(0 0 26px #7dffb0); animation: reveal 1s cubic-bezier(.2, 1.5, .3, 1) both; }
#unlock.won #unlockName { animation: slam .7s .25s cubic-bezier(.2, 1.4, .3, 1) both; }
@keyframes reveal {
  0% { transform: scale(.2) rotate(-25deg); }
  60% { transform: scale(1.25) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}
#unlockConfetti i { position: absolute; top: -24px; border-radius: 2px; animation: fall linear both; }

#adStandIn { background: #05060c; z-index: 20; gap: 14px; }
#adStandIn h2 { margin: 0; font-size: clamp(24px, 6vw, 48px); color: #9aa3b8; }
#adStandInBar { width: min(70vw, 420px); height: 12px; background: #1b2036; border-radius: 7px; overflow: hidden; }
#adStandInFill { display: block; height: 100%; background: #6f7aa0; transform: scaleX(0); transform-origin: left; }

/* ---------- Results screen ---------- */
#done { background: radial-gradient(ellipse at center, rgba(8,10,22,.3), rgba(8,10,22,.82)); gap: clamp(6px, 1.6vh, 14px); overflow: hidden; }
#done > * { position: relative; }
#doneFlash { position: absolute !important; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#doneFlash.go { animation: flash .4s ease-out; }
@keyframes flash { 0% { opacity: .55; } 100% { opacity: 0; } }

#done.run #doneTitle { animation: slam .75s cubic-bezier(.2, 1.4, .3, 1) both; }
@keyframes slam {
  0% { opacity: 0; transform: scale(4.5) rotate(-9deg); }
  55% { opacity: 1; transform: scale(.92) rotate(2deg); }
  75% { transform: scale(1.06) rotate(-1deg); }
  100% { transform: scale(1) rotate(0); }
}

#doneRank { min-height: 1.2em; font-size: clamp(16px, 3.6vw, 30px); color: #5fe0ff; letter-spacing: 3px; text-shadow: 0 3px 0 #000, 0 0 18px rgba(95,224,255,.7); opacity: 0; transform: scale(.4); }
#doneRank.in { opacity: 1; transform: scale(1); transition: opacity .25s, transform .45s cubic-bezier(.2, 1.7, .3, 1); }

#stars { display: flex; gap: clamp(4px, 1.4vw, 14px); }
.star { width: clamp(38px, 9.5vw, 78px); aspect-ratio: 1; filter: drop-shadow(0 4px 0 #000) drop-shadow(0 0 0 transparent); }
.star i, .mark i { display: block; width: 100%; height: 100%; background: #333a55; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.star:nth-child(2), .star:nth-child(4) { transform: translateY(-8%); }
.star:nth-child(3) { transform: translateY(-14%) scale(1.12); }
.star.on { filter: drop-shadow(0 4px 0 #7a2408) drop-shadow(0 0 16px rgba(255,200,60,.95)); animation: starPop .6s cubic-bezier(.2, 1.7, .3, 1) both; }
.star.on i, .mark.on i { background: linear-gradient(#fff8b8, #ffcf3a 45%, #ff8a1e); }
@keyframes starPop {
  0% { scale: 0; rotate: -50deg; }
  55% { scale: 1.5; rotate: 12deg; }
  100% { scale: 1; rotate: 0deg; }
}

#doneScoreBox span { display: block; font-size: 13px; letter-spacing: 3px; opacity: .8; }
#doneScoreBox b { display: block; font-weight: normal; font-size: clamp(40px, 10vw, 86px); line-height: 1; color: #ffd83a; text-shadow: 0 4px 0 #c2410c, 0 8px 0 #000; font-variant-numeric: tabular-nums; }
#doneScoreBox.bump b { animation: bump .3s ease-out; }
@keyframes bump { 0% { transform: scale(1.22); color: #fff; } 100% { transform: scale(1); } }

#goal { width: min(86vw, 600px); margin-bottom: 22px; }
#goalBar { height: 18px; background: rgba(0,0,0,.55); border: 3px solid #000; border-radius: 11px; overflow: hidden; }
#goalFill { display: block; height: 100%; background: linear-gradient(90deg, #ffd83a, #ff8a1e 60%, #ff3a5a); transform: scaleX(0); transform-origin: left; box-shadow: 0 0 12px #ffb52a; }
#goalMarks { position: relative; height: 0; }
.mark { position: absolute; top: -27px; width: 26px; margin-left: -13px; text-align: center; }
.mark i { width: 26px; height: 26px; filter: none; }
.mark b { display: block; margin-top: 3px; font: 800 11px 'Segoe UI', system-ui, sans-serif; opacity: .75; }
.mark.on b { opacity: 1; color: #ffd83a; }

#doneGoals { display: flex; flex-direction: column; gap: 4px; width: min(86vw, 460px); font: 800 clamp(11px, 2vw, 14px) 'Segoe UI', system-ui, sans-serif; letter-spacing: 0; }
#doneGoals div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 12px; background: rgba(10,12,24,.6); border-radius: 9px; opacity: 0; transform: translateX(-18px); }
#doneGoals div.in { opacity: 1; transform: none; transition: opacity .2s, transform .3s cubic-bezier(.2, 1.5, .3, 1); }
#doneGoals .won { color: #7dff6a; }
#doneGoals .won b { color: #ffd83a; }
#doneGoals .missed { color: #9aa3b8; }
#doneGoals .missed.in { opacity: .6; }
#doneStats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px clamp(14px, 4vw, 40px); }
#doneStats > div { opacity: 0; transform: translateY(14px); }
#doneStats > div.in { opacity: 1; transform: none; transition: opacity .25s, transform .3s cubic-bezier(.2, 1.5, .3, 1); }
#doneStats span { display: block; font-size: 11px; letter-spacing: 2px; opacity: .8; }
#doneStats b { font-weight: normal; font-size: clamp(20px, 4.2vw, 34px); color: #fff; text-shadow: 0 3px 0 #000; }
#doneStats .record span { opacity: 1; color: #ff5a8a; animation: pulse .7s ease-in-out infinite alternate; }
#doneStats .record b { color: #ffd83a; }
@keyframes pulse { to { transform: scale(1.12); color: #ffd83a; } }

#doneButtons { opacity: 0; pointer-events: none; transform: translateY(10px); }
#done.ready #doneButtons { opacity: 1; pointer-events: auto; transform: none; transition: opacity .3s, transform .3s; }
#doneSkip { font: 700 11px 'Segoe UI', system-ui, sans-serif; letter-spacing: 2px; opacity: .55; }
#done.ready #doneSkip { visibility: hidden; }

#confetti { position: absolute !important; inset: 0; pointer-events: none; overflow: hidden; }
#confetti i { position: absolute; top: -24px; border-radius: 2px; animation: fall linear both; }
@keyframes fall {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(var(--drift), 105vh) rotate(var(--spin)); opacity: 0; }
}

.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.big { background: #e2452c; border: 3px solid #000; border-radius: 12px; padding: 12px 20px; font-size: 16px; box-shadow: 0 5px 0 #000; }
.big.alt { background: #2a3050; }
.big.ad { background: #1f8f3a; }
.big:disabled { opacity: .55; }
.big:hover { transform: translateY(-2px); }

@media (max-width: 640px) {
  #cards { flex-wrap: wrap; }
  #cards .card { flex: 1 1 28%; max-width: 31%; padding: 5px 6px 8px; }
  #cards .card .stat { display: none; }
  #cards .card img { aspect-ratio: 1 / .78; }
  #score { font-size: 26px; }
  #hudMid { top: 46px; width: 60vw; }
  #time { font-size: 15px; }
  body.touch #special { top: 92px; }
  .tbtn.small { top: 96px; }
}

/* ---------- Short screens: a phone held sideways ---------- */
/* Everything is tightened so that no screen runs off the top or bottom. */
.overlay { overflow-y: auto; }
@media (max-height: 520px), (max-height: 600px) and (min-width: 760px) {
  .overlay { gap: 4px; padding: 8px 14px; }
  h1 { font-size: clamp(22px, 9vh, 40px); }
  .sub { margin: 0 0 4px; font-size: 12px; }
  .card { padding: 5px 6px 7px; border-radius: 12px; }
  .card img { aspect-ratio: auto; width: 100%; height: 30vh; }
  .card .stat { display: none; }
  .card h2 { margin-top: 3px; font-size: 15px; }
  .card .kind, .card .blurb { font-size: 9px; margin-top: 2px; }
  .card .move { margin-top: 3px; font-size: 10px; }
  .card .mini { margin-top: 4px; }
  .card .mini i { width: 12px; height: 12px; }
  .big { padding: 7px 14px; font-size: 12px; box-shadow: 0 3px 0 #000; }
  #btnHowTo, #btnBack { margin-top: 6px; padding: 6px 12px; font-size: 11px; }
  #unlockImg { height: 30vh; }
  #unlockName { font-size: clamp(18px, 7vh, 30px); }
  #loadBar { height: 16px; }

  /* The goals list and the tutorial tuck in beside the controls. */
  body.touch #goals { top: 112px; }
  body.touch #goals div { max-width: 34vw; }
  body.touch #tutorial { bottom: 10px; max-width: 46vw; padding: 6px 8px 6px 12px; font-size: 12px; gap: 8px; }
  body.touch #special { top: 48px; }

  /* Results in two columns: the score on the left, the details and buttons on the right. */
  #done { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: min-content; align-content: center; justify-items: center; align-items: center; gap: 4px 22px; padding: 8px 22px; }
  #doneTitle { grid-column: 1 / 3; grid-row: 1; }
  #doneRank { grid-column: 1; grid-row: 2; font-size: clamp(13px, 5vh, 20px); min-height: 0; }
  #stars { grid-column: 1; grid-row: 3; }
  #doneScoreBox { grid-column: 1; grid-row: 4; }
  #goal { grid-column: 1; grid-row: 5; width: 100%; margin-bottom: 18px; }
  #doneGoals { grid-column: 2; grid-row: 2 / 4; width: 100%; font-size: 11px; }
  #doneStats { grid-column: 2; grid-row: 4; gap: 4px 16px; }
  #doneButtons { grid-column: 2; grid-row: 5; }
  #doneSkip { display: none; }
  .star { width: clamp(26px, 10vh, 44px); }
  #doneScoreBox span { display: none; }
  #doneScoreBox b { font-size: clamp(30px, 14vh, 56px); }
  #doneStats span { font-size: 9px; letter-spacing: 1px; }
  #doneStats b { font-size: clamp(15px, 6vh, 22px); }
  #doneGoals div { padding: 3px 10px; }
  .mark { top: -23px; }
  .mark i { width: 20px; height: 20px; }
  .mark { width: 20px; margin-left: -10px; }
}

/* ---------- Every screen shape, from very tall (9:32) to very wide (32:9) ---------- */
/* If a screen still cannot fit, it scrolls from the top instead of losing its heading. */
.overlay { justify-content: safe center; }

/* Mid widths: the keyboard hints move above the corner button, and the bars above them. */
@media (max-width: 900px) {
  #hints { bottom: 44px; padding: 0 10px; font-size: 10px; }
  #special { bottom: 78px; }
  #tutorial { bottom: 118px; }
}
/* Narrow: the special bar joins the top stack; the combo moves to the right edge. */
@media (max-width: 640px) {
  #special { bottom: auto; top: 92px; }
  #specialBar { width: min(200px, 100vw - 150px); margin-left: auto; margin-right: auto; }
  #combo { position: fixed; right: 14px; top: 156px; margin: 0; text-align: right; font-size: 13px; }
  #comboMult { font-size: 19px; }
  #comboBar { width: 84px; margin-left: auto; }
  #goals div { max-width: calc(100vw - 132px); }
  #tutorial { bottom: 104px; }
}
/* Very narrow: smaller numbers, and the corner button lifts clear of the touch buttons. */
@media (max-width: 300px) {
  #score { font-size: 19px; }
  #hudLeft { left: 8px; }
  #hudRight { right: 6px; gap: 4px; }
  #time { font-size: 13px; margin-right: 0; }
  #hudRight button { padding: 4px 5px; font-size: 9px; letter-spacing: 0; }
  #goals { left: 8px; font-size: 11px; }
  body.touch #btnMenu { bottom: 236px; }
  body.touch #tutorial { bottom: 274px; }
}
/* Short and wide: the hints and bars sit beside the corner button, not on it. */
@media (max-height: 520px) and (min-width: 641px) {
  #goals div { max-width: 30vw; }
}
/* Short and narrow (a small square): two rows of small cards, and a tighter results page. */
@media (max-height: 520px) and (max-width: 640px) {
  #cards .card img { height: 17vh; }
  #cards .card .kind, #cityCards .card .blurb { display: none; }
  body.touch #goals { top: 156px; }
  body.touch #goals div { max-width: calc(100vw - 132px); }
  body.touch #special { top: 92px; }
  body.touch #tutorial { bottom: 236px; max-width: 94vw; }
  /* No room for both: the goals wait until the tutorial has finished. */
  body:has(#tutorial:not(.hidden)) #goals { display: none; }
  #done { gap: 3px 12px; padding: 6px 12px; }
  #doneGoals { font-size: 10px; }
  #doneGoals div { padding: 2px 8px; }
  #doneButtons { gap: 6px; }
  #doneButtons .big { padding: 6px 10px; font-size: 11px; }
}
@media (max-height: 520px), (max-height: 600px) and (min-width: 760px) {
  #done { overflow: hidden auto; align-content: safe center; }
}
/* Narrow with a mouse: the goals sit under the special bar. */
@media (max-width: 640px) {
  #goals { top: 132px; }
}
/* Narrow and not very tall: shorter monster pictures so two rows of cards fit. */
@media (max-width: 640px) and (max-height: 700px) {
  #cards .card img { max-height: 15vh; }
}
/* A small square: smaller touch buttons, so the goals and combo have room above them. */
@media (max-height: 520px) and (max-width: 640px) {
  .tbtn { width: 62px; height: 62px; font-size: 10px; }
  #tPunch { width: 74px; height: 74px; right: 14px; bottom: 18px; font-size: 11px; }
  #tSpecial { right: 98px; bottom: 12px; }
  #tJump { right: 20px; bottom: 100px; }
  #tGrab { right: 92px; bottom: 84px; }
  .tbtn.small { width: 44px; height: 44px; }
  body.touch #tutorial { bottom: 172px; }
}

/* Wide screens: the combo sits in the middle under the bars, clear of the goals and buttons. */
@media (min-width: 641px) {
  #combo { position: fixed; left: 50%; top: 56px; transform: translateX(-50%); margin: 0; text-align: center; white-space: nowrap; }
  #comboBar { margin-left: auto; margin-right: auto; }
  body.touch #combo { top: 88px; }
  /* The keyboard hints keep clear of the corner button. */
  #hints { left: 120px; right: 120px; }
}
/* Very short and wide (32:9 on a small screen): smaller touch buttons. */
@media (max-height: 340px) and (min-width: 641px) {
  .tbtn { width: 62px; height: 62px; font-size: 10px; }
  #tPunch { width: 74px; height: 74px; right: 14px; bottom: 18px; font-size: 11px; }
  #tSpecial { right: 98px; bottom: 12px; }
  #tJump { right: 20px; bottom: 100px; }
  #tGrab { right: 92px; bottom: 84px; }
  .tbtn.small { width: 44px; height: 44px; }
}

/* ---------- Rank, Daily Smash and skins ---------- */
#rankLine { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 10px; margin: -6px 0 10px; font: 800 clamp(11px, 1.8vw, 14px) 'Segoe UI', system-ui, sans-serif; letter-spacing: .5px; text-shadow: 0 2px 0 #000; }
#rankName, #xpRank { color: #ffd83a; }
#rankBar, #xpBar { width: clamp(90px, 22vw, 200px); height: 10px; background: rgba(0,0,0,.55); border: 2px solid #000; border-radius: 6px; overflow: hidden; }
#rankFill, #xpFill { display: block; height: 100%; background: linear-gradient(90deg, #5fe0ff, #7dff6a); transform-origin: left; transform: scaleX(0); }
#xpFill { transition: transform .9s cubic-bezier(.2, .8, .2, 1); }
#rankNext { opacity: .85; }

#menuButtons { margin-top: 14px; align-items: center; }
#menuButtons #btnHowTo { margin-top: 0; }
#btnDaily { font-size: 14px; padding: 8px 18px; background: linear-gradient(#ffb52a, #e2452c); }
#btnDaily small { display: block; margin-top: 2px; font: 700 10.5px 'Segoe UI', system-ui, sans-serif; letter-spacing: .3px; text-shadow: 0 1px 0 rgba(0,0,0,.6); }
#btnDaily.done { background: #23803f; cursor: default; }
#btnDaily.done:hover { transform: none; }

#coatRow { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; }
#coatLabel { font: 800 12px 'Segoe UI', system-ui, sans-serif; letter-spacing: 1px; text-shadow: 0 2px 0 #000; min-width: 9em; text-align: right; }
#coats { display: flex; gap: 9px; }
.coat { position: relative; width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 3px solid #000; box-shadow: 0 3px 0 #000; }
.coat.on { outline: 3px solid #ffd83a; outline-offset: 2px; }
.coat.locked { background-image: linear-gradient(rgba(8,10,22,.68), rgba(8,10,22,.68)); }
.coat.locked::after { content: attr(data-rank); position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 800 12px 'Segoe UI', system-ui, sans-serif; color: #fff; text-shadow: 0 1px 0 #000; }

#doneXp { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; font: 800 clamp(11px, 1.9vw, 14px) 'Segoe UI', system-ui, sans-serif; letter-spacing: .5px; text-shadow: 0 2px 0 #000; opacity: 0; transform: translateY(10px); }
#doneXp.in { opacity: 1; transform: none; transition: opacity .25s, transform .3s cubic-bezier(.2, 1.5, .3, 1); }
#xpGain { color: #7dff6a; }
#xpNews { flex-basis: 100%; font-family: 'Luckiest Guy', 'Arial Black', sans-serif; font-weight: normal; font-size: clamp(14px, 2.8vw, 22px); letter-spacing: 1px; color: #5fe0ff; text-shadow: 0 3px 0 #000, 0 0 16px rgba(95,224,255,.7); }
#xpNews:empty { display: none; }
#xpNews.pop { animation: starPop .6s cubic-bezier(.2, 1.7, .3, 1) both; }
#doneGoals .daily { color: #ffd83a; }

@media (max-width: 640px) {
  #coatLabel { min-width: 0; flex-basis: 100%; text-align: center; }
}
/* Short screens: the same things, smaller, and the results keep their two columns. */
@media (max-height: 520px), (max-height: 600px) and (min-width: 760px) {
  #menu .sub { display: none; }
  #rankLine { margin: 0 0 2px; font-size: 10.5px; }
  #rankBar { height: 8px; }
  #menuButtons { margin-top: 6px; gap: 8px; }
  #btnDaily { padding: 4px 12px; font-size: 11px; }
  #btnDaily small { font-size: 9px; margin-top: 0; }
  #coatRow { margin-top: 5px; }
  .coat { width: 26px; height: 26px; border-width: 2px; }
  #coatLabel { font-size: 10.5px; }
  #doneXp { grid-column: 2; grid-row: 5; font-size: 10.5px; gap: 2px 8px; }
  #xpBar { height: 8px; }
  #xpNews { font-size: clamp(12px, 4.5vh, 16px); }
  #doneButtons { grid-row: 6; }
  #goal { grid-row: 5 / 7; }
}
/* The new rows on the tightest screens. */
#coats { flex-wrap: wrap; justify-content: center; }
@media (max-width: 300px) {
  .coat { width: 26px; height: 26px; border-width: 2px; }
  #coats { gap: 6px; }
  #btnDaily { padding: 7px 10px; font-size: 12px; }
}
@media (max-height: 340px) and (min-width: 641px) {
  #cityMenu .sub { display: none; }
  #cityMenu .card img { height: 24vh; }
  #coatRow { margin-top: 3px; }
  #btnBack { margin-top: 3px; }
}
@media (max-height: 520px) and (max-width: 640px) {
  #xpBar { display: none; }
  #doneStats b { font-size: 14px; }
  #doneStats span { font-size: 8px; }
  #doneRank { display: none; }
  .star { width: 24px; }
}

/* ---------- Languages without Latin letters (Japanese, Korean) ---------- */
/* The display font has no glyphs for them, so their text falls back to the device's own
   font. It is asked for at a heavy weight to keep the chunky look; the display font itself
   (still used for numbers and Latin letters) must not be artificially thickened. */
body.own-script {
  font-family: 'Luckiest Guy', 'Hiragino Sans', 'Noto Sans CJK JP', 'Noto Sans JP', 'Noto Sans CJK KR', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Yu Gothic', system-ui, sans-serif;
  letter-spacing: 0;
}
body.own-script, body.own-script * { font-weight: 800 !important; font-synthesis-weight: none; }
body.own-script .card .kind { letter-spacing: 0; }

/* ---------- Longer words in other languages ---------- */
.card .kind, .card .move, .card h2, .tbtn, #btnDaily, .big { overflow-wrap: anywhere; }
.tbtn { line-height: 1.05; padding: 0 5px; }
#tSpecial, #tGrab { font-size: 11px; }
#doneStats > div { max-width: 46vw; }
@media (max-width: 640px) {
  /* A long special-attack name must not push its bar under the camera buttons. */
  #special { max-width: calc(100vw - 150px); }
  #specialName { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- Monster pick: tall banner cards in a row that scrolls sideways ----------
   Scoped to :is(#menu #cards, #cityMenu #cityCards) so it overrides every earlier .card rule, at every screen shape.
   Card size: as wide as fits two-and-a-bit on a portrait phone, all five in landscape, and never
   taller than about half the screen. The art is 2:3, the same shape as the card. */
:is(#menu #cards, #cityMenu #cityCards) {
  --cw: min(72vw, 340px, calc(74vh * 0.6667));
  display: flex; flex-wrap: nowrap; justify-content: safe center; gap: 12px;
  /* Edge to edge, so the next card peeks in from the side and shows the row scrolls. */
  width: 100vw; max-width: none; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
  padding: 6px 16px 14px; box-sizing: border-box;
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-padding: 0 16px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
:is(#menu #cards, #cityMenu #cityCards)::-webkit-scrollbar { display: none; }
#menu, #cityMenu { overflow-x: hidden; }
/* The banners carry the screen: no title or subtitle above them. */
#menu > h1, #menu > .sub, #cityMenu > h1, #cityMenu > .sub { display: none; }
#menu #rankLine { margin: 0 0 4px; }
:is(#menu #cards, #cityMenu #cityCards) .card {
  flex: 0 0 auto; width: var(--cw); max-width: none; height: calc(var(--cw) * 1.5);
  padding: 0; overflow: hidden; scroll-snap-align: center; container-type: inline-size;
  border: 3px solid #000; border-radius: 16px;
  box-shadow: 0 6px 0 #000, inset 0 0 0 2px rgba(255,255,255,.14);
  background: radial-gradient(circle at 50% 38%, var(--accent, #ff9a3a) 0%, #3a2370 58%, #140d2c 100%);
}
:is(#menu #cards, #cityMenu #cityCards) .card:hover, :is(#menu #cards, #cityMenu #cityCards) .card:focus-visible { transform: translateY(-6px); border-color: #ffd83a; }
:is(#menu #cards, #cityMenu #cityCards) .card .art {
  position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; max-height: none;
  object-fit: cover; object-position: 50% 20%; border-radius: 0; background: none;
}
/* Monsters without banner art yet: their 3D picture, standing on the glow. */
:is(#menu #cards, #cityMenu #cityCards) .card .art.render { object-fit: contain; object-position: 50% 30%; inset: 4% 6% 30%; width: 88%; height: 66%; }
:is(#menu #cards, #cityMenu #cityCards) .card .info {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26% 8px 9px;
  background: linear-gradient(transparent, rgba(10,8,26,.82) 45%, rgba(10,8,26,.95));
}
:is(#menu #cards, #cityMenu #cityCards) .card h2 { margin: 0; font-size: clamp(16px, 13cqw, 30px); line-height: 1; }
:is(#menu #cards, #cityMenu #cityCards) .card .kind { display: block; margin-top: 2px; font-size: clamp(9px, 6.4cqw, 13px); }
:is(#menu #cards, #cityMenu #cityCards) .card .stats { display: none; margin-top: 4px; }
:is(#menu #cards, #cityMenu #cityCards) .card .stat { display: flex; margin-top: 3px; font-size: 10px; }
:is(#menu #cards, #cityMenu #cityCards) .card .stat span { width: 38px; }
:is(#menu #cards, #cityMenu #cityCards) .card .move { margin-top: 4px; font-size: clamp(9px, 6.4cqw, 13px); }
@container (min-width: 190px) { :is(#menu #cards, #cityMenu #cityCards) .card .stats { display: block; } }
/* Locked bonus monster: a glowing silhouette, details hidden. */
:is(#menu #cards, #cityMenu #cityCards) .card.locked { border-color: #7d58cc; background: radial-gradient(circle at 50% 38%, #6a46c8 0%, #2a1d5c 58%, #120d2a 100%); }
:is(#menu #cards, #cityMenu #cityCards) .card.locked .art { filter: brightness(0) drop-shadow(0 0 10px #a77bff); }
:is(#menu #cards, #cityMenu #cityCards) .card.locked .lock { top: 40%; z-index: 1; }
/* A locked monster with banner art: the silhouette instead, until it's earned. */
:is(#menu #cards, #cityMenu #cityCards) .card .lockArt { display: none; }
:is(#menu #cards, #cityMenu #cityCards) .card.locked .lockArt { display: block; }
:is(#menu #cards, #cityMenu #cityCards) .card.locked picture { display: none; }
:is(#menu #cards, #cityMenu #cityCards) .card.locked .stats, :is(#menu #cards, #cityMenu #cityCards) .card.locked .move, :is(#menu #cards, #cityMenu #cityCards) .card.locked .kind { visibility: hidden; }
:is(#menu #cards, #cityMenu #cityCards) .card.locked h2 { font-size: 0; }
:is(#menu #cards, #cityMenu #cityCards) .card.locked h2::after { font-size: clamp(16px, 13cqw, 30px); }
/* Daily Smash and How to Play are off the menu (new players still get the tutorial). */
#menu #menuButtons { display: none; }
.mArrow, #mDots, #cDots, :is(#menu #cards, #cityMenu #cityCards) .card .go { display: none; }

/* ---------- One monster fills the screen (both orientations); arrows and dots move between them ---------- */
#menu, #cityMenu { padding: 0; justify-content: flex-start; overflow: hidden; }
#menu #rankLine {
  position: absolute; z-index: 3; left: 0; right: 0; top: 0; margin: 0;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 18px;
  background: linear-gradient(rgba(8,6,22,.75), transparent);
}
:is(#menu #cards, #cityMenu #cityCards) { --cw: 100vw; gap: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; scroll-padding: 0; }
:is(#menu #cards, #cityMenu #cityCards) .card {
  width: 100vw; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; scroll-snap-stop: always;
  background: radial-gradient(circle at 50% 30%, var(--accent, #ff9a3a) 0%, #3a2370 45%, #120c28 80%);
}
:is(#menu #cards, #cityMenu #cityCards) .card:hover, :is(#menu #cards, #cityMenu #cityCards) .card:focus-visible { transform: none; }
:is(#menu #cards, #cityMenu #cityCards) .card { text-align: center; } /* (it was a button, which centres by itself) */
:is(#menu #cards, #cityMenu #cityCards) .card .stats { display: block; }
:is(#menu #cards, #cityMenu #cityCards) .card .pips i { height: 9px; }
:is(#menu #cards, #cityMenu #cityCards) .card .go {
  display: inline-block; padding: 12px 46px; border: 3px solid #000; border-radius: 14px;
  background: linear-gradient(#ffd83a, #ff9a1e); color: #2a1300; box-shadow: 0 5px 0 #000; text-shadow: none;
}
:is(#menu #cards, #cityMenu #cityCards) .card.locked .go { background: linear-gradient(#b48cff, #7d58cc); color: #fff; }
.mArrow {
  display: flex; align-items: center; justify-content: center; position: absolute; z-index: 3;
  width: 46px; height: 64px; padding: 0 0 6px; border: 3px solid #000; border-radius: 14px;
  background: rgba(12,8,30,.6); color: #ffd83a; font-size: 44px; line-height: 1; box-shadow: 0 4px 0 #000;
}
#mPrev, #cPrev { left: calc(env(safe-area-inset-left) + 8px); }
#mNext, #cNext { right: calc(env(safe-area-inset-right) + 8px); }
.mArrow.off { visibility: hidden; }
#mDots, #cDots { display: flex; gap: 8px; position: absolute; z-index: 3; left: 0; right: 0; justify-content: center; top: calc(env(safe-area-inset-top) + 40px); pointer-events: none; }
#mDots i, #cDots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.35); border: 2px solid #000; }
#mDots i.on, #cDots i.on { background: #ffd83a; }

/* Landscape: the wide banner fills the screen; the details sit on the right over a dark fade. */
@media (orientation: landscape) {
  /* The left three-quarters, so the monster stays clear of the details; it fades out under them. */
  :is(#menu #cards, #cityMenu #cityCards) .card .art {
    inset: 0 auto 0 0; width: 74%; height: 100%; aspect-ratio: auto; object-fit: cover; object-position: 50% 0;
    -webkit-mask-image: linear-gradient(90deg, #000 76%, transparent); mask-image: linear-gradient(90deg, #000 76%, transparent);
  }
  /* Only a tall banner, or just the 3D picture: shown whole, left of the details. */
  :is(#menu #cards, #cityMenu #cityCards) .card .art.tallOnly, :is(#menu #cards, #cityMenu #cityCards) .card .art.render { inset: 8% auto 4% 6%; width: 52%; height: 88%; object-fit: contain; object-position: 50% 50%; }
  :is(#menu #cards, #cityMenu #cityCards) .card .info {
    top: 0; left: auto; width: min(42vw, 420px); box-sizing: border-box;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: calc(env(safe-area-inset-top) + 44px) calc(env(safe-area-inset-right) + 70px) calc(env(safe-area-inset-bottom) + 14px) 34px;
    background: linear-gradient(90deg, transparent, rgba(12,8,30,.82) 26%, rgba(12,8,30,.94));
  }
  :is(#menu #cards, #cityMenu #cityCards) .card h2 { font-size: clamp(26px, 9vh, 52px); }
  :is(#menu #cards, #cityMenu #cityCards) .card .kind { font-size: clamp(11px, 3.4vh, 16px); margin-top: 2px; }
  :is(#menu #cards, #cityMenu #cityCards) .card .stats { width: 100%; max-width: 300px; margin-top: 2vh; }
  :is(#menu #cards, #cityMenu #cityCards) .card .stat { font-size: clamp(10px, 3vh, 14px); margin-top: 1vh; }
  :is(#menu #cards, #cityMenu #cityCards) .card .stat span { width: 56px; }
  :is(#menu #cards, #cityMenu #cityCards) .card .move { margin-top: 2vh; font-size: clamp(12px, 3.8vh, 18px); }
  :is(#menu #cards, #cityMenu #cityCards) .card .go { margin-top: 3vh; padding: 1.6vh 40px; font-size: clamp(16px, 5.5vh, 28px); }
  :is(#menu #cards, #cityMenu #cityCards) .card.locked .lock { top: 36%; left: 6%; right: auto; width: 52%; }
  .mArrow { top: calc(50% - 32px); }
}

/* Portrait: the tall banner across the top; the details below it. */
@media (orientation: portrait) {
  /* The art across the full width at the top, in its own 2:3 shape. */
  :is(#menu #cards, #cityMenu #cityCards) .card .art { inset: 0 0 auto; height: auto; aspect-ratio: 2 / 3; object-position: 50% 0; }
  :is(#menu #cards, #cityMenu #cityCards) .card .art.render { inset: 12% 8% auto; width: 84%; height: 50%; aspect-ratio: auto; object-fit: contain; }
  :is(#menu #cards, #cityMenu #cityCards) .card .info {
    padding: 34vw 22px calc(env(safe-area-inset-bottom) + 26px);
    background: linear-gradient(transparent, rgba(12,8,30,.88) 30%, #0c081e 60%);
  }
  :is(#menu #cards, #cityMenu #cityCards) .card h2 { font-size: clamp(34px, 12vw, 60px); }
  :is(#menu #cards, #cityMenu #cityCards) .card .kind { font-size: clamp(13px, 4vw, 18px); margin-top: 4px; }
  :is(#menu #cards, #cityMenu #cityCards) .card .stats { max-width: 420px; margin: 12px auto 0; }
  :is(#menu #cards, #cityMenu #cityCards) .card .stat { font-size: clamp(12px, 3.6vw, 15px); margin-top: 6px; }
  :is(#menu #cards, #cityMenu #cityCards) .card .stat span { width: 64px; }
  :is(#menu #cards, #cityMenu #cityCards) .card .move { margin-top: 12px; font-size: clamp(14px, 4.4vw, 20px); }
  :is(#menu #cards, #cityMenu #cityCards) .card .go { margin-top: 16px; font-size: clamp(20px, 6.5vw, 30px); }
  :is(#menu #cards, #cityMenu #cityCards) .card.locked .lock { top: 30%; }
  .mArrow { top: 34%; }
}

/* ---------- Title screen: painted key art, the title in its sky, three buttons at the bottom ---------- */
#intro { padding: 0; justify-content: space-between; overflow: hidden; background: radial-gradient(circle at 50% 40%, #6a46c8, #120c28 75%); }
#introArt, #introArt img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
#intro::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(rgba(8,6,22,.35), transparent 22%, transparent 55%, rgba(8,6,22,.9)); }
#intro h1 {
  position: relative; z-index: 1; margin: 0; padding: calc(env(safe-area-inset-top) + 5vh) 16px 0;
  font-size: clamp(46px, 15vw, 96px);
}
#introButtons {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: stretch; gap: 12px;
  width: min(86vw, 360px); padding-bottom: calc(env(safe-area-inset-bottom) + 6vh);
}
#introButtons .big { margin: 0; padding: 14px 20px; font-size: clamp(18px, 5.4vw, 24px); border-radius: 16px; }
#btnFree { background: linear-gradient(#ffd83a, #ff9a1e); color: #2a1300; text-shadow: none; }
#introButtons #btnDaily { font-size: clamp(16px, 4.8vw, 21px); }
#introButtons #btnDaily small { font-size: clamp(10px, 3vw, 12px); }
#introButtons #btnHowTo { font-size: clamp(14px, 4.2vw, 18px); padding: 11px 20px; }
@media (orientation: landscape) {
  #intro h1 { padding-top: calc(env(safe-area-inset-top) + 3vh); font-size: clamp(40px, 13vh, 80px); }
  /* Side by side along the bottom. */
  #introButtons { flex-direction: row; align-items: stretch; width: min(92vw, 860px); padding-bottom: calc(env(safe-area-inset-bottom) + 4vh); }
  #introButtons .big { flex: 1; padding: 10px 14px; font-size: clamp(15px, 5vh, 22px); }
  #introButtons #btnDaily { font-size: clamp(14px, 4.4vh, 19px); }
  #introButtons #btnHowTo { font-size: clamp(13px, 4vh, 17px); }
}

/* DAILY QUESTS and HOW TO PLAY share a row under the main buttons. */
#introRow { display: flex; gap: 12px; }
#introRow .big { flex: 1; position: relative; }
#questBadge { position: absolute; top: -10px; right: -8px; min-width: 22px; padding: 2px 6px; border: 2px solid #000; border-radius: 12px; background: #ffd83a; color: #2a1300; font: 800 12px 'Segoe UI', system-ui, sans-serif; font-style: normal; text-shadow: none; }
#questBadge:empty { display: none; }
#questBadge.alert { background: #ff4a3a; color: #fff; animation: pulse .8s ease-in-out infinite alternate; }
@media (orientation: landscape) {
  #introRow { flex: 1; }
  #introRow .big { font-size: clamp(13px, 4vh, 17px); padding: 10px 10px; }
}

/* The daily quests panel. */
#quests { z-index: 6; background: rgba(6,4,16,.82); }
#questsBox {
  width: min(92vw, 460px); max-height: 92dvh; overflow: auto; box-sizing: border-box; padding: 18px 18px 16px;
  background: linear-gradient(#262a44, #151828); border: 3px solid #000; border-radius: 18px; box-shadow: 0 6px 0 #000;
  display: flex; flex-direction: column; align-items: stretch; gap: 10px; text-align: left;
}
#questsBox h2 { margin: 0; text-align: center; color: #ffd83a; font-size: clamp(24px, 7vw, 34px); text-shadow: 0 3px 0 #000; }
#questStreak { text-align: center; font: 800 15px 'Segoe UI', system-ui, sans-serif; color: #ffb52a; text-shadow: 0 2px 0 #000; }
.quest { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 12px; border: 2px solid #000; border-radius: 12px; background: rgba(255,255,255,.06); }
.quest b { font: 700 15px 'Segoe UI', system-ui, sans-serif; text-shadow: 0 1px 0 #000; }
.quest .xp { font: 800 13px 'Segoe UI', system-ui, sans-serif; color: #5fe0ff; text-shadow: 0 1px 0 #000; }
.quest .bar { grid-column: 1 / 3; height: 10px; border: 2px solid #000; border-radius: 6px; background: rgba(0,0,0,.4); overflow: hidden; }
.quest .bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffd83a, #ff8a1e); }
.quest .count { grid-column: 1 / 3; font: 700 12px 'Segoe UI', system-ui, sans-serif; opacity: .75; margin-top: -2px; }
.quest.done { background: rgba(60,196,122,.18); border-color: #23803f; }
.quest.done .bar i { background: linear-gradient(90deg, #7dff6a, #3cc47a); }
.quest.done b::before { content: '✓ '; color: #7dff6a; }
#questAll { margin: 2px 0 0; text-align: center; font: 700 13px 'Segoe UI', system-ui, sans-serif; opacity: .85; }
#questRescue { padding: 12px; border: 2px solid #ff4a3a; border-radius: 12px; background: rgba(255,74,58,.14); text-align: center; }
#questRescue p { margin: 0 0 10px; font: 700 14px 'Segoe UI', system-ui, sans-serif; }
#questRescue .big, #btnQuestsClose { margin: 0; }

/* Monster pick: BACK to the title screen, top left; the rank line makes room for it. */
#menu #btnHome {
  position: absolute; z-index: 4; top: calc(env(safe-area-inset-top) + 8px); left: calc(env(safe-area-inset-left) + 10px);
  margin: 0; padding: 8px 14px; font-size: clamp(13px, 3.6vw, 17px);
}
#menu #rankLine { padding-left: calc(env(safe-area-inset-left) + 92px); justify-content: flex-start; }
#menu #mDots { top: calc(env(safe-area-inset-top) + 66px); } /* below the rank line, which can wrap beside BACK */

/* ---------- City pick: the same full-screen cards; BACK and the skin row in a bar across the top ---------- */
#cityMenu #cityTop {
  position: absolute; z-index: 3; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 10px) 22px calc(env(safe-area-inset-left) + 10px);
  background: linear-gradient(rgba(8,6,22,.8), transparent);
}
#cityMenu #btnBack { margin: 0; padding: 8px 14px; font-size: clamp(13px, 3.6vw, 17px); flex: none; }
#cityMenu #coatRow { flex: 1; margin: 0; gap: 2px 8px; }
#cityMenu #coatRow .coat { width: 30px; height: 30px; }
#cityMenu #coatLabel { flex-basis: 100%; min-width: 0; text-align: center; font-size: 11px; }
#cityMenu #cDots { top: calc(env(safe-area-inset-top) + 74px); }
#cityMenu #cityCards .card .mini { margin-top: 10px; gap: 6px; }
#cityMenu #cityCards .card .mini i { width: clamp(20px, 6vw, 30px); height: clamp(20px, 6vw, 30px); }
#cityMenu #cityCards .card h2 { margin-top: 0; }
@media (orientation: portrait) {
  /* The street at the bottom of the picture fades into the details instead of ending in a line. */
  #cityMenu #cityCards .card .art { -webkit-mask-image: linear-gradient(#000 72%, transparent 98%); mask-image: linear-gradient(#000 72%, transparent 98%); }
}
@media (orientation: landscape) {
  #cityMenu #cityCards .card .mini i { width: clamp(18px, 6vh, 30px); height: clamp(18px, 6vh, 30px); }
  #cityMenu #cityCards .card .info { padding-top: calc(env(safe-area-inset-top) + 64px); }
  /* The bar spans the art only, clear of the details on the right. */
  #cityMenu #cityTop { right: min(42vw, 420px); }
}

/* Between a pick screen and a round: a solid screen with a small spinner while the city is built and
   first drawn, so nothing half-ready shows. It fades out onto the round. */
#cityLoad {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  transition: opacity .2s;
  background: radial-gradient(circle at 50% 45%, #2a1d5c, #0c081e 70%); font: 800 clamp(15px, 4vw, 20px) 'Luckiest Guy', 'Segoe UI', sans-serif; letter-spacing: 1px; color: #ffd83a; text-shadow: 0 2px 0 #000;
}
#cityLoad.hidden { display: none; }
#cityLoad.fade { opacity: 0; }
#cityLoad .spinner { width: 44px; height: 44px; border-radius: 50%; border: 5px solid rgba(255,255,255,.2); border-top-color: #ffd83a; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Combo pad (touch) ----------
   Console-style face buttons in a diamond for the right thumb: PUNCH left (blue), SMASH top
   (yellow), GRAB right (purple), JUMP bottom (green), and SPECIAL above in the special's colour.
   The whole pad is one block, scaled down on small screens. Overrides the old .tbtn layout. */
#pad { position: absolute; right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); width: 236px; height: 300px; transform-origin: 100% 100%; pointer-events: none; }
#pad .tbtn {
  width: 74px; height: 74px; padding: 0; opacity: .92; font-size: 12px; letter-spacing: .3px; line-height: 1;
  color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.7); border: 3px solid #000;
  box-shadow: 0 4px 0 #000, inset 0 -6px 0 rgba(0,0,0,.22), inset 0 4px 0 rgba(255,255,255,.25);
}
#pad .tbtn:active { transform: translateY(3px) scale(.95); box-shadow: 0 1px 0 #000, inset 0 -3px 0 rgba(0,0,0,.22); }
/* Diamond centred 118px from the right and 118px from the bottom of the pad, 76px apart. */
#pad #tPunch { right: 157px; bottom: 81px; background: radial-gradient(circle at 50% 35%, #5aa8ff, #2a6fd6); }
#pad #tSmash { right: 81px; bottom: 157px; background: radial-gradient(circle at 50% 35%, #ffd84a, #e8a417); color: #3a2200; text-shadow: none; }
#pad #tGrab { right: 5px; bottom: 81px; background: radial-gradient(circle at 50% 35%, #c08cff, #7d4fd6); }
#pad #tJump { right: 81px; bottom: 5px; background: radial-gradient(circle at 50% 35%, #6be07a, #2f9a48); }
#pad #tSpecial {
  right: 70px; bottom: 238px; width: 96px; height: 50px; border-radius: 25px; font-size: 11px;
  background: linear-gradient(#ff8a4a, #e2452c);
}
@media (max-height: 520px), (max-width: 380px) { #pad { transform: scale(.82); } }
@media (max-height: 400px) { #pad { transform: scale(.7); } }
/* Portrait phones: the pad (with SPECIAL on top) takes the lower third, so the tutorial goes up
   where the goals list sits, under the top bars and clear of the monster; the goals wait until
   the tutorial is done. */
@media (orientation: portrait) {
  body.touch #tutorial { top: calc(env(safe-area-inset-top) + 152px); bottom: auto; width: 94vw; max-width: 520px; box-sizing: border-box; }
  body.touch:has(#tutorial:not(.hidden)) #goals { display: none; }
}

/* A combo move's name, big over the monster. */
.pop.move { font-size: 30px; color: #5fe0ff; letter-spacing: 1px; text-shadow: 0 3px 0 #000, 0 0 8px rgba(0,0,0,.6); }

/* The rampage boost offer (a rewarded ad during a round): low on the right on a computer, clear of
   the hints and special bar; above the combo pad on a touch screen, or beside it when short. */
#btnBoost { position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(110px, env(safe-area-inset-bottom)); pointer-events: auto; touch-action: none; background: #1f8f3a; border: 3px solid #000; border-radius: 12px; padding: 9px 14px; font-size: 13px; letter-spacing: 1px; text-shadow: 0 2px 0 #000; box-shadow: 0 4px 0 #000; animation: boostIn .35s ease-out, boostPulse 1.6s ease-in-out .35s infinite; }
#btnBoost:hover { background: #26a845; }
#btnBoost.on { background: #e2452c; animation: none; }
#btnBoost:disabled:not(.on) { opacity: .6; }
body.touch #btnBoost { bottom: 318px; }
@media (max-width: 380px) { body.touch #btnBoost { bottom: 262px; } }
@media (max-height: 520px) { body.touch #btnBoost { bottom: max(14px, env(safe-area-inset-bottom)); right: 214px; } }
@media (max-height: 400px) { body.touch #btnBoost { right: 186px; } }
@keyframes boostIn { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes boostPulse { 50% { transform: scale(1.06); } }
