/* Prevent popup grid/button growth */
.popup-ui {
  box-sizing: border-box;
  overflow: auto;
}

/*──────────────────────────────────────────────────────────────────────────────
  Theme variables
──────────────────────────────────────────────────────────────────────────────*/
:root {
  --bg-color: #ffffff;
  --text-color: #000000;
  --modal-bg: #ffffff;
  --modal-border: #000000;
  --btn-bg-light: #f0f0f0;
  --btn-bg-dark: #2a2a2a;
  --info-color: #555;
  --topbar-btn-bg: #f0f0f0;
  --topbar-btn-text: #000;
}

body.dark {
  --bg-color: #121212;
  --text-color: #eeeeee;
  --modal-bg: #1e1e1e;
  --modal-border: #555;
  --info-color: #eee;
  --topbar-btn-bg: #272727;
  --topbar-btn-text: #ffffff;
}

body {
  margin: 0;
  padding-top: 60px;
  /* height of topBar */
  font-family: sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  /* let modals escape */
  overflow: auto;
}

/*──────────────────────────────────────────────────────────────────────────────
  Specific system ID
──────────────────────────────────────────────────────────────────────────────*/

.modal-input {
  width: 100%;
  padding: 8px;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.system-list {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  padding: 0;
  margin: 0;
}

.system-list li {
  padding: 4px 8px;
  cursor: pointer;
}

.system-list li:hover {
  background: var(--btn-bg-light);
}

#systemList li.used {
  color: red;
}

.system-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98em;
  background: transparent;
  margin-top: 4px;
}

.system-table th,
.system-table td {
  padding: 4px 7px;
  border-bottom: 1px solid #3335;
  text-align: left;
  vertical-align: middle;
}

.system-table th {
  background: #232323;
  color: #ffd700;
  font-size: 1em;
  font-weight: bold;
  letter-spacing: 0.04em;
}

.system-table tr.used {
  background: #8884;
  color: #bbb;
  opacity: 0.65;
}

.system-table tr:hover {
  background: #ffd70033;
  cursor: pointer;
}

.system-table td b {
  font-family: monospace;
}

.system-table td span {
  display: inline-block;
  min-width: 1.2em;
  text-align: center;
}


/*──────────────────────────────────────────────────────────────────────────────
  SVG / hex map
──────────────────────────────────────────────────────────────────────────────*/
svg {
  background: var(--bg-color);
  border: 1px solid #000;
  /* always black */
}

#hexMap {
  width: 95%;
  height: calc(95vh - 60px);
  max-width: 2000px;
  margin: 10px auto;
  display: block;
}

svg text {
  pointer-events: none;
  user-select: none;
}

#hexMap:focus {
  outline: none;
  box-shadow: 0 0 6px rgba(0, 0, 255, 0.4);
}

/*──────────────────────────────────────────────────────────────────────────────
  Hex styling
──────────────────────────────────────────────────────────────────────────────*/
.hex {
  stroke: #000;
  stroke-width: 1;
  cursor: pointer;
}

.hex-overlay {
  font-family: "Segoe UI Symbol", "Noto Emoji";
  font-size: 16px;
  fill: var(--text-color);
  pointer-events: none;
}

.selected {
  fill: #ff0 !important;
  stroke-width: 4;
}

.link-line {
  stroke: blue;
  stroke-width: 2;
  fill: none;
}

/*──────────────────────────────────────────────────────────────────────────────
  Buttons
──────────────────────────────────────────────────────────────────────────────*/
.mode-button,
.primary-button {
  color: var(--text-color);
  /* auto-switches dark/light */
  background-color: var(--btn-bg-light);
  border: none;
  border-radius: 4px;
  padding: 6px 10px;
  margin: 2px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, font-weight 0.1s;

}

body.dark .mode-button,
body.dark .primary-button {
  background-color: var(--btn-bg-dark);
  color: var(--text-color);
  border: #808080;
  border-radius: 1px;
}

/* Active style remains */
.mode-button.active {
  outline: 3px solid var(--text-color);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  font-weight: bold;
}

.primary-button {
  font-size: 1.05em;
  font-weight: bold;
  background-color: #1fa3ff;
  color: #fff;
}

.mode-button:hover,
.primary-button:hover {
  font-weight: bold;
}

