* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #1a1a1a;
  color: #eee;
  height: 100vh;
  overflow: hidden;
}

.screen { display:none; }
.screen.active { display:flex; flex-direction:column; height:100vh; }

#screen-menu {
  background: #fff;
  color: #222;
  align-items: center;
  justify-content: center;
}

.menu-inner {
  max-width: 860px;
  width: 100%;
  padding: 40px 24px;
}

.back-link {
  color: #888;
  text-decoration: none;
  font-size: 0.9rem;
  display: block;
  margin-bottom: 32px;
}

.back-link:hover { color: #333; }

.menu-inner h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.menu-sub {
  color: #888;
  margin-top: 6px;
  margin-bottom: 36px;
  font-size: 0.95rem;
}

.map-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.map-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  position: relative;
}

.map-card:not(.locked):hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.map-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.map-thumb {
  width: 100%;
  height: 100px;
  border-radius: 4px;
  margin-bottom: 14px;
  background: #e8f5e9;
  position: relative;
  overflow: hidden;
}

.squiggle-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='100'%3E%3Cpath d='M0,50 C30,20 60,80 100,50 C140,20 170,80 200,50' stroke='%23c8a96e' stroke-width='18' fill='none'/%3E%3C/svg%3E") center/cover;
}

.zigzag-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='100'%3E%3Cpath d='M0,20 L50,80 L100,20 L150,80 L200,20' stroke='%23c8a96e' stroke-width='18' fill='none' stroke-linejoin='round'/%3E%3C/svg%3E") center/cover;
}

.split-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='100'%3E%3Cpath d='M0,50 L80,50 L120,20 L200,20' stroke='%23c8a96e' stroke-width='14' fill='none'/%3E%3Cpath d='M80,50 L120,80 L200,80' stroke='%23c8a96e' stroke-width='14' fill='none'/%3E%3C/svg%3E") center/cover;
}

.map-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.map-name { font-weight: 600; font-size: 1rem; }

.map-diff {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 500;
}

.easy { background: #e8f5e9; color: #2e7d32; }
.medium { background: #fff3e0; color: #e65100; }
.hard { background: #fce4ec; color: #c62828; }

.map-desc { font-size: 0.82rem; color: #888; }

.lock-label {
  display: block;
  font-size: 0.78rem;
  color: #aaa;
  margin-top: 8px;
}

#hud {
  height: 48px;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  border-bottom: 1px solid #333;
}

.hud-left, .hud-right { display:flex; align-items:center; gap:16px; }

.hud-item { font-size: 0.88rem; color: #ccc; }

.hud-btn {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #ccc;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
  text-decoration: none;
  display: inline-block;
}

.hud-btn:hover { background: #333; color: #fff; }

.wave-btn {
  background: #2d5a27;
  border-color: #4a7a44;
  color: #a8d5a2;
}

.wave-btn:hover { background: #3a6e34; }
.wave-btn:disabled { opacity: 0.4; cursor: not-allowed; }

#game-area {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#canvas {
  flex: 1;
  display: block;
  cursor: crosshair;
}

#tower-panel {
  width: 180px;
  background: #111;
  border-left: 1px solid #2a2a2a;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 12px 10px;
}

.panel-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  margin-bottom: 10px;
}

.tower-btn {
  width: 100%;
  background: #1c1c1c;
  border: 1px solid #333;
  border-radius: 5px;
  padding: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  text-align: left;
  color: #ddd;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}

.tower-btn:hover { background: #252525; }
.tower-btn.selected { border-color: #6a9; background: #1a2a1e; }
.tower-btn.cant-afford { opacity: 0.4; }

.tower-btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  flex-shrink: 0;
}

.tower-btn-info { flex: 1; min-width: 0; }
.tower-btn-name { font-size: 0.8rem; font-weight: 500; display: block; }
.tower-btn-cost { font-size: 0.73rem; color: #f0c040; }

#tower-info {
  margin-top: 12px;
  border-top: 1px solid #2a2a2a;
  padding-top: 12px;
}

#tower-info.hidden { display: none; }

.ti-name {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.ti-stats {
  font-size: 0.76rem;
  color: #aaa;
  line-height: 1.7;
  margin-bottom: 10px;
}

.ti-upgrade, .ti-sell {
  width: 100%;
  padding: 6px;
  border-radius: 4px;
  border: 1px solid;
  cursor: pointer;
  font-size: 0.78rem;
  margin-bottom: 5px;
}

.ti-upgrade {
  background: #1a2d1e;
  border-color: #4a7a44;
  color: #a8d5a2;
}

.ti-upgrade:disabled { opacity: 0.4; cursor: not-allowed; }

.ti-sell {
  background: #2a1a1a;
  border-color: #7a4444;
  color: #d5a8a8;
}

#commentary-bar {
  height: 34px;
  background: #0d0d0d;
  border-top: 1px solid #222;
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
}

#commentary-text {
  font-size: 0.82rem;
  color: #778;
  font-style: italic;
}

#screen-over {
  background: rgba(0,0,0,0.92);
  align-items: center;
  justify-content: center;
}

.over-inner {
  text-align: center;
  padding: 48px;
}

.over-inner h2 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.over-inner p {
  color: #aaa;
  margin-bottom: 32px;
  font-size: 1rem;
}

#btn-retry {
  background: #2d5a27;
  border: 1px solid #4a7a44;
  color: #a8d5a2;
  padding: 12px 32px;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  display: block;
  margin: 0 auto 16px;
}

#btn-retry:hover { background: #3a6e34; }

#btn-over-menu {
  color: #666;
  font-size: 0.88rem;
  display: block;
  text-decoration: none;
}

#btn-over-menu:hover { color: #aaa; }
