/* NeonGrid City Builder - Cyberpunk Terminal Styles */

@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

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

:root {
  --bg-dark: #0a0a0f;
  --bg-panel: #12121a;
  --neon-cyan: #00fff9;
  --neon-pink: #ff00ff;
  --neon-purple: #9d00ff;
  --neon-green: #39ff14;
  --neon-orange: #ff6b00;
  --neon-red: #ff0040;
  --text-dim: #4a4a5a;
  --text-bright: #e0e0ff;
}

body {
  font-family: 'VT323', monospace;
  background: var(--bg-dark);
  color: var(--text-bright);
  overflow: hidden;
  height: 100vh;
  font-size: 16px;
}

/* CRT Scanline Effect */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15),
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 9999;
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.4) 100%);
  pointer-events: none;
  z-index: 9998;
}

/* Main Layout */
#game-container {
  display: grid;
  grid-template-rows: 50px 1fr 200px;
  grid-template-columns: 250px 1fr 280px;
  height: 100vh;
  gap: 2px;
  padding: 4px;
}

/* Header */
#header {
  grid-column: 1 / -1;
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 0 20px rgba(0, 255, 249, 0.3), inset 0 0 30px rgba(0, 255, 249, 0.05);
}

#title {
  font-size: 28px;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan);
  letter-spacing: 4px;
}

#resources {
  display: flex;
  gap: 25px;
}

.resource {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
}

.resource-icon {
  font-size: 20px;
}

.resource-value {
  color: var(--neon-green);
  min-width: 80px;
  text-shadow: 0 0 8px var(--neon-green);
}

.resource-value.credits { color: var(--neon-green); text-shadow: 0 0 8px var(--neon-green); }
.resource-value.energy { color: var(--neon-cyan); text-shadow: 0 0 8px var(--neon-cyan); }
.resource-value.population { color: var(--neon-pink); text-shadow: 0 0 8px var(--neon-pink); }
.resource-value.happiness { color: var(--neon-orange); text-shadow: 0 0 8px var(--neon-orange); }
.resource-value.tech { color: var(--neon-purple); text-shadow: 0 0 8px var(--neon-purple); }

#game-controls {
  display: flex;
  gap: 10px;
}

.btn {
  background: transparent;
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 5px 15px;
  font-family: 'VT323', monospace;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--neon-cyan);
  color: var(--bg-dark);
  box-shadow: 0 0 15px var(--neon-cyan);
}

.btn.active {
  background: var(--neon-pink);
  border-color: var(--neon-pink);
  color: var(--bg-dark);
}

/* Building Panel */
#building-panel {
  background: var(--bg-panel);
  border: 1px solid var(--neon-purple);
  box-shadow: 0 0 15px rgba(157, 0, 255, 0.2);
  overflow-y: auto;
  padding: 10px;
}

#building-panel h3 {
  color: var(--neon-purple);
  text-shadow: 0 0 10px var(--neon-purple);
  margin-bottom: 15px;
  font-size: 20px;
  border-bottom: 1px solid var(--neon-purple);
  padding-bottom: 5px;
}

.building-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin-bottom: 8px;
  background: rgba(157, 0, 255, 0.1);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.building-item:hover {
  border-color: var(--neon-purple);
  background: rgba(157, 0, 255, 0.2);
}

.building-item.selected {
  border-color: var(--neon-pink);
  background: rgba(255, 0, 255, 0.2);
  box-shadow: 0 0 10px rgba(255, 0, 255, 0.3);
}

.building-icon {
  font-size: 24px;
  width: 30px;
  text-align: center;
}

.building-info {
  flex: 1;
}

.building-name {
  color: var(--text-bright);
  font-size: 16px;
}

.building-cost {
  color: var(--neon-green);
  font-size: 14px;
}

.building-key {
  color: var(--text-dim);
  font-size: 14px;
}

/* City View */
#city-view {
  background: #080810;
  border: 1px solid var(--neon-cyan);
  position: relative;
  overflow: hidden;
}

#city-grid {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  grid-template-rows: repeat(15, 1fr);
  height: 100%;
  width: 100%;
}

.cell {
  border: 1px solid #1a1a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.1s;
  position: relative;
}

.cell:hover {
  background: rgba(0, 255, 249, 0.1);
  border-color: var(--neon-cyan);
}

