/* Pen Escape - HUD and panel styling copied from herd-rush/style.css (trimmed), plus Pen Escape bits at the end */
@font-face { font-family: "Lilita"; src: url("fonts/LilitaOne-Regular.ttf") format("truetype"); font-display: block; }
:root {
  --u: clamp(11px, min(2.1vw, 3.3vh), 22px);   /* base unit: legible from 640x360 up to desktop */
  --ink: #1d1442;
}
html, body { margin: 0; height: 100%; overflow: hidden; background: #7cc8ff; }
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
  font-family: "Lilita", "Arial Black", system-ui, sans-serif; color: #fff; }
canvas#game { display: block; position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; touch-action: none; outline: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
.hidden { display: none !important; }
.ic { display: inline-block; width: 1.25em; height: 1.25em; background: center/contain no-repeat; vertical-align: middle; flex: none; }
.stroke { paint-order: stroke fill; -webkit-text-stroke: 0.18em var(--ink); }
.ic.coin { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='21' r='17' fill='%23b86a00'/%3E%3Ccircle cx='20' cy='19' r='17' fill='%23ffc928'/%3E%3Ccircle cx='20' cy='19' r='11.5' fill='%23ffe37a' stroke='%23e89a00' stroke-width='3'/%3E%3Cpath d='M16 13h6l-2 6h4l-8 9 2-7h-4z' fill='%23e89a00'/%3E%3C/svg%3E"); }
.ic.snd { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M6 15h7l9-8v26l-9-8H6z' fill='%23fff' stroke='%231d1442' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M27 13q5 7 0 14M31 9q9 11 0 22' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ic.mute { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M6 15h7l9-8v26l-9-8H6z' fill='%23fff' stroke='%231d1442' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M27 14l9 12M36 14l-9 12' stroke='%23ff5a6e' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ic.ad { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect x='4' y='8' width='32' height='24' rx='6' fill='%23fff'/%3E%3Cpath d='M17 14v12l10-6z' fill='%237a3cff'/%3E%3C/svg%3E"); }
/* pills */
.pill { display: inline-flex; align-items: center; gap: 0.35em; background: linear-gradient(#3b2a86, #241a5c); border: 0.2em solid #fff; border-radius: 2em;
  padding: 0.15em 0.8em 0.15em 0.35em; font-size: calc(var(--u) * 1.35); box-shadow: 0 0.25em 0 rgba(0,0,0,0.25); text-shadow: 0 0.12em 0 rgba(0,0,0,0.35); }
.pill .ic { width: 1.5em; height: 1.5em; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes pulse { 50% { transform: scale(1.07); } }
#hud { position: absolute; inset: 0; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
#hud .tl { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); }
#hud .tc { position: absolute; left: 50%; top: max(8px, env(safe-area-inset-top)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 0.3em; }
#hud .tr { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 0.5em; pointer-events: auto; }
#hud .bottom { position: absolute; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 0.2em; }
#hud .tl { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
#hud .bottom { pointer-events: none; opacity: 0.94; }
/* buttons */
.btn { pointer-events: auto; font-family: inherit; color: #fff; border: 0; cursor: pointer; position: relative; border-radius: 0.8em;
  text-shadow: 0 0.1em 0 rgba(0,0,0,0.35); box-shadow: 0 0.3em 0 rgba(0,0,0,0.28), inset 0 -0.3em 0 rgba(0,0,0,0.18), inset 0 0.18em 0 rgba(255,255,255,0.35);
  border: 0.17em solid #fff; transition: transform 0.08s; display: inline-flex; align-items: center; justify-content: center; gap: 0.35em; }
.btn:active { transform: translateY(0.15em) scale(0.97); }
.btn.round { width: calc(var(--u) * 3.1); height: calc(var(--u) * 3.1); border-radius: 1em; font-size: var(--u); }
.btn.round .ic { width: 1.9em; height: 1.9em; }
.btn.green { background: linear-gradient(#6af06a, #26b14a); }
.btn.blue { background: linear-gradient(#5cc8ff, #2a7cf0); }
.btn.orange { background: linear-gradient(#ffb43a, #f06a1a); }
.btn.purple { background: linear-gradient(#b38bff, #7a3cff); }
.btn.big { font-size: calc(var(--u) * 1.6); padding: 0.4em 1.6em; }
.btn.mid { font-size: calc(var(--u) * 1.15); padding: 0.45em 0.9em; }
#hint .hand { position: absolute; width: 4.2em; height: 4.2em; left: -1em; top: -0.6em; animation: tap 1.1s ease-in-out infinite;
  background: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M22 30V10a4 4 0 0 1 8 0v16l1-4a4 4 0 0 1 8 1v4a4 4 0 0 1 8 1v4a4 4 0 0 1 8 1v12c0 9-7 17-17 17h-3c-6 0-10-3-13-8l-9-14a4 4 0 0 1 6-5z' fill='%23fff' stroke='%231d1442' stroke-width='3.5' stroke-linejoin='round'/%3E%3C/svg%3E"); }
#logo { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%) rotate(-4deg); text-align: center; line-height: 0.85; animation: logoIn 0.7s cubic-bezier(.2,1.5,.4,1); transition: opacity 0.6s, transform 0.6s; }
#logo div { paint-order: stroke fill; -webkit-text-stroke: 0.14em var(--ink); text-shadow: 0 0.1em 0 var(--ink); }
#logo .t1 { font-size: calc(var(--u) * 5.2); color: #ffd23f; }
#logo .t2 { font-size: calc(var(--u) * 6.4); color: #ff7a1a; }
#logo.out { opacity: 0; transform: translate(-50%, -90%) rotate(-4deg) scale(0.8); }
@keyframes logoIn { 0% { transform: translate(-50%, -50%) scale(0.3) rotate(-14deg); } 100% { transform: translate(-50%, -50%) scale(1) rotate(-4deg); } }
#flash { position: absolute; inset: 0; background: radial-gradient(circle, rgba(255,255,255,0) 40%, rgba(255,40,80,0.45)); opacity: 0; transition: opacity 0.25s; }
#flash.on { opacity: 1; transition: none; }
/* world-space popups */
#pops, #labels { position: absolute; inset: 0; overflow: hidden; }
.pop { position: absolute; left: 0; top: 0; display: none; will-change: transform; }
.pop > span { display: block; transform: translate(-50%, -100%); white-space: nowrap; paint-order: stroke fill; -webkit-text-stroke: 0.16em var(--ink); text-shadow: 0 0.08em 0 var(--ink); }
.modal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(20,12,50,0.55); pointer-events: auto; }
.panel { background: linear-gradient(#5a3fd1, #3a2697); border: 0.25em solid #fff; border-radius: 1.6em; padding: 1em 1.2em 1.2em; text-align: center; box-shadow: 0 0.5em 0 rgba(0,0,0,0.3);
  font-size: var(--u); max-width: 92vw; max-height: 92vh; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: 0.7em; animation: panelIn 0.35s cubic-bezier(.2,1.4,.4,1); }
@keyframes panelIn { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.ptitle { font-size: 2.6em; line-height: 1; paint-order: stroke fill; -webkit-text-stroke: 0.14em var(--ink); text-shadow: 0 0.1em 0 var(--ink); }
.ptitle.gold { color: #ffd23f; }
.pcoins, .rescoins { display: inline-flex; align-items: center; gap: 0.3em; font-size: 1.7em; background: rgba(0,0,0,0.25); padding: 0.1em 0.8em 0.1em 0.3em; border-radius: 1em; }
.resline { font-size: 1.4em; }
.row { display: flex; gap: 0.7em; }
#loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2em; background: radial-gradient(circle at 50% 40%, #8fe0ff, #2f8fff); pointer-events: auto; font-size: var(--u); transition: opacity 0.4s; }
#loading.out { opacity: 0; pointer-events: none; }
.ltitle { display: flex; flex-direction: column; align-items: center; line-height: 0.85; transform: rotate(-4deg); }
.ltitle span { font-size: 5em; paint-order: stroke fill; -webkit-text-stroke: 0.14em var(--ink); text-shadow: 0 0.1em 0 var(--ink); color: #ffd23f; }
.ltitle span + span { font-size: 6.2em; color: #ff7a1a; }
.lbar { width: 16em; height: 1.2em; border-radius: 1em; background: rgba(29,20,66,0.5); border: 0.18em solid #fff; overflow: hidden; }
#lfill { height: 100%; width: 0; background: linear-gradient(90deg, #ffd23f, #49e06a); transition: width 0.15s; }

/* ---------- Pen Escape ---------- */
html, body { background: #8fd8ff; }
.ic.heart { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M20 35C6 25 3 18 3 12.5 3 7 7.5 3.5 12 3.5c3.5 0 6 2 8 5 2-3 4.5-5 8-5 4.5 0 9 3.5 9 9C37 18 34 25 20 35z' fill='%23ff4d6d' stroke='%231d1442' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M9 11c0-2 1.5-3.5 3.5-3.5' stroke='%23fff' stroke-width='3' stroke-linecap='round' fill='none'/%3E%3C/svg%3E"); }
.ic.heart.off { filter: grayscale(1) brightness(1.6); opacity: 0.45; }
.ic.retry { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M31 20a11 11 0 1 1-4-8.5' fill='none' stroke='%231d1442' stroke-width='8' stroke-linecap='round'/%3E%3Cpath d='M31 20a11 11 0 1 1-4-8.5' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round'/%3E%3Cpath d='M24 4l10 3-3 10z' fill='%23fff' stroke='%231d1442' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.ic.paw { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg fill='%23fff' stroke='%231d1442' stroke-width='2.5'%3E%3Cellipse cx='20' cy='27' rx='9' ry='7.5'/%3E%3Ccircle cx='9' cy='17' r='4'/%3E%3Ccircle cx='15.5' cy='9.5' r='4'/%3E%3Ccircle cx='24.5' cy='9.5' r='4'/%3E%3Ccircle cx='31' cy='17' r='4'/%3E%3C/g%3E%3C/svg%3E"); }
#hud .tl { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.pill.lvl { font-size: calc(var(--u) * 1.0); padding: 0.2em 0.8em; background: linear-gradient(#ffb43a, #f06a1a); }
.pill.hearts { gap: 0.15em; padding: 0.2em 0.45em; background: linear-gradient(#ff7aa0, #e8366a); }
.pill.hearts .ic { width: 1.55em; height: 1.55em; transition: transform 0.2s; }
.pill.hearts .ic.lost { animation: heartLost 0.6s ease-out; }
@keyframes heartLost { 0% { transform: scale(1.7) rotate(-15deg); filter: none; opacity: 1; } 40% { transform: scale(0.7) rotate(10deg); } 100% { transform: scale(1); } }
.pill.left { font-size: calc(var(--u) * 1.15); }
.shake { animation: shake 0.4s; }
@keyframes shake { 20% { transform: translateX(-0.3em); } 40% { transform: translateX(0.3em); } 60% { transform: translateX(-0.2em); } 80% { transform: translateX(0.15em); } }
#hud .tc .pill.hearts.shake { animation: shake 0.4s; }

/* tap hint: a hand tapping a free animal, placed by main.js */
#hint { position: absolute; left: 50%; top: 60%; width: 1px; height: 1px; font-size: calc(var(--u) * 1.05); }
#hint .hand { left: -0.9em; top: 0.1em; }
#htext { position: absolute; left: 50%; bottom: calc(max(10px, env(safe-area-inset-bottom)) + var(--u) * 3.6); transform: translateX(-50%); font-size: calc(var(--u) * 1.2); white-space: nowrap; font-size: 1.25em; padding: 0.15em 0.7em; border-radius: 1em; background: rgba(29,20,66,0.72); border: 0.15em solid #fff; }
@keyframes tap { 0%, 100% { transform: translate(0, 0.9em) scale(1); } 45% { transform: translate(0, 0) scale(0.9); } 55% { transform: translate(0, 0) scale(0.9); } }
#hint::before { content: ""; position: absolute; left: -1.6em; top: -1.6em; width: 3.2em; height: 3.2em; border-radius: 50%; border: 0.25em solid #fff; animation: ping 1.1s ease-out infinite; }
@keyframes ping { 0%, 40% { transform: scale(0.4); opacity: 0; } 50% { opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }

/* logo */
#logo { top: 26%; }
#logo .t1 { font-size: calc(var(--u) * 4.2); color: #ffd23f; }
#logo .t2 { font-size: calc(var(--u) * 5.2); color: #ff7a1a; }
.ltitle span + span { color: #ff7a1a; }

/* world popups */
.pop.bang > span { font-size: calc(var(--u) * 2.4); color: #ffd23f; }
.pop.bye > span { font-size: calc(var(--u) * 1.3); color: #fff; }
.pop.ouch > span { font-size: calc(var(--u) * 1.3); color: #ff6b8a; }

/* result panels */
.ptitle.pink { color: #ff8fb0; }
.panel .btn.big { min-width: 8.5em; }
.stars { display: flex; gap: 0.3em; align-items: flex-end; }
.stars i { width: 4.2em; height: 4.2em; background: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M20 3l5 10.5 11.5 1.5-8.5 8 2.2 11.5L20 29l-10.2 5.5L12 23l-8.5-8 11.5-1.5z' fill='%23271b66' stroke='%23fff' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.stars i:nth-child(2) { width: 5.2em; height: 5.2em; }
.stars i.on { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M20 3l5 10.5 11.5 1.5-8.5 8 2.2 11.5L20 29l-10.2 5.5L12 23l-8.5-8 11.5-1.5z' fill='%23ffd23f' stroke='%23fff' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M13 16l5-1 2-4' stroke='%23fff6c4' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); animation: starIn 0.45s cubic-bezier(.2,1.8,.4,1) both; }
@keyframes starIn { 0% { transform: scale(0) rotate(-60deg); } 100% { transform: scale(1) rotate(0); } }
.rescoins { color: #ffd23f; }
.resline { color: #e7defe; }

@media (max-aspect-ratio: 4/5) {  /* phone portrait */
  :root { --u: clamp(11px, 3.6vw, 20px); }
  #logo { top: 21%; }
}
@media (max-height: 420px) { /* small landscape */
  .panel { padding: 0.5em 1em 0.7em; gap: 0.45em; }
  .ptitle { font-size: 2em; }
  .stars i { width: 3em; height: 3em; } .stars i:nth-child(2) { width: 3.6em; height: 3.6em; }
}
