/* EAT EARTH - one visual language: hard pixel edges, soil-toned plates, and numbers and headings set in
   the game's own pixel alphabet (--pix, built by js/pixfont.js). Words that need reading use --font. */
:root {
  --bg: #120c09; --panel: #1e1510; --plate: #2b1e16; --plate2: #3a291e; --line: #523c2d; --edge: #0a0605;
  --ink: #f7ecda; --muted: #bba48c; --dim: #86705e; --paper: #24160e;
  --go: #7ed957; --gold: #ffd23f; --gem: #62d6e8; --bad: #e2533b; --accent: #7ed957;
  --pix: "EatPix", ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); font-weight: 600; font-synthesis: none; overflow: hidden;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; padding: 0; background: none; text-align: inherit; touch-action: manipulation; }
i { font-style: normal; }
img { image-rendering: pixelated; -webkit-user-drag: none; }
.hidden { display: none !important; }
/* scrollbars (the shop, the sheets, the save box): a dark slot with a bevelled soil block in it, square, no arrows.
   The block lights up under the pointer and takes the layer's colour while dragged. 8px wide, as the shop's always was. */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: rgba(0,0,0,.32); }
::-webkit-scrollbar-thumb { background: var(--line); box-shadow: inset 2px 2px 0 rgba(255,255,255,.14), inset -2px -2px 0 rgba(0,0,0,.38); }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }
::-webkit-scrollbar-thumb:active { background: var(--accent); }
@supports not selector(::-webkit-scrollbar) { * { scrollbar-width: thin; scrollbar-color: var(--line) rgba(0,0,0,.32); } }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; width: 100vw; }
#stage { position: relative; flex: 1 1 auto; min-width: 0; min-height: 38%; container-type: inline-size; overflow: hidden; background: #0d0907; touch-action: none; cursor: crosshair; }
#wrap { position: absolute; inset: 0; overflow: hidden; }
#game { position: absolute; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; will-change: transform; }
#fx { position: absolute; left: 0; top: 0; pointer-events: none; }
#dark { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, rgba(0,0,0,.36) 0, rgba(0,0,0,0) 104px); }
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud button, .toast { pointer-events: auto; }

/* ---- stage: what you have (top left), where you are (bottom) ---------------------------------------- */
#purse { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); }
#cash { font: 400 32px/1 var(--pix); color: #fff; white-space: nowrap; text-shadow: 3px 3px 0 var(--edge); }
#rate { margin-top: 6px; font: 400 16px/1 var(--pix); color: var(--go); text-shadow: 2px 2px 0 var(--edge); }

#hud-right { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 6px; }
.chip { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; min-width: 36px; padding: 0 9px 1px;
  background: rgba(18,11,8,.86); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--edge); font: 400 16px/1 var(--pix); }