.mode-button.active,
.primary-button.active {
  background: #ffe464;
  color: #000;
  outline: 3px solid #ffb800;
  font-weight: bold;
}

body.dark .mode-button.active,
body.dark .primary-button.active {
  background: #cc8c00;
  color: #fff;
  outline: 3px solid #ffd47f;
}

/* make most top-bar buttons white in dark mode, except dropdown toggles */
body.dark #topBar .mode-button:not(.dropdown-toggle) {
  background-color: var(--topbar-btn-bg);
  color: var(--topbar-btn-text);
  border: 1px solid #000;
}


/* ensure dropdown-toggle buttons keep dark styling */
.dropdown-toggle {
  background-color: var(--btn-bg-dark);
  color: var(--text-color);
  border: none;
}

body.dark .dropdown-toggle:hover,
body.dark .dropdown-toggle:focus {
  background-color: #828282;
  font-weight: bold;
  border: #430000;
  /* background-color: var(--btn-bg-light); */
}

/*──────────────────────────────────────────────────────────────────────────────
  Top bar
──────────────────────────────────────────────────────────────────────────────*/
#topBar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 8px 16px;
  background: var(--bg-color);
  border-bottom: 1px solid var(--modal-border);
  z-index: 100;
  box-sizing: border-box;
}

#leftControls,
#rightControls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#rightControls {
  position: absolute;
  right: 100px;
  /* avoid overlap with versionTag */
  top: 8px;
}

#versionTag {
  position: absolute;
  top: 10px;
  right: 15px;
  background: #444;
  color: #fff;
  font-size: 0.85em;
  padding: 4px 10px;
  border-radius: 4px;
  font-family: monospace;
  z-index: 200;
}

/* group styling for hidden rows */
.sub-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sub-controls.hidden {
  display: none;
}

#layoutControls,
#overlayControls {
  margin-top: 4px;
}

/*──────────────────────────────────────────────────────────────────────────────
  Main controls panel
──────────────────────────────────────────────────────────────────────────────*/
#controlsPanel {
  position: fixed;
  top: 70px;
  /* Adjust to align with your top bar */
  left: 0;
  z-index: 100;
  width: 340px;
  /* Adjust width as needed */
  max-width: 95vw;
  background: rgba(255, 255, 255, 0.9);
}

body.dark #controlsPanel {
  background: rgba(18, 18, 18, 0.9);
  border: 1px solid var(--modal-border, #ccc);
  border-radius: 0 12px 12px 0;
  box-shadow: 2px 4px 16px #0002;
  padding: 18px 18px 18px 18px;
  transition: transform 0.3s, opacity 0.3s;
}

/* slide it off to the left and fade out */
#controlsPanel.collapsed {
  transform: translateX(-110%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s, opacity 0.3s;
}

/* Controls Panel Hide/Show Arrow Buttons */
#controlsPanelCloseBtn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  font-size: 1.3em;
  background: transparent;
  border: none;
  color: #00380c;
  cursor: pointer;
  transition: color 0.2s;
}

#controlsPanelCloseBtn:hover {
  color: #222;
  background: #ffe066;
  border-radius: 50%;
}

#controlsPanelOpenBtn {
  display: none;
  position: fixed;
  top: 90px;
  /* Adjust to match controlsPanel vertical position */
  left: 0;
  z-index: 101;
  font-size: 1.3em;
  background: #ffe066;
  border: none;
  border-radius: 0 8px 8px 0;
  padding: 6px 10px;
  box-shadow: 1px 2px 8px #0002;
  color: #444;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#controlsPanelOpenBtn:hover {
  background: #ffd700;
  color: #222;
}

/* Controls panel size variants */
#controlsPanel.size-small {
  width: 220px !important;
  font-size: 0.92em;
}

#controlsPanel.size-medium {
  width: 340px !important;
  font-size: 1em;
}

#controlsPanel.size-large {
  width: 440px !important;
  font-size: 1em;
}

#controlsPanel.size-xlarge {
  width: 600px !important;
  font-size: 1em;
}

/*──────────────────────────────────────────────────────────────────────────────
  Sector-buttons container
──────────────────────────────────────────────────────────────────────────────*/
#sectorControlsContainer {
  position: fixed;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pos-left {
  top: 285px;
  left: 16px;
  flex-direction: column;
  width: 160px;
}

