/* Editable playground surfaces. The original SVG remains on ::after. */
:root {
  --selection-surface-inset-x: 6px;
  --selection-surface-inset-y: 6px;

  --bubble-surface-color: var(--game-ui-button-bg);
  --bubble-surface-inset-x: 3px;
  --bubble-surface-inset-y: 3px;
}

/* Remove the full-box fill so only the inset surface supplies the background. */
:root[data-environment-mode] :is(.selection-summary, .object-bubble-button) {
  background: transparent;
}

:is(.selection-summary, .object-bubble-button)::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  pointer-events: none;
  z-index: -1;
}

.selection-summary::before {
  width: var(--selection-surface-width, calc(100% - 2 * var(--selection-surface-inset-x)));
  height: var(--selection-surface-height, calc(100% - 2 * var(--selection-surface-inset-y)));
}

.object-bubble-button::before {
  width: var(--bubble-surface-width, calc(100% - 2 * var(--bubble-surface-inset-x)));
  height: var(--bubble-surface-height, calc(100% - 2 * var(--bubble-surface-inset-y)));
  background: var(--bubble-surface-color);
}

/* The whole summary handles theme inversion, including this sharp surface. */
#selectionSummary::before {
  background: rgb(255 255 255 / 25%);
  filter: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Independent geometry for scanner bubbles and selection-summary bubbles. */
