* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, sans-serif;
  color: #1f2937;
  background: #eef2f7;
}

.game {
  position: relative;
  min-height: 100vh;
}

#world-map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  cursor: grab;
  touch-action: none;
}

#world-map.dragging {
  cursor: grabbing;
}

.map-controls {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  transform: translateX(-50%);
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.map-control-button {
  flex: none;
  width: 38px;
  padding: 8px;
}

.player-panel,
.age-panel,
.city-panel,
.market-panel,
.trade-log-panel {
  z-index: 1;
  padding: 20px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.player-panel {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 300px;
}

.age-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 310px;
}

#advance-age-button {
  width: 100%;
  white-space: pre-line;
}

#evolution-status {
  min-height: 1.25rem;
  margin-bottom: 0;
  color: #475569;
}

.player-panel p {
  margin: 10px 0;
}

.city-panel,
.market-panel,
.trade-log-panel {
  position: fixed;
  bottom: 20px;
  height: 230px;
  overflow-y: auto;
}

.market-panel {
  left: 20px;
  width: calc(45vw - 30px);
}

.city-panel {
  left: 45vw;
  width: 30vw;
}

.trade-log-panel {
  right: 20px;
  width: calc(25vw - 30px);
}

h2 {
  margin-top: 0;
}

.buildings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.building-card {
  padding: 12px;
  text-align: center;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}

.building-card h3 {
  margin-top: 0;
}

.build-button {
  width: 100%;
  background: #15803d;
}

.build-button:hover {
  background: #166534;
}

.worker-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.worker-controls button {
  flex: none;
  width: 34px;
  padding: 7px;
}

.worker-controls span {
  flex: 1;
  font-size: 0.9rem;
}

.resource-name {
  margin-top: 0;
  font-size: 1.5rem;
  font-weight: bold;
}

.resources {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.resource-card {
  padding: 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}

.buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

button {
  flex: 1;
  padding: 12px;
  border: 0;
  border-radius: 6px;
  color: white;
  background: #2563eb;
  font-size: 1rem;
  cursor: pointer;
}

button:hover {
  background: #1d4ed8;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.sell-button {
  background: #475569;
}

.sell-button:hover {
  background: #334155;
}

#message {
  min-height: 1.25rem;
  margin-bottom: 0;
  color: #475569;
}

#city-message {
  min-height: 1.25rem;
  margin-bottom: 0;
  color: #475569;
}

#empty-log-message {
  margin-bottom: 0;
  color: #64748b;
}

#trade-log {
  margin: 0;
  padding-left: 24px;
}

#trade-log li {
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
}

#trade-log li:first-child {
  font-weight: bold;
}

@media (max-width: 700px) {
  .game {
    width: min(92%, 600px);
    margin: 20px auto;
    display: grid;
    gap: 20px;
  }

  .map-controls {
    position: sticky;
    top: 10px;
    left: auto;
    justify-self: center;
    transform: none;
  }

  .player-panel,
  .age-panel,
  .city-panel,
  .market-panel,
  .trade-log-panel {
    position: static;
    width: auto;
    height: auto;
    max-height: none;
    overflow-y: visible;
  }

  .resources,
  .buildings {
    grid-template-columns: 1fr;
  }
}
