html {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: sans-serif;
  background-color: #1a1a1a;
  color: #f0f0f0;
}

h1,
h2,
h3 {
  text-align: center;
  color: #ffc107;
  margin: 10px 0;
  font-weight: 300;
}

hr {
  border: none;
  border-top: 1px solid #444;
  margin: 15px 0;
}

#game-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background-color: #000;
}

#game-layout {
  display: flex;
  flex-direction: row;
  width: 98vw;
  height: 97vh;
  border: 2px solid #ffc107;
  background-color: #000;
  box-shadow: 0 0 15px rgba(255, 193, 7, 0.5);
  border-radius: 8px;
  position: relative;
}

#ui-panel {
  width: 280px;
  flex-shrink: 0;
  height: 100%;
  padding: 10px 15px;
  overflow-y: auto;
  border-right: 2px solid #444;
}

#stats p {
  margin: 5px 0;
  font-size: 14px;
}

#budget-details {
  padding-left: 10px;
  border-left: 2px solid #555;
  margin-top: 5px;
}

#tax-rate-controls {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 5px;
  padding: 5px 0;
}

#map-container {
  flex-grow: 1;
  height: 100%;
  position: relative;
  overflow: auto;
  cursor: default;
  border: 20px solid #282c34;
}

#grid-container {
  position: relative;
  border: none;
}

#game-canvas {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 1;
}

.build-cursor {
  cursor: cell;
}

.bulldoze-cursor {
  cursor: not-allowed;
}

.tool-btn,
.tax-btn,
.action-btn,
.control-btn,
#new-game-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 8px 12px;
  margin: 0;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  border: 1px solid #777;
  text-decoration: none;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.tool-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 5px;
}

.tool-btn {
  width: 100%;
  background-color: #333;
  color: #fff;
  text-align: left;
  justify-content: flex-start;
  font-size: 14px;
  font-weight: 400;
  padding: 10px 8px;
  white-space: nowrap;
}

.tool-btn:hover {
  background-color: #444;
  border-color: #999;
}

.tool-btn.active {
  background-color: #ffc107;
  color: #000;
  border-color: #f39c12;
}

.tax-btn {
  background-color: #555;
  color: #fff;
  flex-grow: 1;
}

.tax-btn.active {
  background-color: #4caf50;
  border-color: #81c784;
}

.button-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.button-toolbar h3 {
  width: 100%;
  text-align: center;
  margin-bottom: 10px;
}

.action-btn,
.control-btn,
#new-game-btn {
  flex-grow: 1;
}

#save-btn {
  background-color: #4caf50;
  color: white;
  border-color: #388e3c;
}

#city-log-btn {
  background-color: #ff9800;
  color: white;
  border-color: #f57c00;
}

#how-to-play-btn {
  background-color: #03a9f4;
  color: white;
  border-color: #0288d1;
}

#economy-btn {
  background-color: #673ab7;
  color: white;
  border-color: #512da8;
}

#new-game-btn {
  background-color: #f44336;
  color: white;
  border-color: #d32f2f;
}

.control-btn {
  background-color: #555;
  color: white;
  font-size: 18px;
}

#night-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(25, 25, 50, 0.2);
  z-index: 5;
  pointer-events: none;
}

.night-mode #night-mode-btn {
  background-color: #ffc107;
  color: #000;
}

.night-mode #night-overlay {
  display: block;
}

.night-mode .action-btn {
  background-color: #bdc3c7;
  color: #2c3e50;
  border-color: #95a5a6;
}

.night-mode .action-btn:hover {
  background-color: #ecf0f1;
}

.visual-effect-layer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.cloud,
.cloud-shadow {
  position: absolute;
  border-radius: 50%;
  animation: drift 120s linear infinite;
}

.cloud {
  background-color: rgba(255, 255, 255, 0.4);
}

.cloud-shadow {
  background-color: rgba(0, 0, 0, 0.2);
}

@keyframes drift {
  from {
    transform: translateX(-200px);
  }

  to {
    transform: translateX(3400px);
  }
}

#minimap-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1/1;
  height: auto;
  margin: 15px 0;
  border: 2px solid #555;
  background-color: #000;
  cursor: crosshair;
  transform: translateZ(0);
  will-change: transform;
  overflow: hidden;
  contain: paint layout;
}

#minimap-canvas {
  width: 100%;
  height: 100%;
  background-color: #000;
  border: 1px solid #ffc107;
  image-rendering: pixelated;
}

#minimap-viewport {
  position: absolute;
  border: 1px solid #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transform: translateZ(0);
  will-change: left, top;
}

