:root { background: #2b2729; --pause-size: clamp(56px, 9.4svh, 76px); }
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body.is-loading > :not(#game-preloader) { visibility: hidden; }
.game-preloader { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: #292428; color: #fff; }
.loading-content { width: min(340px, calc(100vw - 64px)); text-align: center; }
#loading-label { margin: 0 0 16px; font: 28px/1.2 'Matcha Style', sans-serif; -webkit-text-stroke: 4px #3b1d13; paint-order: stroke fill; }
.loading-panel { position: relative; width: 100%; }
.loading-panel img { display: block; width: 100%; }
.loading-track { position: absolute; left: 8.5%; right: 8.5%; top: 35%; height: 30%; padding: 4px; border: 3px solid #311c17; border-radius: 10px; background: #78513b; overflow: hidden; }
#loading-fill { width: 100%; height: 100%; border-radius: 4px; background: #ffedb4; transform: scaleX(0); transform-origin: left; transition: transform 0.15s linear; }
#loading-retry { padding: 10px 18px; margin-top: 20px; border: 2px solid #3b1d13; border-radius: 9px; background: #ffedb4; color: #3b1d13; font: 18px 'Matcha Style', sans-serif; }
.tutorial-hint { --keys-width: 24.266667%; --mouse-width: 15.6%; position: fixed; inset-inline: 0; bottom: 20px; margin-inline: auto; width: 60%; container-type: inline-size; z-index: 4; pointer-events: none; }
.tutorial-panel { position: relative; width: 100%; }
.tutorial-panel img { display: block; width: 100%; }
.tutorial-panel p { position: absolute; inset: 23% 7% 18%; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0; padding: 0.12em 0.16em; color: #fff; text-align: center; font: 5.333333cqw/1.08 'Matcha Style', sans-serif; -webkit-text-stroke: 0.22em #3b1d13; paint-order: stroke fill; }
.tutorial-panel p span { min-width: 0; max-width: 100%; overflow-wrap: anywhere; text-wrap: balance; }
.tutorial-camera-hint { font-size: 0.7em; line-height: 1.1; margin-top: 0.15em; }
.tutorial-panel .item-value-equation { flex-direction: row; gap: 0.2em; font-size: clamp(24px, 8cqw, 78px); white-space: nowrap; }
.tutorial-panel .item-value-equation img { width: 1.25em; height: 1.25em; object-fit: contain; flex-shrink: 0; }
.tutorial-panel .item-value-equation span { overflow-wrap: normal; }
/* Let the controls overlap the board edges, leaving more room for the instruction. */
.tutorial-panel .tutorial-keys { position: absolute; left: -4%; top: 52.5%; width: var(--keys-width); object-fit: contain; transform: translateY(-50%); }
.tutorial-panel .tutorial-mouse { position: absolute; right: -4%; top: 52.5%; width: var(--mouse-width); object-fit: contain; transform: translateY(-50%); }
.tutorial-panel.has-keys p { left: calc(var(--keys-width) - 2%); right: calc(var(--mouse-width) - 2%); }
#scene { display: block; width: 100%; height: 100svh; outline: none; touch-action: none; cursor: default; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#scene[data-ready="true"] { cursor: default; }
#scene.is-camera-dragging { cursor: none; }
#scene.is-first-person { cursor: crosshair; }
#tutorial-arrows { position: fixed; inset: 0; width: 100%; height: 100svh; z-index: 7; pointer-events: none; }
#scene[data-animation="paused"] { cursor: grab; }
#scene[data-animation="paused"]:active { cursor: grabbing; }
#scene.laying-tracks, #scene.laying-tracks:active { cursor: crosshair; }
.cover-title {
  --cover-title-top: clamp(5px, 0.8svh, 12px);
  position: fixed;
  top: var(--cover-title-top);
  left: 50%;
  translate: -50% 0;
  width: auto;
  max-width: calc(100vw - 32px);
  height: min(225px, max(56px, calc(27.75svh - var(--cover-title-top))));
  object-fit: contain;
  z-index: 1;
  pointer-events: none;
  user-select: none;
}
@media (max-width: 900px) {
  .cover-title { --cover-title-top: min(92px, 16svh); }
}
.coins-panel { position: fixed; top: 16px; left: 16px; z-index: 3; width: 250px; aspect-ratio: 345 / 99; background: url('../assets/CoinPanel.webp') center / contain no-repeat; pointer-events: none; }
.coins-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#coins-value { position: absolute; inset-block: 0; left: 41%; max-width: 52%; display: flex; align-items: center; color: #ffffff; font: 42px/1 'Matcha Style', sans-serif; font-size: calc(42px * var(--amount-scale, 1)); -webkit-text-stroke: calc(6px * var(--amount-scale, 1)) #3b1d13; paint-order: stroke fill; transition: transform 0.15s ease; }
.coin-icon { position: absolute; left: 5%; top: 4%; width: 29%; height: 92%; }
.coins-panel.is-gaining #coins-value { transform: scale(1.07); }
#coin-flights { position: fixed; inset: 0; z-index: 5; overflow: hidden; pointer-events: none; }
.coin-flight { position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: url('../assets/CoinPanel.webp') 7% center / 345% 100% no-repeat; will-change: transform; }
.mole-shop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; overflow: hidden; background: #120a0399; outline: none; }
.mole-shop-frame { position: relative; width: min(960px, calc(100vw - 32px), calc(130svh - 41.6px)); aspect-ratio: 13 / 10; container-type: inline-size; isolation: isolate; }
.mole-shop img { display: block; user-select: none; pointer-events: none; }
.mole-shop-base, .mole-shop-canopy, .mole-shop-sign { position: absolute; }
.mole-shop-base { left: 0; top: 12.5%; width: 100%; z-index: 1; }
.mole-shop-canopy { left: 2.8%; top: 1%; width: 94.4%; z-index: 0; }
.mole-shop-sign { left: 33%; top: calc(38.461538cqw - 50svh); width: 39%; z-index: 3; }
.mole-shop-sign-art { width: 100%; }
#mole-shop-title { position: absolute; inset: 26% 0 0; display: grid; place-items: center; margin: 0; color: #ffe169; font: 5.2cqw/1 'Matcha Style', sans-serif; white-space: nowrap; -webkit-text-stroke: 0.12em #49230f; paint-order: stroke fill; }
.mole-shop-close { position: absolute; right: 2.4%; top: 24%; z-index: 4; width: 8%; min-width: 32px; padding: 0; border: 0; border-radius: 20%; background: transparent; }
.mole-shop-close-art { width: 100%; }
.mole-shop .mole-shop-mascot { display: none; }
.shop-upgrades, .shop-helmets { position: absolute; z-index: 2; inset: 37% 11.5% 6.8%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5cqw 1.4cqw; overflow-y: auto; padding: 0.5cqw; scrollbar-width: thin; scrollbar-color: #eab266 #713408; }
.mole-shop-tabs { position: absolute; z-index: 4; top: calc(24% + 0.75cqw); right: 13.5%; width: 52%; display: flex; justify-content: center; gap: 6%; }
.mole-shop-tab { width: 47%; border: 0; padding: 0; background: transparent; }
.mole-shop-tab-art { width: 100%; }
.shop-helmets { top: 39%; left: 15%; right: 15%; align-content: start; gap: 0.5cqw 1.4cqw; }
.shop-helmet { position: relative; width: 100%; aspect-ratio: 412 / 237; container-type: inline-size; }
.helmet-base { width: 100%; }
.helmet-icon { position: absolute; top: 8%; left: 25%; width: 50%; height: 58%; object-fit: contain; }
.helmet-status { position: absolute; left: 5%; right: 5%; bottom: 9%; margin: 0; text-align: center; color: #3b1d13; font: 7cqw/1 'Matcha Style', sans-serif; }
.shop-helmet .helmet-price { top: auto; bottom: 8%; left: 8%; width: 42%; }
.shop-helmet .helmet-price.is-unaffordable { left: 29%; }
.shop-helmet .helmet-price span { font-size: calc(8cqw * var(--price-scale, 1)); }
.helmet-action { position: absolute; bottom: 8%; right: 8%; width: 34%; padding: 0; border: 0; background: transparent; }
.helmet-action img { width: 100%; }
.helmet-action span { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 7cqw/1 'Matcha Style', sans-serif; -webkit-text-stroke: 0.14em #3b1d13; paint-order: stroke fill; }
.shop-helmet[data-state="owned"] .helmet-action { right: 33%; }
.shop-helmet.is-locked .helmet-status { inset: 0; display: grid; place-items: center; font-size: 10cqw; }
.shop-upgrade { position: relative; width: 100%; aspect-ratio: 511 / 134; container-type: inline-size; align-self: start; }
.upgrade-base { width: 100%; }
.upgrade-icon { position: absolute; left: 3%; top: 10%; width: 22%; height: 78%; object-fit: contain; }
.upgrade-name { position: absolute; top: 10%; left: 28%; right: 4%; height: 29%; display: flex; align-items: center; margin: 0; color: #31180a; font: 4.4cqw/1.05 'Matcha Style', sans-serif; text-transform: uppercase; }
.upgrade-levels { position: absolute; left: 28%; top: 43%; display: flex; gap: 1cqw; }
.upgrade-levels span { position: relative; width: 4.7cqw; height: 4.7cqw; }
.upgrade-levels img { position: absolute; width: 100%; }
.upgrade-levels .level-filled { visibility: hidden; }
.upgrade-levels .is-filled .level-filled { visibility: visible; }
.upgrade-price { position: absolute; left: 57%; top: 43%; width: 25.5%; }
.upgrade-price-art { width: 100%; }
.upgrade-price span { position: absolute; left: 37%; right: 4%; top: 0; bottom: 0; display: grid; place-items: center; color: white; font: 5.4cqw/1 'Matcha Style', sans-serif; font-size: calc(5.4cqw * var(--price-scale, 1)); -webkit-text-stroke: 0.14em #3b1d13; paint-order: stroke fill; }
.upgrade-price.is-unaffordable span { color: #ff5454; }
.upgrade-buy { position: absolute; top: 43%; right: 4%; width: 11.5%; padding: 0; border: 0; background: transparent; }
.upgrade-buy img { width: 100%; }
@keyframes tutorial-buy-cue { 50% { filter: brightness(1.45); } }
.upgrade-buy.is-tutorial-choice { animation: tutorial-buy-cue 1.1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .upgrade-buy.is-tutorial-choice { animation: none; } }
.upgrade-max { position: absolute; right: 8%; bottom: 19%; color: #3b1d13; font: 5.5cqw/1 'Matcha Style', sans-serif; }
.upgrade-effects { position: fixed; inset: 0; z-index: 6; overflow: hidden; pointer-events: none; }
.upgrade-particle { position: absolute; background: #ffe989; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 94%, 50% 72%, 21% 94%, 32% 57%, 2% 35%, 39% 35%); }
.upgrade-particle.is-coin { background: url('../assets/Icon_Coin.webp') center / contain no-repeat; clip-path: none; }
.shop-upgrade.is-locked .upgrade-base { filter: saturate(0.55) brightness(0.85); }
.shop-upgrade.is-locked .upgrade-name { inset: 0; height: auto; justify-content: center; font-size: 7cqw; }
@media (max-width: 600px) {
  .mole-shop-frame { width: calc(100vw - 12px); height: min(92svh, 760px); aspect-ratio: auto; }
  .mole-shop-base { top: 9%; height: 91%; clip-path: inset(24% 0 0); }
  .mole-shop .mole-shop-mascot { display: block; position: absolute; top: calc(30.84% - 19.23cqw); left: 0; width: 100%; z-index: 1; clip-path: inset(0 0 71.43%); }
  .mole-shop-canopy { top: 5%; }
  .mole-shop-sign { top: calc(46svh - min(46svh, 380px)); }
  .mole-shop-close { top: 19%; width: 10%; }
  .shop-upgrades, .shop-helmets { inset: 35% 6% 7%; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 5px; }
  .shop-helmets { top: 37%; }
  .mole-shop-tabs { top: calc(19% + 0.75cqw); right: 15.5%; width: 65%; }
  .upgrade-name { top: 7%; height: 31%; font-size: 4cqw; line-height: 1; }
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; transition: transform 80ms ease-out, filter 80ms ease-out; transform-origin: center; }
@media (hover: hover) {
  button:enabled:hover { filter: brightness(1.12); transform: scale(1.2); }
}
button:enabled:active { filter: brightness(0.9); transform: scale(0.96); }
button:disabled { opacity: 0.45; cursor: default; }
:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
  button:enabled:is(:hover, :active) { transform: none; }
}
.camera-zoom { position: fixed; z-index: 6; left: max(16px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); color: #fff; font: 20px/1.15 'Matcha Style', Arial, sans-serif; -webkit-text-stroke: 3px #3b1d13; paint-order: stroke fill; pointer-events: none; user-select: none; }
.game-controls { position: fixed; z-index: 5; bottom: 52px; left: 16px; display: flex; gap: 8px; align-items: center; }
.touch-controls { display: none; position: fixed; inset: 0; z-index: 5; pointer-events: none; user-select: none; }
.is-touch-input .touch-controls { display: block; }
.touch-stick { --stick-radius: clamp(42px, 13vmin, 64px); position: absolute; left: calc(max(18px, env(safe-area-inset-left)) + var(--stick-radius)); bottom: calc(max(24px, env(safe-area-inset-bottom)) + var(--stick-radius)); width: calc(var(--stick-radius) * 2); height: calc(var(--stick-radius) * 2); margin: calc(-1 * var(--stick-radius)); border: 2px solid #fff8; border-radius: 50%; background: #321b1433; box-shadow: 0 2px 8px #21110d33; display: grid; place-items: center; opacity: 0.6; }
.touch-stick.is-active { opacity: 1; }
.is-touch-input .touch-stick { bottom: calc(max(52px, calc(env(safe-area-inset-bottom) + 44px)) + var(--stick-radius)); }
.touch-stick-thumb { width: 44%; height: 44%; border-radius: 50%; border: 2px solid #fffd; background: #fff8; box-shadow: 0 2px 5px #21110d44; }
.is-touch-input .tutorial-hint { width: 90%; bottom: max(150px, calc(env(safe-area-inset-bottom) + 140px)); }
.is-touch-input .game-controls { left: auto; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
.is-touch-input .pause-toggle { top: max(9px, env(safe-area-inset-top)); right: max(9px, env(safe-area-inset-right)); }
.is-touch-input .coins-panel { top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); }
.editor-toggle, .editor-panel { color: #3e3020; font: 13px/1.45 system-ui, sans-serif; box-shadow: 0 8px 28px #39261026; }
.editor-toggle { display: flex; gap: 9px; align-items: center; padding: 10px 15px; border: 1px solid #e3d1b7; border-radius: 12px; background: #fffaf0f5; }
.editor-toggle { font-weight: 700; letter-spacing: 0.08em; }
.pause-icon { display: grid; place-items: center; width: clamp(48px, 8svh, 64px); aspect-ratio: 1; padding: 0; border: 0; border-radius: 20%; background: transparent; }
.pause-icon img { display: block; width: 100%; pointer-events: none; }
.pause-toggle { position: fixed; z-index: 6; top: 12px; right: 12px; width: var(--pause-size); }
.pause-menu { position: fixed; inset: 0; margin: 0; padding: clamp(12px, 4svh, 30px); width: 100%; height: 100%; max-width: none; max-height: none; border: 0; background: transparent; color: #fff3dc; overflow: auto; }
.pause-menu[open] { display: flex; }
.pause-menu::backdrop { background: rgb(49 24 13 / 70%); }
body:has(.pause-menu[open]) :is(.cover-title, .tutorial-hint) { visibility: hidden; }
.pause-content { width: min(100%, 400px); margin: auto; display: flex; flex-direction: column; align-items: center; gap: clamp(8px, 1.8svh, 16px); text-align: center; }
.pause-content h1, .pause-language, .pause-action { font-family: 'Matcha Style', Arial, sans-serif; font-weight: normal; }
.pause-content h1 { margin: 0 0 clamp(3px, 1.4svh, 10px); color: #ffcf73; font-size: clamp(48px, 10svh, 76px); line-height: 1; -webkit-text-stroke: 0.15em #3b1d13; paint-order: stroke fill; }
.pause-language { align-self: stretch; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: clamp(22px, 4.6svh, 35px); line-height: 1.08; }
.pause-action { width: min(100%, 290px); aspect-ratio: 499 / 151; min-height: 52px; padding: 9px 19px; border: 0; border-radius: 16px; background: url('../assets/Btn_Clear.webp') center / 100% 100% no-repeat; color: #fff5dd; font-size: clamp(20px, 3.7svh, 30px); line-height: 1.1; -webkit-text-stroke: 0.16em #3b1d13; paint-order: stroke fill; }
.pause-resume { width: min(100%, 345px); min-height: clamp(62px, 12svh, 92px); margin-top: clamp(13px, 4svh, 33px); color: #ffe49f; font-size: clamp(30px, 6svh, 45px); }
.editor-panel { position: fixed; z-index: 2; }
.editor-dot { width: 7px; height: 7px; border-radius: 50%; background: #a79883; }
.editor-toggle[aria-pressed="true"] { background: #49301d; color: #fff8eb; border-color: #49301d; }
.editor-toggle[aria-pressed="true"] .editor-dot { background: #ffc16f; }
.editor-panel { --editor-top: calc(16px + var(--pause-size) * 1.1); top: var(--editor-top); right: 16px; width: 306px; max-height: calc(100svh - var(--editor-top) - 16px); overflow-y: auto; padding: 18px; border: 1px solid #eadbc5; border-radius: 18px; background: #fffaf2f5; backdrop-filter: blur(14px); }
.editor-heading { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 14px; }
.editor-heading h1 { margin: 2px 0 0; font-size: 20px; font-weight: 650; letter-spacing: -0.04em; }
.eyebrow { margin: 0; font-size: 9px; font-weight: 700; letter-spacing: 0.12em; color: #8c765b; }
.editor-badge { font-size: 10px; color: #73634f; padding: 4px 8px; border: 1px solid #e8dac5; border-radius: 20px; white-space: nowrap; }
.editor-badge[data-dirty="true"] { background: #fff0d4; border-color: #eac485; color: #925c14; }
.field-label { display: block; font-size: 11px; font-weight: 650; margin-bottom: 7px; }
.light-field { margin-bottom: 12px; }
.object-row { display: flex; gap: 7px; margin-top: 7px; }
.object-row button { flex: 1; font-size: 11px; }
.editor-selection { margin: 7px 0; color: #80603a; font-size: 11px; font-weight: 650; }
.editor-panel select, .editor-panel input[type="number"] { min-width: 0; width: 100%; border: 1px solid #ddcbb2; border-radius: 8px; padding: 8px; background: #fffdfa; color: #3e3020; }
.editor-panel button { border: 1px solid #dfcdb5; border-radius: 8px; padding: 8px 10px; background: #fffdfa; color: #4a3722; }
.editor-panel .object-row > button:only-child { flex: 0 1 calc(100% - 16px); margin-inline: auto; }
.editor-hint, .editor-help { color: #89765d; font-size: 11px; margin: 8px 0 12px; }
.editor-panel fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.track-builder { padding: 10px; margin-bottom: 14px; background: #f3ebdf; border-radius: 10px; }
.track-builder .editor-hint { margin-bottom: 0; }
#editor-delete { color: #a83922; }
.segmented { display: flex; gap: 4px; background: #efe5d5; padding: 4px; border-radius: 10px; }
.segmented button { flex: 1; border: 0; background: transparent; padding: 7px 2px; }
.segmented button[aria-pressed="true"] { background: #fffdf7; box-shadow: 0 1px 4px #6c421f20; font-weight: 650; }
.axis-row { display: flex; gap: 7px; margin: 10px 0; }
.axis-row button { flex: 1; font-weight: 750; }
.axis-row button[data-axis="x"] { color: #b2513d; }
.axis-row button[data-axis="y"] { color: #4b8856; }
.axis-row button[data-axis="z"] { color: #4872a2; }
.axis-row button[aria-pressed="true"] { background: #f1e4cf; border-color: #b28c5c; }
.value-row { display: flex; gap: 7px; }
.value-row input { text-align: center; font-variant-numeric: tabular-nums; }
.value-row button { width: 35px; flex-shrink: 0; font-size: 17px; padding: 4px; }
.step-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; color: #89765d; font-size: 11px; margin: 9px 0 12px; }
.step-row select { width: 82px; padding: 4px 6px; font-size: 11px; }
.checkbox-row { display: flex; gap: 7px; align-items: center; font-size: 11px; margin: 12px 0; }
.checkbox-row input { accent-color: #a66b2d; }
.transform-summary { margin: 10px 0; padding: 9px 0; border-top: 1px solid #eadbc5; border-bottom: 1px solid #eadbc5; font-size: 10px; }
.transform-summary div { display: flex; justify-content: space-between; gap: 8px; margin: 4px 0; }
.transform-summary dt { color: #89765d; }
.transform-summary dd { margin: 0; font-variant-numeric: tabular-nums; }
.history-row { display: flex; gap: 7px; margin-bottom: 12px; }
.history-row button { flex: 1; font-size: 11px; }
.editor-panel .save-button { display: block; width: calc(100% - 16px); margin-inline: auto; border-color: #513821; background: #513821; color: #fff9ed; font-weight: 700; letter-spacing: 0.06em; }
.editor-status { min-height: 28px; font-size: 11px; color: #726147; margin: 8px 0; overflow-wrap: anywhere; }
.editor-status[data-error="true"] { color: #ae4531; }
.editor-help { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid #eadbc5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-height: 480px) and (orientation: landscape) {
  .is-touch-input .tutorial-hint { bottom: max(84px, calc(env(safe-area-inset-bottom) + 80px)); }
}
@media (max-width: 600px) {
  .coins-panel { top: 10px; left: 10px; }
  .tutorial-hint { bottom: 52px; }
  .game-controls { bottom: 10px; left: 10px; }
  .pause-toggle { top: 9px; right: 9px; }
  .editor-panel { right: 10px; width: 270px; padding: 16px; max-height: calc(100svh - var(--editor-top) - 10px); }
}
@media (max-width: 480px) {
  .game-controls { gap: 6px; }
  .editor-toggle { padding: 8px; font-size: 11px; min-height: 40px; }
  .coins-panel { width: min(160px, calc(100vw - 200px)); }
  #coins-value { font-size: calc(26px * var(--amount-scale, 1)); -webkit-text-stroke-width: calc(4px * var(--amount-scale, 1)); }
}
