@font-face { font-family: 'Press Start 2P'; src: url('Fonts/PressStart2P-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
:root { color-scheme: light; background: #203d53; }
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }
#game { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; cursor: pointer; outline: none; user-select: none; -webkit-user-select: none; }
#game:focus-visible + .hud #current-axe { filter: brightness(1.3); }
.hud { --hud-left: max(10px, env(safe-area-inset-left)); position: fixed; inset: 0; pointer-events: none; font-family: 'Press Start 2P', monospace; color: #fff4cc; text-shadow: 2px 0 #291a13, -2px 0 #291a13, 0 2px #291a13, 0 -2px #291a13, 2px 3px #291a13; image-rendering: pixelated; }
.hud img, .hud svg { width: 100%; height: 100%; object-fit: contain; }
.pixel-icon { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.paired-icon { display: flex; }
.paired-icon > .pixel-icon { width: 50%; }
.paired-icon > .pixel-icon:last-child { transform: scaleX(-1); }
.wood-panel { background: url('Sprites/HUD/wood-panel.png') center / 100% 100% no-repeat; filter: drop-shadow(0 4px 0 #172a27a8); }
.wallet { position: absolute; top: max(6px, env(safe-area-inset-top)); left: var(--hud-left); width: 254px; height: 108px; padding: 22px 25px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.wallet .log-icon { width: 57px; height: 57px; flex-shrink: 0; }
#log-count { font-size: clamp(12px, calc(132px / var(--digits, 1)), 23px); line-height: 1; }
.rates { position: absolute; left: calc(var(--hud-left) + 6px); top: 104px; display: flex; align-items: center; gap: 10px; }
.rate { display: flex; align-items: center; gap: 6px; height: 42px; font-size: 11px; padding: 4px 8px; background: #1c302ccb; border: 2px solid #92aa67; border-radius: 6px; }
.rate > img, .rate .icon { width: 26px; height: 26px; flex: 0 0 26px; }
.rate > span:last-child { line-height: 1; white-space: nowrap; }
.hud button { pointer-events: auto; font: inherit; color: inherit; text-shadow: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
.hud button:focus-visible { outline: 3px solid #fff4cc; outline-offset: 3px; }
.hud button:enabled:active { transform: translateY(2px); }
.wood-button { background: #98502a; border: 3px solid #392319 !important; border-radius: 10px; box-shadow: inset 3px 3px #dd9043, inset -3px -4px #653c28, 0 4px #182921a6; }
#open-shop { position: absolute; top: max(22px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right)); width: 64px; height: 64px; padding: 9px; }
#shop { pointer-events: auto; position: absolute; right: max(18px, env(safe-area-inset-right)); top: max(22px, env(safe-area-inset-top)); width: 322px; max-height: calc(100% - 44px - env(safe-area-inset-bottom)); display: flex; flex-direction: column; padding: 10px; background: #8e4728; border: 5px solid #36241c; border-radius: 15px; box-shadow: inset 3px 3px #dc8f42, inset -3px -3px #633722, 0 5px #102c26a6; }
.shop-tabs { display: flex; gap: 5px; padding-bottom: 9px; flex-shrink: 0; }
.shop-tabs button { width: 49px; height: 48px; padding: 8px; background: #653c28; border-radius: 7px; box-shadow: inset 0 -3px #462c20; }
.shop-tabs button[aria-pressed="true"] { background: #ca8a42; box-shadow: inset 0 3px #efb05a, inset 0 -3px #69482b; }
.shop-tabs #close-shop { width: 39px; padding: 11px; margin-left: auto; }
.shop-list { display: grid; gap: 9px; overflow-y: auto; overscroll-behavior: contain; padding: 2px 4px 6px 0; scrollbar-width: thin; scrollbar-color: #f7c776 #673722; }
.shop-row { min-height: 78px; display: grid; grid-template-columns: 52px minmax(38px,1fr) 112px; align-items: center; gap: 7px; padding: 9px 8px; background: #edbf7a; border: 3px solid #462c1e; border-radius: 10px; box-shadow: inset 2px 2px #ffe0a1, inset -2px -2px #be8048, 0 2px #613920; }
.row-icon { width: 51px; height: 51px; }
.row-stats { display: grid; gap: 7px; font-size: 13px; text-align: center; line-height: 1.25; }
.row-stats small { font: inherit; font-size: 9px; color: #a0d970; }
.buy { width: 112px; height: 42px; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 6px; background: url('Sprites/HUD/buy-button.png') center / 100% 100% no-repeat; font-size: 11px !important; border-radius: 11px; }
.buy img { width: 29px; height: 29px; flex-shrink: 0; }
.cost { min-width: 0; line-height: 1; white-space: nowrap; font-size: clamp(7px, calc(56px / var(--price-digits, 5)), 11px); }
.cost .locked-price { display: flex; gap: 2px; align-items: center; font-size: inherit; }
.shop-row.locked .buy > img { display: none; }
.buy > .pixel-icon { width: 20px; height: 20px; flex-shrink: 0; }
.cost > .pixel-icon { width: 27px; height: 27px; }
.locked-price > .pixel-icon { width: 16px; height: 16px; flex-shrink: 0; }
.shop-row.locked .buy > .pixel-icon { display: none; }
.item-row .buy > .pixel-icon { width: 22px; height: 22px; }
.buy:disabled { filter: saturate(.45) brightness(.85); cursor: default; }
.shop-row.locked > .row-icon { opacity: .45; }
.shop-row.locked .buy { filter: sepia(.6) saturate(.6); }
.item-row { grid-template-columns: 45px 30px 91px 47px; }
.item-row .row-icon { width: 44px; height: 44px; }
.item-row .buy { width: 91px; font-size: 10px !important; }
.item-row .buy img { width: 22px; height: 22px; }
.use { width: 47px; height: 49px; padding: 10px; background: #b87136; border: 2px solid #5c3825 !important; border-radius: 8px; box-shadow: inset 0 3px #f6bd6b, inset 0 -3px #885126; }
.use:disabled { opacity: .45; cursor: default; }
.achievement-row { grid-template-columns: 49px 1fr 30px; }
#upgrade-tray { display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 20px) / 5); gap: 5px; padding: 3px 0 9px; overflow-x: auto; overflow-y: hidden; flex-shrink: 0; scroll-snap-type: x mandatory; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #edc477 #42271b; }
.upgrade-tile { position: relative; height: 63px; padding: 4px 6px 16px; background: #985629; border: 2px solid #ffd77d !important; border-radius: 7px; box-shadow: inset 0 2px #d79748, inset 0 -3px #4b2b1d; scroll-snap-align: start; }
.upgrade-tile small { position: absolute; top: 2px; right: 3px; font-size: 8px; color: #c4ed77; }
.tile-price { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 8px; }
.new-offer { animation: upgrade-arrive .24s ease-out; }
@keyframes upgrade-arrive { from { opacity: .3; translate: 12px 0; } to { opacity: 1; translate: 0 0; } }
@media (prefers-reduced-motion: reduce) { .new-offer { animation: none; } }
.special-row .row-stats { font-size: 11px; }
.achievement-row .row-stats { font-size: 11px; }
.achievement-check { width: 28px; height: 28px; }
.achievement-row:not(.achieved) { filter: saturate(.55); }
.gold { filter: sepia(1) saturate(4) hue-rotate(4deg) brightness(1.2); }
.diamond { filter: sepia(1) saturate(4) hue-rotate(125deg) brightness(1.1); }
.iron { filter: saturate(.5); }
#effects { position: absolute; top: 155px; left: calc(var(--hud-left) + 6px); display: flex; flex-direction: column; gap: 8px; }
.effect { display: flex; align-items: center; gap: 6px; height: 42px; padding: 4px 8px; background: #253729c9; border: 2px solid #d1aa61; border-radius: 6px; font-size: 11px; }
.effect .icon { width: 26px; height: 26px; }
#beetle { position: absolute; width: 58px; height: 58px; padding: 0; background: transparent; filter: drop-shadow(0 0 8px #ffe765); animation: beetle-sway 2s ease-in-out infinite; }
@keyframes beetle-sway { 50% { rotate: 6deg; scale: 1.08; } }
#notice { position: absolute; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; height: 61px; padding: 8px 18px; background: #764423ed; border: 3px solid #261d17; border-radius: 10px; font-size: 15px; }
#notice .icon { width: 40px; height: 40px; }
#save-warning { position: absolute; left: 10px; bottom: 12px; width: 29px; height: 29px; }
@media (max-width: 600px) {
  #game { filter: saturate(.85); }
  .wallet { width: 213px; height: 94px; padding: 19px 22px; }
  .wallet .log-icon { width: 45px; height: 45px; }
  #log-count { font-size: clamp(12px, calc(112px / var(--digits, 1)), 19px); }
  .rates { top: 93px; gap: 6px; }
  .rate, .effect { height: 38px; font-size: 9px; padding: 3px 5px; }
  #effects { top: 139px; }
  #open-shop { width: 56px; height: 56px; right: 14px; top: 23px; }
  #shop { top: auto; bottom: max(10px, env(safe-area-inset-bottom)); right: 10px; width: min(322px, calc(100% - 20px)); max-height: min(470px, 65%); }
  #notice { bottom: 15px; }
}
@media (max-height: 480px) {
  #shop { max-height: calc(100% - 20px); top: 10px; right: 10px; bottom: auto; }
  #effects { flex-direction: row; top: auto; bottom: 15px; }
  .effect { font-size: 9px; gap: 3px; padding: 3px; }
}
@media (prefers-reduced-motion: reduce) { #beetle { animation: none; } }
/* Moldura com nove fatias preserva cantos e textura em telas estreitas. */
#shop { border: 24px solid transparent; border-radius: 0; padding: 1px; background: none; box-shadow: 0 5px 12px #102c2670; isolation: isolate; }
#shop::before { content: ''; position: absolute; inset: -24px; border: 24px solid transparent; border-image: url('Sprites/HUD/shop-frame.png') 250 / 24px / 5px stretch; z-index: 2; pointer-events: none; }
#shop::after { content: ''; position: absolute; inset: -10px; background: #603820; z-index: -1; pointer-events: none; }
.shop-tabs button { padding: 5px; background: #a86332; border: 2px solid #42271b; box-shadow: inset 0 2px #e9aa5d, inset 0 -2px #63371f; }
.shop-tabs button[aria-pressed="true"] { background-color: #ddaa57; border-color: #ffe0a1; }
.shop-row { grid-template-columns: 55px minmax(30px,1fr) 108px; padding: 8px 6px; gap: 5px; background: #cb8b48 url('Sprites/HUD/wood-panel.png') center / 110% 160% no-repeat; border-color: #41291e; box-shadow: inset 0 2px #dfaa65, 0 2px #3c261d; }
.row-icon { width: 55px; height: 55px; }
.shop-row.locked > .row-icon { opacity: .8; filter: saturate(.65); }
.buy { width: 108px; }
.item-row { grid-template-columns: 42px 26px 83px 43px; }
.item-row .buy { width: 83px; }
.item-row .use { width: 43px; }
.achievement-row { grid-template-columns: 49px 1fr 30px; }

/* Controles ficam dentro do cartão, com margem para bordas e foco. */
.shop-row { min-height: 88px; grid-template-columns: 48px minmax(0, 1fr) 100px; padding: 12px 10px; gap: 6px; overflow: hidden; background-size: 100% 100%; background-clip: padding-box; }
.row-icon { width: 48px; height: 48px; }
.row-stats { min-width: 0; }
.buy { width: 100%; max-width: 100px; height: 38px; justify-self: end; align-self: center; }
.item-row { grid-template-columns: 48px minmax(0, 1fr) 84px 36px; }
.item-row .row-icon { width: 40px; height: 40px; }
.item-row .buy { width: 100%; }
.item-row .cost { font-size: clamp(7px, calc(40px / var(--price-digits, 5)), 9px); }
.item-row .use { width: 36px; height: 38px; padding: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; line-height: 1; }
.item-row .use > .pixel-icon { width: 22px; height: 22px; }
.achievement-row { grid-template-columns: 48px minmax(0,1fr) 28px; }
