@font-face { font-family: 'Barlow'; src: url('../../assets/fonts/barlow-condensed-latin-800-italic.woff2') format('woff2'); font-weight: 800; font-style: italic; font-display: swap; }
@font-face { font-family: 'Barlow'; src: url('../../assets/fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'DM'; src: url('../../assets/fonts/dm-sans-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'DM'; src: url('../../assets/fonts/dm-sans-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --ink: #17351f; --ink2: #4b6a52; --cream: #fffaf0; --card: #fff3dc; --line: #e8d9b8;
  --sun: #ffd23f; --sun2: #e0a800; --coral: #ff6b4a; --leaf: #2f9e4f; --leaf2: #23803d; --sky: #4fb0f2;
  --shadow: 0 18px 50px #0a1f1240;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd0f0; color: var(--ink); font-family: DM, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible + span { outline: 3px solid var(--sky); outline-offset: 3px; }
[hidden] { display: none !important; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#touch { position: fixed; inset: 0; z-index: 2; display: none; touch-action: none; }
body.playing #touch { display: block; }
#fade { position: fixed; inset: 0; background: #fffaf0; opacity: 0; pointer-events: none; z-index: 30; transition: opacity .35s ease; }
#fade.on { opacity: 1; transition: none; }

.back { position: fixed; top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); z-index: 6; padding: 10px 14px; border-radius: 999px; background: #ffffffd9; color: var(--ink); font-weight: 700; font-size: 13px; text-decoration: none; box-shadow: 0 6px 18px #0002; }
body:not(.menu-on) .back { display: none; }

/* ---------- panels ---------- */
.panel { position: fixed; z-index: 5; top: 18px; right: 18px; bottom: 18px; width: min(410px, 42vw); overflow-y: auto; overscroll-behavior: contain;
  background: #fffaf0ee; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 26px; padding: 22px 22px 18px; box-shadow: var(--shadow); border: 3px solid #ffffff; }
.logo { font: 800 italic 74px/0.82 Barlow, sans-serif; letter-spacing: -1px; display: flex; gap: 10px; align-items: baseline; text-shadow: 0 4px 0 #17351f22; }
.logo span { color: var(--leaf); }
.logo b { color: var(--coral); font-weight: 800; }
.tag { margin: 8px 0 14px; color: var(--ink2); font-size: 14px; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.stats-row > div { background: var(--card); border-radius: 14px; padding: 9px 11px; }
.stats-row small { display: block; font-size: 10px; font-weight: 700; letter-spacing: 1.2px; color: var(--ink2); }
.stats-row b { font: 800 italic 26px/1.1 Barlow, sans-serif; }
.coin-num::before, .coin-chip i { content: ''; display: inline-block; width: .72em; height: .72em; margin-right: 5px; border-radius: 50%; vertical-align: -1px;
  background: radial-gradient(circle at 35% 30%, #fff3b0 0 18%, #ffd23f 22% 60%, #d99a00 64%); box-shadow: inset 0 0 0 2px #c98d00; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 12px; }
.modes button { background: #fff; border: 3px solid var(--line); border-radius: 16px; padding: 9px 6px; text-align: center; transition: transform .1s; }
.modes button b { display: block; font: 800 italic 22px Barlow, sans-serif; }
.modes button small { display: block; font-size: 10.5px; color: var(--ink2); line-height: 1.25; margin-top: 2px; }
.modes button[aria-pressed=true] { border-color: var(--leaf); background: #e7f8e3; box-shadow: 0 4px 0 var(--leaf2); }
.modes button:active { transform: translateY(2px); }
.play { width: 100%; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 16px 20px; border-radius: 20px; background: var(--sun); color: var(--ink);
  font: 800 italic 40px/1 Barlow, sans-serif; letter-spacing: 1px; box-shadow: 0 7px 0 var(--sun2), 0 12px 24px #b0800044; transition: transform .08s, box-shadow .08s; }
.play span { font-size: .6em; }
.play:hover { filter: brightness(1.04); }
.play:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--sun2); }
.card { background: var(--card); border-radius: 18px; padding: 12px 14px; margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.card-head b { font: 800 italic 24px Barlow, sans-serif; }
.card-head span { font-size: 12px; font-weight: 700; color: var(--ink2); }
.missions ol, .mini-missions { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 7px; }
.mission { display: grid; grid-template-columns: 26px 1fr auto; gap: 4px 9px; align-items: center; background: #fff; border-radius: 12px; padding: 8px 10px; font-size: 13px; }
.mission i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #f0e3c4; font-size: 12px; font-weight: 700; grid-row: 1 / 3; }
.mission.done i { background: var(--leaf); color: #fff; }
.mission span { font-weight: 700; line-height: 1.25; }
.mission em { font-style: normal; font-size: 11px; color: var(--ink2); }
.mission .bar { grid-column: 2 / 4; height: 6px; background: #f0e3c4; border-radius: 9px; overflow: hidden; }
.mission .bar b { display: block; height: 100%; background: linear-gradient(90deg, var(--leaf), #8ee06a); border-radius: 9px; }
.mission.done span { text-decoration: line-through; text-decoration-color: #2f9e4f88; }
.fine { font-size: 11.5px; color: var(--ink2); margin: 8px 0 0; line-height: 1.45; }
.menu-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 14px; }
.menu-buttons button { background: #fff; border: 3px solid var(--line); border-radius: 16px; padding: 10px 4px 9px; font-weight: 700; font-size: 13px; position: relative; }
.menu-buttons button span { display: block; font-size: 22px; margin-bottom: 2px; }
.menu-buttons button i { position: absolute; top: 6px; right: 8px; font-style: normal; font-size: 10px; background: var(--coral); color: #fff; border-radius: 999px; padding: 1px 6px; }
.menu-buttons button:hover, .modes button:hover { border-color: #d9c18c; }
.settings { display: grid; gap: 10px; margin-top: 12px; background: var(--card); border-radius: 16px; padding: 12px 14px; }
.switch { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 46px; height: 26px; border-radius: 999px; background: #d9cdb0; position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px #0003; }
.switch input:checked + span { background: var(--leaf); }
.switch input:checked + span::after { left: 23px; }
.controls-help { font-size: 11.5px; color: var(--ink2); text-align: center; margin: 14px 0 0; }

/* side panels */
.side-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.side-head h2 { font: 800 italic 38px/1 Barlow, sans-serif; margin: 0; flex: 1; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; background: #fff; border: 3px solid var(--line); font-weight: 700; font-size: 18px; display: grid; place-items: center; flex: none; }
.coin-chip { display: inline-flex; align-items: center; background: #fff; border: 3px solid #f2dc9a; border-radius: 999px; padding: 5px 12px; font: 800 italic 22px Barlow, sans-serif; }
.count { font: 800 italic 22px Barlow, sans-serif; color: var(--ink2); }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--card); padding: 4px; border-radius: 14px; margin-bottom: 12px; }
.tabs button { padding: 9px 2px; border-radius: 11px; font-weight: 700; font-size: 12.5px; color: var(--ink2); }
.tabs button[aria-selected=true] { background: #fff; color: var(--ink); box-shadow: 0 2px 6px #0001; }
.shop-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.item { background: #fff; border: 3px solid var(--line); border-radius: 18px; padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 6px; position: relative; min-height: 150px; }
.item.on { border-color: var(--leaf); box-shadow: 0 4px 0 var(--leaf2); }
.item.preview { border-color: var(--sky); }
.item .swatch { width: 100%; height: 58px; border-radius: 12px; display: grid; place-items: center; font-size: 34px; position: relative; overflow: hidden; }
.item .swatch .dino-dot { width: 46px; height: 46px; border-radius: 50% 50% 46% 46%; box-shadow: inset -6px -6px 0 #0002; position: relative; }
.item .swatch .dino-dot::after { content: ''; position: absolute; width: 9px; height: 9px; background: #fff; border-radius: 50%; top: 12px; left: 9px; box-shadow: 0 0 0 3px #1b1b22 inset, 18px 0 0 0 #fff; }
.item .swatch .belly { position: absolute; width: 26px; height: 16px; left: 10px; bottom: 5px; border-radius: 50%; }
.item b { font: 800 italic 21px/1 Barlow, sans-serif; }
.item small { font-size: 11px; color: var(--ink2); line-height: 1.3; flex: 1; }
.item .buy { margin-top: 2px; padding: 8px; border-radius: 11px; background: var(--sun); font-weight: 700; font-size: 13px; text-align: center; box-shadow: 0 3px 0 var(--sun2); }
.item .buy.owned { background: #e7f8e3; box-shadow: 0 3px 0 #b9e3b0; }
.item .buy.equipped { background: var(--leaf); color: #fff; box-shadow: 0 3px 0 var(--leaf2); }
.item .buy.short { background: #f0e3c4; box-shadow: 0 3px 0 #d9cdb0; color: #8a7a5a; }
.item.wide { grid-column: 1 / -1; min-height: 0; display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 4px 12px; }
.item.wide .icon { font-size: 30px; grid-row: 1 / 4; width: 52px; height: 52px; border-radius: 14px; background: var(--card); display: grid; place-items: center; }
.item.wide .buy { grid-column: 3; grid-row: 1 / 4; min-width: 96px; }
.pips { display: flex; gap: 4px; }
.pips i { width: 18px; height: 7px; border-radius: 9px; background: #f0e3c4; }
.pips i.on { background: linear-gradient(90deg, var(--leaf), #8ee06a); }
.trophy-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.trophy { background: #fff; border: 3px solid var(--line); border-radius: 16px; padding: 10px; display: grid; grid-template-columns: 40px 1fr; gap: 2px 10px; align-items: center; opacity: .62; }
.trophy.got { opacity: 1; border-color: #f2c94c; background: #fffbea; }
.trophy span { font-size: 28px; grid-row: 1 / 4; filter: grayscale(1); }
.trophy.got span { filter: none; }
.trophy b { font: 800 italic 18px/1.05 Barlow, sans-serif; }
.trophy small { font-size: 11px; color: var(--ink2); line-height: 1.25; }
.trophy em { font-style: normal; font-size: 11px; font-weight: 700; color: #b07d00; }
.lifetime { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 12px; }
.lifetime div b { display: block; font: 800 italic 22px Barlow, sans-serif; }
.lifetime div small { color: var(--ink2); font-size: 10.5px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.hud-left { position: absolute; left: max(16px, env(safe-area-inset-left)); top: max(14px, env(safe-area-inset-top)); display: flex; gap: 12px; align-items: center; }
.pause-btn { pointer-events: auto; width: 50px; height: 50px; font: 800 italic 20px Barlow, sans-serif; background: #ffffffe6; border-color: #fff; box-shadow: 0 6px 16px #0003; }
.hearts { display: flex; gap: 4px; }
.heart { width: 30px; height: 28px; position: relative; filter: drop-shadow(0 3px 3px #0004); }
.heart::before, .heart::after { content: ''; position: absolute; top: 2px; width: 15px; height: 24px; background: #ff4d5e; border-radius: 15px 15px 0 0; border: 2px solid #fff; border-bottom: 0; }
.heart::before { left: 15px; transform: rotate(-45deg); transform-origin: 0 100%; }
.heart::after { left: 0; transform: rotate(45deg); transform-origin: 100% 100%; }
.heart.empty::before, .heart.empty::after { background: #ffffff55; }
.heart.lost { animation: heartpop .5s ease; }
@keyframes heartpop { 40% { transform: scale(1.5); } 100% { transform: scale(1); } }
.hud-right { position: absolute; right: max(16px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); text-align: right; color: #fff; text-shadow: 0 3px 0 #0d2a17aa, 0 0 14px #0006; }
.score { display: flex; align-items: baseline; gap: 8px; justify-content: flex-end; }
.score b { font: 800 italic 52px/0.95 Barlow, sans-serif; letter-spacing: 1px; }
.mult { font: 800 italic 22px Barlow, sans-serif; background: var(--coral); color: #fff; border-radius: 10px; padding: 1px 8px; text-shadow: none; box-shadow: 0 3px 0 #c9452d; }
.coin-chip.big { margin-top: 6px; color: var(--ink); text-shadow: none; font-size: 26px; border-color: #ffe9a6; box-shadow: 0 4px 12px #0003; }
.coin-chip.bump { animation: bump .18s ease; }
@keyframes bump { 50% { transform: scale(1.12); } }
.hud-right small { display: block; margin-top: 4px; font: 700 15px Barlow, sans-serif; letter-spacing: 1px; opacity: .95; }
.powers { position: absolute; left: max(16px, env(safe-area-inset-left)); top: calc(max(14px, env(safe-area-inset-top)) + 62px); display: grid; gap: 6px; }
.power { display: grid; grid-template-columns: 30px 92px; align-items: center; gap: 8px; background: #ffffffe0; border-radius: 999px; padding: 4px 12px 4px 5px; box-shadow: 0 4px 12px #0002; }
.power span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; }
.power i { display: block; height: 8px; border-radius: 9px; background: #e9dfc8; overflow: hidden; }
.power i b { display: block; height: 100%; border-radius: 9px; }
.power.ending { animation: blink .4s steps(2) infinite; }
@keyframes blink { 50% { opacity: .45; } }

#banner { position: fixed; left: 50%; top: 27%; transform: translate(-50%, -50%) scale(.9); z-index: 6; text-align: center; color: #fff; pointer-events: none; opacity: 0; transition: opacity .4s, transform .4s; text-shadow: 0 4px 0 #0d2a17aa, 0 0 22px #0007; }
#banner.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#banner small { display: block; font: 700 16px Barlow, sans-serif; letter-spacing: 4px; }
#banner b { display: block; font: 800 italic clamp(44px, 9vw, 92px)/0.95 Barlow, sans-serif; white-space: nowrap; }
#hint { position: fixed; left: 50%; bottom: 20%; transform: translateX(-50%); z-index: 6; pointer-events: none; opacity: 0; transition: opacity .15s; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#hint.on { opacity: 1; }
#hint b { font: 800 italic 42px/1 Barlow, sans-serif; color: #fff; padding: 8px 22px; border-radius: 999px; background: var(--leaf); box-shadow: 0 6px 0 var(--leaf2), 0 10px 24px #0004; animation: nudge .5s ease-in-out infinite alternate; }
#hint.slide b { background: var(--sky); box-shadow: 0 6px 0 #2a83c0, 0 10px 24px #0004; }
#hint.move b { background: var(--coral); box-shadow: 0 6px 0 #c9452d, 0 10px 24px #0004; }
#hint small { font-weight: 700; font-size: 13px; color: #fff; text-shadow: 0 2px 6px #000a; }
@keyframes nudge { to { transform: translateY(-6px); } }
#toasts { position: fixed; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 8; display: grid; gap: 8px; pointer-events: none; width: min(420px, calc(100vw - 180px)); }
.toast { background: #fffaf0f2; border-radius: 16px; padding: 10px 14px; box-shadow: 0 10px 26px #0003; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; animation: toastIn .35s ease; border: 3px solid #fff; }
.toast span { font-size: 22px; }
.toast small { display: block; font-weight: 400; color: var(--ink2); font-size: 12px; }
.toast.out { animation: toastOut .4s ease forwards; }
@keyframes toastIn { from { transform: translateY(-14px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-14px); opacity: 0; } }

#pad { position: fixed; inset: auto 0 0 0; z-index: 5; display: flex; justify-content: space-between; padding: 0 max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); pointer-events: none; }
#pad > div { display: flex; gap: 12px; }
#pad .pad-right { flex-direction: column-reverse; }
#pad button { pointer-events: auto; width: 76px; height: 76px; border-radius: 50%; background: #ffffff55; border: 3px solid #ffffffcc; color: #fff; font-size: 30px; text-shadow: 0 2px 4px #0006; touch-action: none; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#pad button.down { background: #ffffffaa; transform: scale(.94); }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: #0d2a1755; padding: 18px; overflow-y: auto; }
.sheet { width: min(430px, 100%); background: var(--cream); border-radius: 26px; padding: 22px; box-shadow: var(--shadow); border: 3px solid #fff; text-align: center; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); max-height: calc(100vh - 36px); overflow-y: auto; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.sheet h2 { font: 800 italic 46px/1 Barlow, sans-serif; margin: 2px 0 6px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 3px; color: var(--coral); margin: 0; }
.final-score { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 12px; }
.final-score b { font: 800 italic 66px/1 Barlow, sans-serif; color: var(--leaf); }
.best-badge { background: var(--coral); color: #fff; font-weight: 700; font-size: 12px; padding: 5px 10px; border-radius: 999px; transform: rotate(-6deg); animation: wiggle 1s ease-in-out infinite; }
@keyframes wiggle { 50% { transform: rotate(4deg) scale(1.08); } }
.sheet .stats-row { text-align: left; }
.rewards { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 10px 0 12px; }
.rewards span { background: #fffbea; border: 2px solid #f2c94c; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.rewards:empty { display: none; }
.sheet .mini-missions { margin: 16px 0 2px; text-align: left; }
.sheet .play { margin-top: 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.row button { background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 11px; font-weight: 700; font-size: 15px; }

/* ---------- layouts ---------- */
@media (max-width: 760px) and (orientation: portrait) {
  .panel { top: auto; left: 10px; right: 10px; bottom: 10px; width: auto; max-height: 60vh; border-radius: 24px; padding: 16px 16px 14px; }
  .panel.side { max-height: 64vh; }
  .logo { font-size: 54px; }
  .tag { margin: 4px 0 10px; font-size: 13px; }
  .stats-row b { font-size: 22px; }
  .play { font-size: 34px; padding: 13px; }
  .modes button b { font-size: 19px; }
  .modes button small { font-size: 9.5px; }
  .score b { font-size: 42px; }
  .coin-chip.big { font-size: 22px; }
  #toasts { width: calc(100vw - 32px); top: calc(max(14px, env(safe-area-inset-top)) + 118px); }
  #hint b { font-size: 34px; padding: 6px 18px; }
  .shop-list, .trophy-list { grid-template-columns: repeat(2, 1fr); }
  #pad button { width: 68px; height: 68px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .panel { top: 8px; bottom: 8px; right: 8px; width: min(380px, 48vw); padding: 14px 16px; border-radius: 20px; }
  .logo { font-size: 46px; margin-bottom: 10px; }
  .tag { display: none; }
  .stats-row { margin-bottom: 8px; }
  .stats-row > div { padding: 5px 9px; }
  .stats-row b { font-size: 20px; }
  .play { font-size: 28px; padding: 10px; }
  .card { margin-top: 10px; }
  .score b { font-size: 40px; }
  .hud-right small { display: none; }
  #banner { top: 30%; }
  #hint { bottom: 12%; }
  #hint b { font-size: 32px; }
  #pad button { width: 62px; height: 62px; font-size: 24px; }
  .sheet { padding: 14px 18px; }
  .sheet h2 { font-size: 34px; }
  .final-score b { font-size: 46px; }
  .back { top: 8px; left: 8px; padding: 8px 12px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  #hint b, .best-badge { animation: none; }
}