.pos-top {
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  flex-direction: row;
  max-width: calc(160px * 4 + 4px);
}

.pos-right {
  top: 220px;
  right: 16px;
  left: auto;
  flex-direction: column;
  width: 160px;
}

#effectsToggleBtn,
#wormholeToggleBtn {
  display: block;
  width: 160px;
  padding: 6px 10px;
  font-weight: bold;
  text-align: center;
  margin: 2px auto;
}

/*──────────────────────────────────────────────────────────────────────────────
  Color overrides for sector buttons
──────────────────────────────────────────────────────────────────────────────*/
.btn-1 {
  background: #cce5ff;
}

.btn-2 {
  background: #49a1ff;
}

.btn-3 {
  background: #005cbf;
  color: #fff;
}

.btn-legendary {
  background: #b300ff;
  color: #fff;
}

.btn-empty {
  background: #fff;
  color: #2e2e2e;
}

.btn-special {
  background: #ff83a0;
}

.btn-void {
  background: #2b2b2b;
  color: #fff;
}

.btn-supernova {
  background: #ffe5b4;
}

.btn-nebula {
  background: #e6ccff;
}

.btn-asteroid {
  background: #d9d9d9;
}

.btn-rift {
  background: #7b7b7b;
  color: #fff;
}

.btn-homesystem {
  background: #059f00;
  color: #fff;
}

#effectsToggleBtn {
  background-color: var(--btn-bg-light);
  color: var(--text-color);
  /* Use theme text color */
  border: 1px solid var(--modal-border);
  transition: background 0.18s, color 0.18s, font-weight 0.1s;
}

body.dark #effectsToggleBtn {
  background-color: var(--btn-bg-dark);
  color: var(--text-color);
  border: 1px solid var(--modal-border);
}

#effectsToggleBtn:hover {
  font-weight: bold;
}

#effectsToggleBtn.active {
  background-color: #ffe464;
  /* Pick your toggled color */
  color: #000;
  border-color: #ffb800;
  font-weight: bold;
}

body.dark #effectsToggleBtn.active {
  background-color: #cc8c00;
  color: #ffffff;
  border-color: #ffd47f;
}

/*──────────────────────────────────────────────────────────────────────────────
  Lookup-ID button
──────────────────────────────────────────────────────────────────────────────*/
.mode-button.btn-lookup-id {
  background: #b8860b;
  color: #222;
  border: 2px solid #aa8800;
  font-weight: 600;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
  padding: 0.5em 1.1em;
  margin: 0.15em;
  transition: background 0.15s, color 0.15s;
}

body.dark .mode-button.btn-lookup-id {
  background: #e1b23e;
  color: #221a00;
  border-color: #af8900;
}

body.dark .mode-button.btn-lookup-id:hover,
body.dark .mode-button.btn-lookup-id:focus {
  background: #ffd700;
  color: #111;
  border-color: #e2b100;
}

/*──────────────────────────────────────────────────────────────────────────────
  Dropdowns / Popups (Modern dropdown style)
──────────────────────────────────────────────────────────────────────────────*/
.popup-group {
  position: relative;
}

.popup-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  box-shadow: 0 8px 18px #222a;
  border-radius: 10px;
  padding: 10px 0 10px 0;
  z-index: 500;
  animation: popupFadeIn 0.13s;
}

/* Show the panel when parent has .open */
.popup-group.open .popup-panel {
  display: block;
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: translateY(7px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dropdown buttons inside the panel */
.popup-panel .mode-button,
.popup-panel button {
  display: block;
  width: 100%;
  background: none;
  color: var(--text-color);
  border: none;
  text-align: left;
  padding: 8px 18px;
  font-size: 1em;
  cursor: pointer;
  border-radius: 0;
  margin: 0;
  transition: background 0.18s, color 0.18s;
}

.popup-panel .mode-button:hover,
.popup-panel button:hover {
  background: #ffe464;
  color: #222;
  font-weight: bold;
}

body.dark .popup-panel .mode-button:hover,
body.dark .popup-panel button:hover {
  background: #3e2c00;
  color: #ffd47f;
}

/* Add divider support if you want */
.popup-panel .divider {
  height: 1px;
  background: #ddd;
  margin: 7px 0;
}

body.dark .popup-panel .divider {
  background: #555;
}


/*──────────────────────────────────────────────────────────────────────────────
  Wormhole toggle
──────────────────────────────────────────────────────────────────────────────*/
.popup-group {
  position: relative;
}

.popup-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--btn-bg-dark);
  border: 1px solid var(--modal-border);
  padding: 5px;
  z-index: 10;
  resize: both;
  overflow: auto;
  /* required so content scrolls when you shrink it */
  max-width: 90vw;
  /* don’t let them drag you off-screen */
  max-height: 90vh;
}