.chip:active { transform: translateY(3px); box-shadow: none; }
.chip img { width: 18px; height: 18px; }
#gem-btn { color: var(--gem); }
#gem-btn.pulse { border-color: var(--gem); animation: pulse 1s steps(2) infinite; }
#shard-btn { color: var(--gold); }
/* gold plates mark relics you have not looked at yet: a count on the menu button, a tag on the Museum row, a tag on the relic */
.dot { display: none; position: absolute; top: -8px; right: -8px; min-width: 20px; padding: 2px 3px 4px 5px; background: var(--gold); color: #2a1800; text-align: center; box-shadow: 0 0 0 2px var(--edge); }
.has > .dot { display: block; }
.has { border-color: var(--gold); }

#strata { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px 10px; background: rgba(12,7,5,.9); border-top: 2px solid rgba(255,255,255,.1); }
#strata-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
#zone-name { min-width: 0; overflow: hidden; white-space: nowrap; font: 400 16px/1 var(--pix); text-transform: uppercase; color: var(--accent); }
#depth { flex: none; font: 400 16px/1 var(--pix); white-space: nowrap; }
#strata-bot { display: flex; align-items: center; gap: 8px; margin-top: 6px; height: 14px; }
#strata-track { flex: 1; height: 6px; background: rgba(255,255,255,.13); }
#strata-fill { display: block; height: 100%; width: 0; background: var(--accent); }
#strata-next { font-size: 12px; line-height: 14px; font-weight: 700; color: var(--muted); white-space: nowrap; }
#strata.seal #zone-name, #strata.seal #depth { color: #ff9a85; }
#strata.seal #strata-track { height: 10px; }
#strata.seal #strata-fill { background: var(--bad); }
#strata.hit #strata-track { animation: shakeX .12s steps(2); }

#status { position: absolute; left: 12px; right: 36px; bottom: 66px; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
#combo { opacity: 0; transition: opacity .25s; }
#combo.show { opacity: 1; }
#combo-txt { display: block; font: 400 16px/1 var(--pix); color: #ffb02e; text-shadow: 2px 2px 0 var(--edge); }
#combo-bar { display: block; width: 120px; height: 6px; margin-top: 5px; background: rgba(12,7,5,.8); box-shadow: 0 0 0 2px var(--edge); }
#combo-fill { display: block; height: 100%; width: 0; background: #ff8a2e; }
#combo.max #combo-txt { color: #ff7fae; }
#combo.max #combo-fill { background: #ff4f8a; }
#bonus { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.bonus-chip { position: relative; padding: 6px 8px 10px; font: 400 16px/1 var(--pix); background: var(--gold); color: #2a1800; box-shadow: 0 3px 0 var(--edge); }
.bonus-chip i { position: absolute; left: 0; bottom: 0; height: 4px; background: #8a4a00; }

/* the journey gauge: surface at the top, one band per layer, the core at the bottom, and you on the way down */
#trip { position: absolute; right: max(12px, env(safe-area-inset-right)); top: 62px; bottom: 116px; width: 8px; box-shadow: 0 0 0 2px var(--edge); }
#trip-segs { display: flex; flex-direction: column; height: 100%; }
#trip-segs i { flex: 1; }
#trip-segs i.ahead { filter: brightness(.5) saturate(.6); }
#trip-you { position: absolute; left: -8px; right: -4px; top: 0; height: 4px; margin-top: -2px; background: #fff; box-shadow: 0 0 0 2px var(--edge); transition: top .3s linear; }
#trip-you::before { content: ''; position: absolute; left: -6px; top: -4px; border: 6px solid transparent; border-left-color: #fff; border-right: 0; filter: drop-shadow(-2px 0 0 var(--edge)); }
#trip-core { position: absolute; left: 50%; bottom: -20px; width: 18px; height: 18px; margin-left: -9px; background: #ffd23f;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); box-shadow: inset 0 0 0 4px #ff8c2e; animation: pulse 1s steps(2) infinite; }
#trip-lbl { position: absolute; right: 16px; bottom: -18px; font: 400 16px/1 var(--pix); color: #ffd23f; text-shadow: 2px 2px 0 var(--edge); white-space: nowrap; }

/* ---- stage: things that come and go ------------------------------------------------------------------ */
#toasts { position: absolute; left: 50%; top: 68px; transform: translateX(-50%); width: min(94%, 380px); display: flex; flex-direction: column; align-items: center; }
.toast { display: flex; align-items: center; gap: 9px; max-width: 100%; padding: 6px 12px 7px 7px; background: rgba(18,11,8,.95); border: 2px solid var(--line);
  box-shadow: 0 3px 0 var(--edge); animation: drop .16s steps(3); cursor: pointer; }
.toast.out { animation: lift .16s steps(3) forwards; }
.toast img { width: 32px; height: 32px; flex: none; }
.toast b { display: block; font-size: 14px; font-weight: 800; line-height: 1.25; color: var(--gold); }
.toast span { display: block; font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--muted); }
.toast.gold { border-color: var(--gold); }
.toast.gem { border-color: var(--gem); }
.toast.gem b { color: var(--gem); }

/* cream bubbles are the game talking to you: the coach on the stage, the upgrade tip in the shop */
#coach { position: absolute; left: 50%; top: 54%; transform: translateX(-50%); padding: 10px 12px 11px; background: var(--ink); color: var(--paper);
  font: 400 16px/1 var(--pix); text-transform: uppercase; white-space: nowrap; box-shadow: 0 4px 0 var(--edge); animation: bob .8s steps(2) infinite; }
#coach i { margin-left: 8px; }
#coach small { display: block; margin-bottom: 7px; font: 800 12px/1.2 var(--font); text-transform: none; color: #7a5a40; }
#coach .a-right { display: none; }
#coach.to-panel { left: var(--cx, 50%); top: auto; bottom: 76px; }
#coach.to-panel .a-down { position: absolute; left: var(--ax, 50%); top: 100%; margin: -4px 0 0 -5px; color: var(--ink); text-shadow: 0 4px 0 var(--edge); }
#coach.to-hud { left: var(--cx, 50%); top: var(--cy, 60px); }
#coach.to-hud .a-up { position: absolute; left: var(--ax, 50%); bottom: 100%; margin: 0 0 0 -8px; border: 8px solid transparent; border-bottom-color: var(--ink); border-top: 0; }

