@font-face { font-family: "Pixelify Sans"; src: url(fonts/pixelify-cyr.woff2) format("woff2"); font-weight: 400 700; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url(fonts/pixelify-lat.woff2) format("woff2"); font-weight: 400 700; unicode-range: U+0000-00FF, U+2000-206F, U+2190-2193; font-display: swap; }
@font-face { font-family: "Rubik"; src: url(fonts/rubik-cyr.woff2) format("woff2"); font-weight: 300 900; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; font-display: swap; }
@font-face { font-family: "Rubik"; src: url(fonts/rubik-lat.woff2) format("woff2"); font-weight: 300 900; unicode-range: U+0000-00FF, U+2000-206F; font-display: swap; }

:root {
  --paper: #F3E6C8; --paper2: #E4D0A6; --ink: #2B1D14; --amber: #F2A230; --terra: #D2553A; --teal: #2F8C7E; --stone: #9A8F80;
  --px: "Pixelify Sans", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", monospace; --tx: "Rubik", system-ui, sans-serif;
  --gy: 70vh; --tex: none;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--ink); font-family: var(--tx); font-weight: 500; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#stage { position: fixed; inset: 0; }
#stage canvas { image-rendering: pixelated; display: block; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; z-index: 5; }
.pxi, .ico img { image-rendering: pixelated; vertical-align: middle; }
.ico { display: inline-flex; width: 18px; height: 18px; margin-right: 8px; vertical-align: -2px; }
.ico img { width: 100%; height: 100%; }
.ico-coin { display: inline-block; width: 22px; height: 22px; background-size: 100% 100%; image-rendering: pixelated; vertical-align: middle; }

/* paper, ink outline, hard shadow */
.paper, .plate, .btn, .card, .sheet, .panel-page, .tab, .tablet { background-color: var(--paper); background-image: var(--tex); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); border-radius: 4px; }
.plate { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; font-family: var(--px); font-size: 20px; font-variant-numeric: tabular-nums; }
.btn, .tab, h2, h3, .plaque, .toggle-row .lbl, .disc, .concept-tag { text-transform: uppercase; letter-spacing: 0.5px; }
.btn { font-family: var(--px); font-size: 24px; color: var(--ink); padding: 10px 22px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 2px; line-height: 1.1; }
.btn:hover { background-color: #F8EDD4; }
.btn:active, .btn.pressed { transform: translate(4px, 4px); box-shadow: none; }
.btn.amber { background-color: var(--amber); }
.btn.amber:hover { background-color: var(--terra); color: var(--paper); }
.btn.teal { background-color: var(--teal); color: var(--paper); }
.btn.terra { background-color: var(--terra); color: var(--paper); }
.btn.stone, .btn:disabled { background-color: var(--stone); color: #4a4038; cursor: default; }
.btn.sm { font-size: 18px; padding: 6px 12px; box-shadow: 3px 3px 0 var(--ink); }
.btn.sm.sq { padding: 6px 8px; }
.btn.sm .ico { margin-right: 6px; width: 14px; height: 14px; }
.btn.big { font-size: 28px; padding: 14px 34px; }
.btn:focus-visible, .tab:focus-visible, .disc:focus-visible { outline: 3px dashed var(--amber); outline-offset: 3px; }
h2, h3 { font-family: var(--px); font-weight: 700; margin: 0; }

/* concept */
#concept { background: var(--paper2); background-image: var(--tex); z-index: 20; }
.concept-scroll { position: absolute; inset: 0 0 86px 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.concept-sheet { width: min(100%, 1100px, calc((100vh - 120px) * 1.0 + 300px)); margin: 0 auto; padding: 14px 12px 20px; }
.concept-tag { font-family: var(--px); font-size: 18px; text-align: center; margin-bottom: 10px; }
.concept-img-wrap { position: relative; border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); border-radius: 4px; overflow: hidden; background: var(--paper); }
.concept-img-wrap img { display: block; width: 100%; height: auto; }
#concept.zoom .concept-sheet { width: max(1100px, 260vw); }
.concept-img-wrap img { cursor: zoom-in; }
#concept.zoom .concept-img-wrap img { cursor: zoom-out; }
.concept-hot { position: absolute; left: 33.5%; top: 92.4%; width: 32%; height: 5.8%; background: transparent; border: 0; cursor: pointer; }
.concept-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 86px; display: flex; align-items: center; justify-content: center; background: var(--paper); border-top: 3px solid var(--ink); }

/* menu */
#menu { pointer-events: none; }
#menu > * { pointer-events: auto; }
.topbar { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: flex-start; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.topbar .plate { font-size: 18px; }
.menu-col { position: absolute; left: 0; right: 0; top: 52px; bottom: calc(100% - var(--gy) + 10px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; pointer-events: none; }
.menu-col > * { pointer-events: auto; }
.logo { width: min(440px, 80vw); height: auto; image-rendering: auto; filter: none; }
.menu-stack { display: flex; flex-direction: column; gap: 12px; width: min(300px, 78vw); }
.menu-stack .btn { width: 100%; }
.menu-stack .btn.play { font-size: 30px; padding: 14px 22px; }
.menu-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 13px; color: var(--paper); text-shadow: 2px 2px 0 var(--ink); }
/* portrait: logo in the sky, buttons in the soil */
body.portrait .menu-col { top: 50px; bottom: auto; height: calc(var(--gy) - 120px); justify-content: center; }
body.portrait .menu-stack { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--gy) + 46px); }
body.portrait .menu-stack .btn { padding: 8px 16px; font-size: 22px; }
body.portrait .menu-stack .btn.play { font-size: 26px; padding: 10px 16px; }
@media (max-height: 520px) and (orientation: landscape) {
  .logo { width: min(300px, 40vw); }
  .menu-col { flex-direction: row; gap: 28px; }
  .menu-stack { gap: 8px; width: 240px; }
  .menu-stack .btn { font-size: 20px; padding: 6px 14px; }
  .menu-stack .btn.play { font-size: 24px; padding: 8px 14px; }
}