#tooltip {
  position: fixed;
  display: none;
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1001;
  white-space: pre-wrap;
}

#event-ticker {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  background-color: rgba(0, 0, 0, 0.7);
  color: #ffc107;
  padding: 5px 15px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.5s;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: #2c2c2c;
  color: #f0f0f0;
  padding: 20px;
  border: 2px solid #ffc107;
  border-radius: 10px;
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 0 15px rgba(255, 193, 7, 0.5);
}

.modal-content h2 {
  color: #ffc107;
}

.modal-content li {
  padding-bottom: 10px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: #aaaaaa;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: #ffc107;
}

.text-green {
  color: #81c784;
}

.text-red {
  color: #e57373;
}

#fireworks-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
  z-index: 5000;
  cursor: pointer;
  overflow: hidden;
}

#fireworks-container.active {
  display: block;
}

.congrats-text {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 100;
  width: 90%;
}

.congrats-text h1 {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: clamp(2.5rem, 7vw, 7rem);
  font-weight: bold;
  color: #ffc107;
  margin-bottom: 20px;
  animation: text-glow 1.5s ease-in-out infinite alternate;
}

.congrats-text p {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: clamp(1rem, 2.5vw, 2.2rem);
  color: #f0f0f0;
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
}

@keyframes text-glow {
  from {
    text-shadow: 0 0 10px #ffc107, 0 0 20px #ffc107, 0 0 30px #f39c12;
  }

  to {
    text-shadow: 0 0 20px #f39c12, 0 0 35px #f39c12, 0 0 50px #f1c40f;
  }
}

.explosion {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  transform-origin: 50% 50%;
  animation: explosion-anim 1.2s ease-in-out infinite;
}

.explosion::before {
  content: '';
  position: absolute;
  left: -2px;
  top: -2px;
  width: inherit;
  height: inherit;
  border-radius: 50%;
  box-shadow: 15px 23px 5px #ff0040, -11px -20px 6px #00ffb8, 23px -1px 3px #9d00ff, -1px -25px 5px #ffc107, 24px 21px 4px #00aeff, 11px -14px 6px #ff4d00, -12px -24px 3px #00ff73, 21px 11px 5px #ff00d9, -25px 14px 4px #a6ff00, -25px -10px 6px #ff0062, 11px 29px 3px #00ffea, -11px -7px 5px #ffc107, 18px -10px 4px #0066ff, -23px -9px 6px #ff002f, 1px 22px 3px #a6ff00, -2px -23px 5px #00ffd0, 15px -25px 4px #ff00a2, -13px 25px 6px #b300ff;
}

@keyframes explosion-anim {
  0% {
    transform: scale(0.1) rotate(0deg);
    opacity: 1;
  }

  60% {
    opacity: 1;
  }

  100% {
    transform: scale(20) rotate(90deg);
    opacity: 0;
  }
}

.explosion:nth-child(1) {
  left: 91%;
  top: 32%;
  animation-delay: 0.8s;
}

.explosion:nth-child(2) {
  left: 81%;
  top: 69%;
  animation-delay: 0.2s;
}

.explosion:nth-child(3) {
  left: 2%;
  top: 60%;
  animation-delay: 1.1s;
}

.explosion:nth-child(4) {
  left: 16%;
  top: 8%;
  animation-delay: 1.5s;
}

.explosion:nth-child(5) {
  left: 63%;
  top: 5%;
  animation-delay: 0.1s;
}

.explosion:nth-child(6) {
  left: 18%;
  top: 68%;
  animation-delay: 2.3s;
}

.explosion:nth-child(7) {
  left: 91%;
  top: 88%;
  animation-delay: 1.7s;
}

.explosion:nth-child(8) {
  left: 89%;
  top: 22%;
  animation-delay: 2.1s;
}

.explosion:nth-child(9) {
  left: 45%;
  top: 45%;
  animation-delay: 0.5s;
}

.explosion:nth-child(10) {
  left: 8%;
  top: 23%;
  animation-delay: 2.8s;
}

.explosion:nth-child(11) {
  left: 69%;
  top: 82%;
  animation-delay: 0.9s;
}

.explosion:nth-child(12) {
  left: 42%;
  top: 12%;
  animation-delay: 3.1s;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #2c2c2c;
}

::-webkit-scrollbar-thumb {
  background: #007bff;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #0056b3;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #007bff #2c2c2c;
}

@keyframes pulse-fire {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.3);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0.8;
  }
}

.fire-cell {
  position: absolute;
  width: 32px;
  height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 15;
}

.fire-emoji {
  font-size: 28px;
  animation: pulse-fire 1s ease-in-out infinite;
  transform-origin: center;
}