/* ---- panel: what to do next, then everything you can buy --------------------------------------------- */
#panel { flex: none; height: 44vh; height: 44dvh; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-top: 3px solid var(--edge); touch-action: pan-y; }
#grip { display: none; }      /* only the phone sheet (end of file) has a grip */

#goal { position: relative; flex: none; display: grid; grid-template: "tag val" auto "txt val" auto / 1fr auto; column-gap: 12px; row-gap: 4px; align-content: center; align-items: center;
  width: 100%; min-height: 54px; padding: 7px 12px 11px; background: var(--plate); }
#goal-tag { grid-area: tag; font: 800 11px/1 var(--font); letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); }
#goal-txt { grid-area: txt; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 14px; line-height: 1.25; font-weight: 700; }
#goal-val { grid-area: val; font: 400 16px/1 var(--pix); color: var(--muted); white-space: nowrap; }
#goal-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--edge); }
#goal-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }
#goal.idle { cursor: default; }
#goal:not(.idle):not(.done) #goal-val::after { content: ' >'; color: var(--dim); }
#goal.hot #goal-val { color: var(--accent); animation: blink .5s steps(2) infinite; }
#goal.done { background: var(--gold); color: #2a1800; }
#goal.done #goal-tag { color: #7a5600; }
#goal.done #goal-val { padding: 8px 9px 9px; background: #2a1800; color: var(--gold); }
#goal.done #goal-fill { background: #2a1800; }
#goal.done:active { transform: translateY(2px); }

#save-warning { flex: none; padding: 8px 12px; background: #54271a; color: #ffe0b2; font-size: 12px; line-height: 1.4; text-align: left; }

#shop { flex: 1; overflow-x: hidden; overflow-y: auto; padding: 7px 8px calc(10px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sect { display: flex; align-items: center; justify-content: space-between; min-height: 25px; margin-bottom: 5px; padding: 0 2px; font: 800 11px/1 var(--font); letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); }
.modes { display: flex; gap: 4px; }
.modes button { padding: 4px 7px 5px; background: var(--plate); color: var(--dim); font: 400 16px/1 var(--pix); letter-spacing: 0; }
.modes button.on { background: var(--gold); color: #2a1800; }

#upwrap { position: relative; }
#ups { display: flex; gap: 6px; padding-bottom: 8px; overflow-x: auto; scrollbar-width: none; }
#ups::-webkit-scrollbar { display: none; }
.up { flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 58px; padding: 3px 3px 5px; background: var(--plate); border: 2px solid transparent; box-shadow: 0 3px 0 var(--edge); }
.up img { width: 40px; height: 40px; opacity: .4; }
.up b { font: 800 12px/1 var(--font); color: var(--dim); }
.up.can { background: var(--plate2); border-color: var(--gold); }
.up.can img { opacity: 1; }
.up.can b { color: var(--gold); }
.up.sel { border-color: var(--ink); }
.up:active { transform: translateY(3px); box-shadow: none; }
#tip { position: relative; z-index: 5; display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 3px; align-items: center;
  margin: -2px 0 10px; padding: 9px 10px 10px; background: var(--ink); color: var(--paper); box-shadow: 0 4px 0 var(--edge); }
#tip::before { content: ''; position: absolute; left: var(--ax, 29px); top: -5px; width: 10px; height: 5px; margin-left: -5px; background: var(--ink); }
#tip b { font-size: 14px; font-weight: 800; line-height: 1.2; }
#tip span { grid-column: 1; font-size: 12px; line-height: 1.3; color: #5e4838; }
#tip em { grid-column: 2; grid-row: 1 / span 2; font: 400 16px/1 var(--pix); }
#tip .btn { grid-column: 2; grid-row: 1 / span 2; }
#tip.hover { pointer-events: none; }
#tip.hover .btn, #tip:not(.hover) em { display: none; }

