@layer components {
  .spacewarp-app {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    height: 100dvh;
    min-height: 460px;
    width: 100vw;
    max-width: 100vw;
    overflow: hidden;
    background: #05070c;
    color: #edf3ff;
    font-family: Cambria, Georgia, "Times New Roman", serif;
  }

  .spacewarp-stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: #03050a;
  }

  .spacewarp-canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #03050a;
  }

  .spacewarp-ship-status {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 5;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    pointer-events: auto;
  }

  .spacewarp-ship-slot {
    display: grid;
    width: 66px;
    gap: 3px;
    justify-items: center;
    border: 0;
    background: transparent;
    color: #edf3ff;
    cursor: pointer;
    padding: 0;
    text-align: center;
  }

  .spacewarp-ship-slot:disabled {
    cursor: default;
  }

  .spacewarp-ship-slot-frame {
    position: relative;
    display: grid;
    width: 66px;
    aspect-ratio: 1;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgb(158 184 224 / 38%);
    background: rgb(3 5 10 / 74%);
    box-shadow: 0 10px 26px rgb(0 0 0 / 34%);
  }

  .spacewarp-ship-slot.active .spacewarp-ship-slot-frame {
    border-color: rgb(255 227 107 / 70%);
  }

  .spacewarp-ship-slot-frame img {
    display: block;
    max-width: 82%;
    max-height: 82%;
    object-fit: contain;
  }

  .spacewarp-ship-slot-health {
    position: absolute;
    right: 5px;
    bottom: 12px;
    left: 5px;
    height: 5px;
    overflow: hidden;
    border: 1px solid rgb(3 5 10 / 70%);
    background: rgb(0 0 0 / 58%);
  }

  .spacewarp-ship-slot-shield {
    position: absolute;
    right: 5px;
    bottom: 5px;
    left: 5px;
    height: 5px;
    overflow: hidden;
    border: 1px solid rgb(3 5 10 / 70%);
    background: rgb(0 0 0 / 58%);
  }

  .spacewarp-ship-slot-health span {
    display: block;
    width: calc(var(--ship-health, 1) * 100%);
    height: 100%;
    background: linear-gradient(90deg, #ff4f5f, #ffe36b 48%, #67f08b);
  }

  .spacewarp-ship-slot-shield span {
    display: block;
    width: calc(var(--ship-shield, 0) * 100%);
    height: 100%;
    background: linear-gradient(90deg, #2176ff, #51c8ff 52%, #b9f3ff);
  }

  .spacewarp-ship-slot-health-text {
    position: absolute;
    top: 4px;
    right: 5px;
    border: 1px solid rgb(3 5 10 / 54%);
    background: rgb(3 5 10 / 62%);
    color: #f4f8ff;
    font: 700 0.68rem/1 Cambria, Georgia, "Times New Roman", serif;
    padding: 2px 3px;
  }

  .spacewarp-ship-slot-key {
    min-height: 1em;
    color: #9db0cb;
    font-size: 0.74rem;
    line-height: 1;
  }

  .spacewarp-cargo {
    position: fixed;
    bottom: 10px;
    left: 10px;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(var(--cargo-columns, 4), 42px);
    gap: 6px;
    pointer-events: auto;
  }

  .spacewarp-cargo-slot {
    display: grid;
    width: 42px;
    aspect-ratio: 1;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgb(158 184 224 / 34%);
    background: rgb(3 5 10 / 66%);
    box-shadow: 0 10px 26px rgb(0 0 0 / 28%);
    color: #edf3ff;
    padding: 0;
  }

  .spacewarp-cargo-slot.empty {
    background:
      linear-gradient(135deg, rgb(255 255 255 / 5%), rgb(255 255 255 / 0%)),
      rgb(3 5 10 / 58%);
  }

  .spacewarp-cargo-slot.filled {
    cursor: pointer;
  }

  .spacewarp-cargo-slot img {
    display: block;
    max-width: 78%;
    max-height: 78%;
    object-fit: contain;
  }

  .spacewarp-cargo.full-feedback .spacewarp-cargo-slot {
    animation: spacewarp-cargo-full 0.32s ease-out;
  }

  @keyframes spacewarp-cargo-full {
    0%,
    100% {
      border-color: rgb(158 184 224 / 34%);
      transform: translateX(0);
    }

    18%,
    54% {
      border-color: rgb(255 79 95 / 82%);
      background: rgb(88 13 24 / 78%);
      transform: translateX(-3px);
    }

    36%,
    72% {
      border-color: rgb(255 79 95 / 82%);
      background: rgb(88 13 24 / 78%);
      transform: translateX(3px);
    }
  }

  .spacewarp-interaction-prompt {
    position: fixed;
    z-index: 7;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgb(255 227 107 / 54%);
    background: rgb(3 5 10 / 84%);
    box-shadow: 0 10px 28px rgb(0 0 0 / 34%);
    color: #edf3ff;
    padding: 7px 9px;
    pointer-events: none;
    transform: translate(-50%, 0);
    white-space: nowrap;
  }

  .spacewarp-interaction-prompt.hidden {
    display: none;
  }

  .spacewarp-interaction-prompt kbd {
    display: inline-grid;
    min-width: 28px;
    min-height: 24px;
    place-items: center;
    border: 1px solid rgb(255 227 107 / 64%);
    background: rgb(255 255 255 / 12%);
    color: #ffe36b;
    font: 700 0.8rem/1 Cambria, Georgia, "Times New Roman", serif;
    padding: 2px 6px;
  }

  .spacewarp-interaction-prompt span {
    color: #f4f8ff;
    font-size: 0.9rem;
    font-weight: 700;
  }

  .spacewarp-minimap {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 4;
    width: 286px;
    height: 187px;
    border: 0;
    border-bottom: 1px solid rgb(158 184 224 / 34%);
    border-left: 1px solid rgb(158 184 224 / 34%);
    background: rgb(3 5 10 / 78%);
    pointer-events: none;
  }

  .spacewarp-minimap.hidden {
    display: none;
  }

  .spacewarp-minimap.size-small {
    width: 208px;
    height: 136px;
  }

  .spacewarp-minimap.size-medium {
    width: 286px;
    height: 187px;
  }

  .spacewarp-minimap.size-large {
    width: 338px;
    height: 221px;
  }

  .spacewarp-minimap-canvas {
    display: block;
    width: 100%;
    height: 100%;
  }

  .spacewarp-indicators {
    position: fixed;
    inset: 0;
    z-index: 6;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  .spacewarp-modal {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    background: rgb(3 5 10 / 42%);
  }

  .spacewarp-modal.hidden,
  .spacewarp-panel-page.hidden {
    display: none;
  }

  .spacewarp-modal-shell {
    display: grid;
    width: min(780px, calc(100vw - 32px));
    height: min(680px, calc(100dvh - 32px));
    max-height: min(680px, calc(100dvh - 32px));
    border: 1px solid rgb(158 184 224 / 38%);
    background: rgb(7 12 22 / 94%);
    box-shadow: 0 24px 70px rgb(0 0 0 / 46%);
    color: #edf3ff;
  }

  .spacewarp-panel-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .spacewarp-interaction-shell {
    align-content: start;
    width: min(460px, calc(100vw - 32px));
    height: auto;
    min-height: 0;
    gap: 14px;
    padding: 16px;
  }

  .spacewarp-interaction-menu-header {
    display: grid;
    gap: 5px;
  }

  .spacewarp-interaction-menu-header strong {
    color: #f4f8ff;
    font-size: 1.1rem;
  }

  .spacewarp-interaction-menu-header span {
    color: #9db0cb;
    line-height: 1.35;
  }

  .spacewarp-interaction-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .spacewarp-help-list dd {
    color: #9db0cb;
  }

  .spacewarp-panel-tabs button,
  .spacewarp-map-toolbar button,
  .spacewarp-interaction-actions button {
    border: 1px solid rgb(158 184 224 / 30%);
    background: rgb(7 12 22 / 74%);
    color: #edf3ff;
    cursor: pointer;
    padding: 7px 9px;
  }

  .spacewarp-panel-tabs button:hover,
  .spacewarp-panel-tabs button.active,
  .spacewarp-map-toolbar button:hover,
  .spacewarp-map-toolbar button.active,
  .spacewarp-interaction-actions button:hover {
    background: rgb(255 255 255 / 13%);
  }

  .spacewarp-map-toolbar button.active {
    border-color: rgb(255 227 107 / 62%);
    color: #ffe36b;
  }

  .spacewarp-panel-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid rgb(158 184 224 / 18%);
    padding: 10px 14px;
  }

  .spacewarp-panel-page {
    min-height: 0;
    overflow: auto;
    padding: 14px;
  }

  .spacewarp-setting {
    display: grid;
    max-width: 260px;
    gap: 7px;
  }

  .spacewarp-settings-grid {
    display: grid;
    max-width: 320px;
    gap: 14px;
  }

  .spacewarp-setting-check {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .spacewarp-setting span,
  .spacewarp-help-list dt {
    color: #f4f8ff;
    font-weight: 700;
  }

  .spacewarp-setting input,
  .spacewarp-setting select {
    border: 1px solid rgb(158 184 224 / 36%);
    background: rgb(3 5 10 / 72%);
    color: #edf3ff;
    padding: 8px 9px;
  }

  .spacewarp-setting input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #ffe36b;
    padding: 0;
  }

  .spacewarp-map-page {
    display: grid;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    padding: 0;
    overflow: hidden;
  }

  .spacewarp-map-frame {
    position: relative;
    min-height: 0;
    height: 100%;
  }

  .spacewarp-map-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    max-width: calc(100% - 20px);
    pointer-events: none;
  }

  .spacewarp-map-toolbar span {
    border: 1px solid rgb(158 184 224 / 24%);
    background: rgb(7 12 22 / 74%);
    color: #9db0cb;
    font-size: 0.92rem;
    padding: 7px 9px;
    white-space: nowrap;
  }

  .spacewarp-map-toolbar button,
  .spacewarp-map-toolbar span {
    pointer-events: auto;
  }

  .spacewarp-map {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 1px solid rgb(158 184 224 / 26%);
    background: #03050a;
    cursor: grab;
    touch-action: none;
  }

  .spacewarp-map:active {
    cursor: grabbing;
  }

  .spacewarp-cheat-grid {
    display: grid;
    gap: 18px;
    padding: 14px;
  }

  .spacewarp-cheats-page {
    padding: 0;
  }

  .spacewarp-debug-page {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 0;
    padding: 0;
  }

  .spacewarp-debug-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid rgb(158 184 224 / 24%);
    background: rgb(3 5 10 / 82%);
  }

  .spacewarp-debug-actions button {
    border: 1px solid rgb(158 184 224 / 30%);
    background: rgb(7 12 22 / 74%);
    color: #edf3ff;
    cursor: pointer;
    padding: 7px 9px;
  }

  .spacewarp-debug-actions button:hover,
  .spacewarp-debug-actions button.active {
    background: rgb(255 255 255 / 13%);
  }

  .spacewarp-debug-output-grid {
    display: grid;
    min-height: 0;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    overflow: auto;
    padding: 14px;
  }

  .spacewarp-debug-output {
    display: grid;
    min-height: 220px;
    grid-template-rows: auto 1fr;
    border: 1px solid rgb(158 184 224 / 24%);
    background: rgb(3 5 10 / 54%);
  }

  .spacewarp-debug-output h3 {
    margin: 0;
    border-bottom: 1px solid rgb(158 184 224 / 20%);
    color: #f4f8ff;
    font-size: 0.92rem;
    padding: 9px 11px;
  }

  .spacewarp-debug-readout {
    overflow: auto;
    margin: 0;
    background: rgb(2 4 8 / 90%);
    color: #b9c7dc;
    font: 0.78rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
    padding: 10px 14px;
    white-space: pre-wrap;
  }

  .spacewarp-cheat-details {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    gap: 8px;
    margin: 0;
    border: 1px solid rgb(158 184 224 / 24%);
    border-top: 0;
    border-right: 0;
    border-left: 0;
    background: rgb(7 12 22);
    padding: 10px 14px;
  }

  .spacewarp-cheat-details strong {
    color: #f4f8ff;
  }

  .spacewarp-cheat-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .spacewarp-cheat-tags span {
    border: 1px solid rgb(158 184 224 / 24%);
    background: rgb(255 255 255 / 7%);
    color: #d7e2f3;
    padding: 4px 6px;
  }

  .spacewarp-cheat-category {
    display: grid;
    gap: 8px;
  }

  .spacewarp-cheat-category h3 {
    margin: 0;
    color: #f4f8ff;
    font-size: 1rem;
  }

  .spacewarp-cheat-ship-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 10px;
  }

  .spacewarp-cheat-ship {
    display: grid;
    min-height: 118px;
    grid-template-rows: minmax(58px, 1fr) auto;
    gap: 8px;
    align-items: center;
    justify-items: center;
    border: 1px solid rgb(158 184 224 / 28%);
    background: rgb(3 5 10 / 48%);
    color: #edf3ff;
    cursor: pointer;
    padding: 10px;
    text-align: center;
  }

  .spacewarp-cheat-ship:hover,
  .spacewarp-cheat-ship.active {
    border-color: rgb(255 227 107 / 58%);
    background: rgb(255 255 255 / 10%);
  }

  .spacewarp-cheat-ship img {
    display: block;
    max-width: 76px;
    max-height: 58px;
    object-fit: contain;
  }

  .spacewarp-cheat-ship span {
    font-weight: 700;
  }

  .spacewarp-cheat-ship-label {
    display: grid;
    justify-items: center;
    gap: 2px;
    max-width: 100%;
    min-width: 0;
    line-height: 1.15;
  }

  .spacewarp-cheat-ship-label span,
  .spacewarp-cheat-ship-label small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .spacewarp-cheat-ship-label small {
    color: #9db0cb;
    font-size: 0.76rem;
    font-weight: 400;
  }

  .spacewarp-help-list {
    display: grid;
    gap: 8px;
    margin: 0;
  }

  .spacewarp-help-list div {
    display: grid;
    grid-template-columns: minmax(90px, auto) minmax(0, 1fr);
    gap: 12px;
  }

  .spacewarp-help-list dt,
  .spacewarp-help-list dd {
    margin: 0;
  }

  .spacewarp-load {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 2;
    border: 1px solid rgb(158 184 224 / 28%);
    background: rgb(7 12 22 / 78%);
    color: #cfdaec;
    padding: 8px 10px;
  }

  .spacewarp-load.hidden {
    display: none;
  }
}
