/* galaxy map overrides (loaded after style.css) */
#map {
  --m-acc: #5fe8dc;
  --m-acc-rgb: 95, 232, 220;
  --m-gold: #ffcf6e;
  --m-fic: #d696ff;
  --m-panel: rgba(5, 14, 22, 0.8);
  --m-frame: rgba(95, 232, 220, 0.34);
  --m-ch: 12px;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(10, 22, 38, 0.55), rgba(0, 0, 0, 0) 70%),
    rgba(1, 3, 8, 0.985);
  font-family: var(--kr);
  animation: map-in 0.32s ease-out both;
}
#map.closing { animation: map-out 0.17s ease-in both; pointer-events: none; }
#map:not(.closing) #map-canvas { animation: map-canvas-in 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes map-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes map-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes map-canvas-in { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }
@keyframes map-slide-l { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes map-slide-r { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes map-slide-u { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* vignette + faint scanline grid over the canvas */
#map::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%),
    repeating-linear-gradient(0deg, rgba(var(--m-acc-rgb), 0.018) 0 1px, transparent 1px 4px);
}

/* ---------- shared chamfered panel: outer layer = frame colour, ::before = panel fill */
#map .map-head, #map-info, #map-legend, #map-stats, #map-keys {
  isolation: isolate;
  background: var(--m-frame);
  clip-path: polygon(var(--m-ch) 0, 100% 0, 100% calc(100% - var(--m-ch)), calc(100% - var(--m-ch)) 100%, 0 100%, 0 var(--m-ch));
  border: 0;
  z-index: 2;
}
#map .map-head::before, #map-info::before, #map-legend::before, #map-stats::before, #map-keys::before {
  content: ''; position: absolute; inset: 1px; z-index: -1;
  background: linear-gradient(180deg, rgba(10, 30, 40, 0.86), var(--m-panel) 60%);
  clip-path: polygon(calc(var(--m-ch) - 0.5px) 0, 100% 0, 100% calc(100% - var(--m-ch) + 0.5px), calc(100% - var(--m-ch) + 0.5px) 100%, 0 100%, 0 calc(var(--m-ch) - 0.5px));
}

/* ---------- header */
#map .map-head {
  left: 28px; top: 22px; padding: 14px 20px 14px 22px; min-width: 380px; max-width: 560px;
  animation: map-slide-l 0.4s 0.05s ease-out both;
}
#map .map-head::after {          /* accent tick on the bevel */
  content: ''; position: absolute; left: 0; top: var(--m-ch); bottom: 18px; width: 2px; background: var(--m-acc); opacity: 0.85;
}
#map .map-head .kicker { color: var(--m-acc); letter-spacing: 0.34em; font-size: 12.5px; }
#map .map-head h2 { font-family: var(--kr); font-size: 30px; font-weight: 500; color: #fff; margin: 4px 0 4px; letter-spacing: -0.01em; text-shadow: 0 0 18px rgba(var(--m-acc-rgb), 0.25); }
#map .map-head p { font-size: 13px; color: rgba(200, 240, 245, 0.7); line-height: 1.5; }
#map .map-tabs { margin-top: 12px; gap: 6px; }
#map .map-tabs button {
  position: relative; font-family: var(--kr); font-size: 13px; font-weight: 500; padding: 8px 18px;
  color: rgba(210, 245, 248, 0.8); background: rgba(var(--m-acc-rgb), 0.05); border: 1px solid rgba(var(--m-acc-rgb), 0.28);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#map .map-tabs button:hover { background: rgba(var(--m-acc-rgb), 0.13); color: #fff; border-color: rgba(var(--m-acc-rgb), 0.6); }
#map .map-tabs button.on { background: linear-gradient(180deg, rgba(var(--m-acc-rgb), 0.3), rgba(var(--m-acc-rgb), 0.12)); color: #fff; border-color: var(--m-acc); box-shadow: inset 0 -2px 0 var(--m-acc); }

