:root {
  --bg: #171226; --panel: rgba(26, 20, 38, 0.88); --panel2: #241b36;
  --ink: #efe8f4; --dim: #a99cba; --accent: #7fd7d1; --warm: #ffb74f;
  --bad: #ff6a5f; --good: #8fe388; --line: rgba(127,215,209,0.25);
  --radius: 14px; --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
.game-page { overflow: hidden; touch-action: none; }
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hud-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(6px); box-shadow: 0 6px 24px rgba(0,0,0,0.45); }

#stats { position: fixed; top: 10px; left: 10px; right: 10px; max-width: 640px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 8px 14px; align-items: baseline; pointer-events: none; }
.stat { display: flex; align-items: baseline; gap: 6px; }
.stat .k { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.stat b { font-size: 19px; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--dim); font-size: 12px; }
b.negative { color: var(--bad); } b.positive { color: var(--good); }
.bar { position: relative; flex-basis: 100%; height: 6px; background: rgba(0,0,0,0.45);
  border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #b7f0e2); width: 0%;
  transition: width 0.4s; }
.bar.year i { background: linear-gradient(90deg, var(--warm), #ff8a5f); }

#tools { position: fixed; left: 10px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.tool { display: flex; flex-direction: column; gap: 1px; align-items: flex-start; min-width: 74px;
  background: transparent; color: var(--ink); border: 1px solid transparent; border-radius: 10px;
  padding: 6px 8px; cursor: pointer; font-family: var(--font); text-align: left; }
.tool .num { font-size: 10px; color: var(--dim); }
.tool .tname { font-size: 14px; font-weight: 700; }
.tool .tcost { font-size: 10px; color: var(--dim); }
.tool:hover { background: rgba(127,215,209,0.12); }
.tool.active { background: rgba(127,215,209,0.22); border-color: var(--accent); }

#touchpad { position: fixed; right: 10px; bottom: 12px; display: grid; gap: 6px;
  grid-template-areas: "zin zout rl rr" "up left right down" "place place bulld bulld";
  pointer-events: auto; }
#touchpad button { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 17px; cursor: pointer; touch-action: none; }
#touchpad button:active { background: rgba(127,215,209,0.3); }
#touchpad .dpad { grid-area: up / up / down / down; display: grid; gap: 4px;
  grid-template-areas: ". u ." "l . r" ". d ."; }
#touchpad .dpad button { width: 42px; height: 42px; }
#b-up { grid-area: u; } #b-left { grid-area: l; } #b-right { grid-area: r; } #b-down { grid-area: d; }
#b-zin { grid-area: zin; } #b-zout { grid-area: zout; } #b-rl { grid-area: rl; } #b-rr { grid-area: rr; }
#b-place { grid-area: place; width: auto; padding: 0 18px; font-weight: 700; color: #0e2b28;
  background: var(--accent); border: none; }
#b-bulldoze { grid-area: bulld; width: auto; padding: 0 14px; background: var(--panel);
  border: 1px solid var(--line); color: var(--warm); }

#toasts { position: fixed; top: 92px; left: 0; right: 0; display: flex; flex-direction: column;
  align-items: center; gap: 6px; pointer-events: none; z-index: 5; }
.toast { background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  padding: 6px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transform: translateY(8px);
  transition: all 0.25s; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { border-color: var(--bad); color: #ffc9c4; }
.toast.good { border-color: var(--accent); }

#overlay-root { position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(12, 8, 22, 0.62); backdrop-filter: blur(4px); z-index: 10; padding: 16px; }
#overlay-root.show { display: flex; }
.card { max-width: 460px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 18px; padding: 26px 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); text-align: center; }
.card h2 { margin: 0 0 4px; font-size: 30px; letter-spacing: 0.04em; }
.card h2.win { color: var(--accent); } .card h2.lose { color: var(--bad); }
.card .tag { color: var(--accent); margin: 0 0 14px; font-size: 14px; }
.rules { text-align: left; font-size: 14px; line-height: 1.5; color: var(--ink); }
.rules ul { margin: 8px 0; padding-left: 18px; }
.rules .keys { color: var(--dim); font-size: 12px; }
button.big { margin-top: 14px; font-family: var(--font); font-size: 17px; font-weight: 800;
  letter-spacing: 0.03em; color: #10241f; background: linear-gradient(135deg, var(--accent), var(--warm));
  border: none; border-radius: 999px; padding: 13px 34px; cursor: pointer; }
button.big:hover { filter: brightness(1.12); transform: translateY(-1px); }

@media (max-width: 640px) {
  #tools { flex-direction: row; top: auto; bottom: 12px; left: 10px; transform: none; }
  .tool { min-width: 56px; }
  #stats { max-width: none; font-size: 12px; }
  #touchpad { bottom: 84px; }
}
