* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  --region-image: none;
  background:
    linear-gradient(135deg, rgba(2, 6, 23, 0.65), rgba(2, 6, 23, 0.78)),
    var(--region-image) center / cover no-repeat fixed,
    radial-gradient(circle at top left, rgba(52, 211, 153, 0.16), transparent 34rem),
    linear-gradient(135deg, #111827 0%, #18212f 52%, #211b2f 100%);
  color: #f8fafc;
  font-family: Arial, sans-serif;
  padding: 24px;
  transition: background 320ms ease;
}

.discovery-shell {
  width: min(1500px, 100%);
  margin: 0 auto;

  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.discovery-map-panel,
.side-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;

  background: rgba(15, 23, 42, 0.4);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.discovery-map-panel {
  padding: 12px;
  min-width: 0;
}

.map-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-controls button {
  width: 34px;
  height: 34px;

  border: 0;
  border-radius: 8px;

  background: rgba(52, 211, 153, 0.18);
  color: #bbf7d0;

  cursor: pointer;

  font-size: 1.2rem;
  font-weight: 900;
}

.map-controls button:hover {
  background: rgba(52, 211, 153, 0.3);
}

#zoomText {
  min-width: 52px;
  text-align: center;
  color: #d1fae5;
  font-weight: 800;
}

.map-viewport {
  width: 100%;
  height: calc(100dvh - 70px);

  overflow: hidden;

  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.18);

  background: rgba(2, 6, 23, 0.5);

  position: relative;
  touch-action: manipulation;
}

.map-grid {
  position: absolute;
  left: 0;
  top: 0;

  display: grid;

  width: max-content;

  background-image: var(--map-background);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;

  transform-origin: top left;
  will-change: transform;
  transition: transform 220ms ease-out;
}

.map-tile {
  position: relative;

  width: var(--tile-size);
  height: var(--tile-size);

  border: 1px solid rgba(91, 95, 103, 0.2);
  background: rgba(15, 23, 42, 0.2);
  
  cursor: default;
}

.tile-shelter-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 70%;
  height: 70%;
  object-fit: contain;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 4;
}
.map-tile.is-blocked {
    background: rgba(15, 23, 42, 0.2);
    border-color: rgba(15, 23, 42, 0.33);
    box-shadow: inset 0 0 0 999px rgba(15, 23, 42, 0.33);
}

.map-tile.is-walkable {
    background: rgba(15, 23, 42, 0.2);
    border-color: rgba(148, 163, 184, 0.2);
}

.map-tile.has-required-item {
    border-color: rgba(15, 23, 42, 0.33);
    box-shadow: inset 0 0 0 999px rgba(15, 23, 42, 0.33);
}

.map-tile.is-current {
  border: 2px solid rgba(96, 165, 250, 0.95);
  box-shadow:
    inset 0 0 0 2px rgba(59, 130, 246, 0.45),
    0 0 16px rgba(59, 130, 246, 0.28);
  z-index: 3;
}

.map-tile.is-current::after {
  content: "●";

  position: absolute;
  inset: 0;

  display: grid;
  place-items: center;

  color: #60a5fa;
  font-size: calc(var(--tile-size) * 0.46);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.map-tile.is-movable {
  cursor: pointer;
  border: 2px solid rgba(52, 211, 153, 0.88);
  box-shadow: inset 0 0 0 2px rgba(52, 211, 153, 0.22);
}

.map-tile.is-movable:hover {
  background: rgba(52, 211, 153, 0.18);
}

.map-tile.has-exit::before {
  content: "⇄";

  position: absolute;
  top: 4px;
  right: 5px;

  color: #facc15;
  font-size: 1.2rem;
  font-weight: 900;
}

.discovery-side-panel {
  display: grid;
  gap: 14px;

  position: sticky;
  top: 24px;
}

.side-card {
  padding: 14px;
}

.side-card h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.side-card p {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.88rem;
  font-weight: 700;
}

.discovery-log {
  display: grid;
  gap: 8px;
}

.discovery-log p {
  margin: 0;
  padding: 8px 10px;

  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.16);

  background: rgba(30, 41, 59, 0.56);
  color: #dbeafe;

  font-size: 0.82rem;
  font-weight: 700;
}

.map-viewport {
  width: 100%;
  height: calc(100vh - 70px);

  overflow: hidden;

  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.18);

  background: rgba(2, 6, 23, 0.5);

  position: relative;
}

.discovery-coordinate-box {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;

  min-width: 42px;
  padding: 5px 9px;

  border: 1px solid rgba(220, 200, 155, 0.65);
  border-radius: 5px;

  background: rgba(25, 22, 18, 0.82);
  color: #ead9ad;

  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-align: center;

  pointer-events: none;
  backdrop-filter: blur(2px);
}

.map-title-overlay {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 30;

  transform: translateX(-50%);

  min-width: 120px;
  padding: 4px 8px;
  border-radius: 8px;

  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);

  color: #f8fafc;
  font-size: 1.05rem;
  font-weight: 900;
  text-align: center;

  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);

  pointer-events: none;
}