/* ---------- info panel */
#map-info {
  right: 28px; top: 22px; width: 350px; padding: 20px 22px 18px; border: 0;
  --m-frame: rgba(95, 232, 220, 0.42);
}
#map-info.pop { animation: map-slide-r 0.28s ease-out both; }
#map-info.fic { --m-frame: rgba(214, 150, 255, 0.5); }
#map-info::after { content: ''; position: absolute; right: 0; top: 0; width: 46px; height: 2px; background: var(--m-acc); }
#map-info.fic::after { background: var(--m-fic); }
#map-info .kicker { color: var(--m-acc); letter-spacing: 0.18em; font-size: 12.5px; text-transform: none; }
#map-info.fic .kicker { color: var(--m-fic); }
#map-info h3 { font-family: var(--kr); font-size: 23px; font-weight: 600; color: #fff; margin: 6px 0 8px; }
#map-info p { font-size: 13px; color: rgba(214, 238, 244, 0.86); line-height: 1.65; }
#map-info dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 14px 0 12px; padding: 12px 0 2px; font-size: 13px; border-top: 1px solid rgba(var(--m-acc-rgb), 0.16); }
#map-info dt { color: rgba(184, 239, 245, 0.62); }
#map-info dd { text-align: right; color: #fff; font-family: var(--lat); font-weight: 600; font-size: 14px; }
#map-info dd.gold { color: var(--m-gold); }
#map-info dd.good { color: #8dffc8; }
#map-info .mi-tag { display: inline-flex; align-items: center; gap: 7px; margin-top: 6px; padding: 3px 9px 3px 8px; font-size: 13px; font-weight: 500; }
#map-info .mi-tag.fic { color: #f1d6ff; background: rgba(214, 150, 255, 0.14); border: 1px solid rgba(214, 150, 255, 0.45); }
#map-info .mi-tag i { width: 8px; height: 8px; background: var(--m-fic); transform: rotate(45deg); }
#map-info .mi-tag.gat { color: #ffe7b0; background: rgba(255, 207, 110, 0.12); border: 1px solid rgba(255, 207, 110, 0.5); }
#map-info .mi-tag.gat i { background: var(--m-gold); border-radius: 50%; transform: none; box-shadow: 0 0 6px var(--m-gold); }
#map-info .mi-tag + .mi-tag { margin-left: 6px; }
#map-info button {
  width: 100%; margin-top: 8px; padding: 10px 16px; font-size: 14px; font-weight: 500;
  color: rgba(220, 248, 250, 0.9); background: rgba(var(--m-acc-rgb), 0.06); border: 1px solid rgba(var(--m-acc-rgb), 0.32);
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  transition: background 0.15s, border-color 0.15s;
}
#map-info button:hover { background: rgba(var(--m-acc-rgb), 0.16); border-color: rgba(var(--m-acc-rgb), 0.7); }
#map-info button.primary { color: #fff; background: linear-gradient(180deg, rgba(var(--m-acc-rgb), 0.34), rgba(var(--m-acc-rgb), 0.16)); border-color: var(--m-acc); }
#map-info button.primary:hover { background: linear-gradient(180deg, rgba(var(--m-acc-rgb), 0.48), rgba(var(--m-acc-rgb), 0.24)); }
#map-info button:disabled { opacity: 0.4; cursor: default; }
#map-info button kbd { margin: 0 0 0 6px; font-size: 12.5px; }
#map-info button + button { margin-top: 6px; }

/* ---------- legend (bottom-left) */
#map-legend {
  left: 28px; bottom: 22px; max-width: min(640px, calc(100vw - 420px)); padding: 11px 18px;
  display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: rgba(200, 240, 245, 0.78);
  animation: map-slide-u 0.4s 0.1s ease-out both;
}
#map-legend .lg { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
#map-legend .lg i { position: relative; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0; flex: none; }
#map-legend .st i { background: #ffd68a; box-shadow: 0 0 6px #ffd68a; }
#map-legend .bh i { background: #ff9a4d; box-shadow: 0 0 6px #ff9a4d; }
#map-legend .ps i { background: #8cc4ff; box-shadow: 0 0 6px #8cc4ff; }
#map-legend .gx i { width: 16px; height: 8px; background: radial-gradient(ellipse, #fff5e0 0, #ffcf8a 30%, rgba(160, 190, 255, 0.5) 60%, transparent 72%); }
#map-legend .civ i { border: 1.5px solid #8dffc8; }
#map-legend .vis i { background: #8dffc8; }
#map-legend .vis i::after { content: ''; position: absolute; left: 2.5px; top: 1.5px; width: 2.5px; height: 4.5px; border: solid #02101a; border-width: 0 1.4px 1.4px 0; transform: rotate(40deg); }
#map-legend .unv i { border: 1.2px solid rgba(220, 240, 255, 0.85); box-shadow: 0 0 0 3px rgba(2, 6, 14, 1), 0 0 0 4px rgba(var(--m-acc-rgb), 0.35); }
#map-legend .trail i { width: 18px; height: 2px; border-radius: 0; background: #ffdc96; box-shadow: 0 0 5px rgba(255, 207, 110, 0.7); }
#map-legend .route i { width: 18px; height: 2px; border-radius: 0; background: repeating-linear-gradient(90deg, var(--m-acc) 0 5px, transparent 5px 8px); }
#map-legend .here i { border: 1.8px solid #8dffc8; }
#map-legend .fic { color: #ecd2ff; }
#map-legend .fic i { width: 8px; height: 8px; border-radius: 0; background: var(--m-fic); transform: rotate(45deg); }
#map-legend .trv i { width: 7px; height: 9px; border-radius: 0; background: var(--m-gold); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); filter: drop-shadow(0 0 4px rgba(255, 190, 90, 0.9)); }
#map-legend .gat i { width: 10px; height: 10px; border: 1.5px solid var(--m-gold); box-shadow: 0 0 8px rgba(255, 196, 90, 0.8); }

