:root {
  color-scheme: dark;
  --ink: #f2e7d6;
  --muted: #a99b8e;
  --panel: rgba(24, 17, 19, 0.94);
  --line: rgba(255, 239, 215, 0.17);
  --hot: #e95035;
  --gold: #f3b641;
}

* { box-sizing: border-box; }

html, body {
  width: 100%; height: 100%; margin: 0; overflow: hidden;
  background: #0e0a0c; color: var(--ink);
  font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  touch-action: none; user-select: none; -webkit-user-select: none;
}

button, a { font: inherit; -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

#game-shell { position: fixed; inset: 0; overflow: hidden; background: #160f12; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hud {
  position: absolute; z-index: 5; inset: max(10px, env(safe-area-inset-top)) 12px auto;
  height: 54px; display: flex; align-items: center; gap: 10px;
  pointer-events: none;
}

.hud > * { pointer-events: auto; }
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 34px; height: 34px; border: 2px solid #e7d5c0; border-radius: 50%;
  display: grid; place-items: center; color: #b43c32; box-shadow: inset 0 0 0 6px #28161a;
}
.brand b, .brand small { display: block; line-height: .88; letter-spacing: .12em; }
.brand b { font-size: 15px; }
.brand small { margin-top: 5px; color: #c65e4b; font-size: 10px; }

.depth-stat { margin-left: auto; text-align: right; text-shadow: 0 2px 8px #000; }
.depth-stat small { display: block; color: var(--muted); font-size: 9px; letter-spacing: .15em; }
.depth-stat strong { font-size: 16px; }

.money, .round-button {
  border: 1px solid var(--line); background: rgba(15, 10, 12, .72); border-radius: 999px;
  min-height: 36px; cursor: pointer;
}
.money { padding: 0 13px; color: var(--gold); display: flex; gap: 7px; align-items: center; }
.round-button { width: 36px; padding: 0; }
.round-button.dark { background: #24191c; font-size: 22px; }

.progress { position: absolute; z-index: 5; top: 0; left: 0; right: 0; height: 3px; background: #21171a; }
.progress i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #a8302b, #ff9c43); box-shadow: 0 0 9px #e84c31; }

.biome-label {
  position: absolute; z-index: 3; top: 23%; left: 50%; transform: translate(-50%, -50%);
  color: rgba(255, 239, 220, .52); font-size: 10px; letter-spacing: .42em;
  transition: opacity .35s; pointer-events: none; white-space: nowrap;
}

.toast, .hint {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%);
  background: rgba(18, 12, 14, .88); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 13px; font-size: 11px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .2s, transform .2s;
}
.toast { top: 82px; color: #ffe3a0; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }
.hint { bottom: calc(82px + env(safe-area-inset-bottom)); opacity: 1; color: #cabdb1; }
.hint.gone { opacity: 0; }

.toolbar {
  position: absolute; z-index: 7; left: 50%; transform: translateX(-50%);
  bottom: max(10px, env(safe-area-inset-bottom)); height: 62px;
  display: flex; padding: 5px; gap: 4px; border: 1px solid var(--line); border-radius: 13px;
  background: rgba(17, 12, 14, .9); box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.tool {
  width: 94px; border: 1px solid transparent; border-radius: 9px; background: transparent;
  display: grid; place-items: center; align-content: center; gap: 4px; cursor: pointer;
}
.tool:hover { background: rgba(255,255,255,.05); }
.tool.active { border-color: #b34837; background: #321b1c; }
.tool b { font-size: 9px; letter-spacing: .04em; white-space: nowrap; }
.tool em { color: #f3b641; font-style: normal; }
.tool-icon { width: 24px; height: 24px; position: relative; display: block; }
.pick-icon::before { content: ""; position: absolute; width: 4px; height: 22px; background: #b47e53; border-radius: 2px; transform: rotate(38deg); left: 11px; top: 2px; }
.pick-icon::after { content: ""; position: absolute; width: 21px; height: 7px; border: 3px solid #ddd0bc; border-bottom: 0; border-radius: 100% 100% 0 0; transform: rotate(-8deg); top: 2px; left: 1px; }
.dynamite-icon { width: 10px; height: 22px; margin-left: 7px; background: #c64134; border-radius: 2px; box-shadow: inset 3px 0 rgba(255,255,255,.12); }
.dynamite-icon::after { content: ""; width: 8px; height: 8px; border: 2px solid #e7c86d; border-left-color: transparent; border-bottom-color: transparent; border-radius: 50%; position: absolute; left: 6px; top: -7px; }
.magnet-icon { border: 5px solid #b9c7cf; border-bottom: 0; border-radius: 12px 12px 0 0; height: 20px; margin-top: 3px; }
.magnet-icon::before, .magnet-icon::after { content: ""; position: absolute; width: 5px; height: 7px; background: #d34d42; bottom: -4px; }
.magnet-icon::before { left: -5px; } .magnet-icon::after { right: -5px; }
.shop-icon { display: grid; place-items: center; border: 2px solid #d3b374; border-radius: 50%; color: #e6c47e; font-weight: 900; }

.panel {
  position: absolute; z-index: 20; inset: 0; display: grid; place-items: center;
  background: rgba(6, 4, 5, .7); padding: 16px;
}
.panel[hidden] { display: none; }
.panel-card {
  width: min(440px, 100%); padding: 20px; border: 1px solid #554044; border-radius: 16px;
  background: var(--panel); box-shadow: 0 24px 80px #000;
}
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.panel h1 { margin: 4px 0 0; font: 700 26px/1.1 Georgia, serif; }
.panel small { color: var(--muted); font-size: 9px; letter-spacing: .15em; }
.shop-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px; padding: 13px 0; border-top: 1px solid var(--line); }
.shop-row div b, .shop-row div small { display: block; }
.shop-row div b { font-size: 12px; }
.shop-row div small { margin-top: 4px; letter-spacing: 0; }
.shop-row button, .restart {
  border: 0; border-radius: 8px; background: #e3b34d; color: #25190f; font-weight: 900; padding: 10px 12px; cursor: pointer;
}
.shop-row button:disabled { opacity: .35; cursor: default; }
.shop-symbol { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #80683b; border-radius: 9px; color: #e6bd68; }
.shop-symbol.red { color: #ee6150; border-color: #7e3c37; }
.shop-symbol.blue { color: #9fc9d3; border-color: #3d6973; }
.shop-note { margin: 15px 0 0; color: #8f8075; text-align: center; font-size: 10px; }
.end-card { text-align: center; padding: 30px 24px; }
.end-card h1 { color: #e25642; font-size: clamp(28px, 8vw, 42px); }
.end-card p { color: #bbaaa0; font-size: 12px; }
.end-stats { display: grid; grid-template-columns: 1fr 1fr; border-block: 1px solid var(--line); margin: 22px 0; padding: 17px 0; }
.end-stats b, .end-stats small { display: block; }
.end-stats b { margin-top: 5px; font-size: 18px; }
.restart { width: 100%; padding: 14px; background: #c94737; color: white; }

@media (max-width: 560px) {
  .hud { display: grid; grid-template-columns: 32px 1fr auto auto; }
  .brand span:last-child { display: none; }
  .brand-mark { width: 32px; height: 32px; }
  .hud { gap: 6px; }
  .depth-stat { margin-left: 0; }
  .depth-stat strong { font-size: 14px; }
  .money { padding-inline: 10px; }
  .toolbar { width: calc(100% - 16px); }
  .tool { flex: 1 1 0; width: auto; min-width: 0; padding-inline: 2px; }
  .tool b { font-size: 8px; }
  .hint { font-size: 9px; bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (max-height: 540px) {
  .toolbar { height: 52px; }
  .tool-icon { transform: scale(.75); height: 18px; }
  .hint { display: none; }
}