.map-controls-overlay {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 30;

  padding: 6px;

  border-radius: 8px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);

  backdrop-filter: blur(10px);
}

.map-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-controls button {
  width: 28px;
  height: 28px;

  border: 0;
  border-radius: 6px;

  background: rgba(52, 211, 153, 0.2);
  color: #bbf7d0;

  cursor: pointer;

  font-size: 1rem;
  font-weight: 900;
}

.map-controls button:hover {
  background: rgba(52, 211, 153, 0.3);
}

#zoomText {
  min-width: 44px;
  text-align: center;
  color: #d1fae5;
  font-size: 0.78rem;
  font-weight: 900;
}

.tile-actions {
  display: grid;
  gap: 8px;
}

.tile-action-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;

  background: linear-gradient(180deg, #34d399, #059669);
  color: #06131c;

  cursor: pointer;

  font-size: 0.9rem;
  font-weight: 900;

  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.tile-action-button:hover {
  filter: brightness(1.08);
}

.tile-action-button.secondary {
  background: rgba(96, 165, 250, 0.18);
  color: #bfdbfe;
  border: 1px solid rgba(96, 165, 250, 0.35);
}

.found-loot-card {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px;

  border-radius: 8px;
  border: 1px solid rgba(52, 211, 153, 0.28);

  background: rgba(30, 41, 59, 0.58);
}

.found-loot-card img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.found-loot-card div {
  display: grid;
  gap: 4px;
}

.found-loot-card strong {
  color: #f8fafc;
  font-size: 0.92rem;
}

.found-loot-card span {
  color: #a7f3d0;
  font-size: 0.78rem;
  font-weight: 900;
}

.found-loot-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.found-loot-list {
  display: grid;
  gap: 8px;
}

.encounter-card {
  display: grid;
  gap: 5px;

  padding: 10px;

  border-radius: 8px;
  background: rgba(30, 41, 59, 0.58);
}

.encounter-card strong {
  color: #f8fafc;
  font-size: 0.95rem;
}

.encounter-card span {
  color: #cbd5e1;
  font-size: 0.82rem;
  font-weight: 700;
}

.encounter-card-friendly {
  border: 1px solid rgba(52, 211, 153, 0.32);
}

.encounter-card-enemy {
  border: 1px solid rgba(248, 113, 113, 0.38);
}

.encounter-hunt-chance {
  color: #a7f3d0;
  font-size: 0.78rem;
  font-weight: 900;
}

.hunt-tool-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  overflow: hidden;
}

.hunt-tool-button {
  min-height: 28px;
  padding: 5px 8px;

  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 7px;

  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;

  cursor: pointer;

  font-size: 0.72rem;
  font-weight: 900;
}

.hunt-tool-button:hover {
  border-color: rgba(52, 211, 153, 0.42);
  color: #d1fae5;
}

.hunt-tool-button.is-selected {
  border-color: rgba(52, 211, 153, 0.8);
  background: rgba(52, 211, 153, 0.16);
  color: #bbf7d0;
}

.tile-resource-marker,
.tile-encounter-marker {
  position: absolute;
  bottom: 5px;
  z-index: 4;

  width: 8px;
  height: 8px;

  border-radius: 50%;

  pointer-events: none;
}

.tile-resource-marker {
  left: 5px;

  background: rgba(134, 239, 172, 0.95);
  box-shadow: 0 0 8px rgba(134, 239, 172, 0.55);
}

.tile-encounter-marker {
  right: 5px;

  background: rgba(251, 146, 60, 0.95);
  box-shadow: 0 0 8px rgba(251, 146, 60, 0.55);
}

body:not(.show-map-debug-markers) .tile-resource-marker,
body:not(.show-map-debug-markers) .tile-encounter-marker {
  display: none;
}

.tile-required-item-marker {
  position: absolute;
  left: 50%;
  bottom: 5px;
  z-index: 4;

  width: 8px;
  height: 8px;

  border-radius: 50%;
  background: rgba(165, 96, 250, 0.95);
  box-shadow: 0 0 8px rgba(97, 54, 150, 0.95);

  transform: translateX(-50%);
  pointer-events: none;
}

body:not(.show-map-debug-markers) .tile-required-item-marker {
  display: none;
}

.tile-shelter-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;

  width: 22px;
  height: 22px;
  object-fit: contain;

  transform: translate(-50%, -50%);
  pointer-events: none;
}

.tile-workstation-marker {
  position: absolute;
  z-index: 7;

  width: 12px;
  height: 12px;
  object-fit: contain;

  pointer-events: none;

  filter:
    drop-shadow(0 1px 1px rgba(0, 0, 0, 0.85))
    drop-shadow(0 0 2px rgba(0, 0, 0, 0.55));
}

.tile-workstation-marker.marker-top-left {
  top: 2px;
  left: 2px;
}

.tile-workstation-marker.marker-top-right {
  top: 2px;
  right: 2px;
}