/* ---------- stats (bottom-right) */
#map-stats {
  position: absolute; right: 28px; bottom: 22px; width: 260px; padding: 12px 18px 13px;
  --m-frame: rgba(255, 207, 110, 0.36);
  animation: map-slide-u 0.4s 0.14s ease-out both;
}
#map-stats .kicker { color: var(--m-gold); letter-spacing: 0.22em; font-size: 12.5px; }
#map-stats .ms-main { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; font-family: var(--lat); color: rgba(220, 240, 245, 0.75); font-size: 14px; }
#map-stats .ms-main b { font-size: 28px; font-weight: 700; color: #fff; line-height: 1; }
#map-stats .ms-main span { font-family: var(--kr); font-size: 13px; }
#map-stats .ms-main em { margin-left: auto; font-style: normal; font-weight: 700; font-size: 17px; color: var(--m-gold); }
#map-stats .ms-bar { position: relative; height: 4px; margin: 9px 0 8px; background: rgba(255, 207, 110, 0.14); clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%); }
#map-stats .ms-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #d9a443, var(--m-gold)); box-shadow: 0 0 8px rgba(255, 207, 110, 0.7); }
#map-stats .ms-sub { font-size: 13px; color: rgba(200, 236, 242, 0.75); }
#map-stats .ms-sub b { color: #fff; font-family: var(--lat); font-weight: 700; font-size: 15px; }
#map-stats .ms-trv { margin-top: 3px; }
#map-stats .ms-trv b { color: var(--m-gold); }
#map-stats .ms-gather {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; width: 100%; margin-top: 9px; padding: 7px 10px 7px 9px;
  font-family: var(--kr); font-size: 13px; text-align: left; color: rgba(255, 233, 189, 0.85); cursor: pointer;
  background: rgba(255, 207, 110, 0.08); border: 1px solid rgba(255, 207, 110, 0.4);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  transition: background 0.15s, border-color 0.15s;
}
#map-stats .ms-gather::before { content: none; }
#map-stats .ms-gather:hover {background: rgba(255, 207, 110, 0.18); border-color: var(--m-gold); }
#map-stats .ms-gather i { width: 8px; height: 8px; border-radius: 50%; background: var(--m-gold); box-shadow: 0 0 7px var(--m-gold); flex: none; }
#map-stats .ms-gather b { color: #fff; font-weight: 600; }
#map-stats .ms-gather em { margin-left: auto; font-style: normal; color: var(--m-gold); font-family: var(--lat); font-weight: 700; }

/* ---------- key hints (row inside the header) */
#map #map-keys {
  position: static; display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; padding-top: 10px;
  font-size: 13px; color: rgba(200, 236, 242, 0.72);
  background: none; clip-path: none; border-top: 1px solid rgba(var(--m-acc-rgb), 0.14);
}
#map #map-keys::before { content: none; }
#map-keys span { white-space: nowrap; }
#map-keys kbd { font-size: 12.5px; margin-right: 4px; }

#map-canvas { cursor: grab; }
#map-canvas:active { cursor: grabbing; }

@media (max-width: 1180px) {
  #map-legend { max-width: calc(100vw - 340px); }
}
