:root {
  --bg-dark: #0e1116;
  --bg-panel: #1b1f26;
  --bg-panel-light: #232a33;
  --accent: #f6c453;
  --accent-2: #a2f6d3;
  --danger: #e05d5d;
  --text: #f1f1f1;
  --muted: #9aa3ad;
  --shadow: rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: "CairoPlay", "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1c2230, #0a0b0f 65%);
  color: var(--text);
  min-height: 100vh;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

#hud {
  background: linear-gradient(90deg, #1e232b, #12161c);
  box-shadow: 0 8px 20px var(--shadow);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

#time-display {
  font-size: 14px;
  color: var(--accent-2);
}

.hud-resources {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.hud-btn {
  background: var(--bg-panel-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hud-btn.active {
  background: var(--accent);
  color: #1b1f26;
}

.zone-switch {
  display: flex;
  gap: 8px;
}

.zone-btn {
  background: var(--bg-panel-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.zone-btn.active {
  background: var(--accent);
  color: #1b1f26;
}

.zone-btn:hover,
.hud-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px var(--shadow);
}

#game {
  flex: 1;
}

#zone-view {
  position: relative;
  height: calc(100vh - 64px);
  overflow: hidden;
}

#zone-background {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  filter: saturate(0.8) contrast(1.12);
  transition: filter 0.6s ease;
}

#zone-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  mix-blend-mode: screen;
  opacity: 0.28;
}

#zone-overlay {
  position: relative;
  z-index: 2;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  background: rgba(7, 10, 14, 0.35);
}

#zone-entities {
  position: relative;
  flex: 1;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.08)),
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
  overflow: hidden;
}

.survivor-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 10px rgba(162, 246, 211, 0.5);
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.survivor-dot:hover {
  transform: translate(-50%, -50%) scale(1.2);
}

#hover-card {
  position: fixed;
  z-index: 10;
  background: rgba(21, 25, 32, 0.95);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: 0 10px 20px var(--shadow);
  max-width: 220px;
}

#zone-title {
  font-size: 28px;
  color: var(--accent-2);
}

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

.building-card {
  background: rgba(27, 31, 38, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 6px 16px var(--shadow);
}

.building-card img {
  width: 32px;
  height: 32px;
}

#panels {
  position: fixed;
  right: 18px;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 5;
}

.panel {
  width: min(320px, 90vw);
  background: var(--bg-panel);
  border-radius: 12px;
  box-shadow: 0 12px 24px var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.panel.open {
  display: flex;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-panel-light);
}

.panel-header h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
}

.panel-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
}

.panel-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.resource {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel-light);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 14px;
  justify-content: space-between;
}

.hud-resources .resource {
  padding: 4px 8px;
  font-size: 12px;
  min-width: 92px;
}

.resource img {
  width: 18px;
  height: 18px;
}

.resource span {
  flex: 1;
}

.build-btn {
  background: var(--bg-panel-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease;
}

.build-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#survivor-list,
#event-log {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.survivor-item {
  cursor: pointer;
}

.survivor-item:hover {
  color: var(--accent-2);
}

.panel-body select {
  background: var(--bg-panel-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, rgba(21, 27, 38, 0.95), rgba(7, 8, 10, 0.95));
}

.menu-card {
  background: var(--bg-panel);
  padding: 36px 42px;
  border-radius: 16px;
  text-align: center;
  width: min(420px, 90vw);
  box-shadow: 0 16px 32px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.legal-card {
  background: var(--bg-panel);
  padding: 32px 36px;
  border-radius: 16px;
  width: min(760px, 92vw);
  max-height: 82vh;
  overflow: auto;
  box-shadow: 0 16px 32px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.legal-card h1 {
  font-size: 28px;
  color: var(--accent);
}

.legal-card h2 {
  font-size: 16px;
  color: var(--accent-2);
  margin-top: 8px;
}

.legal-card p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.menu-card h1 {
  font-size: 34px;
  color: var(--accent);
}

.subtitle {
  color: var(--muted);
  margin-bottom: 6px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-buttons button {
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #1b1f26;
  font-weight: 600;
  cursor: pointer;
}

.menu-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  font-size: 14px;
  color: var(--muted);
}

.menu-card input[type="range"] {
  width: 100%;
}

.toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.keybinds {
  text-align: left;
  background: var(--bg-panel-light);
  padding: 10px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
}

.keybind {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(21, 25, 32, 0.95);
  padding: 10px 16px;
  border-radius: 999px;
  color: var(--accent);
  box-shadow: 0 8px 16px var(--shadow);
}

@media (max-width: 900px) {
  #hud {
    flex-direction: column;
    align-items: flex-start;
  }

  #zone-view {
    height: calc(100vh - 112px);
  }

  #panels {
    right: 12px;
    left: 12px;
    top: auto;
    bottom: 20px;
    align-items: center;
  }

  .panel {
    width: 100%;
  }
}
