:root {
  --panel: rgba(255, 255, 255, 0.86);
  --ink: #23303d;
  --accent: #ff9f1c;
  --good: #2ec46d;
  --btn: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #6fb3f2; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
/* Buttons react at once (no double-tap zoom); menus can be scrolled with a finger. */
#hud .btn, #hud a { touch-action: manipulation; }
.overlay, .sheet { touch-action: pan-y; overscroll-behavior: contain; }
#hud { position: fixed; inset: 0; pointer-events: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#hud > * { position: absolute; }
.hidden { display: none !important; }

.btn { pointer-events: auto; width: var(--btn); height: var(--btn); border-radius: 18px; border: 3px solid rgba(255, 255, 255, 0.9); background: var(--panel); font-size: calc(var(--btn) * 0.52); line-height: 1; display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18); padding: 0; position: relative; transition: transform 0.08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.btn.sel { border-color: var(--accent); background: #fff3d6; transform: translateY(-6px) scale(1.08); }
.btn .key { position: absolute; right: -6px; bottom: -6px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 7px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.touch .btn .key, .pad .btn .key.kbm { display: none; }
.btn.fresh { animation: pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) 3; }
.btn.pulse { animation: pulse 0.9s ease-in-out infinite; border-color: var(--accent); }
@keyframes pop { 0% { transform: scale(0.2) rotate(-25deg); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 159, 28, 0.7); } 50% { transform: scale(1.14); box-shadow: 0 0 0 16px rgba(255, 159, 28, 0); } }

#toolbar { left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 10px; }
#abilities { right: 14px; bottom: 14px; display: flex; gap: 10px; }
#topright { right: 14px; top: 14px; display: flex; gap: 10px; }
#hud.idle #hint, #hud.idle #toasts, #hud.idle .wanted { display: none; } /* watching is meant to be calm */
.overlay.busy { font-size: 90px; z-index: 9; animation: busy 1.2s linear infinite; }
@keyframes busy { 50% { background: rgba(30, 45, 70, 0.8); } }
.parent .log summary { cursor: pointer; }
.btn.off { filter: grayscale(1); opacity: 0.5; }
#hint .finger.hold { animation: hold 1.4s ease-in-out infinite; }
@keyframes hold { 0%, 15%, 100% { transform: translateY(-8px); } 30%, 85% { transform: translateY(4px) scale(0.9); } }

#power { left: 14px; top: 14px; width: 96px; height: 96px; }
#power svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#power circle { fill: none; stroke-width: 10; }
#power .bg { stroke: rgba(255, 255, 255, 0.75); fill: rgba(255, 255, 255, 0.6); }
#power .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.25s; }
#power .face { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; }
#power .stage { position: absolute; right: -8px; bottom: -4px; min-width: 34px; height: 34px; border-radius: 17px; background: var(--accent); color: #fff; font-weight: 800; font-size: 20px; display: grid; place-items: center; border: 3px solid #fff; }
#power.grow { animation: grow 1s cubic-bezier(0.2, 1.8, 0.4, 1); }
@keyframes grow { 0% { transform: scale(1); } 40% { transform: scale(1.7); } 100% { transform: scale(1); } }

#worldbar { left: 50%; top: 14px; transform: translateX(-50%); width: min(46vw, 520px); }
#worldbar .track { height: 26px; border-radius: 13px; background: rgba(255, 255, 255, 0.7); border: 3px solid #fff; overflow: hidden; position: relative; }
#worldbar .fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffd166, #ef476f); transition: width 0.3s; }
#worldbar .pct { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 16px; text-shadow: 0 0 4px #fff; }
#worldbar .icons { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; font-size: 20px; line-height: 1.1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }
#worldbar .icons span { position: relative; }
#worldbar .icons .done { filter: grayscale(1) brightness(0.75); }
#worldbar .icons .done::after { content: "✔"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--good); font-size: 0.9em; font-weight: 900; text-shadow: 0 0 3px #fff; }
#worldbar .icons .tally { font-weight: 800; font-size: 18px; background: var(--panel); border-radius: 12px; padding: 2px 10px; }

#bcount { pointer-events: none; transform: translate(-50%, -100%); background: var(--panel); border-radius: 16px; padding: 6px 10px 8px; display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; border: 3px solid #fff; white-space: nowrap; }
#bcount .ico { font-size: 30px; }
#bcount .bar { width: 70px; height: 12px; border-radius: 6px; background: #d9dee3; overflow: hidden; }
#bcount .bar i { display: block; height: 100%; background: var(--good); }
#stamp { pointer-events: none; transform: translate(-50%, -50%); font-size: 90px; animation: stamp 1.3s ease-out forwards; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4)); }
#stamp::after { content: "✔"; position: absolute; right: -14px; bottom: -6px; color: var(--good); font-size: 60px; font-weight: 900; text-shadow: 0 0 6px #fff, 0 0 6px #fff; }
@keyframes stamp { 0% { transform: translate(-50%, -50%) scale(3) rotate(-20deg); opacity: 0; } 20% { transform: translate(-50%, -50%) scale(1) rotate(-8deg); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%, -160%) scale(0.8) rotate(-8deg); opacity: 0; } }

