/* Wreck the Workplace. The look and layout of every screen are Monster City's: chunky
   yellow lettering with hard black shadows, dark panels and red buttons. Sizes are in pixels and
   screen shares, as there; only the touch pad is scaled as a whole, by --pad (src/main.js). */
:root { --pad: 1; }

/* 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; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #2a1f3d;
  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; touch-action: none; }
.hidden { display: none !important; }
/* On YouTube the player uses YouTube's own mute button, so the game's are hidden. */
body.hostMute #btnMute, body.hostMute #btnSound { 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; }
body.rampage #score { color: #ff7a2a; }
#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; }
#wreckPct { color: #ffd83a; }
#pctBar { height: 12px; background: rgba(0,0,0,.5); border: 2px solid #000; border-radius: 7px; margin-top: 4px; overflow: hidden; }
#wreckFill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffb52a, #ff4a1e); transform: scaleX(0); transform-origin: left; transition: transform .25s; }
/* The rewarded ad offered during play sits under the bar. */
#btnRampage { pointer-events: auto; margin-top: 10px; padding: 6px 14px; font-size: 12px; box-shadow: 0 3px 0 #000; text-shadow: 0 2px 0 #000; white-space: nowrap; }
/* On YouTube the offer is made plainly: bigger, and it pulses. */
body.eagerAds #btnRampage { padding: 9px 20px; font-size: 15px; background: linear-gradient(#ffcf3a, #ff8a1e); color: #3a1c00; text-shadow: none; animation: rampagePulse 1.1s ease-in-out infinite; }
body.eagerAds #btnRampage.on { animation: none; color: #fff; text-shadow: 0 2px 0 #000; }
@keyframes rampagePulse { 0%, 100% { transform: scale(1); box-shadow: 0 3px 0 #000, 0 0 0 0 rgba(255,207,58,.8); } 50% { transform: scale(1.07); box-shadow: 0 3px 0 #000, 0 0 0 9px rgba(255,207,58,0); } }
#rampageTip { margin-top: 8px; font: 700 12px 'Segoe UI', system-ui, sans-serif; color: #ffe27a; text-shadow: 0 2px 0 #000; }
#btnRampage.on { background: linear-gradient(#ffb52a, #e2452c); pointer-events: none; }

#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 line of help ---------- */
#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 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-align: center; pointer-events: none; }
#tutorial b { color: #ffd83a; }
#tutorialCount { opacity: .6; font-size: .8em; }
#tutorialCount:empty { display: none; }
#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 #hint { opacity: .45; }
#tutorial.big { animation: toastIn .35s cubic-bezier(.2, 1.5, .3, 1); font-family: 'Luckiest Guy', 'Arial Black', sans-serif; font-weight: normal; letter-spacing: 1px; color: #ffd83a; }
@keyframes toastIn { 0% { opacity: 0; transform: translateX(-50%) scale(.7); } }
/* On touch screens it sits near the top, clear of the character and the pad. */
body.touch #tutorial { bottom: auto; top: 176px; }

/* ---------- 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.big { color: #ff7a2a; font-size: 28px; }
.pop.good { color: #7dff6a; }
.pop.oops { color: #fff; font-size: 18px; }

/* ---------- Touch controls ---------- */
/* The walking stick: appears wherever the left thumb lands. */
#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; pointer-events: 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%); }
/* The combo pad: console-style face buttons in a diamond for the right thumb. */
#pad {
  position: absolute; right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom));
  width: 236px; height: 300px; transform: scale(var(--pad)); transform-origin: 100% 100%; pointer-events: none;
}
#pad .tbtn {
  position: absolute; pointer-events: auto; touch-action: none;
  width: 74px; height: 74px; padding: 0 4px; opacity: .94; font-size: 12px; letter-spacing: .3px; line-height: 1.05; border-radius: 50%;
  color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.7); border: 3px solid #000; white-space: normal; overflow-wrap: anywhere;
  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); }
#pad #tPunch { right: 157px; bottom: 81px; background: radial-gradient(circle at 50% 35%, #f0624a, #e2452c); }
#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%, #b98cf0, #9a5fe0); }
#pad #tJump { right: 81px; bottom: 5px; background: radial-gradient(circle at 50% 35%, #6be07a, #46b356); }
/* SPECIAL fills up as it recharges. */
#pad #tSpecial {
  right: 62px; bottom: 238px; width: 112px; height: 50px; border-radius: 25px; font-size: 11px; padding: 0 6px;
  background: linear-gradient(90deg, #2f9be0 calc(var(--fill, 1) * 100%), #4a5068 calc(var(--fill, 1) * 100%));
}
#pad #tSpecial.ready { background: linear-gradient(#4fd8ff, #2f9be0); animation: ready 1.2s infinite; }
@keyframes ready { 50% { filter: brightness(1.25); } }
#pad .tbtn.pulse { 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); } }
/* On a computer with no touch screen, keys do the work: no pad. */
body:not(.touch) #pad, body:not(.touch) #stickZone { display: none; }

