/* Squirmy Wormy look: chunky sticker panels over the big city.
   Title panel on the left; in game: hearts top-left, goal top-center/right,
   map bottom-left, talking at the bottom, build bar along the bottom underground. */
:root {
  --ink: #2b1d14;
  --ink-soft: #5a4232;
  --card: #fff8ec;
  --card-2: #f7e6cc;
  --worm: #f2899d;
  --maple: #e8632c;
  --gold: #ffc928;
  --leaf: #4f9a32;
  --sky: #9fd8f0;
  --soil: #6b4a32;
  --line: #e7cfa9;
  --display: "Grandstander", "Chalkboard SE", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --r: 14px;
  --shadow: 4px 4px 0 var(--ink);
  color-scheme: light;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #a9d8ee; color: var(--ink); font-family: var(--body); font-size: 15px;
  overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
button { font-family: var(--display); cursor: pointer; color: var(--ink); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--maple); outline-offset: 2px; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 1px;
  border: 2px solid var(--ink); border-bottom-width: 3px; border-radius: 6px;
  background: #fff; font: 700 12px/1.3 var(--body); text-align: center; color: var(--ink);
}
.sticker { background: var(--card); border: 3px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow); }
.dim { opacity: 0.75; font-size: 13px; }
.yellow { color: #b88a00; font-weight: 900; }

/* ------------------------------------------------ title */
#title {
  position: fixed; inset: 0; display: flex; align-items: stretch;
  background: linear-gradient(90deg, rgba(43, 29, 20, 0.5) 0%, rgba(43, 29, 20, 0.12) 46%, rgba(43, 29, 20, 0) 60%);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.title-panel {
  width: min(540px, 100%); margin-block: 16px; padding: 16px 22px;
  background: var(--card); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 6px 6px 0 var(--ink);
  overflow-y: auto; max-height: calc(100% - 32px); align-self: center; display: flex; flex-direction: column; gap: 8px;
}
.logo { margin: 0; font-family: var(--display); font-weight: 900; font-size: clamp(42px, 8vw, 62px); line-height: 0.95; display: flex; flex-wrap: wrap; gap: 0 12px; }
.logo span { display: inline-block; paint-order: stroke fill; -webkit-text-stroke: 7px var(--ink); }
.logo .l1 { color: var(--worm); transform: rotate(-3deg); animation: squirm 2.4s ease-in-out infinite; }
.logo .l2 { color: var(--gold); transform: rotate(2deg); animation: squirm 2.4s ease-in-out infinite reverse; }
.tagline { margin: 0 0 2px; font-size: 15px; line-height: 1.35; max-width: 52ch; }
.label { margin: 4px 0 0; font: 800 13px var(--display); text-transform: uppercase; letter-spacing: 1.2px; color: var(--ink-soft); }
.worm-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.worm-card {
  padding: 6px 6px 7px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; box-shadow: 3px 3px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: var(--body); min-width: 0;
  transition: transform 0.12s ease, background 0.12s ease;
}
.worm-card canvas { width: 100%; max-width: 120px; aspect-ratio: 2 / 1; }
.worm-card b { font: 800 17px var(--display); }
.worm-card small { font-size: 12px; opacity: 0.75; text-align: center; line-height: 1.15; }
.worm-card:hover { transform: translate(-1px, -1px); }
.worm-card.sel { background: var(--gold); transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.levels { display: flex; gap: 8px; flex-wrap: wrap; }
.levels button { flex: 1 1 0; min-width: 0; padding: 6px; font-size: 14px; font-weight: 800; border: 3px solid var(--ink); border-radius: 10px; background: #fff; box-shadow: 2px 2px 0 var(--ink); }
.levels button.sel { background: var(--sky); }
.level-info { margin: 0; font-size: 13px; opacity: 0.8; }
.level-info:empty { display: none; }
.level-row { display: flex; flex-direction: column; gap: 6px; }
.play-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
button.big {
  font-size: 21px; font-weight: 900; padding: 8px 18px; border: 3px solid var(--ink); border-radius: 14px;
  background: var(--gold); box-shadow: 4px 4px 0 var(--ink); transition: transform 0.1s ease;
}
button.big:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
button.big:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
button.small { font-size: 14px; font-weight: 800; padding: 7px 12px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; }
button.mid { font-size: 16px; font-weight: 900; padding: 9px 12px; border: 3px solid var(--ink); border-radius: 12px; background: var(--sky); box-shadow: 3px 3px 0 var(--ink); }
button.mid.alt { background: #c9ec9f; }
button.mid:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.menu-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }
.menu-btns .dim:empty { display: none; }
.menu-btns > .dim { flex-basis: 100%; margin: 0; }
.friends-row, .continue-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
#continueInfo { pointer-events: none; }
.join-box { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.join-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#joinCode { width: 6.2em; font: 900 28px var(--display); letter-spacing: 0.18em; text-transform: uppercase; text-align: center; padding: 4px 6px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink); }
.msg { margin: 0; font-weight: 700; color: #b8392a; }
.msg:empty { display: none; }
.lobby { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.code-card { display: flex; flex-direction: column; align-items: flex-start; padding: 10px 16px; align-self: flex-start; background: var(--gold); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 4px 4px 0 var(--ink); }
.code-card .label { margin: 0; color: var(--ink); }
#lobbyCode { font: 900 54px/1 var(--display); letter-spacing: 0.16em; }
.lobby-hint { margin: 0; font-size: 15px; line-height: 1.35; max-width: 46ch; }
.lobby-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lobby-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #fff; border: 2px solid var(--ink); border-radius: 10px; font-weight: 700; font-size: 14px; min-width: 0; }
.lobby-list li.empty { background: transparent; border-style: dashed; font-weight: 400; opacity: 0.7; }
.pdot { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--ink); font: 900 13px var(--display); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.small-check { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 14px; }
.small-check input { width: 18px; height: 18px; accent-color: var(--leaf); }
.how { border-top: 2px dashed var(--line); padding-top: 10px; font-size: 14px; line-height: 1.45; }
.how h3 { margin: 6px 0 4px; font: 800 16px var(--display); }
.how table { border-collapse: collapse; width: 100%; }
.how td { padding: 3px 4px; vertical-align: top; }
.how td:first-child { white-space: nowrap; width: 1%; }
.how p { margin: 8px 0 0; max-width: 62ch; }

/* ------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: none; }
#topLeft { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: max(12px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.hearts { display: flex; gap: 4px; padding: 6px 10px; background: var(--card); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 3px 3px 0 var(--ink); }
.hearts i { font-style: normal; font-size: 24px; line-height: 1; filter: drop-shadow(1px 1px 0 var(--ink)); transition: transform 0.2s ease; }
.hearts i.gone { filter: grayscale(1) opacity(0.35); }
.hearts i.hit { animation: heartHit 0.6s ease; }
.hearts.shell { background: #ffe4c4; }
.chips { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.chip {
  display: flex; align-items: center; gap: 7px; padding: 4px 11px; background: var(--card);
  border: 3px solid var(--ink); border-radius: 999px; box-shadow: 3px 3px 0 var(--ink); font-weight: 700; font-size: 14px; max-width: 320px; white-space: nowrap;
}
.chip.good { background: #c9ec9f; } .chip.bad { background: #ffc9c0; } .chip.zoom { background: var(--gold); animation: wobble 0.35s ease-in-out infinite; } .chip.hide { background: var(--sky); }
#goal { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: 290px; padding: 9px 12px; font-size: 14px; }
#goal h3 { margin: 0 0 4px; font: 800 17px var(--display); }
#goal p { margin: 0; line-height: 1.3; }
.proj-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; max-height: 46vh; overflow: hidden; }
.proj-list li { display: flex; gap: 7px; align-items: flex-start; line-height: 1.25; padding: 2px 4px; border-radius: 6px; font-size: 13px; }
.proj-list li .box { flex: none; width: 17px; height: 17px; margin-top: 1px; border: 2px solid var(--ink); border-radius: 4px; background: #fff; font: 900 12px/13px var(--display); text-align: center; color: var(--leaf); }
.proj-list li.done { opacity: 0.5; }
.proj-list li.done .t { text-decoration: line-through; }
.proj-list li.next { background: var(--gold); font-weight: 700; }
.proj-list li em { font-style: normal; font-weight: 800; color: var(--maple); margin-left: 4px; }
#minimap { position: absolute; left: max(12px, env(safe-area-inset-left, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: 170px; height: 170px; background: var(--card); border: 3px solid var(--ink); border-radius: 50%; box-shadow: 3px 3px 0 var(--ink); }
#netChip { position: absolute; right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); font: 800 13px var(--display); background: var(--gold); }
#crosshair { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); opacity: 0.8; }
#prompt {
  position: absolute; left: 50%; bottom: calc(118px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 7px 14px 7px 7px; border-radius: 999px; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; gap: 9px; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}
#prompt .key { background: var(--gold); color: var(--ink); font: 900 15px var(--display); border-radius: 999px; min-width: 28px; height: 28px; display: grid; place-items: center; padding: 0 6px; }
#prompt.bad { background: #8a2f22; }
#subtitle {
  position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(720px, calc(100vw - 32px)); padding: 12px 16px; background: var(--card); border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow);
  font-size: 18px; line-height: 1.35; display: flex; flex-direction: column; gap: 3px;
}
#subtitle.blocking { pointer-events: auto; cursor: pointer; }
#subWho { font: 800 14px var(--display); text-transform: uppercase; letter-spacing: 1px; align-self: flex-start; padding: 1px 9px; border-radius: 999px; color: #fff; background: var(--soil); }
#subWho:empty { display: none; }
#subtitle.w-maple #subWho { background: var(--maple); }
#subtitle.w-narr { background: #fff1c9; font-style: italic; }
#subNext { position: absolute; right: 14px; bottom: 8px; font: 700 12px var(--body); opacity: 0.6; font-style: normal; animation: nudge 1s ease-in-out infinite; }
#toast { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); font: 900 clamp(30px, 6vw, 52px) var(--display); color: var(--gold); white-space: nowrap; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--ink); }
#toast.bad { color: #ff7a6b; }
#toast.pop { animation: pop 1.4s ease forwards; }
#banner {
  position: absolute; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); transform: translateX(-50%);
  background: var(--gold); border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); padding: 8px 18px 10px;
  display: flex; flex-direction: column; align-items: center; text-align: center; max-width: min(460px, calc(100vw - 32px));
}
#banner small { font: 800 12px var(--display); text-transform: uppercase; letter-spacing: 1.4px; }
#banner b { font: 900 21px/1.15 var(--display); text-wrap: balance; }
#banner i { font-size: 13px; margin-top: 2px; font-style: normal; }
#banner.pop { animation: drop 3.6s ease forwards; }
#shouts { position: absolute; left: 50%; top: 36%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#shouts div { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 4px 12px; font: 800 17px var(--display); animation: pop2 2.4s ease forwards; }
#nap { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); text-align: center; font-family: var(--display); color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
#nap b { display: block; font-size: 56px; font-weight: 900; color: var(--sky); animation: bob 1.4s ease-in-out infinite; }
#nap span { font-size: 24px; font-weight: 800; }
#help { position: absolute; right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(56px + env(safe-area-inset-bottom, 0px)); padding: 8px 12px; font-size: 13px; line-height: 1.9; }
#skipIntro { position: absolute; left: 50%; transform: translateX(-50%); top: calc(14px + env(safe-area-inset-top, 0px)); pointer-events: auto !important; font-size: 14px; font-weight: 800; padding: 7px 12px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; }
#goUnder { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(170px + env(safe-area-inset-bottom, 0px)); pointer-events: auto !important; }
#hotbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 5px; padding: 6px; background: var(--card); border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); pointer-events: auto !important; max-width: calc(100vw - 24px); overflow-x: auto; }
#hotbar button { position: relative; width: 50px; height: 50px; border: 2px solid var(--ink); border-radius: 11px; background: #fff; font-size: 25px; padding: 0; flex: none; }
#hotbar button small { position: absolute; left: 3px; top: 1px; font: 800 10px var(--body); opacity: 0.6; }
#hotbar button img.blk { width: 34px; height: 34px; display: block; margin: auto; image-rendering: pixelated; pointer-events: none; }
#hotbar button .emo { pointer-events: none; }
#hotbar button.more { background: #f4ead6; }
#hotbar button.sel { background: var(--gold); transform: translateY(-4px); box-shadow: 0 4px 0 var(--ink); }
#hotbar button.locked { opacity: 0.35; }
#hotbar .name { position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -10px); white-space: nowrap; background: var(--ink); color: #fff; border-radius: 999px; padding: 3px 11px; font: 700 14px var(--body); }

/* the dirt around your eyes while dug in, and a red flash when hurt */
#dirt { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.35s ease;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(60, 38, 22, 0) 38%, rgba(60, 38, 22, 0.75) 70%, rgba(40, 24, 12, 0.98) 100%),
    repeating-radial-gradient(circle at 30% 40%, rgba(110, 76, 50, 0.18) 0 3px, rgba(0, 0, 0, 0) 3px 9px); }
body.under #dirt { opacity: 1; }
body.under #game { filter: sepia(0.55) brightness(0.8); }
body.tunnel #game { filter: brightness(0.12) sepia(1); }
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(255, 60, 40, 0) 40%, rgba(255, 40, 30, 0.75) 100%); }
#flash.on { animation: flash 0.7s ease; }
body.slow #game { filter: saturate(1.6) hue-rotate(-25deg); }
body.zoom #game { filter: saturate(1.35) brightness(1.08); }
#danger { position: fixed; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 90px 30px rgba(232, 68, 58, 0.75); transition: opacity 0.2s ease; }
#danger.on { opacity: 1; animation: pulse 0.5s ease-in-out infinite alternate; }
#dangerArrow { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px; display: grid; place-items: center; font: 900 46px var(--display); color: #e8443a; -webkit-text-stroke: 4px #fff; paint-order: stroke fill; }

/* ------------------------------------------------ touch */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#touch > * { pointer-events: auto; }
#stick { position: absolute; left: max(24px, env(safe-area-inset-left, 0px)); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); width: 130px; height: 130px; border-radius: 50%; background: rgba(255, 248, 236, 0.35); border: 3px solid rgba(43, 29, 20, 0.6); display: grid; place-items: center; touch-action: none; }
#knob { width: 56px; height: 56px; border-radius: 50%; background: var(--card); border: 3px solid var(--ink); }
.tbtns { position: absolute; right: max(18px, env(safe-area-inset-right, 0px)); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 64px); gap: 10px; }
.tbtns button, #t-map, #t-pause { border: 3px solid var(--ink); border-radius: 50%; background: var(--card); box-shadow: 2px 2px 0 var(--ink); font: 900 15px var(--display); touch-action: none; }
#t-dig { grid-column: 2; grid-row: 1; background: #c9ec9f; }
#t-act { grid-column: 3; grid-row: 1 / span 2; border-radius: 30px; background: var(--gold); }
#t-up { grid-column: 1; grid-row: 1; } #t-down { grid-column: 1; grid-row: 2; }
#t-place { grid-column: 2; grid-row: 2; } #t-build { grid-column: 1; grid-row: 1; }
body.journey #t-up, body.journey #t-down, body.journey #t-place, body.journey #t-build { display: none; }
body.citymode #t-dig { grid-column: 2; grid-row: 1; }
body.citymode #t-build { grid-column: 3; grid-row: 1; border-radius: 50%; }
body.citymode #t-act { display: none; }
#touch button.on { background: var(--sky); transform: translate(2px, 2px); box-shadow: none; }
#t-map { position: absolute; right: max(12px, env(safe-area-inset-right, 0px)); top: calc(150px + env(safe-area-inset-top, 0px)); width: 46px; height: 46px; font-size: 20px; }
#t-pause { position: absolute; right: max(12px, env(safe-area-inset-right, 0px)); top: calc(204px + env(safe-area-inset-top, 0px)); width: 46px; height: 46px; font-size: 16px; }
body.touch #help, body.touch #crosshair { display: none; }
.touch-only { display: none; }
body.touch .touch-only { display: inline; }
body.touch .desk-only { display: none; }
body.touch #minimap { width: 120px; height: 120px; bottom: auto; top: calc(110px + env(safe-area-inset-top, 0px)); }
body.touch #prompt, body.touch #subtitle { bottom: calc(176px + env(safe-area-inset-bottom, 0px)); }
body.touch #hotbar { bottom: calc(160px + env(safe-area-inset-bottom, 0px)); }
body.citymode #help { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); left: 50%; right: auto; transform: translateX(-50%); width: min(620px, calc(100vw - 24px)); text-align: center; }
body.citymode #prompt { bottom: calc(176px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 1100px) { #banner { top: calc(130px + env(safe-area-inset-top, 0px)); } }

/* ------------------------------------------------ modals */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(43, 29, 20, 0.55); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.modal .card { width: min(460px, 100%); background: var(--card); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 6px 6px 0 var(--ink); padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100% - 32px); overflow-y: auto; }
.modal h2 { margin: 0; font: 900 30px var(--display); }
.modal label { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; font-weight: 700; }
.modal label.check { display: flex; gap: 9px; font-weight: 600; }
.modal input[type=range] { width: 100%; accent-color: var(--leaf); }
.modal input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--leaf); }
.modal .row { display: flex; gap: 10px; flex-wrap: wrap; }
.map-card { width: min(680px, 100%) !important; align-items: center; padding: 14px !important; }
#bigmap { width: min(640px, calc(100vw - 64px), calc(100vh - 120px)); aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 12px; background: #4b4e55; }
.build-card { width: min(720px, 100%) !important; }
.build-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.build-tabs button { padding: 5px 11px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; font: 700 13px var(--body); }
.build-tabs button.sel { background: var(--gold); }
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; max-height: 50vh; overflow-y: auto; padding: 2px 4px 6px 2px; }
.build-grid button { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding: 7px 4px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; box-shadow: 2px 2px 0 var(--ink); font: 700 12px var(--body); line-height: 1.15; }
.build-grid button .emo { font-size: 30px; line-height: 40px; height: 40px; }
.build-grid button img.blk { width: 40px; height: 40px; image-rendering: pixelated; }
.travel-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.travel-grid button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; box-shadow: 3px 3px 0 var(--ink); font: 800 16px var(--display); }
.travel-grid button .emo { font-size: 34px; }
.travel-grid button small { font: 600 12px var(--body); opacity: 0.7; }
.travel-grid button.sel { background: var(--gold); }
.chip.loc { background: #fff; }
.build-grid button.sel { background: var(--gold); }
.build-grid button.locked { opacity: 0.4; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; }
#crash { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px)); background: var(--card); border: 3px solid var(--ink); border-radius: 16px; padding: 16px; }
#crash code { font-size: 12px; opacity: 0.7; word-break: break-word; }

@keyframes pop { 0% { transform: translateX(-50%) scale(0.4); opacity: 0; } 12% { transform: translateX(-50%) scale(1.12); opacity: 1; } 22% { transform: translateX(-50%) scale(1); } 80% { opacity: 1; } 100% { transform: translateX(-50%) translateY(-24px); opacity: 0; } }
@keyframes pop2 { 0% { transform: scale(0.5); opacity: 0; } 10% { transform: scale(1.1); opacity: 1; } 20% { transform: scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes drop { 0% { transform: translate(-50%, -140%); } 8% { transform: translate(-50%, 6%); } 14% { transform: translate(-50%, 0); } 90% { transform: translate(-50%, 0); opacity: 1; } 100% { transform: translate(-50%, -140%); opacity: 0; } }
@keyframes wobble { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes squirm { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-3px); } }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes heartHit { 0% { transform: scale(1); } 30% { transform: scale(1.6) rotate(-12deg); } 100% { transform: scale(1); } }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }
@keyframes pulse { from { box-shadow: inset 0 0 70px 20px rgba(232, 68, 58, 0.55); } to { box-shadow: inset 0 0 110px 40px rgba(232, 68, 58, 0.85); } }

@media (max-width: 720px) {
  #title { background: rgba(43, 29, 20, 0.35); align-items: flex-start; }
  .title-panel { padding: 14px; align-self: flex-start; }
  .worm-cards { grid-template-columns: repeat(3, 1fr); }
  .worm-card small { display: none; }
  .lobby-list { grid-template-columns: 1fr; }
  #goal { width: min(220px, 50vw); font-size: 12.5px; padding: 7px 9px; }
  #goal h3 { font-size: 14px; }
  .hearts i { font-size: 19px; }
  .chip { font-size: 12px; padding: 3px 8px; }
  #subtitle { font-size: 16px; }
  #help { display: none; }
  .build-grid { grid-template-columns: repeat(3, 1fr); }
}
/* short screens (phones sideways): keep the middle of the screen clear */
@media (max-height: 520px) {
  #goal { width: min(250px, 40vw); padding: 6px 9px; }
  #goal p { font-size: 12px; }
  .proj-list li:not(.next) { display: none; }
  body.touch #t-map { top: auto; bottom: calc(176px + env(safe-area-inset-bottom, 0px)); right: max(240px, env(safe-area-inset-right, 0px)); }
  body.touch #t-pause { top: auto; bottom: calc(176px + env(safe-area-inset-bottom, 0px)); right: max(190px, env(safe-area-inset-right, 0px)); }
  body.touch #hotbar { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 440px); padding: 4px; gap: 3px; }
  body.touch #hotbar button { width: 40px; height: 40px; font-size: 20px; }
  body.touch #hotbar button img.blk { width: 28px; height: 28px; }
  body.touch #prompt, body.touch #subtitle { bottom: calc(66px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 440px); }
  body.touch.citymode #prompt { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  body.touch #subtitle { font-size: 14px; padding: 8px 12px; }
  #banner { top: calc(8px + env(safe-area-inset-top, 0px)); padding: 4px 12px 6px; }
  #banner b { font-size: 16px; }
  body.touch #minimap { width: 96px; height: 96px; top: calc(64px + env(safe-area-inset-top, 0px)); }
  .tbtns { grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; transition: none !important; }
}