.popup-group.open .popup-panel {
  display: block;
}

.wormhole-button.active {
  outline: 3px solid var(--text-color);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  font-weight: bold;
}

#wormholeToggleBtn {
  background-color: var(--btn-bg-light);
  color: #000;
  border: 1px solid var(--modal-border);
}

body.dark #wormholeToggleBtn {
  background-color: var(--btn-bg-dark);
  color: #fff;
  border: 1px solid var(--modal-border);
}

/*──────────────────────────────────────────────────────────────────────────────
  Search Filter
──────────────────────────────────────────────────────────────────────────────*/
details {
  margin: 0.5em 0;
}

details[open] .filter-button {
  display: inline-block;
  margin: 0.25em;
}

.filter-button {
  display: inline-block;
  margin: 4px;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: var(--btn-bg-light);
  cursor: pointer;
}

.filter-button.active {
  background: #f5c000;
  border-color: #b38f00;
  color: #000;
}

body.dark .filter-button.active {
  background: #b38f00;
}

#systemLookupModal ul.system-list li {
  font-size: 0.9rem;
  line-height: 2.0;
  padding: 4px 8px;
}

#systemLookupModal {
  width: 600px;
  max-width: 90vw;
}

#systemLookupModal details#lookupFilters {
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
}

#systemLookupModal #uiFiltersContainer {
  max-height: 200px;
  overflow-y: auto;
  width: 100%;
  box-sizing: border-box;
}

/*──────────────────────────────────────────────────────────────────────────────
  Modals
──────────────────────────────────────────────────────────────────────────────*/
.modal {
  display: none;
  position: fixed;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--modal-bg);
  color: var(--text-color);
  padding: 1em;
  border: 1px solid var(--modal-border);
  z-index: 1000;
  max-width: 80%;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  resize: both;
  overflow: auto;
  /* required so content scrolls when you shrink it */
  max-width: 90vw;
  /* don’t let them drag you off-screen */
  max-height: 90vh;
}

.modal textarea {
  width: 100%;
  height: 100px;
  background: var(--modal-bg);
  color: var(--text-color);
  border: 1px solid var(--modal-border);
}

.modal-header.draggable-handle {
  cursor: move;
  background: #222;
  color: #fff;
  padding: 0.1em;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-content {
  box-sizing: border-box;
  border-radius: 8px;
  overflow: auto;
  min-width: 340px;
  min-height: 80px;
}

#controls,
#Info,
#Info2 {
  color: var(--info-color);
}

#calcSlicePopup.modal {
  z-index: 9999;
  position: fixed;
  top: 60px;
  /* or as you like */
  left: 20vw;
}

/*──────────────────────────────────────────────────────────────────────────────
  Wormhole overlays
──────────────────────────────────────────────────────────────────────────────*/
.hex-wormhole-circle {
  stroke: white;
  stroke-width: 1.5;
  pointer-events: none;
}

.hex-wormhole-label {
  fill: white;
  font-size: 12px;
  text-anchor: middle;
  pointer-events: none;
}

.wormhole-button {
  border-radius: 4px;
  padding: 6px 10px;
  margin: 2px;
  cursor: pointer;
  font-weight: bold;
  border: 1px solid #000;
  color: #fff;
}

#wormholeLineLayer,
#wormholeLineLayer line {
  pointer-events: none;
}

/*──────────────────────────────────────────────────────────────────────────────
  ControlsPanel buttons
──────────────────────────────────────────────────────────────────────────────*/
#controlsPanel button {
  background-color: var(--btn-bg-light);
  color: #000;
  border: 1px solid var(--modal-border);
}

