* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --night: #0a0f1a;
  --deep: #0f1923;
  --green: #1a3a1a;
  --paper: #e0e8d0;
  --gold: #ffd700;
  --wood: #8B4513;
  --stone: #708090;
  --soft: #8899aa;
  --line: rgba(100,140,80,.25);
  --glass: rgba(10,15,26,.88);
  --shadow: 0 20px 60px rgba(0,0,0,.5);
}
body {
  min-height: 100vh;
  color: var(--paper);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  background: var(--night);
  overflow-x: hidden;
}
.parallax-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: var(--night);
}
.parallax-layer {
  position: absolute; left: 50%; width: 200vw; height: 200vh;
  transform: translate(-50%, -50%); opacity: 0.08;
}
.parallax-grid {
  background-image:
    linear-gradient(rgba(100,140,80,.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100,140,80,.3) 1px, transparent 1px);
  background-size: 48px 48px;
}
.topbar {
  width: min(1120px, calc(100% - 40px)); margin: 0 auto; min-height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  position: relative; z-index: 1;
}
.brand {
  font-size: 1.3rem; font-weight: 900; color: transparent;
  background: linear-gradient(45deg, var(--gold), #ffaa00);
  -webkit-background-clip: text; background-clip: text; letter-spacing: .04em; text-decoration: none;
}
.trail { display: flex; align-items: center; gap: 8px; color: var(--soft); font-size: .85rem; }
.trail a { color: var(--gold); text-decoration: none; }
.td-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 10px 0 30px; position: relative; z-index: 1; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 28px; margin: 14px 0 18px; }
.eyebrow { font-size: .68rem; color: var(--gold); font-weight: 800; text-transform: uppercase; letter-spacing: .2em; margin-bottom: 8px; }
h1 { font: clamp(2.2rem, 5vw, 3.6rem)/1 Georgia, serif; color: var(--paper); letter-spacing: -.04em; }
.lede { color: var(--soft); line-height: 1.6; max-width: 600px; margin-top: 10px; font-size: .92rem; }
.legend { display: flex; gap: 10px; flex-shrink: 0; }
.legend span {
  min-width: 72px; text-align: center; padding: 10px 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,.03); border-radius: 14px; color: var(--soft); font-size: .7rem;
}
.legend strong { display: block; font: 1.4rem Georgia, serif; color: var(--gold); margin-bottom: 3px; }
.game-frame {
  overflow: hidden; border-radius: 20px; background: var(--glass);
  border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(12px);
  max-width: 900px; margin: 0 auto 1.5rem;
}
.hud {
  min-height: 56px; display: grid; grid-template-columns: 1.2fr 0.8fr 1fr 1fr;
  gap: 12px; align-items: center; padding: 10px 16px;
  background: linear-gradient(90deg, rgba(10,20,10,.95), rgba(15,25,15,.9));
  border-bottom: 1px solid var(--line);
}
.label { display: block; font-size: .58rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.hud-stat strong { font: 1rem Georgia, serif; color: var(--gold); display: inline-block; margin: 2px 0; }
.viewport {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  background: #1a2a1a; overflow: hidden;
}
.viewport canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
.tower-panel {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 6px 10px;
  background: rgba(0,0,0,.75); border-radius: 12px;
  border: 1px solid var(--line); z-index: 10;
}
.tower-btn {
  width: 48px; height: 48px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  background: rgba(255,255,255,.08); border: 2px solid transparent;
  border-radius: 8px; cursor: pointer; transition: all .15s;
}
.tower-btn:hover { background: rgba(255,255,255,.15); }
.tower-btn.selected { border-color: var(--gold); background: rgba(255,215,0,.15); }
.tower-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.tower-icon { font-size: 1.2rem; line-height: 1; }
.tower-cost { font-size: .55rem; color: var(--gold); font-weight: 800; }
.game-controls {
  position: absolute; top: 8px; right: 8px;
  display: flex; gap: 6px; z-index: 10;
}
.btn-start {
  padding: 8px 16px; border: none; border-radius: 8px;
  background: #4CAF50; color: #fff; font-weight: 800; font-size: .75rem;
  cursor: pointer; transition: background .15s;
}
.btn-start:hover { background: #66BB6A; }
.btn-start.running { background: #FF9800; }
.btn-speed {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(255,255,255,.1); color: var(--paper); font-weight: 800; font-size: .75rem;
  cursor: pointer;
}
.ad-slot {
  position: relative; width: 100%; min-height: 80px; margin-bottom: 14px; display: flex;
  justify-content: center; align-items: center; padding: 6px; border: 1px dashed var(--line);
  border-radius: 12px; overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01)), rgba(10,15,26,.5);
}
.ad-slot::before {
  content: "Ad Zone"; position: absolute; top: 6px; right: 10px; color: rgba(136,153,170,.5);
  font-size: .6rem; letter-spacing: .08em; text-transform: uppercase;
}
.ad-placeholder { color: #667788; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.ad-slot .adsbygoogle { display: block; width: 100%; min-width: 240px; min-height: 60px; }
.overlay {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  border: 1px solid var(--line); border-radius: 16px; background: rgba(10,15,26,.95);
  box-shadow: 0 20px 60px rgba(0,0,0,.5); backdrop-filter: blur(12px); z-index: 20;
  padding: 24px; text-align: center; min-width: 280px;
}
.overlay h2 { font: 1.6rem Georgia, serif; color: var(--gold); margin-bottom: 8px; }
.overlay p { color: var(--soft); line-height: 1.5; font-size: .85rem; margin-bottom: 16px; }
.overlay .actions { display: flex; gap: 8px; justify-content: center; }
.overlay button {
  padding: 10px 18px; border: none; border-radius: 8px;
  font-weight: 800; font-size: .8rem; cursor: pointer; transition: transform .15s;
}
.overlay button:hover { transform: translateY(-1px); }
.overlay .btn-primary { background: var(--gold); color: #1a1a00; }
.overlay .btn-secondary { background: rgba(255,255,255,.1); color: var(--paper); }
.touch-controls {
  display: none; padding: 10px; text-align: center;
  background: rgba(10,15,26,.9); border-top: 1px solid var(--line);
}
.touch-info { display: flex; gap: 16px; justify-content: center; color: var(--soft); font-size: .7rem; }
.underbar {
  padding: 12px 16px; display: flex; align-items: center; justify-content: center; gap: 16px;
  background: rgba(10,15,26,.85); border-top: 1px solid var(--line);
}
.controls { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--soft); font-size: .7rem; }
kbd {
  font: inherit; font-weight: 800; padding: 2px 5px; border-radius: 4px; color: var(--gold);
  border: 1px solid var(--line); background: rgba(255,215,0,.08); margin-right: 2px;
}
@media (max-width: 900px) {
  .intro { display: block; }
  .legend { margin-top: 14px; }
  .hud { grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 12px; }
  .game-frame { max-width: 100%; }
  .underbar { flex-direction: column; align-items: stretch; }
}
@media (hover: none), (pointer: coarse), (max-width: 760px) {
  .touch-controls { display: block; }
  .underbar .controls { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}