/* ---------- The title across the screen (combos, a store's name, STORE WRECKED) ---------- */
#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: four sharp shadows for the outline, no blurred glow. */
#bannerTitle {
  font-size: clamp(38px, 11vw, 112px); line-height: 1; color: var(--hot); letter-spacing: 3px; padding: 0 10px;
  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); }
#bannerBonus:empty { display: none; }
@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(#b3243a, #4a1230); gap: 18px; z-index: 10; }
#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; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; justify-content: safe center; gap: 10px; padding: 16px; background: rgba(8,10,22,.5); text-align: center; overflow-y: auto; }
h1 { margin: 0; font-weight: normal; font-size: clamp(30px, 8vw, 78px); 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); }
h2 { font-weight: normal; }
.credit { margin: 18px 0 0; opacity: 0.7; font: 600 12px 'Segoe UI', system-ui, sans-serif; text-shadow: 0 1px 0 #000; }
.sub { margin: 4px 0 14px; font: 700 clamp(14px, 2.4vw, 20px) 'Segoe UI', system-ui, sans-serif; text-shadow: 0 2px 0 #000; }
#totalLine { 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; }
#totalLine b { color: #ffd83a; }
#cards, #storeCards { display: flex; gap: clamp(8px, 1.6vw, 18px); justify-content: center; width: 100%; max-width: 900px; }
.card { position: relative; 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: cover; display: block; background: radial-gradient(circle at 50% 70%, #3a4170, transparent 70%); border-radius: 10px; }
.card h2 { margin: 8px 0 0; font-size: clamp(13px, 2.8vw, 24px); line-height: 1; color: #ffd83a; text-shadow: 0 2px 0 #000; overflow-wrap: anywhere; }
.card .kind { margin-top: 4px; 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; overflow-wrap: anywhere; }
.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; }
#storeButtons { margin-top: 16px; }
#time.low { color: #ff5a5a; }
#btnEndless.locked { opacity: 0.55; font-size: 13px; }
#btnEndless.lit { background: #ff7a2f; color: #fff; }
#done.endless #stars, #done.endless #goal { display: none; }
#menuButtons { margin-top: 14px; }
#btnSound { font-size: 13px; padding: 9px 16px; }

/* ---------- Locked characters and stores ---------- */
.card.locked { border-color: #7d58cc; background: linear-gradient(#2a2148, #130f24); }
.card.locked img { filter: brightness(.18) saturate(.4) drop-shadow(0 0 10px #a77bff); }
.card.locked .stat, .card.locked .move, .card.locked .mini, .card.locked .blurb { visibility: hidden; }
/* A locked character keeps its name secret until it is earned. */
#cards .card.locked h2 { font-size: 0; }
#cards .card.locked h2::after { content: '? ? ?'; font-size: clamp(13px, 2.8vw, 24px); }
#cards .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: 6px; right: 6px; top: 26%; font-size: clamp(10px, 1.7vw, 15px); line-height: 1.1; 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; }
.card.nope { animation: nope .3s; }
@keyframes nope { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Pause ---------- */
#pause { background: rgba(8,10,22,.8); z-index: 6; }
#credits { background: rgba(8,10,22,.92); z-index: 7; }
#creditLines { max-width: 560px; font: 600 14px 'Segoe UI', system-ui, sans-serif; }
#creditLines p { margin: 0 0 10px; }
#creditLines b { display: block; font: normal 13px 'Luckiest Guy', 'Arial Black', sans-serif; letter-spacing: 1px; color: #ffd83a; }
#btnStartRampage.lit { background: #ff7a2f; color: #fff; }
/* While the host has the game paused: a shield over the page, and every animation stands still. */
#hostShield { display: none; position: fixed; inset: 0; z-index: 1000; }
body.hostPaused #hostShield { display: block; }
body.hostPaused *, body.hostPaused *::before, body.hostPaused *::after { animation-play-state: paused !important; transition: none !important; }
#pauseNote { max-width: 420px; }

#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(44px, 11vw, 86px); 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) { 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; margin-left: -20px; margin-right: -20px; font: 800 11px 'Segoe UI', system-ui, sans-serif; opacity: .75; }
.mark.on b { opacity: 1; color: #ffd83a; }

/* What the wreck unlocked: a new character, the next store. */
#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:empty { display: none; }
#doneGoals div { padding: 4px 12px; background: rgba(10,12,24,.6); border-radius: 9px; color: #7dff6a; opacity: 0; transform: translateX(-18px); }
#doneGoals div.in { opacity: 1; transform: none; transition: opacity .2s, transform .3s cubic-bezier(.2, 1.5, .3, 1); }
#doneStats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px clamp(14px, 4vw, 40px); }
#doneStats > div { opacity: 0; transform: translateY(14px); max-width: 46vw; }
#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; text-shadow: 0 2px 0 #000; overflow-wrap: anywhere; }
.big.alt { background: #2a3050; }
.big.ad { background: #1f8f3a; }
.big:disabled { opacity: .55; }
.big:hover { transform: translateY(-2px); }

/* ---------- Narrow screens (a phone held upright) ---------- */
@media (max-width: 640px) {
  .card { padding: 6px 6px 9px; border-radius: 13px; }
  .card .stat span { width: 34px; }
  #score { font-size: 26px; }
  #hudMid { top: 46px; width: 60vw; }
  #time { font-size: 15px; }
  /* The combo moves to the right edge, under the buttons. */
  #combo { position: fixed; right: 14px; top: 132px; margin: 0; text-align: right; font-size: 13px; }
  #comboMult { font-size: 19px; }
  #comboBar { width: 84px; margin-left: auto; }
}
/* Very narrow: smaller numbers and 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; }
  .card .stat { display: none; }
}
/* Wide screens: the combo sits in the middle under the bar, clear of the buttons. */
@media (min-width: 641px) {
  #combo { position: fixed; left: 16px; top: 58px; margin: 0; white-space: nowrap; }
}

/* ---------- Short screens: a phone held sideways ---------- */
/* Everything is tightened so that no screen runs off the top or bottom. */
@media (max-height: 520px), (max-height: 600px) and (min-width: 760px) {
  .overlay { gap: 4px; padding: 8px 14px; }
  h1 { font-size: clamp(22px, 9vh, 40px); }
  h1 br { display: none; }
  .sub { margin: 0 0 4px; font-size: 12px; }
  #menu .sub { display: none; }
  #totalLine { margin: 0 0 2px; font-size: 10.5px; }
  .card { padding: 5px 6px 7px; border-radius: 12px; max-width: 200px; }
  .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; }
  #storeButtons, #menuButtons { margin-top: 6px; }
  #btnSound { padding: 6px 12px; font-size: 11px; }
  #loadBar { height: 16px; }
  #tutorial { bottom: 10px; max-width: 46vw; padding: 6px 12px; font-size: 12px; }
  body.touch #tutorial { top: auto; bottom: 10px; left: 30%; }

  /* 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; align-content: safe center; justify-items: center; align-items: center; gap: 4px 22px; padding: 8px 22px; overflow: hidden auto; }
  #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; width: 20px; margin-left: -10px; }
  .mark i { width: 20px; height: 20px; }
}
/* Short and narrow (a small square): a tighter results page. */
@media (max-height: 520px) and (max-width: 640px) {
  .card img { height: 22vh; }
  .card .kind, .card .blurb { display: none; }
  #done { gap: 3px 12px; padding: 6px 12px; }
  #doneGoals { font-size: 10px; }
  #doneButtons { gap: 6px; }
  #doneButtons .big { padding: 6px 10px; font-size: 11px; }
  #doneStats b { font-size: 14px; }
  #doneStats span { font-size: 8px; }
  #doneRank { display: none; }
  .star { width: 24px; }
}

/* Wide but not tall (a laptop window): shorter pictures and title, so the cards and the button fit. */
@media (min-width: 641px) and (min-height: 521px) and (max-height: 860px) {
  h1 { font-size: clamp(30px, 9vh, 78px); }
  .card img { aspect-ratio: auto; height: 30vh; }
  .sub { margin: 2px 0 8px; }
}

/* The credits on a short, wide screen: two columns, so the BACK button stays in view. */
@media (max-height: 430px) {
  #credits h1 { font-size: 22px; margin: 0; }
  #creditLines { columns: 2; column-gap: 28px; max-width: 92vw; font-size: 11px; text-align: left; }
  #creditLines p { margin: 0 0 5px; break-inside: avoid; }
  #creditLines b { font-size: 11px; }
}

/* ---------- The smallest phones held upright (320 x 568) ---------- */
/* Longer languages (French, Italian...) need a little more room here: gaps and labels tighten. */
@media (max-width: 360px) and (max-height: 600px) {
  .overlay { gap: 6px; }
  #menuButtons { margin-top: 6px; }
  #done { gap: 4px; }
  #doneStats { gap: 4px 12px; }
  #doneStats span { letter-spacing: 1px; font-size: 10px; }
  #doneStats b { font-size: 20px; }
  #hudRight { right: 8px; gap: 5px; }
  #hudRight button { padding: 5px 6px; font-size: 10px; letter-spacing: 0; }
}
