:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fffef2;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 216, 99, .12), transparent 26rem),
    radial-gradient(circle at 82% 80%, rgba(47, 169, 162, .16), transparent 30rem),
    #0f202b;
}

.game-shell {
  width: min(1180px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  padding: 0 4px;
}

.brand, .scoreboard, .instruction-title, .score-label {
  letter-spacing: .13em;
  font-weight: 800;
  font-size: .74rem;
}

.brand { display: flex; align-items: center; gap: 10px; color: #fff3a2; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: #ffd44e; box-shadow: 0 0 14px #ffd44e; }
.resources { display: flex; align-items: center; gap: 8px; }

.scoreboard, .coinboard {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 7px 11px;
  color: #17333c;
  border-radius: 999px;
  background: #fff8cf;
  box-shadow: 0 5px 18px rgba(0,0,0,.18);
}
.coinboard { color: #fff7cf; background: #326049; }
.lemon-icon { color: #f3b823; text-shadow: 0 1px 0 #fff; font-size: .9rem; }
.coin-icon { color: #ffe35c; text-shadow: 0 0 9px rgba(255, 227, 92, .7); font-size: .95rem; }
.axe-icon { color: #fff1aa; font-size: .57rem; font-weight: 900; letter-spacing: .06em; }
.score-divider { opacity: .4; }
.score-label { margin-left: 4px; font-size: .56rem; opacity: .65; }

.game-card {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255,255,255,.13);
  background: #143240;
}

canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
canvas.camera-dragging { cursor: grabbing; }

.instruction-card {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(325px, calc(100% - 36px));
  padding: 21px 22px 19px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 17px;
  text-align: center;
  background: rgba(14, 39, 47, .91);
  box-shadow: 0 18px 35px rgba(0,0,0,.25);
  backdrop-filter: blur(9px);
  transition: opacity .25s ease, transform .25s ease;
}
.instruction-card.hidden { opacity: 0; transform: translate(-50%, -42%); pointer-events: none; }
.instruction-title { display: block; color: #ffe271; margin-bottom: 13px; }
.instruction-line { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 29px; color: #d9e8de; font-size: .76rem; }
.instruction-line + .instruction-line { margin-top: 5px; }
.instruction-line span { margin-left: 4px; text-align: left; min-width: 110px; }
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  padding: 0 6px;
  border: 1px solid rgba(255,255,255,.35);
  border-bottom-width: 3px;
  border-radius: 6px;
  color: #17333c;
  font: 800 .67rem/1 inherit;
  background: #fffdf0;
}
kbd.wide-key { min-width: 82px; }

#startButton {
  width: 100%;
  margin-top: 16px;
  padding: 10px 14px;
  cursor: pointer;
  border: 0;
  border-radius: 9px;
  color: #23403d;
  font: 800 .72rem/1 inherit;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: #ffd44e;
  box-shadow: 0 4px 0 #cf9d21;
  transition: transform .12s ease, filter .12s ease;
}
#startButton:hover { filter: brightness(1.07); }
#startButton:active { transform: translateY(3px); box-shadow: 0 1px 0 #cf9d21; }

.shop-panel {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: none;
  opacity: 0;
  background: rgba(8, 33, 40, .52);
  backdrop-filter: blur(4px);
  transition: opacity .18s ease;
}
.shop-panel.open { opacity: 1; pointer-events: auto; }
.shop-window {
  position: relative;
  width: min(340px, 100%);
  max-height: calc(100% - 28px);
  padding: 24px;
  text-align: center;
  color: #15343b;
  border: 4px solid #75451e;
  border-radius: 18px;
  background: #fff4b2;
  box-shadow: 0 15px 0 #8a5429, 0 27px 45px rgba(0,0,0,.36);
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateY(10px) scale(.96);
  transition: transform .18s ease;
}
.shop-panel.open .shop-window { transform: translateY(0) scale(1); }
.shop-kicker { display: block; color: #438a54; font-size: .65rem; font-weight: 900; letter-spacing: .15em; }
.shop-window h2 { margin: 5px 0 9px; font-size: 1.5rem; letter-spacing: -.04em; }
.shop-copy { margin: 0 auto 14px; max-width: 255px; font-size: .78rem; line-height: 1.45; }
.shop-stats { display: flex; justify-content: center; gap: 12px; margin: 12px 0; }
.shop-stats span { padding: 7px 9px; border-radius: 8px; color: #23403d; font-size: .72rem; font-weight: 800; background: rgba(255,255,255,.5); }
.shop-buy { width: 100%; padding: 11px; cursor: pointer; border: 0; border-radius: 9px; color: #193a3e; font: 900 .78rem/1 inherit; letter-spacing: .05em; text-transform: uppercase; background: #f3bc32; box-shadow: 0 4px 0 #bd7e1d; }
.shop-axe-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 9px 10px;
  border: 1px solid rgba(71, 114, 54, .35);
  border-radius: 10px;
  color: #29483b;
  text-align: left;
  background: rgba(112, 162, 81, .18);
}
.shop-axe-preview > span { font-size: 1.8rem; }
.shop-axe-preview p { flex: 1; margin: 0; font-size: .66rem; line-height: 1.25; }
.shop-axe-preview b { display: block; font-size: .66rem; letter-spacing: .06em; }
.shop-axe-preview small { display: block; margin-top: 2px; font-size: .58rem; }
.shop-axe-preview strong { color: #497c38; font-size: .72rem; white-space: nowrap; }
.shop-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.shop-tool .shop-axe-preview { height: 82px; margin: 0; padding: 7px; flex-direction: column; justify-content: center; gap: 2px; text-align: center; }
.shop-tool .shop-axe-preview > span { font-size: 1.55rem; line-height: 1; }
.shop-tool .shop-axe-preview p { flex: 0; font-size: .59rem; }
.shop-tool .shop-axe-preview b { font-size: .61rem; }
.shop-tool .shop-axe-preview small { margin-top: 1px; font-size: .53rem; }
.shop-tool .shop-axe-preview strong { font-size: .63rem; }
.shop-tool .shop-buy { margin-top: 7px; padding: 9px 4px; font-size: .62rem; }
#buyAxe, #buyPickaxe { margin-top: 8px; background: #85b75a; box-shadow: 0 4px 0 #527c38; }
#buyPickaxe { background: #8aa4ae; box-shadow: 0 4px 0 #56737d; }
.shop-buy:active { transform: translateY(3px); box-shadow: 0 1px 0 #bd7e1d; }
#buyAxe:active, #buyPickaxe:active { box-shadow: 0 1px 0 #527c38; }
#buyPickaxe:active { box-shadow: 0 1px 0 #56737d; }
.shop-buy span { margin-left: 6px; opacity: .65; font-size: .65rem; }
.shop-buy:disabled { cursor: default; color: rgba(25, 58, 62, .65); filter: saturate(.45); box-shadow: 0 2px 0 #527c38; }
.shop-pickaxe-preview { border-color: rgba(73, 108, 120, .35); background: rgba(116, 150, 161, .16); }
.shop-pickaxe-preview strong { color: #527986; }
.build-hint { margin: 15px 0 0; color: #3d5b4d; font-size: .73rem; line-height: 1.5; }
.build-hint kbd { vertical-align: middle; color: #17333c; }
.shop-message { min-height: 18px; margin: 8px 0 0; color: #9b521e; font-size: .7rem; font-weight: 800; letter-spacing: .04em; }
.shop-close { position: absolute; top: 8px; right: 9px; width: 28px; height: 28px; cursor: pointer; border: 0; border-radius: 50%; color: #75451e; font-size: 1.35rem; line-height: 1; background: transparent; }

.notice {
  position: absolute;
  left: 50%;
  bottom: 72px;
  z-index: 2;
  min-width: 140px;
  max-width: calc(100% - 80px);
  transform: translate(-50%, 16px);
  padding: 8px 13px;
  border-radius: 999px;
  pointer-events: none;
  color: #1c3d3c;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-align: center;
  opacity: 0;
  background: #fff7c9;
  box-shadow: 0 6px 16px rgba(0,0,0,.2);
  transition: opacity .18s ease, transform .18s ease;
}
.notice.show { opacity: 1; transform: translate(-50%, 0); }

.inventory-bar {
  position: absolute;
  left: 60%;
  bottom: 16px;
  z-index: 2;
  display: flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 13px;
  background: rgba(12, 42, 49, .28);
  box-shadow: 0 5px 13px rgba(0,0,0,.13);
  backdrop-filter: blur(2px);
  transform: translateX(-50%);
  transition: opacity .2s ease;
}
.instruction-card:not(.hidden) ~ .inventory-bar { opacity: 0; visibility: hidden; }
.inventory-slot {
  appearance: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 39px;
  height: 39px;
  padding: 0;
  border: 1px solid rgba(255,244,181,.25);
  border-radius: 7px;
  color: #fff7cf;
  font: inherit;
  cursor: default;
  background: rgba(30, 59, 58, .30);
  box-shadow: inset 0 0 0 2px rgba(6, 26, 32, .16);
}
.inventory-slot.filled { border-color: rgba(255, 239, 123, .58); background: rgba(76, 111, 62, .48); }
.inventory-slot.filled { cursor: pointer; }
.inventory-slot.selected { border-color: #fff178; background: rgba(127, 171, 72, .72); box-shadow: 0 0 0 2px rgba(255, 241, 120, .42), inset 0 0 0 2px rgba(255, 255, 218, .18); }
.inventory-icon { display: none; color: #ffdf75; font-size: 1.1rem; font-weight: 900; }
.inventory-slot.filled .inventory-icon { display: block; }
.inventory-slot .axe-icon { font-size: .53rem; letter-spacing: .06em; }
.inventory-slot .pickaxe-icon { font-size: 1rem; }
.inventory-slot b { display: none; position: absolute; right: 3px; bottom: 2px; min-width: 13px; padding: 1px 3px; border-radius: 4px; color: #17333c; font-size: .57rem; line-height: 1.1; text-align: center; background: #fff8cf; }
.inventory-slot.filled b { display: block; }

.sound-button {
  position: absolute;
  right: 18px;
  bottom: 17px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 50%;
  cursor: pointer;
  color: #fffef2;
  font-size: 1rem;
  background: rgba(13, 43, 51, .36);
}
.sound-button.muted { opacity: .42; }

.footer-copy { margin: 0; color: rgba(232, 248, 239, .65); text-align: center; font-size: .73rem; }

@media (max-width: 600px) {
  .game-shell { width: min(100vw - 18px, 1180px); }
  .topbar { min-height: 32px; }
  .brand { font-size: .63rem; }
  .resources { transform: scale(.9); transform-origin: right center; }
  .game-card { border-radius: 16px; }
  .inventory-bar { left: 60%; bottom: 10px; transform: translateX(-50%) scale(.85); transform-origin: center bottom; }
  .notice { bottom: 63px; }
  .footer-copy { display: none; }
}
