@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&display=swap');

:root {
  --green: #4aff91;
  --green-dim: #1a6b3a;
  --green-dark: #0a2e18;
  --amber: #ffb347;
  --red: #ff4444;
  --blue: #44aaff;
  --bg: #050e08;
  --panel: #0a1a0f;
  --border: #1e4a28;
  --text: #7aff9a;
  --text-dim: #3a7a4a;
  --metal: #88ccff;
  --energy: #ffee44;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  overflow: hidden;
  width: 100vw; height: 100vh;
}

.hidden { display: none !important; }

/* ===== TITLE SCREEN ===== */
#title-screen {
  position: relative;
  width: 100vw; height: 100vh;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

#title-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

.scanlines {
  position: absolute; inset: 0; z-index: 1;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,0,0,0.15) 2px, rgba(0,0,0,0.15) 4px
  );
  pointer-events: none;
}

.title-content {
  position: relative; z-index: 2;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}

.title-badge {
  font-size: 11px; letter-spacing: 4px;
  color: var(--text-dim);
  border: 1px solid var(--green-dim);
  padding: 4px 16px;
  animation: blink 2s infinite;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

.game-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(60px, 12vw, 120px);
  font-weight: 900;
  line-height: 0.9;
  color: var(--green);
  text-shadow: 0 0 40px rgba(74,255,145,0.5), 0 0 80px rgba(74,255,145,0.2);
  letter-spacing: -2px;
}

.game-title span {
  color: transparent;
  -webkit-text-stroke: 2px var(--green);
}

.subtitle {
  font-size: 13px; letter-spacing: 6px;
  color: var(--amber);
}

.menu-buttons {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
  margin-top: 10px;
}

.btn-primary {
  background: var(--green);
  color: #000;
  border: none;
  font-family: 'Orbitron', monospace;
  font-size: 14px; font-weight: 700;
  padding: 14px 32px;
  cursor: pointer;
  clip-path: polygon(8px 0%, 100% 0%, calc(100% - 8px) 100%, 0% 100%);
  transition: all 0.15s;
}
.btn-primary:hover { background: #fff; transform: scale(1.05); }

.btn-secondary {
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green-dim);
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  padding: 14px 32px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--green); background: rgba(74,255,145,0.1); }

.title-stats {
  display: flex; gap: 24px;
  font-size: 11px; color: var(--text-dim);
  letter-spacing: 2px;
}

/* ===== HOW TO PLAY ===== */
#howto-screen {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
}

.howto-box {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 40px;
  max-width: 600px; width: 90%;
  max-height: 90vh; overflow-y: auto;
}

.howto-box h2 {
  font-family: 'Orbitron', monospace;
  color: var(--green);
  font-size: 24px; margin-bottom: 24px;
  letter-spacing: 4px;
}

.howto-box h3 {
  color: var(--amber);
  margin: 20px 0 8px;
  font-size: 13px; letter-spacing: 2px;
}

.howto-box p { color: var(--text-dim); line-height: 1.6; font-size: 13px; }

.howto-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 20px;
}

.howto-item { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }

.key {
  background: var(--green-dark);
  border: 1px solid var(--green-dim);
  padding: 2px 8px;
  font-size: 11px;
  color: var(--green);
  white-space: nowrap;
}

.res-m { color: var(--metal); }
.res-e { color: var(--energy); }

/* ===== GAME SCREEN ===== */
#game-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
}

#top-bar {
  height: 40px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 10;
}

.res-display { display: flex; gap: 20px; font-size: 13px; }
#metal-display { color: var(--metal); }
#energy-display { color: var(--energy); }
#pop-display { color: var(--text-dim); }

.game-title-small {
  font-family: 'Orbitron', monospace;
  font-size: 14px; font-weight: 700;
  color: var(--green-dim);
  letter-spacing: 4px;
}

.top-right { display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--text-dim); }

.btn-tiny {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
}
.btn-tiny:hover { border-color: var(--green); color: var(--green); }

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

/* ===== BOTTOM PANEL ===== */
#bottom-panel {
  height: 130px;
  background: var(--panel);
  border-top: 2px solid var(--border);
  display: flex;
  flex-shrink: 0;
  z-index: 10;
}

#minimap-container {
  width: 130px;
  height: 130px;
  position: relative;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

#minimap {
  width: 130px; height: 130px;
  display: block;
}

.minimap-label {
  position: absolute; bottom: 4px; left: 0; right: 0;
  text-align: center;
  font-size: 9px; letter-spacing: 3px;
  color: var(--text-dim);
}

#selection-info {
  width: 220px;
  padding: 10px 14px;
  border-right: 1px solid var(--border);
  display: flex; gap: 10px; align-items: flex-start;
  flex-shrink: 0;
}

#sel-icon { font-size: 32px; line-height: 1; }

#sel-details { flex: 1; }

#sel-name {
  font-size: 11px; letter-spacing: 1px;
  color: var(--green);
  margin-bottom: 4px;
}

#sel-stats {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.6;
  min-height: 32px;
}

#sel-hp-bar {
  height: 4px;
  background: var(--green-dark);
  margin-top: 8px;
  width: 100%;
}

#sel-hp-fill {
  height: 100%;
  background: var(--green);
  width: 100%;
  transition: width 0.2s;
}

#action-panel {
  flex: 1;
  padding: 8px 12px;
  overflow: hidden;
}

#action-title {
  font-size: 10px; letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

#action-buttons {
  display: flex; flex-wrap: wrap; gap: 6px;
}

.action-btn {
  width: 64px; height: 64px;
  background: var(--green-dark);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  transition: all 0.1s;
  position: relative;
}

.action-btn:hover { border-color: var(--green); background: rgba(74,255,145,0.15); }
.action-btn.active { border-color: var(--amber); background: rgba(255,179,71,0.15); }
.action-btn .btn-icon { font-size: 20px; }
.action-btn .btn-label { font-size: 8px; color: var(--text-dim); text-align: center; }
.action-btn .btn-cost { font-size: 7px; color: var(--metal); }
.action-btn.disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== NOTIFICATIONS ===== */
#notification {
  position: fixed;
  top: 56px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--amber);
  font-size: 12px; letter-spacing: 2px;
  padding: 8px 20px;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

#notification.show { opacity: 1; }
#notification.warn { border-color: var(--red); color: var(--red); }
#notification.good { border-color: var(--green); color: var(--green); }

/* ===== DRAG SELECT ===== */
#drag-select {
  position: fixed;
  border: 1px solid var(--green);
  background: rgba(74,255,145,0.05);
  pointer-events: none;
  display: none;
  z-index: 20;
}

/* ===== GAME OVER ===== */
#gameover-screen {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
}

.gameover-box {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}

#go-result {
  font-family: 'Orbitron', monospace;
  font-size: clamp(48px, 10vw, 96px);
  font-weight: 900;
  color: var(--green);
  text-shadow: 0 0 60px rgba(74,255,145,0.6);
  letter-spacing: 8px;
}

#go-result.defeat {
  color: var(--red);
  text-shadow: 0 0 60px rgba(255,68,68,0.6);
}

#go-stats {
  font-size: 13px; color: var(--text-dim);
  line-height: 2;
  letter-spacing: 2px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--green-dim); }