.row { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 6px; padding: 6px 10px 9px 8px; background: var(--plate); box-shadow: 0 3px 0 var(--edge); }
.row .ico { flex: none; width: 40px; height: 40px; background: rgba(0,0,0,.28); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.row-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15px; line-height: 1.15; font-weight: 800; }
.row-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 8px; }
.price { font: 400 16px/1 var(--pix); color: var(--dim); white-space: nowrap; }
.row-stat { font-size: 12.5px; line-height: 1; font-weight: 700; color: var(--muted); white-space: nowrap; }
.row-desc { font-size: 13px; line-height: 1.3; font-weight: 600; color: var(--muted); }
.row-desc b { color: var(--ink); font-weight: 800; }
.row-own { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.row-own b { font: 400 24px/1 var(--pix); }
.row-own i { font-size: 11.5px; line-height: 1; font-weight: 700; color: var(--gold); white-space: nowrap; }
.row-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0,0,0,.32); }
.row-bar i { display: block; height: 100%; width: 0; background: var(--gold); }
.row-bar.green i { background: var(--go); }
button.row .ico, button.row .row-name { opacity: .55; }
button.row.own .row-desc, button.row:not(.own) .row-stat { display: none; }
button.row.can { background: var(--plate2); box-shadow: inset 4px 0 0 var(--go), 0 3px 0 var(--edge); }
button.row.can .ico, button.row.can .row-name { opacity: 1; }
button.row.can .price { color: var(--go); }
button.row:active { transform: translateY(3px); box-shadow: none; }
.row.locked { background: none; box-shadow: none; border: 2px dashed var(--line); padding: 4px 8px 7px 6px; }
.row.locked .ico { opacity: .5; }
.row.locked .row-name { color: var(--dim); }
.row.locked.far { opacity: .5; }
.row.dim { opacity: .6; }
.row.fresh { animation: glow 1s steps(2) 5; }
.attn { animation: attn .6s steps(2) infinite; }
.nope { animation: shakeX .12s steps(2) 2; }
.bump { animation: bump .12s steps(2); }

