* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Rajdhani', sans-serif;
  background: #070b14;
  color: #e0e0e0;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: none;
}

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  pointer-events: none;
  display: none;
}

#hud > * { pointer-events: auto; }

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 16px;
}

.hud-panel {
  background: rgba(10, 15, 26, 0.9);
  border: 1px solid rgba(45, 90, 39, 0.6);
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  padding: 8px 14px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
}

.hud-panel-red {
  background: rgba(10, 15, 26, 0.9);
  border: 1px solid rgba(192, 57, 43, 0.6);
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  padding: 8px 14px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
}

.hud-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(to top, rgba(7, 11, 20, 0.95), transparent);
}

.unit-btn {
  background: rgba(10, 15, 26, 0.9);
  border: 1px solid rgba(45, 90, 39, 0.5);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  padding: 8px 16px;
  color: #c0e8b8;
  font-family: 'Teko', sans-serif;
  font-size: 15px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.unit-btn:hover { filter: brightness(1.4); transform: translateY(-2px); }
.unit-btn:active { filter: brightness(0.8); transform: translateY(1px); }
.unit-btn.disabled { opacity: 0.3; pointer-events: none; }
.unit-btn .cost { font-size: 11px; color: #d4a017; }
.unit-btn .emoji { font-size: 22px; line-height: 1; }

.hp-bar-bg {
  width: 100%;
  height: 4px;
  background: #1a1f2e;
  border-radius: 2px;
  margin-top: 4px;
}
.hp-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}

/* Menu Screen */
#menu-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #070b14;
  background-image:
    linear-gradient(rgba(26,82,118,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26,82,118,0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: grid-move 20s linear infinite;
}

.menu-content {
  text-align: center;
  position: relative;
  z-index: 2;
}

.title-text {
  font-family: 'Teko', sans-serif;
  font-size: clamp(48px, 12vw, 96px);
  font-weight: 700;
  letter-spacing: 8px;
  color: #e8e8e8;
  text-shadow: 0 0 20px rgba(45,90,39,0.5), 0 0 40px rgba(45,90,39,0.2);
  line-height: 1;
  animation: title-flicker 4s ease-in-out infinite;
}

.subtitle-text {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: #2d5a27;
  letter-spacing: 6px;
  margin-top: 8px;
  margin-bottom: 48px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.btn-military {
  position: relative;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  transition: all 0.2s ease;
  padding: 12px 32px;
  font-family: 'Teko', sans-serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 3px;
  color: #c0e8b8;
  background: linear-gradient(90deg, #2d5a27, #1a3a17);
  border: none;
  cursor: pointer;
  min-width: 240px;
}

.btn-military:hover {
  filter: brightness(1.3);
  transform: translateY(-1px);
}

.btn-military:active {
  filter: brightness(0.9);
  transform: translateY(1px);
}

.btn-military.btn-blue {
  background: linear-gradient(90deg, #1a5276, #0f3050);
  color: #a0c8e8;
}

.btn-military.btn-gray {
  background: linear-gradient(90deg, #444, #2a2a2a);
  color: #bbb;
}

.btn-military.btn-gold {
  background: linear-gradient(90deg, #553, #332);
  color: #d4a017;
}

.btn-back {
  margin-top: 24px;
  min-width: 140px;
  background: linear-gradient(90deg, #333, #222);
  color: #888;
  font-size: 14px;
}

.stats-text {
  margin-top: 32px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  color: #555;
}

.footer-link {
  position: fixed;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
}

.footer-link a { color: #2d5a27; text-decoration: none; }
.footer-link a:hover { color: #4a8a42; }

/* Screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #070b14;
  background-image:
    linear-gradient(rgba(26,82,118,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26,82,118,0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  overflow-y: auto;
}

.screen.hidden { display: none; }

.screen-content {
  text-align: center;
  padding: 40px 20px;
  max-width: 600px;
  width: 100%;
}

.screen-title {
  font-family: 'Teko', sans-serif;
  font-size: 36px;
  font-weight: 700;
  color: #2d5a27;
  letter-spacing: 4px;
  margin-bottom: 24px;
}

/* Level Select */
.level-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.level-card {
  background: rgba(10, 15, 26, 0.9);
  border: 1px solid rgba(45, 90, 39, 0.4);
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.level-card:hover { filter: brightness(1.3); transform: translateX(4px); }
.level-card.locked { opacity: 0.35; pointer-events: none; }
.level-card.completed { border-color: rgba(212, 160, 23, 0.5); }

.level-name {
  font-family: 'Teko', sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 2px;
}

.level-sub {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  color: #556;
  margin-top: 2px;
}

.level-status {
  font-family: 'Teko', sans-serif;
  font-size: 14px;
  letter-spacing: 2px;
}

/* How to play */
.briefing-content {
  text-align: left;
  max-width: 500px;
  margin: 0 auto;
}

.briefing-section {
  background: rgba(10, 15, 26, 0.9);
  border: 1px solid rgba(45, 90, 39, 0.3);
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
  padding: 12px 16px;
  margin-bottom: 10px;
}

.briefing-section h3 {
  font-family: 'Teko', sans-serif;
  color: #d4a017;
  font-size: 16px;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.briefing-section p {
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  color: #8899aa;
  line-height: 1.5;
}

/* Result Screen */
.result-title {
  font-family: 'Teko', sans-serif;
  font-size: 64px;
  font-weight: 700;
  letter-spacing: 6px;
  animation: banner-pulse 2s ease-in-out infinite;
}

.result-title.victory { color: #2d5a27; }
.result-title.defeat { color: #c0392b; }

.result-theater {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: #555;
  margin-bottom: 20px;
}

.result-stats {
  background: rgba(10, 15, 26, 0.9);
  border: 1px solid rgba(45, 90, 39, 0.4);
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  padding: 20px;
  margin: 0 auto 24px;
  max-width: 300px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  color: #8899aa;
  line-height: 2;
}

.scanline-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.05;
  z-index: 1;
}

.scanline-overlay::after {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  background: #22c55e;
  animation: scanline 4s linear infinite;
}

/* Battle log overlay */
#battle-log-panel {
  position: fixed;
  bottom: 80px;
  left: 10px;
  width: 280px;
  max-height: 160px;
  background: rgba(5, 8, 8, 0.92);
  border: 1px solid rgba(45, 90, 39, 0.4);
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
  z-index: 10;
  display: none;
}

#battle-log-panel .log-title {
  padding: 4px 10px;
  border-bottom: 1px solid rgba(45, 90, 39, 0.3);
  font-family: 'Teko', sans-serif;
  font-size: 13px;
  color: #2d5a27;
  letter-spacing: 2px;
}

#battle-log-panel .log-content {
  padding: 6px 10px;
  overflow-y: auto;
  max-height: 130px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  color: #22c55e;
}

#battle-log-panel .log-content::-webkit-scrollbar { width: 3px; }
#battle-log-panel .log-content::-webkit-scrollbar-track { background: #0a0f1a; }
#battle-log-panel .log-content::-webkit-scrollbar-thumb { background: #2d5a27; }

/* Minimap */
#minimap {
  position: fixed;
  bottom: 80px;
  right: 10px;
  width: 150px;
  height: 150px;
  background: rgba(5, 8, 8, 0.9);
  border: 1px solid rgba(45, 90, 39, 0.5);
  z-index: 10;
  display: none;
}

/* Animations */
@keyframes scanline {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

@keyframes grid-move {
  0% { background-position: 0 0; }
  100% { background-position: 40px 40px; }
}

@keyframes title-flicker {
  0%, 95%, 100% { opacity: 1; }
  96% { opacity: 0.4; }
  97% { opacity: 1; }
  98% { opacity: 0.3; }
}

@keyframes banner-pulse {
  0%, 100% { text-shadow: 0 0 10px currentColor, 0 0 20px currentColor; }
  50% { text-shadow: 0 0 20px currentColor, 0 0 40px currentColor, 0 0 60px currentColor; }
}

@keyframes shake {
  0%, 100% { transform: translate(0); }
  10%, 30%, 50%, 70%, 90% { transform: translate(-3px, 1px); }
  20%, 40%, 60%, 80% { transform: translate(3px, -1px); }
}

@keyframes float-up {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1.4); }
}

.shake { animation: shake 0.3s ease-in-out; }

/* Selection ring */
@keyframes selection-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Responsive */
@media (max-width: 600px) {
  .title-text { letter-spacing: 4px; }
  .subtitle-text { letter-spacing: 3px; font-size: 12px; }
  .btn-military { min-width: 200px; padding: 10px 24px; font-size: 16px; }
  .unit-btn { min-width: 64px; padding: 6px 10px; font-size: 13px; }
  .unit-btn .emoji { font-size: 18px; }
  #battle-log-panel { width: 200px; font-size: 9px; }
  #minimap { width: 100px; height: 100px; }
}