body.dark #controlsPanel button {
  background-color: var(--btn-bg-dark);
  color: #fff;
  border: 1px solid var(--modal-border);
}

/*──────────────────────────────────────────────────────────────────────────────
  Re-apply .btn-* colors in dark mode
──────────────────────────────────────────────────────────────────────────────*/
.mode-button.btn-1 {
  background-color: #cce5ff !important;
  border: 1px solid black;
}

.mode-button.btn-2 {
  background-color: #49a1ff !important;
  border: 1px solid black;
}

.mode-button.btn-3 {
  background-color: #005cbf !important;
  color: #fff !important;
  border: 1px solid black;
}

.mode-button.btn-legendary {
  background-color: #b300ff !important;
  color: #fff !important;
  border: 1px solid black;
}

.mode-button.btn-empty {
  background-color: #fae7b5 !important;
  border: 1px solid black;
}

.mode-button.btn-special {
  background-color: #ff83a0 !important;
  border: 1px solid black;
}

.mode-button.btn-void {
  background-color: #2b2b2b !important;
  color: #fff !important;
  border: 1px solid black;
}

.mode-button.btn-supernova {
  background-color: #ffe5b4 !important;
  color: #000;
  border: 1px solid black;
}

.mode-button.btn-nebula {
  background-color: #e6ccff !important;
  color: #000;
  border: 1px solid black;
}

.mode-button.btn-asteroid {
  background-color: #d9d9d9 !important;
  border: 1px solid black;
  color: #000;
}

.mode-button.btn-rift {
  background-color: #7b7b7b !important;
  color: #fff !important;
  border: 1px solid black;
}

.mode-button.btn-homesystem {
  background-color: #059f00 !important;
  color: #fff !important;
  border: 1px solid black;
}



body.dark .mode-button.btn-asteroid,
body.dark .mode-button.btn-nebula,
body.dark .mode-button.btn-supernova,
body.dark .mode-button.btn-1,
body.dark .mode-button.btn-2,
body.dark .mode-button.btn-empty,
body.dark .mode-button.btn-special {
  color: #000 !important;

}

/*──────────────────────────────────────────────────────────────────────────────
  Border Anomalies and other Popup & Buttons
──────────────────────────────────────────────────────────────────────────────*/
.border-anomalies-popup {
  position: absolute;
  background: rgba(32, 32, 32, 0.89);
  /* match .popup-ui */
  /*background: var(--modal-bg);*/
  border: 2px solid #e32b2b;
  border-radius: 10px;
  padding: 12px 14px 12px 10px;
  z-index: 1000;
  min-width: 180px;
  color: var(--text-color);
}

body.dark .border-anomalies-popup {
  background: var(--modal-bg);
  border-color: #e32b2b;
  color: var(--text-color);
}

body.light .border-anomalies-popup {
  background: var(--modal-bg);
  border-color: #c02b2b;
  color: var(--text-color);
}

.popup-close-btn {
  position: absolute;
  top: 2px;
  right: 6px;
  font-size: 20px;
  background: none;
  color: inherit;
  border: none;
  cursor: pointer;
}

.popup-help-btn {
  background: #32c24d;
  color: #fff;
  position: absolute;
  right: 34px;
  top: 6px;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
}

/* For all .mode-button in popup: */
.border-anomalies-popup .mode-button {
  margin: 2px 4px 2px 0;
}

.popup-tool-label {
  margin: 22px 0 10px 2px;
  font-weight: bold;
}

.border-anomalies-popup,
.border-anomalies-popup,
.popup-panel,
.popup-panel * {
  user-select: none;
}



/*──────────────────────────────────────────────────────────────────────────────
Layout butoons and other Popup & Buttons
──────────────────────────────────────────────────────────────────────────────*/

.layout-options-popup {
  position: absolute;
  background: var(--modal-bg);
  border: 2px solid #0097d6;
  border-radius: 10px;
  padding: 12px 14px 12px 10px;
  z-index: 1000;
  min-width: 220px;
  color: var(--text-color);
  box-shadow: 0 8px 22px #222a;
}