/* pages */
.panel-page { position: absolute; inset: 12px; max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; overflow: hidden; }
.panel-page.wide { max-width: 1200px; }
.ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 3px solid var(--ink); background: var(--paper2); }
.ph h2 { font-size: clamp(24px, 4vw, 36px); }
.tabs { display: flex; gap: 8px; padding: 12px 12px 4px; flex-wrap: wrap; }
.tab { font-family: var(--px); font-size: 18px; padding: 6px 12px; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); }
.tab.on { background-color: var(--amber); }
.tab:active { transform: translate(3px, 3px); box-shadow: none; }

/* mode cards */
.mode-cards { flex: 1; display: flex; gap: 22px; align-items: center; justify-content: center; padding: 18px; flex-wrap: wrap; overflow: auto; }
.card.mode { width: min(330px, 100%); padding: 12px; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.card.mode:active { transform: translate(4px, 4px); box-shadow: none; }
.card.mode canvas { width: 100%; image-rendering: pixelated; border: 3px solid var(--ink); display: block; background: var(--paper2); }
.card.mode h3 { font-size: 26px; margin: 10px 0 4px; }
.card.mode p { margin: 0; font-size: 14px; line-height: 1.35; }
.card.mode:hover h3 { color: var(--terra); }

/* shop */
.shop-sub { padding: 2px 14px 6px; font-size: 13px; }
.grid { flex: 1; overflow: auto; padding: 10px 14px 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; align-content: start; grid-auto-rows: max-content; -webkit-overflow-scrolling: touch; }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 420px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 10px; } }
.item { position: relative; padding: 8px 8px 14px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.item .pv { aspect-ratio: 1/1; background: var(--paper2); border: 3px solid var(--ink); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.item .pv canvas { image-rendering: pixelated; max-width: 92%; max-height: 92%; }
.item.bg .pv { aspect-ratio: 16/10; }
.item.bg .pv canvas { max-width: 100%; max-height: 100%; width: 100%; height: 100%; }
.item .nm { font-family: var(--px); font-size: 16px; line-height: 1.1; min-height: 2.2em; }
.item .rar { font-size: 11px; color: #5a4a3a; margin-top: -4px; }
.item .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-family: var(--px); font-size: 17px; }
.item .row .btn { font-size: 15px; padding: 4px 10px; box-shadow: 2px 2px 0 var(--ink); border-width: 2px; }
.item .lockmsg { font-size: 12px; line-height: 1.25; display: flex; gap: 6px; align-items: center; color: #4a3a2c; }
.item .strip { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; border-top: 3px solid var(--ink); }
.item.sel { border-color: var(--teal); box-shadow: 4px 4px 0 var(--teal); outline: 3px solid var(--teal); }
.item .chk { position: absolute; right: 12px; top: 12px; width: 28px; height: 28px; background: var(--teal); border: 3px solid var(--ink); display: flex; align-items: center; justify-content: center; }
.item .slot { position: absolute; left: 12px; top: 12px; font-size: 11px; background: var(--paper); border: 2px solid var(--ink); padding: 0 4px; }
.cant { color: var(--terra); }

/* records tablet */
.tablet { margin: 14px; flex: 1; overflow: auto; background-color: #D8CFBD; padding-bottom: 12px; }
#recBody { padding: 10px 14px; }
.bigrec { text-align: center; padding: 10px; }
.bigrec .v { font-family: var(--px); font-size: clamp(44px, 9vw, 72px); font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 10px 0; }
.stat { background: var(--paper); border: 3px solid var(--ink); padding: 8px 10px; }
.stat b { display: block; font-family: var(--px); font-size: 24px; font-weight: 400; }
.stat span { font-size: 12px; }
table.lb { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-family: var(--px); font-size: 18px; }
table.lb td { background: var(--paper); padding: 6px 10px; border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink); }
table.lb td:first-child { border-left: 3px solid var(--ink); width: 54px; }
table.lb td:last-child { border-right: 3px solid var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
table.lb tr.me td { background: var(--paper2); }
table.lb a { color: var(--ink); }
table.lb canvas { image-rendering: pixelated; width: 26px; vertical-align: middle; }
.medal { display: inline-flex; width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--ink); align-items: center; justify-content: center; font-size: 15px; }
.note { font-size: 13px; padding: 6px 2px; }

/* map */
#map { background: #3A2A1E; background-image: var(--tex); }
.map-head { position: absolute; left: 0; right: 0; top: 0; height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px; z-index: 3; }
.map-nav { display: flex; align-items: center; gap: 8px; }
.map-nav .plate { min-width: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 44vw; }
.btn.arrow { font-size: 26px; padding: 0 12px; height: 38px; }
.map-scroll { position: absolute; left: 0; right: 0; top: 62px; bottom: 30px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.map-strip { position: relative; height: 100%; }
.sheetimg { position: absolute; top: 0; height: 100%; }
.sheetimg img { height: 100%; width: 100%; display: block; }
.plaque { position: absolute; left: 50%; top: 4%; transform: translateX(-50%); white-space: nowrap; font-family: var(--px); font-size: clamp(14px, 2.2vh, 20px); padding: 4px 12px; background: var(--paper); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); z-index: 2; }
.map-svg { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 1; }
.disc { position: absolute; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); background: #D8CFBD; font-family: var(--px); font-size: 20px; color: var(--ink); cursor: pointer; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 0; }
.disc.done { border: 5px solid var(--teal); background: #E8E0CC; }
.disc.cur { background: var(--amber); animation: bob 0.8s steps(1) infinite; }
.disc.lock { background: var(--stone); color: #4a4038; cursor: pointer; }
.disc .lk { position: absolute; right: -8px; top: -8px; width: 22px; height: 22px; background: var(--paper); border: 2px solid var(--ink); display: flex; align-items: center; justify-content: center; }
.disc .lk img { width: 14px; height: 14px; }
.disc .st { position: absolute; top: 48px; left: 50%; transform: translateX(-50%); display: flex; gap: 1px; }
.disc .st img { width: 13px; height: 13px; }
.disc .cap { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-family: var(--tx); font-size: 10px; background: var(--paper); border: 2px solid var(--ink); padding: 0 4px; }
@keyframes bob { 0% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (max-width: 640px) { #mapPoints { display: none; } .map-nav .plate { max-width: 52vw; font-size: 15px; } }
.map-hint { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; color: var(--paper); font-size: 12px; }

/* hud */
#hud { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#hud .btn, #hud .touch { pointer-events: auto; }
.hud-coins { position: absolute; left: 10px; top: 10px; font-size: 24px; }
.hud-right { position: absolute; right: 10px; top: 10px; display: flex; align-items: center; gap: 10px; }
.hud-score { font-family: var(--px); font-size: clamp(18px, 3.6vw, 28px); font-variant-numeric: tabular-nums; color: var(--ink); background: rgba(243, 230, 200, 0.85); border: 3px solid var(--ink); padding: 2px 10px; letter-spacing: 1px; }
.hud-score .hi { color: #6a5a4a; }
.hud-path { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); width: min(36vw, 360px); height: 34px; }
.path-line { position: absolute; left: 0; right: 14px; top: 22px; height: 0; border-top: 3px dashed var(--ink); }
#pathDino { position: absolute; top: 2px; width: 26px; image-rendering: pixelated; margin-left: -13px; }
.path-flag { position: absolute; right: -6px; top: 4px; width: 20px; height: 20px; }
#hudLevel { position: absolute; left: 50%; top: 32px; transform: translateX(-50%); font-family: var(--px); font-size: 14px; font-weight: 400; background: var(--paper); border: 2px solid var(--ink); padding: 0 6px; white-space: nowrap; }
.hud-hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 14px; color: var(--paper); text-shadow: 2px 2px 0 var(--ink); }
.touch { display: none; position: absolute; left: 12px; right: 12px; bottom: 14px; justify-content: space-between; gap: 14px; }
body.touchdev .touch { display: flex; }
body.touchdev .hud-hint { display: none; }
.tbtn { font-size: 22px; padding: 12px 16px; min-width: 40%; min-height: 64px; opacity: 0.94; touch-action: none; }
body.touchdev:not(.portrait) .touch { top: calc(var(--run) + 8px); bottom: auto; }
body.touchdev:not(.portrait) .tbtn { min-height: 0; height: calc(100vh - var(--run) - 18px); max-height: 80px; min-width: 30%; font-size: 20px; padding: 4px 12px; }
@media (max-height: 520px) { .sheet { padding: 10px 14px 12px; } .sheet h2 { font-size: 28px; } .toggle-row { padding: 4px; font-size: 20px; } .sheet .acts { gap: 8px; margin-top: 8px; } .sheet .btn { font-size: 19px; padding: 6px 14px; } .sheet .btn.big { font-size: 22px; } .stars img { width: 34px; height: 34px; } .sheet .big { font-size: 30px; } .sheet canvas.pv { max-width: 260px; } }
body.portrait .touch { top: calc(var(--run) + 24px); bottom: auto; flex-direction: row; }
body.portrait .tbtn { min-height: 92px; font-size: 24px; }
body.portrait .hud-path { top: 62px; width: 80vw; }
@media (max-width: 560px) { .hud-coins { font-size: 18px; } .hud-score { font-size: 17px; } }

/* modal */
#modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(43, 29, 20, 0.45); padding: 12px; }
#modal.center { align-items: center; }
.sheet { width: min(520px, 100%); max-height: calc(100% - 10px); overflow: auto; padding: 18px 18px 20px; text-align: center; animation: up 150ms steps(3) both; }
@keyframes up { from { transform: translateY(60px); } to { transform: none; } }
.sheet h2 { font-size: clamp(30px, 6vw, 44px); margin-bottom: 6px; }
.sheet .big { font-family: var(--px); font-size: 40px; font-variant-numeric: tabular-nums; }
.sheet p { margin: 6px 0; font-size: 15px; }
.sheet .acts { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.sheet .line { display: flex; justify-content: center; gap: 18px; font-family: var(--px); font-size: 22px; flex-wrap: wrap; }
.stars { display: flex; justify-content: center; gap: 8px; margin: 8px 0; }
.stars img { width: 44px; height: 44px; }
.sheet canvas.pv { width: 100%; max-width: 360px; image-rendering: pixelated; border: 3px solid var(--ink); }
.unlock { background: var(--paper2); border: 3px solid var(--ink); padding: 6px 10px; margin-top: 10px; font-size: 14px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 4px; font-family: var(--px); font-size: 24px; border-bottom: 2px dashed var(--paper2); }
.tog { width: 72px; height: 34px; border: 3px solid var(--ink); background: var(--stone); position: relative; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); padding: 0; }
.tog::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: var(--paper); border: 3px solid var(--ink); }
.tog.on { background: var(--teal); }
.tog.on::after { left: auto; right: 3px; }
.toggle-row .lbl { display: flex; align-items: center; gap: 10px; }
.toggle-row .lbl img { width: 22px; height: 22px; }

#toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 40; background: var(--paper); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 8px 14px; font-family: var(--px); font-size: 18px; max-width: 92vw; text-align: center; }

/* softly rounded buttons */
.btn, .tab { border-radius: 10px; }
.btn.sm, .item .row .btn { border-radius: 8px; }
.tog { border-radius: 10px; }
.tog::after { border-radius: 6px; }
.plate { border-radius: 8px; }
.hud-right { right: max(12px, env(safe-area-inset-right)); }

/* language */
.langbtn { gap: 8px; font-size: 16px; padding: 4px 10px; }
.langbtn .flag, .langopt .flag { image-rendering: pixelated; flex: none; }
.langs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0 4px; }
.langopt { justify-content: flex-start; gap: 10px; font-size: 18px; padding: 8px 12px; text-transform: none; }
.langopt.on { background-color: var(--teal); color: var(--paper); }
body.lang-zh .btn, body.lang-zh .tab, body.lang-zh h2, body.lang-zh h3 { font-weight: 700; }
@media (max-width: 560px) { .langbtn span { display: none; } }
/* level progress */
.path-bar { position: absolute; left: 0; right: 14px; top: 18px; height: 10px; border: 3px solid var(--ink); background: var(--paper); border-radius: 6px; overflow: hidden; box-shadow: 2px 2px 0 var(--ink); }
#pathFill { height: 100%; width: 0; background: var(--teal); }
.hud-path .path-line { display: none; }
#pathDino { z-index: 2; top: -4px; }
.path-flag { z-index: 2; top: 2px; }
#hudLevel { top: 36px; left: 30%; }
#hudLeft { position: absolute; left: 72%; top: 36px; transform: translateX(-50%); font-family: var(--px); font-size: 14px; font-weight: 400; background: var(--amber); border: 2px solid var(--ink); border-radius: 6px; padding: 0 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#hudLevel { border-radius: 6px; }

/* level path sits under the top row when the screen is not wide enough */
@media (max-width: 1100px) {
  #hud.levelmode .hud-path { top: 58px; }
}
@media (max-width: 1100px) and (max-height: 430px) {
  #hud.levelmode .hud-path { top: 52px; }
}
body.portrait #hud.levelmode .hud-path { top: 60px; }

/* menu level plate with progress to the next level */
#menuLevel { flex-direction: column; align-items: stretch; gap: 3px; padding: 5px 12px 6px; min-width: 210px; max-width: min(320px, 60vw); }
#menuLevel .ml-top { font-size: 18px; line-height: 1.1; }
#menuLevel .ml-bar { display: block; height: 12px; border: 3px solid var(--ink); border-radius: 6px; background: var(--paper2); overflow: hidden; }
#menuLevel .ml-bar i { display: block; height: 100%; background: var(--amber); }
#menuLevel .ml-note { font-family: var(--tx); font-size: 12px; line-height: 1.2; white-space: normal; }
.topbar { align-items: flex-start; }
@media (max-width: 480px) { #menuLevel { min-width: 0; max-width: 54vw; } #menuLevel .ml-top { font-size: 15px; } }