.object-detail-bubble {
  --detail-background: var(--object-bubble-background, #fff);
  --detail-surface-inset-x: var(--object-bubble-surface-inset-x, 3px);
  --detail-surface-inset-y: var(--object-bubble-surface-inset-y, 3px);
  --detail-width: var(--object-bubble-width, 16vh);
  --detail-height: var(--object-bubble-height, auto);
  --detail-padding: var(--object-bubble-padding, 8px);
  --detail-gap: var(--object-bubble-gap, 0.6vh);
  --detail-frame-size: var(--object-bubble-frame-size, 8px);
  --detail-frame-slice: var(--object-bubble-frame-slice, 8);
  --detail-frame-image: var(--object-bubble-frame-image, url("./rss/svg/9slice-box_button1.svg?release=1ab06ec4ffb09b19942a9b7c"));
  --detail-button-height: var(--object-bubble-button-height, 3vh);
  --detail-button-color: var(--object-bubble-button-color, #f0f0f0);
  --detail-button-hover: var(--object-bubble-button-hover, #e2e2e2);
  --detail-button-text: var(--object-bubble-button-text, #000);
}

.object-detail-bubble.ship-detail-bubble {
  --detail-width: var(--object-bubble-width, min(23vh, calc(100% - 2vh)));
}


:root[data-environment-mode] .object-detail-bubble {
  isolation: isolate;
  box-sizing: border-box;
  width: var(--detail-width);
  height: var(--detail-height);
  /* Both the surface and content use the same inset values. Padding is the
     additional breathing room INSIDE the surface, not outside its boundary. */
  padding: calc(var(--detail-surface-inset-y) + var(--detail-padding))
    calc(var(--detail-surface-inset-x) + var(--detail-padding));
  gap: var(--detail-gap);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.object-detail-bubble::before {
  content: "";
  position: absolute;
  inset: var(--detail-surface-inset-y) var(--detail-surface-inset-x);
  box-sizing: border-box;
  background: var(--detail-background);
  filter: none;
  backdrop-filter: none;
  pointer-events: none;
  z-index: -1;
}

.object-detail-bubble::after {
  content: "";
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  border: var(--detail-frame-size) solid transparent;
  border-image-source: var(--detail-frame-image);
  border-image-slice: var(--detail-frame-slice);
  border-image-width: var(--detail-frame-size);
  border-image-repeat: stretch;
  pointer-events: none;
  z-index: -1;
}

/* One solid surface per action. No inset fill or SVG on these inner buttons. */
:root[data-environment-mode] .object-detail-bubble .object-bubble-button {
  height: var(--detail-button-height);
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: var(--detail-button-color);
  color: var(--detail-button-text);
  box-shadow: none;
}

.object-detail-bubble .object-bubble-button::before,
.object-detail-bubble .object-bubble-button::after {
  content: none;
}

:root[data-environment-mode] .object-detail-bubble .object-bubble-button:hover {
  background: var(--detail-button-hover);
}

/* Main location readout with a scalable SVG decoration. */
:root[data-environment-mode] .readout {
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  color: #000;
  text-shadow: none;
  /* Keep the text box separate; the decoration lives outside its left edge.
     Reserve screen space so the decoration stays inside the viewport. */
  --readout-deco-width: 1.8vh;
  --readout-deco-height: 2.4vh;
  left: calc(2.2vh + var(--readout-deco-width) + var(--readout-deco-gap, 6px));
  padding: 0;
}

.readout::before,
.readout::after {
  content: none;
}

/* The SVG viewBox fits the decoration box at every viewport height. */
.readout > .readout-deco {
  position: absolute;
  top: 0;
  right: calc(100% + var(--readout-deco-gap, 6px));
  display: block;
  width: var(--readout-deco-width);
  height: var(--readout-deco-height);
  margin: 0;
  object-fit: contain;
  object-position: left top;
  pointer-events: none;
}

.readout > .readout-row {
  min-width: 0;
}

/* Paint the translucent stroke behind the solid foreground text.
   The HUD's existing filter inverts both layers together in dark mode. */
:root[data-environment-mode] .readout-location {
  position: relative;
  isolation: isolate;
  padding: 0;
  margin: 0;
}

:root[data-environment-mode] .readout-location::before {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  z-index: -1;
  box-sizing: border-box;
  padding: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: inherit;
  color: rgba(255, 255, 255, 0.25);
  -webkit-text-stroke: 2px rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

/* Anchored to the summary's lower-right corner; DOM/focus order starts at cam. */
.selection-actions {
  position: absolute;
  top: calc(100% + var(--selection-actions-offset, 6px));
  right: 0;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: var(--selection-actions-gap, 6px);
  width: max-content;
  cursor: default;
}

:root[data-environment-mode] .selection-actions .selection-action {
  display: grid;
  place-items: center;
  flex: 0 0 var(--selection-action-size, 3vh);
  width: var(--selection-action-size, 3vh);
  height: var(--selection-action-size, 3vh);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

:root[data-environment-mode] .selection-actions .selection-action[hidden] {
  display: none;
}

.selection-action > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.selection-actions .selection-action:disabled {
  opacity: 0.35;
  cursor: default;
}

.selection-actions .selection-action:focus-visible {
  outline: 2px solid var(--game-ui-button-color);
  outline-offset: 2px;
}

.bottom-nav-stack {
  gap: 0;
}

/* The general-settings shell uses the actual fitting + shared panel classes.
   Its width/height/padding are owned by those common rules, not copied values. */
.settings-screen.game-popup-backdrop {
  z-index: 171;
  background: var(--backdrop-bg);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
}

.settings-dialog {
  gap: 16px;
}

.settings-dialog .settings-workspace__header {
  flex-shrink: 0;
  justify-content: space-between;
  padding: 1vh 1.2vh 1vh 1.6vh;
}

.settings-dialog .settings-overview-title {
  font-size: 2.4vh;
  font-weight: normal;
}

.settings-screen .settings-dialog button.object-list-close {
  flex-shrink: 0;
  width: 4vh;
  height: 4vh;
  padding: 0;
  border: 0;
  background: transparent;
}

.settings-dialog .settings-workspace__layout {
  flex: 1;
  min-height: 0;
  gap: 16px;
  margin-inline: 12px;
}

/* Compact settings rows; the content and tab strip scroll independently. */
.settings-dialog :is(.settings-language-row, .world-setting,
  .key-binding-row, .settings-resource-actions) {
  grid-template-columns: minmax(0, 1fr);
}

.settings-dialog :is(.settings-menu, .settings-resource-actions) {
  max-width: none;
}





.settings-dialog .key-binding-row {
  min-height: 0;
  padding-block: 8px;
  gap: 6px;
}

.settings-dialog .settings-content {
  padding-right: 4px;
}

.settings-screen .settings-dialog button.key-binding-button {
  width: 100%;
}

.settings-dialog .settings-workspace__footer {
  flex-shrink: 0;
  margin: 0 12px 8px;
}

.settings-dialog .settings-workspace__footer:has(> button[hidden]) {
  display: none;
}

#communicationTests {
  z-index: 171;
}

#communicationLogs {
  z-index: 172;
}

.settings-navigation {
  display: flex;
  min-width: 0;
  border-bottom: 1px solid var(--preflight-line-strong);
}
.settings-dialog .settings-menu {
  display: flex;
  min-width: 0;
  width: 100%;
  gap: 0;
  overflow: hidden;
}
.settings-dialog .settings-tab-slot {
  flex: 0 0 auto;
  height: auto;
  min-width: max-content;
  border-bottom: 4px solid transparent;
}
.settings-dialog .settings-tab-slot:has(.active) {
  border-bottom-color: var(--preflight-text);
}
.settings-dialog .settings-tab-button {
  box-sizing: border-box;
  width: auto;
  height: auto;
  padding: 12px 20px;
  border: 0;
  border-image: none;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
  opacity: 0.3;
}
.settings-dialog .settings-tab-button.active { opacity: 1; }
.settings-dialog .settings-tab-button:active { border: 0; }
.settings-tab-overflow {
  display: flex;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  touch-action: pan-x;
}
.settings-dialog .key-binding-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.world-setting-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.settings-dialog .rail-choice-control {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  grid-template-columns: none;
  gap: 6px;
}
.settings-screen .settings-dialog button.rail-choice-option { padding-inline: 4px; }
.settings-screen .settings-dialog button.settings-toggle {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 24px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #b8b8b8;
  transition: background 180ms ease;
}
.settings-screen .settings-dialog button.settings-toggle[aria-checked="true"] { background: #000; }
.settings-toggle > span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 180ms ease;
}
.settings-toggle[aria-checked="true"] > span { transform: translateX(20px); }
.settings-screen .settings-dialog button.settings-toggle:active { clip-path: none; }
.settings-dialog .rail-choice-option:disabled { opacity: 0.3; cursor: default; }
@media (prefers-reduced-motion: reduce) {
  .settings-toggle, .settings-toggle > span { transition: none !important; }
}