.layout-options-popup .popup-header {
  cursor: move;
  background: #1976d2;
  color: #fff;
  padding: 7px 16px;
  font-weight: bold;
  border-radius: 10px 10px 0 0;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.layout-options-popup .popup-close-btn {
  background: none;
  color: #fff;
  border: none;
  font-size: 22px;
  cursor: pointer;
  margin-left: 10px;
}

.layout-options-popup .popup-tool-label {
  margin: 22px 0 10px 2px;
  font-weight: bold;
}

.layout-options-popup .mode-button {
  margin: 2px 4px 2px 0;
  width: 95%;
  display: block;
  text-align: left;
}

.popup-panel.draggable {
  cursor: default;
  /* rest of your styling */
}

.draggable-handle {
  cursor: move;
  padding: 4px 8px;
  font-weight: bold;
  background: var(--btn-bg-dark);
  color: var(--text-color);
  border-bottom: 1px solid #555;
  user-select: none;
}

.popup-section-label {
  font-size: 1em;
  font-weight: 600;
  margin: 12px 0 4px 2px;
}

.popup-btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  justify-content: flex-start;
  margin-top: 8px;
}

.popup-btn-grid .mode-button {
  height: 38px;
  flex: 2 2 50px;
  /* grows, minimum width */
  min-width: 70px;
}

#layoutOptionsPopup {
  left: 50%;
  top: 16%;
  transform: translate(0, 0);
}

/* Wormhole popup grid */
.wormhole-btn-grid {
  display: grid;
  grid-template-columns: repeat(4, 3fr);
  /* 2 columns, adjust as needed */
  gap: 10px 14px;
  padding: 10px 4px;
}

.wormhole-btn-grid .mode-button {
  min-width: 80px;
  max-width: 150px;
  height: 30px;
  font-size: 1em;
  justify-self: stretch;
  text-align: center;
}

/* Effect popup grid */
.effect-btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 2fr);
  /* 2 columns, adjust as needed */
  gap: 10px 14px;
  padding: 10px 4px;
}

.effect-btn-grid .mode-button {
  min-width: 120px;
  max-width: 150px;
  height: 30px;
  font-size: 1em;
  justify-self: stretch;
  text-align: center;
}

/* ---- TI4 Map Editor Hover Info Styles ---- */
.hover-info {
  display: none;
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  background: rgba(30, 30, 40, 0.98);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px #222a;
  padding: 12px 18px;
  font-size: 15px;
  max-width: 370px;
  line-height: 1.4;
  transition: opacity 0.13s;
  opacity: 0.97;
}

.hover-info hr {
  margin: 4px 0 7px 0;
  border: 0;
  border-top: 1px solid #345;
}

.hover-info ul {
  margin: 0 0 4px 12px;
  padding-left: 1em;
}

.hover-info pre {
  font-size: 12px;
  margin: 2px 0 0 0;
  color: #fffc;
  background: transparent;
  border: none;
  box-shadow: none;
}

/*──────────────────────────────────────────────────────────────────────────────
 show small tumbnail
──────────────────────────────────────────────────────────────────────────────*/

.tile-thumb {
  border-radius: 4px;
  box-shadow: 0 1px 2px #0006;
  margin-right: 4px;
  display: inline-block;
  background: #222;
  vertical-align: middle;
}

#tilePreviewPopup {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  display: none;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 10px;
  box-shadow: 0 2px 16px #000b;
  padding: 6px;
}

#tilePreviewPopup img {
  display: block;
  max-width: 190px;
  max-height: 210px;
  object-fit: contain;
  border-radius: 10px;
}


