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

body {
  background: #1a1a2e;
  color: #e0e0e0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#game-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.5rem 1rem;
  background: #252542;
  border-bottom: 2px solid #3a3a5c;
  flex-shrink: 0;
}

#tool-section {
  display: flex;
  gap: 0.5rem;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0.8rem;
  background: #3a3a5c;
  border: 2px solid #4a4a7c;
  border-radius: 6px;
  color: #c0c0d0;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 60px;
}

.tool-btn:hover {
  background: #4a4a7c;
  border-color: #6a6a9c;
}

.tool-btn.active {
  background: #5a5aac;
  border-color: #7a7acc;
  color: #fff;
}

.tool-btn[data-tool="steel"].active { border-color: #8090c0; background: #4050a0; }
.tool-btn[data-tool="wood"].active { border-color: #a08060; background: #705030; }
.tool-btn[data-tool="cable"].active { border-color: #909090; background: #505050; }
.tool-btn[data-tool="road"].active { border-color: #60a060; background: #306030; }
.tool-btn[data-tool="delete"].active { border-color: #c06060; background: #802020; }

.tool-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.tool-label {
  font-size: 0.7rem;
  margin-top: 2px;
}

#control-section {
  display: flex;
  gap: 0.5rem;
}

#control-section button {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  background: #3a3a5c;
  border: 2px solid #4a4a7c;
  border-radius: 6px;
  color: #c0c0d0;
  cursor: pointer;
  transition: all 0.15s;
}

#control-section button:hover:not(:disabled) {
  background: #4a4a7c;
}

#control-section button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#test-btn:hover:not(:disabled) {
  background: #306030;
  border-color: #408040;
}

#stop-btn:hover:not(:disabled) {
  background: #603030;
  border-color: #804040;
}

#info-section {
  margin-left: auto;
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
}

#level-display {
  color: #8090c0;
  font-weight: 600;
}

#budget-display {
  color: #a0a0b0;
}

#game-canvas {
  flex: 1;
  width: 100%;
  cursor: crosshair;
}

#help-panel {
  position: fixed;
  right: 1rem;
  top: 4rem;
  width: 220px;
  padding: 1rem;
  background: rgba(37, 37, 66, 0.95);
  border: 1px solid #3a3a5c;
  border-radius: 8px;
  font-size: 0.8rem;
}

#help-panel h3 {
  color: #8090c0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

#help-panel p {
  margin-bottom: 0.4rem;
  color: #b0b0c0;
}

#help-panel ul {
  margin-left: 1rem;
  margin-bottom: 0.5rem;
  color: #a0a0b0;
}

#help-panel li {
  margin-bottom: 0.2rem;
}

#levels-btn {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #3a3a5c;
  border: 1px solid #4a4a7c;
  border-radius: 4px;
  color: #c0c0d0;
  cursor: pointer;
}

#levels-btn:hover {
  background: #4a4a7c;
}

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

.modal.hidden {
  display: none;
}

.modal-content {
  background: #252542;
  border: 2px solid #4a4a7c;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  min-width: 300px;
}

.modal-content h2 {
  color: #60c060;
  margin-bottom: 1rem;
}

.modal-content.failure h2 {
  color: #c06060;
}

.modal-content p {
  margin-bottom: 0.5rem;
  color: #c0c0d0;
}

.modal-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.modal-buttons button {
  padding: 0.6rem 1.2rem;
  background: #3a3a5c;
  border: 2px solid #4a4a7c;
  border-radius: 6px;
  color: #c0c0d0;
  cursor: pointer;
  font-size: 0.9rem;
}

.modal-buttons button:hover {
  background: #4a4a7c;
}

#next-btn {
  background: #306030;
  border-color: #408040;
}

#next-btn:hover {
  background: #408040;
}

#level-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}

#level-buttons button {
  padding: 0.8rem;
  background: #3a3a5c;
  border: 2px solid #4a4a7c;
  border-radius: 6px;
  color: #c0c0d0;
  cursor: pointer;
  font-size: 1rem;
}

#level-buttons button:hover {
  background: #4a4a7c;
}

#level-buttons button.completed {
  background: #306030;
  border-color: #408040;
}

#level-buttons button.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

#close-levels-btn {
  margin-top: 1rem;
  padding: 0.5rem 1.5rem;
  background: #3a3a5c;
  border: 2px solid #4a4a7c;
  border-radius: 6px;
  color: #c0c0d0;
  cursor: pointer;
}
