:root {
  --bg: #f2f1ea;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #5d6b7a;
  --accent: #c4412d;
  --border: #d8dde3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #e9e4d8 0%, var(--bg) 220px);
}

.topbar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #fff8eb;
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 12px;
  padding: 12px;
}

.map-panel,
.side-panel {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.map-panel {
  display: flex;
  flex-direction: column;
}

.map-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  --marker-zoom-scale: 1;
  background: #111;
  overflow: hidden;
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
}

.map-wrap.dragging {
  cursor: grabbing;
}

.map-content {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
}

#mapImage {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
}

#markerLayer {
  position: absolute;
  inset: 0;
}

.marker {
  --icon-width: 34px;
  --icon-height: 34px;
  --marker-active-scale: 1;
  --marker-completed-scale: 1;
  position: absolute;
  width: var(--icon-width);
  height: var(--icon-height);
  border: 0;
  padding: 0;
  background-color: transparent;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.9));
  transform: translate(-50%, -50%) scale(calc(var(--marker-zoom-scale) * var(--marker-active-scale) * var(--marker-completed-scale)));
  cursor: pointer;
}

.marker.dlc {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.9)) hue-rotate(26deg) saturate(1.1);
}

.marker.active {
  --marker-active-scale: 1.24;
  z-index: 2;
  filter: drop-shadow(0 0 0.35rem rgba(255, 211, 77, 0.95)) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.95));
}

.marker.claimed {
  opacity: 0.92;
}

.marker.claimed.active {
  opacity: 1;
}

.marker.mission-completed {
  --marker-completed-scale: 0.5;
  opacity: 0.5;
}

.marker.mission-completed.active {
  opacity: 0.5;
}

.marker:hover {
  z-index: 3;
}

.marker.sprite-block-locked {
  background-image: url("./assets/icons/blockcrate_locked.png");
}

.marker.sprite-block-unlocked {
  background-image: url("./assets/icons/blockcrate_unlocked.png");
}

.marker.sprite-power-locked {
  background-image: url("./assets/icons/powercrate_locked.png");
}

.marker.sprite-power-unlocked {
  background-image: url("./assets/icons/powercrate_unlocked.png");
}

.marker.sprite-mission-main {
  background-image: url("./assets/icons/mission_main.png");
}

.marker.sprite-mission-side {
  background-image: url("./assets/icons/mission_side.png");
}

.hover-label {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 0.78rem;
  line-height: 1.2;
  max-width: 420px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.coords-readout {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 5;
  max-width: min(72%, 560px);
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.68);
  color: #ffffff;
  font-size: 0.78rem;
  line-height: 1.25;
  white-space: pre-line;
  pointer-events: none;
}

.map-zoom-readout {
  position: absolute;
  right: 8px;
  bottom: 48px;
  z-index: 6;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-size: 0.78rem;
  line-height: 1.2;
  pointer-events: none;
}

.map-controls {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-controls button {
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.68);
  color: #ffffff;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.map-controls button:hover {
  background: rgba(0, 0, 0, 0.82);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.hint a {
  color: #1d4f8f;
  text-decoration: none;
}

.hint a:hover {
  text-decoration: underline;
}

.side-panel label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.side-panel {
  display: flex;
  flex-direction: column;
}

.side-tools {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.mini-label {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

#claimFilter {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 0.9rem;
  background: #ffffff;
}

#campaignSelect {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
  background: #ffffff;
  margin-bottom: 8px;
}

#itemTypeFilter {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 0.9rem;
  background: #ffffff;
}

#searchInput {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.95rem;
}

.counts {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.counts .dot {
  margin: 0 6px;
}

#itemList {
  flex: 1;
  min-height: 0;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  overflow: auto;
}

#itemList li {
  padding: 6px 8px;
  border: 2px solid rgba(224, 123, 46, 0.45);
  background: #fff8f2;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
}

#itemList li:hover {
  border-color: rgba(208, 109, 36, 0.62);
  background: #fff2e8;
}

#itemList li.active:not(.claimed) {
  border-width: 3px;
  border-color: #cf6d24;
  background: #fbe5d3;
}

#itemList li strong {
  display: block;
  font-size: 0.92rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

#itemList li .item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

#itemList li .claim-toggle {
  flex: 0 0 auto;
  border: 2px solid #2d7f33;
  border-radius: 999px;
  background: #38a543;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.74rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}

#itemList li .claim-toggle:hover {
  background: #2d8f37;
}

#itemList li .claim-toggle.claimed {
  border-color: #d06624;
  background: #e07b2e;
}

#itemList li .claim-toggle.claimed:hover {
  background: #cf6d24;
}

#itemList li.claimed {
  border-color: rgba(56, 165, 67, 0.45);
  background: #f1fbf2;
}

#itemList li.claimed:hover {
  border-color: rgba(45, 143, 55, 0.64);
  background: #e9f8ec;
}

#itemList li.claimed strong {
  color: #2a5d30;
}

#itemList li.claimed.active {
  border-width: 3px;
  border-color: #2d8f37;
  background: #dff3e3;
}

#itemList li span {
  color: var(--muted);
  font-size: 0.8rem;
}

#itemList li .rewards {
  margin-top: 4px;
  color: #334455;
  font-size: 0.78rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: unset;
  }

  #itemList {
    max-height: 40vh;
  }

  .map-wrap {
    width: 100%;
    min-height: 200px;
  }
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 8px 14px;
  background: #fff8eb;
  color: var(--muted);
  font-size: 0.8rem;
}