.btn { flex: none; display: inline-block; padding: 10px 12px 13px; background: var(--go); color: #0f2a0c; font: 400 16px/1 var(--pix); text-align: center; text-transform: uppercase; white-space: nowrap;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.22), 0 3px 0 var(--edge); }
.btn:active { transform: translateY(3px); box-shadow: inset 0 -4px 0 rgba(0,0,0,.22); }
.btn.gold { background: var(--gold); color: #2a1800; }
.btn.gem { background: var(--gem); color: #06303a; }
.btn.no { background: #4a3a2e; color: #a08a76; }
.btn.plain { background: var(--plate2); color: var(--ink); }
.btn.warn { background: var(--plate2); color: #ff9a85; }
.btn.wide { display: block; width: 100%; margin-top: 12px; padding: 14px 12px 17px; white-space: normal; line-height: 1.25; }

/* ---- sheets (dialogs) -------------------------------------------------------------------------------- */
#modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); background: rgba(6,3,2,.8); touch-action: pan-y; }
#modal-card { width: min(100%, 440px); max-height: 90vh; max-height: 90dvh; overflow-y: auto; padding: 0 14px 16px; background: var(--panel); border: 3px solid var(--line);
  box-shadow: 0 6px 0 var(--edge); text-align: center; animation: pop .14s steps(3); }
.mhead { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; height: 46px; margin: 0 -8px -34px; padding-top: 8px; pointer-events: none; }
.mhead button { width: 34px; height: 34px; background: var(--plate2); box-shadow: 0 3px 0 var(--edge); font: 400 16px/1 var(--pix); text-align: center; pointer-events: auto; }
.mhead button:active { transform: translateY(3px); box-shadow: none; }
.mhead i { width: 34px; }
#modal-card h2 { margin: 0 34px 6px; padding-top: 18px; font: 400 24px/1.25 var(--pix); text-transform: uppercase; color: var(--gold); }
#modal-card p { margin: 6px 0; font-size: 14px; line-height: 1.45; color: var(--ink); }
#modal-card p.sub { margin-bottom: 12px; font-size: 12px; font-weight: 700; color: var(--muted); }
#modal-card p.note { margin-top: 12px; font-size: 12px; color: var(--muted); }
#modal-card .hero { display: block; width: 96px; height: 96px; margin: 22px auto 0; }
#modal-card .hero + h2 { padding-top: 6px; }
#modal-card .hero.unk { filter: brightness(0); opacity: .35; }
#modal-card .gain { margin: 12px 0 6px; font: 400 24px/1.25 var(--pix); color: var(--go); }
#modal-card .gain.gold { color: var(--gold); }
#modal-card .left { text-align: left; }
#modal-card .row { cursor: default; }
#modal-card .row.can { background: var(--plate2); }
/* the Gem Shop lesson talks in the coach's cream bubble, notched down at the button to press */
#modal-card .hint { position: relative; margin: 2px 0 12px; padding: 9px 12px 10px; background: var(--ink); color: var(--paper); font: 400 16px/1 var(--pix); text-transform: uppercase; text-align: center; box-shadow: 0 4px 0 var(--edge); }
#modal-card .hint::after { content: ''; position: absolute; right: 38px; top: 100%; border: 7px solid transparent; border-top-color: var(--ink); border-bottom: 0; }
#modal-card .hint.done { background: var(--gem); color: #06303a; }
#modal-card .hint.done::after { display: none; }
#modal-card .row.pick { box-shadow: inset 4px 0 0 var(--gem), 0 3px 0 var(--edge); }
.mrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin-bottom: 6px; padding: 13px 12px 15px; background: var(--plate); box-shadow: 0 3px 0 var(--edge); font-size: 15px; font-weight: 800; }
.mrow b { font: 400 16px/1 var(--pix); color: var(--muted); }
.mrow.on b { color: var(--go); }
.mrow u { margin-left: 8px; padding: 2px 5px 4px 6px; background: var(--gold); color: #2a1800; font: 400 16px/1 var(--pix); text-decoration: none; }
.mrow.new { background: var(--plate2); box-shadow: inset 4px 0 0 var(--gold), 0 3px 0 var(--edge); }
.mrow:active { transform: translateY(3px); box-shadow: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
/* museum wings, one per world, once there is more than Earth's (js/ui2.js) */
.wing { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 0 8px; padding: 0 2px 5px; border-bottom: 2px solid var(--plate2);
  font: 800 14px/1 var(--font); letter-spacing: 2px; text-transform: uppercase; color: var(--gold); }
.wing:first-child { margin-top: 2px; }
.wing span { font-size: 11px; letter-spacing: 1px; color: var(--dim); }
.relic { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1; background: var(--plate); border: 2px solid transparent; }
.relic img { width: 44px; height: 44px; }
.relic.unk img { filter: brightness(0); opacity: .3; }
.relic.got { background: var(--plate2); border-color: var(--gold); }
.relic.new::before { content: 'NEW'; position: absolute; left: -2px; top: -2px; padding: 2px 3px; background: var(--gold); color: #2a1800; font: 800 9px/1 var(--font); letter-spacing: .5px; }
.relic u { position: absolute; right: 3px; bottom: 2px; font-size: 10px; font-weight: 800; text-decoration: none; color: var(--gold); }
.stat { display: flex; justify-content: space-between; gap: 10px; padding: 7px 4px; font-size: 13px; border-bottom: 2px solid var(--plate); }
.stat b { font-weight: 800; color: var(--gold); text-align: right; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pair .btn { margin-top: 8px; }
#modal-card textarea { display: block; width: 100%; height: 84px; margin-top: 8px; padding: 8px; border: 2px solid var(--line); border-radius: 0; background: var(--bg); color: var(--ink);
  font: 11px monospace; resize: none; -webkit-user-select: text; user-select: text; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 12px 0 6px; }
.days div { padding: 7px 0; background: var(--plate); font-size: 10px; font-weight: 800; color: var(--muted); }
.days div b { display: block; margin-top: 5px; font: 400 16px/1 var(--pix); color: var(--gem); }
.days div.done { opacity: .45; }
.days div.today { background: var(--plate2); outline: 2px solid var(--gold); color: var(--ink); }
.tally { margin: 12px 0 4px; text-align: left; }
.tally .stat b { font: 400 16px/1 var(--pix); }
.tally.fresh .stat { animation: drop .2s steps(3) backwards; animation-delay: calc(.4s + var(--i) * .3s); }
#fin-gain.landed { animation: bump .3s steps(2); }
/* a new layer's card (js/ui2.js UI.layer): framed in the layer's colour; its button wakes up after a moment */
#modal-card[data-sheet="layer"] { border-color: var(--accent); }
#modal-card[data-sheet="layer"] .kicker { display: block; padding-top: 20px; font: 800 11px/1 var(--font); letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
#modal-card[data-sheet="layer"] h2 { margin-bottom: 8px; padding-top: 9px; color: var(--accent); }
#modal-card .unlock { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; padding: 7px 10px; background: var(--accent); color: #17100b; }
#modal-card .unlock img { width: 32px; height: 32px; }
#modal-card .unlock span { text-align: left; font: 800 10px/1 var(--font); letter-spacing: 1.5px; text-transform: uppercase; }
#modal-card .unlock b { display: block; margin-top: 4px; font: 400 16px/1 var(--pix); letter-spacing: 0; }
#modal-card .btn[disabled] { opacity: .45; cursor: default; }

/* the finale cinematic (js/finale.js) has the stage to itself */
#hud, #panel { transition: opacity .3s steps(3); }
body.cine #hud { opacity: 0; }
body.cine #panel { opacity: .35; pointer-events: none; }

/* ---- ads (js/ads.js) ----------------------------------------------------------------------------------
   Double Dig lives with the timed bonuses at the foot of the dig: a x2 chip with a video icon, gold while it runs. */
#perks { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
#boost-btn { height: 32px; color: var(--gold); }      /* as tall as a bonus chip, so it clears the gauge's CORE label */
#boost-btn.on { background: var(--gold); border-color: var(--gold); color: #2a1800; }
svg.vid { flex: none; width: 15px; height: 11px; shape-rendering: crispEdges; }
.btn svg.vid { margin-right: 7px; vertical-align: -1px; }
/* the "Ad break" / "Loading video" pill while a video loads, and the cover that holds the game still while one loads or plays */
#ad-warn { position: fixed; left: 50%; top: 50%; z-index: 81; transform: translate(-50%, -50%); padding: 12px 16px 14px; background: var(--ink); color: var(--paper);
  font: 400 24px/1 var(--pix); text-transform: uppercase; white-space: nowrap; box-shadow: 0 4px 0 var(--edge); pointer-events: none; }
#ad-cover { position: fixed; inset: 0; z-index: 80; background: rgba(6,3,2,.55); touch-action: none; }
/* a video offer and its "no thanks" are the same button; long labels wrap rather than spill */
.pair.offer { margin-top: 12px; }
.pair.offer .btn { margin-top: 0; padding: 12px 8px 15px; white-space: normal; line-height: 1.15; }
.claims { flex: none; display: flex; gap: 6px; }
.claims .btn { min-width: 64px; padding-left: 8px; padding-right: 8px; }
@media (max-width: 480px) {      /* narrow phones: the quest keeps its full line, the two buttons go under it */
  #modal-card .row.offer-row { flex-wrap: wrap; row-gap: 8px; }
  .offer-row .claims { flex-basis: 100%; justify-content: flex-end; }
}
#modal-card .hint.off { background: var(--plate2); color: #ff9a85; }
#modal-card .hint.off::after { display: none; }
#modal-card { overscroll-behavior: contain; }
/* the banner at the foot of the dig: wide screens only (placed in the wide block below), on a dark plate */
#ad-slot { display: none; }
#ad-banner { background: #0a0605; }

@keyframes pulse { 50% { filter: brightness(1.35); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes attn { 50% { filter: brightness(1.3); transform: translateY(-2px); } }
@keyframes glow { 50% { box-shadow: inset 0 0 0 2px var(--gold), 0 3px 0 var(--edge); } }
@keyframes shakeX { 50% { transform: translateX(-4px); } }
@keyframes bump { 50% { transform: translateY(-3px); } }
@keyframes bob { 50% { margin-top: -4px; margin-bottom: 4px; } }
@keyframes drop { from { transform: translateY(-10px); opacity: 0; } }
@keyframes lift { to { transform: translateY(-8px); opacity: 0; } }
@keyframes pop { from { opacity: 0; } }
@keyframes fade { to { opacity: 0; } }

/* ---- wide screens: the shop stands to the right of the dig -------------------------------------------- */
@media (min-width: 820px) and (min-aspect-ratio: 11/10) {
  :root { --pw: clamp(340px, 30vw, 440px); }
  #app { flex-direction: row; }
  #panel { width: var(--pw); height: 100%; border-top: 0; border-left: 3px solid var(--edge); }
  #cash { font-size: 40px; }
  #toasts { top: 14px; }
  #ups { flex-wrap: wrap; overflow: visible; }
  #tip { position: fixed; right: calc(var(--pw) + 12px); top: var(--ty, 80px); width: 290px; margin: 0; }
  #tip::before { left: auto; right: -5px; top: 16px; width: 5px; height: 10px; margin: 0; }
  #coach.to-panel { left: auto; right: 34px; top: var(--cy, 30%); bottom: auto; transform: translateY(-50%); }
  #coach.to-panel .a-right { display: inline; }
  #coach.to-panel .a-down { display: none; }
  /* Smaller windows (CrazyGames' 821x462, 907x510, 1077x606, 1080x607) leave a narrower dig: a toast no longer
     fits between the cash and the chips, so it drops below the cash. Wider digs keep the layout above untouched. */
  @container (max-width: 839px) { #toasts { top: 80px; } }

  /* The banner at the foot of the dig (js/ads.js sets body.dig-ad, --adw and --adh only where it fits): over the
     right end of the layer bar, which keeps its name, depth and a shorter bar to the left. A 320x50 fits the bar as
     it is; bigger ones make it taller (--sh), and the chips and the gauge above it move up with it. The banner sits
     above the sheets' dimming, and a tall sheet stops short of it. */
  #ad-slot { display: block; position: fixed; z-index: 55; right: calc(var(--pw) + 6px); bottom: 2px; transition: opacity .3s steps(3); }
  body.dig-ad { --sh: max(56px, calc(var(--adh) + 6px)); }
  body.dig-ad #strata { display: flex; flex-direction: column; justify-content: center; min-height: var(--sh); padding-right: calc(var(--adw) + 18px); }
  body.dig-ad #strata-track { min-width: 48px; }
  body.dig-ad #strata-next { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  body.dig-ad #status { bottom: calc(var(--sh) + 10px); }
  body.dig-ad #trip { bottom: calc(var(--sh) + 60px); }
  body.dig-ad #modal-card { max-height: min(90vh, calc(100vh - 2 * var(--sh) - 12px)); max-height: min(90dvh, calc(100dvh - 2 * var(--sh) - 12px)); }
  body.cine #ad-slot { opacity: 0; }
}
@media (max-width: 359px) { #cash { font-size: 24px; } }
@media (max-height: 700px) and (max-width: 819px) { #panel { height: 48dvh; } }
@media (max-height: 520px) and (max-width: 819px) { #panel { height: 50dvh; } }
/* Use the actual stage width, including when the shop sits beside it. */
@container (max-width: 440px) {
  #hud-right { display: grid; grid-template-columns: auto auto; row-gap: 18px; }
  #menu-btn { grid-column: 2; grid-row: 1; justify-self: end; }
  #gem-btn { grid-column: 1; grid-row: 2; }
  #shard-btn { grid-column: 2; grid-row: 2; }
  #toasts { top: 106px; }
  #trip { top: 112px; }
}

/* ---- phones: the dig gets the screen ------------------------------------------------------------------
   Everything below applies only where the wide layout above does not, so wide screens stay as they are.
   Portrait: the shop is a short sheet under the dig, with a grip to pull it up over the dig for a longer shop.
   Landscape: the shop stands beside the dig, like on wide screens. Both use the same compact shop. */
@media not all and (min-width: 820px) and (min-aspect-ratio: 11/10) {
  /* where you are, in one line at the foot of the dig: the layer and the depth. No layer bar, seal bar, seal
     shout, journey gauge or combo meter here: the seal is in plain view, and the dig needs the room. The combo
     still counts; it just is not drawn. */
  #strata { padding: 12px 12px 8px; background: linear-gradient(to bottom, rgba(12,7,5,0), rgba(12,7,5,.8) 55%); border-top: 0; }
  #zone-name, #depth { text-shadow: 2px 2px 0 var(--edge); }
  #strata.seal #zone-name { color: var(--accent); }
  #strata.seal #depth { color: var(--ink); }
  #strata-bot, #trip, #combo { display: none; }
  /* on a narrow stage the counters stack under the menu button (@container above): gems sit right under it,
     shards (after the first planet) to their left, so the gem chip never hangs off to one side */
  #gem-btn { grid-column: 2; justify-self: end; }
  #shard-btn { grid-column: 1; }

  #status { right: 12px; bottom: calc(42px + var(--cover, 0px)); }

  /* the compact shop: shorter goal bar, small upgrade tiles, two-line eater rows, one locked eater, and the
     newest eater on top so the one you most likely want is in reach without scrolling */
  #goal { min-height: 44px; padding: 6px 12px 9px; row-gap: 3px; }
  #goal-tag { font-size: 10px; }
  #goal-txt { font-size: 13px; line-height: 1.2; }
  #shop { display: flex; flex-direction: column; padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
  #shop > * { flex-shrink: 0; }
  #upwrap { order: -99; }
  #shop .sect { order: -98; min-height: 22px; margin-bottom: 4px; }
  #shop > button.row:nth-of-type(1) { order: -1; }   #shop > button.row:nth-of-type(2) { order: -2; }   #shop > button.row:nth-of-type(3) { order: -3; }
  #shop > button.row:nth-of-type(4) { order: -4; }   #shop > button.row:nth-of-type(5) { order: -5; }   #shop > button.row:nth-of-type(6) { order: -6; }
  #shop > button.row:nth-of-type(7) { order: -7; }   #shop > button.row:nth-of-type(8) { order: -8; }   #shop > button.row:nth-of-type(9) { order: -9; }
  #shop > button.row:nth-of-type(10) { order: -10; } #shop > button.row:nth-of-type(11) { order: -11; } #shop > button.row:nth-of-type(12) { order: -12; }
  .modes button { padding: 3px 6px 4px; }
  #ups { gap: 5px; padding-bottom: 6px; }
  .up { min-width: 50px; gap: 2px; padding: 2px 3px 3px; }
  .up img { width: 30px; height: 30px; }
  .up b { font-size: 11px; }
  #shop .row { gap: 8px; margin-bottom: 5px; padding: 4px 8px 6px 6px; }
  #shop .row .ico { width: 32px; height: 32px; }
  #shop .row-main { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 8px; row-gap: 3px; }
  #shop .row-name { grid-column: 1 / -1; font-size: 14px; line-height: 1.1; }
  #shop .row-line { flex-wrap: nowrap; overflow: hidden; }
  #shop button.row.own .row-line { grid-column: 1 / -1; }
  #shop .row-stat { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
  #shop .row-desc { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; line-height: 1.2; }
  #shop .row-own { gap: 3px; }
  #shop .row-own b { line-height: .875; }
  #shop .row-own i { font-size: 10.5px; }
  #shop .row.locked { padding: 3px 8px 5px 6px; }
  #shop .row.locked .ico { width: 24px; height: 24px; }
  #shop .row.locked .row-name { grid-column: auto; }
  #shop .row.locked.far { display: none; }

  @media not all and (min-aspect-ratio: 3/2) {
    /* --ph: the sheet's resting height; --ph-open: pulled up. Pulled up, it slides over the dig rather than
       shrinking it, so the world never has to be refitted; --cover is how much of the dig it hides. */
    :root { --ph: clamp(216px, 32dvh, 330px); --ph-open: min(64dvh, calc(100dvh - 160px)); }
    #app.sheet-open { --cover: calc(var(--ph-open) - var(--ph)); }
    #panel { position: relative; z-index: 6; height: var(--ph); transition: opacity .3s steps(3), height .15s steps(3), margin-top .15s steps(3); }
    #app.sheet-open #panel { height: var(--ph-open); margin-top: calc(var(--ph) - var(--ph-open)); box-shadow: 0 -4px 0 rgba(10,6,5,.5); }
    #grip { display: flex; flex: none; align-items: center; justify-content: center; width: 100%; height: 16px; background: var(--panel); touch-action: none; }
    #grip i { display: block; width: 36px; height: 4px; background: var(--line); box-shadow: 0 2px 0 var(--edge); }
    #grip:active i, #app.sheet-open #grip i { background: var(--dim); }
    /* an upgrade's tip opens just above its tile, where the finger does not cover it and the list does not jump */
    #tip { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(100% - var(--ty, 0px) + 7px); margin: 0; }
    #tip::before { top: 100%; }
    /* a coach that sends you to the shop moves into the sheet (js/ui.js coachHome), its arrow tip on what to press */
    #panel > #coach { z-index: 7; pointer-events: none; }
    #panel > #coach.to-panel { top: auto; bottom: calc(100% - var(--top, 0px) + 13px); }
    #panel.coached #goal > span, #panel.coached #goal-val { visibility: hidden; }      /* the bubble says it instead */
  }
  @supports not (height: 1dvh) {
    @media not all and (min-aspect-ratio: 3/2) { :root { --ph: clamp(216px, 32vh, 330px); --ph-open: min(64vh, calc(100vh - 160px)); } }
  }

  @media (min-aspect-ratio: 3/2) {
    :root { --pw: clamp(236px, 36vw, 300px); }
    #app { flex-direction: row; }
    #panel { width: var(--pw); height: 100%; border-top: 0; border-left: 3px solid var(--edge); padding-right: env(safe-area-inset-right); }
    #shop .row-stat { display: none; }
    #tip { position: fixed; right: calc(var(--pw) + 12px); top: var(--ty, 80px); width: min(330px, calc(100vw - var(--pw) - 24px)); margin: 0; }
    #tip::before { left: auto; right: -5px; top: 16px; width: 5px; height: 10px; margin: 0; }
    #coach.to-panel { left: auto; right: 34px; top: var(--cy, 30%); bottom: auto; transform: translateY(-50%); }
    #coach.to-panel .a-right { display: inline; }
    #coach.to-panel .a-down { display: none; }
  }
}
@media (prefers-reduced-motion: reduce) { #coach, .attn, #trip-core, #goal.hot #goal-val, #gem-btn.pulse { animation: none; } }