#worldbar .wanted { margin-top: 4px; text-align: center; font-size: 24px; letter-spacing: 2px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
#worldbar .wanted.pop { animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1); }
#power.gain { animation: gain 0.3s ease-out; }
#power.gain .fg { filter: drop-shadow(0 0 6px #ffd54a); }
@keyframes gain { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
.spark { pointer-events: none; width: 22px; height: 22px; margin: -11px; border-radius: 50%; background: radial-gradient(circle, #fff 0%, #ffd54a 45%, rgba(255, 159, 28, 0) 72%); z-index: 5; }
.spark.go { transition: left 0.4s cubic-bezier(0.5, 0, 0.8, 0.4), top 0.4s cubic-bezier(0.2, 0.6, 0.6, 1); }

/* Achievements: a card that slides in at the left edge, and the list of all of them. */
#toasts { left: 14px; top: 150px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { position: relative; display: flex; align-items: center; gap: 12px; background: var(--panel); border: 3px solid var(--accent); border-radius: 18px; padding: 8px 16px 8px 10px; max-width: min(78vw, 360px); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18); animation: toast 4.2s ease-in-out forwards; }
.toast .ico { font-size: 38px; line-height: 1; }
.toast .cup { position: absolute; right: -12px; top: -14px; font-size: 24px; }
.toast b, .card b { display: block; font-size: 17px; }
.toast small, .card small { display: block; font-size: 13px; opacity: 0.8; }
@keyframes toast { 0% { transform: translateX(-120%); } 8% { transform: translateX(6%); } 12%, 88% { transform: none; opacity: 1; } 100% { transform: translateX(-120%); opacity: 0; } }
.trophies h2 { margin: 0; font-size: 26px; }
.trophies .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; width: min(88vw, 800px); }
.card { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border-radius: 14px; background: #ece8dd; }
.card .ico { font-size: 30px; line-height: 1; filter: grayscale(1); opacity: 0.45; }
.card.got { background: #fff3d6; outline: 2px solid var(--accent); }
.card.got .ico { filter: none; opacity: 1; }
.card > div { flex: 1; min-width: 0; }
.card .bar { margin-top: 4px; height: 6px; border-radius: 3px; background: #d5d0c4; overflow: hidden; }
.card .bar i { display: block; height: 100%; background: var(--good); }
.parent input[type=range] { flex: 1; max-width: 200px; height: 30px; accent-color: var(--accent); }

#next { left: 50%; top: 42%; transform: translate(-50%, -50%); width: 150px; height: 150px; font-size: 80px; border-radius: 40px; }
#cross { width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 4px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4); }

/* Demonstration bubble: shows the input device doing the thing, never words. */
#hint { left: 50%; bottom: calc(var(--btn) + 64px); transform: translateX(-50%); background: var(--panel); border: 3px solid #fff; border-radius: 22px; padding: 10px 18px; display: flex; align-items: center; gap: 14px; font-size: 40px; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.15); }
#hint .keys { display: grid; grid-template-columns: repeat(3, 34px); gap: 4px; }
.keycap { width: 34px; height: 34px; border-radius: 8px; background: #fff; border: 2px solid var(--ink); border-bottom-width: 5px; font-size: 16px; font-weight: 800; display: grid; place-items: center; }
.keycap.wide { width: 130px; }
.keycap.blink, .padbtn.blink { animation: key 1s steps(2) infinite; }
@keyframes key { 0% { background: #fff; transform: none; } 100% { background: var(--accent); transform: translateY(3px); border-bottom-width: 2px; } }
.padbtn { width: 46px; height: 46px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); font-size: 18px; font-weight: 800; display: grid; place-items: center; }
#hint svg { width: 46px; height: 62px; }
#hint svg .body { fill: #fff; stroke: var(--ink); stroke-width: 3; }
#hint svg .lmb { fill: var(--accent); animation: lmb 1s steps(2) infinite; }
@keyframes lmb { 0% { opacity: 0; } 100% { opacity: 1; } }
#hint .finger { animation: tap 1s ease-in-out infinite; }
@keyframes tap { 0%, 100% { transform: translateY(-8px); } 50% { transform: translateY(4px) scale(0.9); } }

#legal { left: 14px; top: 122px; pointer-events: auto; font-size: 12px; line-height: 1; color: var(--ink); background: rgba(255, 255, 255, 0.85); padding: 5px 8px; border-radius: 8px; text-decoration: none; }
#legal:hover, #legal:focus-visible { background: #fff; text-decoration: underline; }
#stick { left: 26px; bottom: 26px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255, 255, 255, 0.28); border: 3px solid rgba(255, 255, 255, 0.7); }
#stick i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); }

.overlay { inset: 0; pointer-events: auto; background: rgba(30, 45, 70, 0.72); display: grid; place-items: center; overflow: auto; }
.sheet { background: #fdfaf3; border-radius: 28px; padding: 22px; max-width: min(94vw, 860px); max-height: 94vh; overflow: auto; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: center; }
.tile { --btn: 112px; }
.tile .key { left: -6px; right: auto; bottom: -6px; min-width: 28px; height: 28px; border-radius: 14px; font-size: 15px; background: #9aa5ad; }
.tile .key.ok { background: var(--good); }
.tile.complete::after { content: "✔"; position: absolute; right: -8px; top: -10px; width: 34px; height: 34px; border-radius: 50%; background: var(--good); color: #fff; font-size: 22px; font-weight: 900; display: grid; place-items: center; border: 3px solid #fff; }
.touch .tile .key { display: grid; }
.small { --btn: 56px; }
.stickers { font-size: 26px; max-width: 640px; text-align: center; line-height: 1.3; }
.mixer { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 12px; align-items: center; font-size: 28px; width: min(80vw, 420px); }
.mixer input { width: 100%; height: 30px; accent-color: var(--accent); }
.parent { align-items: stretch; min-width: min(90vw, 380px); font-size: 17px; }
.parent h2 { margin: 0; font-size: 22px; }
.parent label { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.parent button { font: inherit; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--ink); background: #fff; cursor: pointer; }
.parent button.danger { border-color: #c0392b; color: #c0392b; }
.parent button.danger.solid { background: #c0392b; color: #fff; }
.parent .note { margin: 6px 0 0; font-size: 14px; max-width: 420px; }
.parent .row { justify-content: stretch; }
.parent .row button { flex: 1; }
.parent label { text-align: left; }
.parent input[type=checkbox] { width: 24px; height: 24px; }

#menuBtn, #legal2, #touchpad { display: none; }
.btn .badge { position: absolute; right: -4px; top: -6px; font-size: 0.5em; }

/* ---------------------------------------------------------------------------------------------
   Compact layout: touch devices and small windows. The playing field comes first:
   - everything that does not steer the creature folds into one menu (top right),
   - the counters shrink, the row of building icons and the hint bubble move out of the way,
   - on touch, the toolbar is replaced by three buttons under the right thumb next to "jump".
   All positions respect the notch and the rounded corners (safe areas).
   --------------------------------------------------------------------------------------------- */
body.compact { --btn: 46px; --sl: calc(8px + env(safe-area-inset-left)); --sr: calc(8px + env(safe-area-inset-right)); --st: calc(8px + env(safe-area-inset-top)); --sb: calc(8px + env(safe-area-inset-bottom)); }
.compact #power { left: var(--sl); top: var(--st); width: 52px; height: 52px; }
.compact #power .face { font-size: 24px; }
.compact #power .stage { min-width: 22px; height: 22px; font-size: 13px; border-width: 2px; right: -6px; bottom: -4px; }
.compact #legal { display: none; }
.compact #worldbar { top: var(--st); width: min(34vw, 300px); }
.compact #worldbar .track { height: 18px; border-width: 2px; }
.compact #worldbar .pct { font-size: 12px; }
.compact #worldbar .icons { display: none; }
.compact #bcount { font-size: 14px; padding: 3px 7px 4px; border-width: 2px; border-radius: 12px; gap: 5px; }
.compact #bcount .ico { font-size: 20px; }
.compact #bcount .bar { width: 44px; height: 8px; }
.compact #stamp { font-size: 56px; }
/* On a phone the stars are only a hint: tiny, half see-through, tucked under the bar. */
.compact #worldbar .wanted { font-size: 10px; letter-spacing: 0; margin-top: 1px; opacity: 0.7; filter: none; }
.compact #toasts { left: var(--sl); top: calc(var(--st) + 62px); }
.compact .toast { padding: 5px 12px 5px 8px; gap: 8px; border-width: 2px; border-radius: 14px; max-width: 62vw; }
.compact .toast .ico { font-size: 26px; }
.compact .toast b { font-size: 14px; }
.compact .toast small { font-size: 11px; }
.compact .trophies .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.compact #next { width: 96px; height: 96px; font-size: 50px; border-radius: 28px; }
.compact #hint { bottom: auto; top: calc(var(--st) + 30px); padding: 6px 12px; gap: 8px; font-size: 26px; border-width: 2px; border-radius: 16px; transform: translateX(-50%) scale(0.8); transform-origin: top center; }

.compact #menuBtn { display: grid; right: var(--sr); top: var(--st); }
.compact #topright { display: none; }
.compact #topright.open { display: grid; grid-template-columns: repeat(3, var(--btn)); gap: 10px; right: var(--sr); top: calc(var(--st) + var(--btn) + 10px); padding: 12px; background: var(--panel); border: 3px solid #fff; border-radius: 20px; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18); pointer-events: auto; --btn: 52px; }
.compact #topright.open #legal2 { display: block; grid-column: 1 / -1; text-align: center; font-size: 13px; color: var(--ink); padding: 8px 4px 2px; }
.compact #toolbar { bottom: var(--sb); gap: 6px; }
.compact #abilities { right: var(--sr); bottom: var(--sb); gap: 6px; }
.compact .tile { --btn: 72px; }
.compact .sheet { padding: 14px; gap: 10px; border-radius: 20px; max-height: 92vh; max-height: 92dvh; }
.compact .mixer { font-size: 20px; gap: 4px 8px; }

/* Touch: stick under the left thumb, action buttons under the right one. */
.touch #toolbar { display: none; }
.touch #stick { left: calc(var(--sl) + 10px); bottom: calc(var(--sb) + 10px); width: 104px; height: 104px; background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.5); }
.touch #stick i { width: 46px; height: 46px; margin: -23px; }
.touch #touchpad, .touch #abilities { display: block; right: var(--sr); bottom: var(--sb); width: 0; height: 0; }
.touch #touchpad .btn, .touch #abilities .btn { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.72); }
.touch #abilities .btn[data-id=stomp] { --btn: 76px; right: 0; bottom: 0; }
.touch #touchpad .btn[data-id=light] { --btn: 66px; right: 86px; bottom: 6px; }
.touch #touchpad .btn[data-id=heavy] { --btn: 62px; right: 8px; bottom: 86px; }
.touch #touchpad .btn[data-id=cycle] { --btn: 44px; right: 84px; bottom: 82px; }
.touch #abilities .btn[data-id=roar] { --btn: 44px; right: 138px; bottom: 76px; }

