* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #201a12;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #f1ead9;
}

#world-canvas {
  position: fixed;
  inset: 0;
  display: block;
  cursor: grab;
}

#world-canvas:active { cursor: grabbing; }

.panel {
  position: fixed;
  background: rgba(24, 20, 14, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  backdrop-filter: blur(3px);
  z-index: 5;
}

#hud {
  top: 14px;
  left: 14px;
  width: 260px;
  max-height: 396px;
  overflow-y: auto;
}

.hud-title {
  font-size: 15px;
  font-weight: 600;
  justify-content: space-between;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding-bottom: 6px;
}

.phase {
  padding: 1px 8px;
  border-radius: 20px;
  background: rgba(255, 210, 100, 0.18);
  font-size: 11px;
}

.phase.night {
  background: rgba(100, 130, 255, 0.22);
}

.phase.weather {
  background: rgba(120, 170, 220, 0.28);
}

.phase.herd {
  background: rgba(150, 120, 70, 0.32);
}

.hidden { display: none !important; }

#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: rgba(24, 20, 14, 0.92);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 13px;
  color: #f1ead9;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.birth { border-color: rgba(159, 220, 138, 0.5); }
.toast.weather { border-color: rgba(142, 203, 255, 0.5); }
.toast.herd { border-color: rgba(217, 184, 114, 0.6); }
.toast.worker-death { border-color: rgba(224, 90, 90, 0.7); }

.gather-popup {
  position: fixed;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 25;
  color: #9fdc8a;
  font-weight: 700;
  font-size: 13px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  opacity: 0;
  transition: opacity 0.2s ease, top 0.8s ease;
}

.gather-popup.show {
  opacity: 1;
}

.hud-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hud-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
}

.hud-grid > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.k { color: #cfc3a8; }
.v { font-weight: 600; }

.small-note {
  margin-top: 6px;
  font-size: 11px;
  color: #b9ac8c;
}

#controls {
  top: 420px;
  bottom: 310px;
  left: 14px;
  width: 260px;
  overflow-y: auto;
}

#controls button {
  background: #3d5a2e;
  color: #f1ead9;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

#controls button:hover { background: #4a6d38; }

.restart-row {
  margin-top: 8px;
  flex-wrap: wrap;
}

.restart-row label {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.restart-row input {
  width: 46px;
  background: #2a2318;
  color: #f1ead9;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 2px 4px;
}

#legend {
  bottom: 14px;
  left: 14px;
  width: 190px;
}

#log-panel {
  bottom: 14px;
  right: 14px;
  width: 340px;
}

#worker-panel {
  top: 14px;
  bottom: 260px;
  right: 14px;
  width: 270px;
  overflow-y: auto;
}

#worker-panel button {
  background: #7a4a2e;
  color: #f1ead9;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
}

#worker-panel button:hover { background: #915a38; }

.task-slot-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0;
  font-size: 11px;
}

.task-slot-row select {
  flex: 1;
  background: #2a2318;
  color: #f1ead9;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 3px 4px;
  font-size: 11px;
}

#log-panel select {
  background: #2a2318;
  color: #f1ead9;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 3px 4px;
  font-size: 12px;
}

#log-list {
  height: 160px;
  overflow-y: auto;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
}

.log-entry {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #e6dfce;
}

.log-entry.log-death { color: #ff9b8a; }
.log-entry.log-birth { color: #9fdc8a; }
.log-entry.log-hunt { color: #ffbf6b; }
.log-entry.log-herd { color: #d9b872; }
.log-entry.log-worker { color: #9bd6c9; }
.log-entry.log-worker-death { color: #ff8a8a; font-weight: 600; }
.log-entry.log-conflict { color: #d59bff; }
.log-entry.log-narration { color: #b9ac8c; }
.log-entry.log-info { color: #8ecbff; }

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
}

.swatch, .dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.dot { border-radius: 50%; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal.hidden { display: none; }

.modal-card {
  background: #241d14;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 22px 26px;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  line-height: 1.5;
}

.modal-card h2 { margin-top: 0; }

.modal-card button {
  margin-top: 10px;
  background: #3d5a2e;
  color: #f1ead9;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
}