/* --- Add all general wizard CSS here, using class selectors for highlights and popups --- */
.tile-selection-highlight {
  stroke: #ff8000 !important;
  stroke-width: 7 !important;
  filter: drop-shadow(0 0 10px #ff8000);
  fill: rgba(255, 128, 0, 0.15) !important;
}

.tile-paste-ghost {
  stroke: #00bfff !important;
  stroke-width: 7 !important;
  filter: drop-shadow(0 0 12px #00bfff);
  fill: rgba(0, 191, 255, 0.18) !important;
  opacity: 0.5 !important;
}

.tile-paste-ghost-image {
  opacity: 0.5 !important;
  pointer-events: none !important;
}

/* --- Tile Copy/Cut/Paste Wizard Styles --- */

.wizard-btn {
  background: #222;
  color: #fff;
  border: 1px solid #888;
  border-radius: 4px;
  padding: 4px 12px;
  margin: 0 4px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.wizard-btn:hover,
.wizard-btn:focus {
  background: #444;
  color: #ffe066;
  border-color: #ffe066;
}

.wizard-popup {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #232323;
  color: #fff;
  border: 2px solid #ffb800;
  border-radius: 12px;
  z-index: 10010;
  min-width: 320px;
  box-shadow: 0 4px 24px #000a;
  font-size: 1.08em;
  padding: 0;
  user-select: none;
}

.wizard-popup.hidden {
  display: none;
}

.wizard-popup-header {
  background: #333;
  padding: 10px 16px;
  font-weight: bold;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  cursor: move;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wizard-close-btn {
  background: none;
  color: #fff;
  font-size: 22px;
  border: none;
  cursor: pointer;
  margin-left: 10px;
}

.wizard-popup-body {
  padding: 18px 20px 16px 20px;
}

.wizard-controls {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.wizard-warning {
  color: #ffb800;
  font-weight: bold;
  margin-top: 10px;
  min-height: 22px;
}

/* Add styles for wizard info/warning popup to ensure it is visually and functionally distinct */
.wizard-info-content {
  padding: 0;
  min-width: 320px;
  max-width: 480px;
  background: #fffbe6;
  /* border: 2px solid #e6b800; */
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  font-family: inherit;
}

.wizard-info-header {
  background: #ffe066;
  color: #7a5c00;
  font-weight: bold;
  padding: 10px 16px;
  border-bottom: 1px solid #e6b800;
  border-radius: 8px 8px 0 0;
  cursor: move;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wizard-info-message {
  padding: 18px 20px 12px 20px;
  color: #7a5c00;
  font-size: 1.05em;
  line-height: 1.5;
}

.popup-ui-info .popup-ui-close {
  top: 8px;
  right: 8px;
  background: #ffe066;
  color: #7a5c00;
  border: none;
  font-size: 1.3em;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  position: absolute;
  z-index: 2;
  cursor: pointer;
  transition: background 0.2s;
}

.popup-ui-info .popup-ui-close:hover {
  background: #fffbe6;
}

/* Ensure popups always have a background, even if dark mode is not enabled */
.popup-ui,
.popup-ui-info,
.wizard-main-popup {
  background: rgba(32, 32, 32, 0.89);
  color: #f0f0f0;
  border: 2px solid #2196f3;
  box-shadow: 0 0 0 3px #2196f355, 0 4px 24px rgba(0, 0, 0, 0.18);
  border-radius: 16px;
  max-width: 95vw;
  max-height: 90vh;
  overflow: auto;
  position: fixed;
  padding: 0.5em 1.2em;
  pointer-events: auto;
  z-index: 10003;
}

/* Prevent non-modal popups from blocking pointer events outside the popup */
.popup-ui-overlay {
  pointer-events: none !important;
  background: transparent !important;
}

.popup-ui-content,
.wizard-info-content {
  background: transparent;
  color: #f0f0f0;
}

.wizard-info-header,
.modal-header {
  background: rgba(48, 48, 48, 0.85);
  color: #ffe066;
  border-bottom: 1px solid #444;
}

.popup-ui-close {
  background: rgba(48, 48, 48, 0.85);
  color: #ffe066;
}

/* Popup wizard content indentation */
.popup-content,
.wizard-popup-content {
  padding-left: 24px;
  /* Increased from default for better appearance */
}

.popup-ui-title {
  flex: 1;
  font-weight: bold;
  font-size: 1.1em;
  color: #ffe066;
  text-align: left;
  padding-left: 4px;
}

/* Make the controls panel close and open buttons yellow, round, and accessible, with hover/focus states */
#controlsPanelCloseBtn,
#controlsPanelOpenBtn {
  background: #ffe066;
  color: #333;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.5em;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
  cursor: pointer;
  outline: none;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#controlsPanelCloseBtn:hover,
#controlsPanelOpenBtn:hover,
#controlsPanelCloseBtn:focus,
#controlsPanelOpenBtn:focus {
  background: #ffd43b;
  color: #111;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

#controlsPanelCloseBtn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1002;
}

#controlsPanelOpenBtn {
  position: fixed;
  top: 100px;
  left: 0;
  z-index: 1001;
  opacity: 0.95;
}