.cell.road { color: #3a3a4a; background: #0f0f15; }
.cell.empty { color: #1a1a2a; }

.cell.building {
  font-size: 10px;
  text-align: center;
  line-height: 1.1;
}

.cell .building-ascii {
  font-size: 8px;
  line-height: 1;
  white-space: pre;
}

/* Building colors */
.cell[data-type="residential"] { color: #00ffaa; text-shadow: 0 0 5px #00ffaa; background: rgba(0, 255, 170, 0.05); }
.cell[data-type="power"] { color: #ffff00; text-shadow: 0 0 5px #ffff00; background: rgba(255, 255, 0, 0.05); }
.cell[data-type="commercial"] { color: #00aaff; text-shadow: 0 0 5px #00aaff; background: rgba(0, 170, 255, 0.05); }
.cell[data-type="industrial"] { color: #ff8800; text-shadow: 0 0 5px #ff8800; background: rgba(255, 136, 0, 0.05); }
.cell[data-type="police"] { color: #4488ff; text-shadow: 0 0 5px #4488ff; background: rgba(68, 136, 255, 0.05); }
.cell[data-type="hospital"] { color: #ff4444; text-shadow: 0 0 5px #ff4444; background: rgba(255, 68, 68, 0.05); }
.cell[data-type="entertainment"] { color: #ff00ff; text-shadow: 0 0 5px #ff00ff; background: rgba(255, 0, 255, 0.05); }
.cell[data-type="spaceport"] { color: #aa00ff; text-shadow: 0 0 8px #aa00ff; background: rgba(170, 0, 255, 0.1); }
.cell[data-type="datacenter"] { color: #00ffff; text-shadow: 0 0 5px #00ffff; background: rgba(0, 255, 255, 0.05); }
.cell[data-type="water"] { color: #0088ff; text-shadow: 0 0 5px #0088ff; background: rgba(0, 136, 255, 0.05); }
.cell[data-type="transit"] { color: #88ff00; text-shadow: 0 0 5px #88ff00; background: rgba(136, 255, 0, 0.05); }
.cell[data-type="research"] { color: #ff0088; text-shadow: 0 0 5px #ff0088; background: rgba(255, 0, 136, 0.05); }
.cell[data-type="clonefarm"] { color: #00ff88; text-shadow: 0 0 5px #00ff88; background: rgba(0, 255, 136, 0.05); }
.cell[data-type="billboard"] { color: #ffff00; text-shadow: 0 0 10px #ffff00; animation: pulse 1s infinite; }
.cell[data-type="defense"] { color: #ff0000; text-shadow: 0 0 5px #ff0000; background: rgba(255, 0, 0, 0.05); }
.cell[data-type="blackmarket"] { color: #8800ff; text-shadow: 0 0 5px #8800ff; background: rgba(136, 0, 255, 0.05); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Traffic */
.traffic {
  position: absolute;
  font-size: 10px;
  transition: all 0.5s;
  z-index: 10;
}

/* Weather Overlay */
#weather-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.weather-particle {
  position: absolute;
  color: rgba(200, 200, 255, 0.5);
  font-size: 12px;
  animation: fall linear infinite;
}

@keyframes fall {
  to { transform: translateY(100vh); }
}

/* Day/Night Overlay */
#daynight-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
  transition: background 2s;
}

#daynight-overlay.day { background: transparent; }
#daynight-overlay.night { background: rgba(0, 0, 50, 0.3); }
#daynight-overlay.twilight { background: rgba(50, 0, 50, 0.2); }

/* Event Panel */
#event-panel {
  background: var(--bg-panel);
  border: 1px solid var(--neon-orange);
  box-shadow: 0 0 15px rgba(255, 107, 0, 0.2);
  display: flex;
  flex-direction: column;
}

#event-panel h3 {
  color: var(--neon-orange);
  text-shadow: 0 0 10px var(--neon-orange);
  padding: 10px;
  border-bottom: 1px solid var(--neon-orange);
  font-size: 20px;
}

#event-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.event-entry {
  padding: 8px;
  margin-bottom: 8px;
  background: rgba(255, 107, 0, 0.1);
  border-left: 3px solid var(--neon-orange);
  font-size: 14px;
  animation: slideIn 0.3s;
}

.event-entry.warning { border-color: var(--neon-red); background: rgba(255, 0, 64, 0.1); }
.event-entry.success { border-color: var(--neon-green); background: rgba(57, 255, 20, 0.1); }
.event-entry.info { border-color: var(--neon-cyan); background: rgba(0, 255, 249, 0.1); }

@keyframes slideIn {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.event-time {
  color: var(--text-dim);
  font-size: 12px;
}

/* Bottom Panel */
#bottom-panel {
  grid-column: 1 / -1;
  background: var(--bg-panel);
  border: 1px solid var(--neon-green);
  display: flex;
  gap: 2px;
}

#tech-tree, #achievements {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
}

#tech-tree {
  border-right: 1px solid var(--neon-green);
}

#tech-tree h3, #achievements h3 {
  color: var(--neon-green);
  text-shadow: 0 0 10px var(--neon-green);
  margin-bottom: 15px;
  font-size: 20px;
}

.tech-node {
  display: inline-block;
  padding: 8px 15px;
  margin: 5px;
  background: rgba(57, 255, 20, 0.1);
  border: 1px solid var(--neon-green);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tech-node:hover:not(.locked):not(.researched) {
  background: var(--neon-green);
  color: var(--bg-dark);
}

.tech-node.researched {
  background: var(--neon-green);
  color: var(--bg-dark);
  box-shadow: 0 0 15px var(--neon-green);
}

.tech-node.locked {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--text-dim);
}

.tech-node.current {
  border-color: var(--neon-cyan);
  animation: glow 1s infinite;
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px var(--neon-cyan); }
  50% { box-shadow: 0 0 20px var(--neon-cyan); }
}

.achievement {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(57, 255, 20, 0.05);
  border: 1px solid #2a2a3a;
}

.achievement.unlocked {
  border-color: var(--neon-green);
  background: rgba(57, 255, 20, 0.1);
}

.achievement-icon {
  font-size: 24px;
}

.achievement-name {
  color: var(--text-bright);
  font-size: 16px;
}

.achievement.unlocked .achievement-name {
  color: var(--neon-green);
  text-shadow: 0 0 8px var(--neon-green);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-panel);
  border: 2px solid var(--neon-pink);
  box-shadow: 0 0 30px rgba(255, 0, 255, 0.5);
  padding: 30px;
  max-width: 500px;
  animation: modalIn 0.3s;
}

@keyframes modalIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal h2 {
  color: var(--neon-pink);
  text-shadow: 0 0 15px var(--neon-pink);
  margin-bottom: 20px;
  font-size: 28px;
}

.modal p {
  margin-bottom: 20px;
  line-height: 1.6;
  font-size: 18px;
}

.modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.modal .btn {
  min-width: 120px;
}

.modal .btn.success { border-color: var(--neon-green); color: var(--neon-green); }
.modal .btn.success:hover { background: var(--neon-green); }
.modal .btn.danger { border-color: var(--neon-red); color: var(--neon-red); }
.modal .btn.danger:hover { background: var(--neon-red); }

/* Sound Visualization */
#sound-viz {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  height: 30px;
  align-items: flex-end;
  z-index: 100;
}

.sound-bar {
  width: 4px;
  background: var(--neon-cyan);
  box-shadow: 0 0 5px var(--neon-cyan);
  transition: height 0.1s;
}

/* Notifications */
#notification {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--neon-cyan);
  padding: 10px 20px;
  z-index: 100;
  animation: notifyIn 0.3s;
  box-shadow: 0 0 20px rgba(0, 255, 249, 0.3);
}

@keyframes notifyIn {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Info tooltip */
#tooltip {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--neon-cyan);
  padding: 10px;
  font-size: 14px;
  z-index: 100;
  display: none;
  max-width: 200px;
}

#tooltip h4 {
  color: var(--neon-cyan);
  margin-bottom: 5px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--neon-purple); }
::-webkit-scrollbar-thumb:hover { background: var(--neon-pink); }

/* Mini map for time/weather */
#time-display {
  display: flex;
  align-items: center;
  gap: 10px;
}

#weather-icon {
  font-size: 20px;
}

/* Game Paused Overlay */
#paused-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  color: var(--neon-red);
  text-shadow: 0 0 30px var(--neon-red);
  z-index: 500;
  display: none;
  animation: blink 1s infinite;
}

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

/* Responsive */
@media (max-width: 1200px) {
  #game-container {
    grid-template-columns: 200px 1fr 220px;
  }
  #bottom-panel {
    flex-direction: column;
  }
  #tech-tree {
    border-right: none;
    border-bottom: 1px solid var(--neon-green);
  }
}