.tile-workstation-marker.marker-bottom-left {
  bottom: 2px;
  left: 2px;
}

.tile-workstation-marker.marker-bottom-right {
  right: 2px;
  bottom: 2px;
}

@media (max-width: 1100px) {
  body {
    padding: 12px;
  }

  .discovery-shell {
    grid-template-columns: 1fr;
  }

  .discovery-side-panel {
    position: static;
  }

  .map-viewport {
    height: 72dvh;
  }
}

@media (max-width: 700px) {
  body {
    padding: 8px;
  }

  .discovery-map-panel {
    padding: 6px;
  }

  .map-viewport {
    height: 68dvh;
  }

  .map-title-overlay {
    top: 8px;
    min-width: 110px;
    padding: 7px 12px;
    font-size: 0.95rem;
  }

  .map-controls-overlay {
    right: 50%;
    bottom: 8px;
    transform: translateX(50%);
    padding: 5px;
  }

  .map-controls button {
    width: 30px;
    height: 30px;
  }

  #zoomText {
    min-width: 40px;
    font-size: 0.72rem;
  }
}

.discovery-movement-marker {
  position: fixed;
  z-index: 9999;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.discovery-movement-marker.is-rafting {
  width: 32px;
  height: 32px;
  font-size: 24px;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.65));
}

.movement-footprints {
  position: relative;
  width: 26px;
  height: 26px;
  transform-origin: center;
  pointer-events: none;
}

.movement-step {
  position: absolute;
  width: 8px;
  height: 13px;
  border-radius: 50% 50% 45% 45%;
  background: rgba(238, 220, 177, 0.95);
  border: 1px solid rgba(55, 39, 25, 0.9);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
}

.movement-step-left {
  left: 4px;
  bottom: 3px;
  transform: rotate(-12deg);
  animation: walkingStepLeft 0.32s ease-in-out infinite alternate;
}

.movement-step-right {
  right: 4px;
  top: 3px;
  transform: rotate(12deg);
  animation: walkingStepRight 0.32s ease-in-out infinite alternate;
}

.map-grid.is-player-moving .map-tile {
  pointer-events: none;
}

.map-tile.is-move-source {
  opacity: 0.7;
}

.map-tile.is-move-target {
  animation: movementTargetPulse 0.55s ease-in-out infinite alternate;
}

@keyframes walkingStepLeft {
  from {
    transform: translateY(2px) rotate(-12deg);
    opacity: 0.65;
  }

  to {
    transform: translateY(-2px) rotate(-12deg);
    opacity: 1;
  }
}

@keyframes walkingStepRight {
  from {
    transform: translateY(-2px) rotate(12deg);
    opacity: 1;
  }

  to {
    transform: translateY(2px) rotate(12deg);
    opacity: 0.65;
  }
}

@keyframes movementTargetPulse {
  from {
    box-shadow: inset 0 0 0 1px rgba(238, 220, 177, 0.25);
  }

  to {
    box-shadow:
      inset 0 0 0 2px rgba(238, 220, 177, 0.85),
      0 0 10px rgba(238, 220, 177, 0.5);
  }
}

.buried-stash-card {
  display: flex;
  flex-direction: column;
  gap: 10px;

  padding: 12px;
  margin-top: 10px;

  border: 1px solid rgba(177, 143, 82, 0.75);
  border-radius: 7px;

  background:
    linear-gradient(
      145deg,
      rgba(72, 54, 30, 0.95),
      rgba(34, 29, 22, 0.97)
    );

  box-shadow:
    inset 0 0 10px rgba(0, 0, 0, 0.45),
    0 3px 9px rgba(0, 0, 0, 0.35);
}

.buried-stash-card > strong {
  color: #e5c885;
  font-size: 15px;
}

.tile-buried-stash-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 22px;
  height: 22px;

  transform: translate(-50%, -50%) rotate(-8deg);

  color: #8f1717;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;

  text-shadow:
    0 1px 0 rgba(255, 220, 160, 0.45),
    0 2px 3px rgba(0, 0, 0, 0.8);

  pointer-events: none;
}

.tile-storage-markers {
  position: absolute;
  right: 3px;
  bottom: 3px;
  z-index: 8;

  display: flex;
  align-items: flex-end;
  gap: 1px;

  pointer-events: none;
}

.tile-storage-marker {
  width: 26px;
  height: 26px;

  object-fit: contain;
  image-rendering: auto;

  pointer-events: none;
  user-select: none;
}

.has-storage-container {
  position: relative;
}

.discovery-timed-action-button {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.discovery-timed-action-button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;

  background: rgba(7, 15, 27, 0.7);

  transform: scaleX(0);
  transform-origin: right center;

  pointer-events: none;
}

.discovery-timed-action-button.is-performing-action::before {
  animation:
    discovery-action-drain
    var(--discovery-action-duration, 3000ms)
    linear
    forwards;
}

.discovery-timed-action-button.is-performing-action {
  cursor: wait;
}

@keyframes discovery-action-drain {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}