/* Admin console layout on top of the pirate theme. */
.admin-grid {
  display: grid; grid-template-columns: 210px 1fr; gap: 14px;
  padding: 14px; max-width: 1240px; margin: 0 auto; width: 100%;
}
.admin-nav { display: flex; flex-direction: column; gap: 8px; align-self: start; }
.admin-tab { text-align: left; }
.admin-tab.active { border-color: var(--gold); color: var(--gold-bright); }
.admin-body { min-height: 70vh; }
.admin-locked { display: grid; place-items: center; padding: 60px 0; }
#admin-login-form { display: flex; flex-direction: column; gap: 10px; }
#admin-login-form input {
  background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 8px;
  color: var(--ink); padding: 12px 14px; font-size: 15px;
}
.admin-note { color: var(--ink-dim); font-size: 13px; line-height: 1.5; margin: 6px 0 14px; }
.admin-note code, .keyword-editor code { background: #0a1020; padding: 1px 5px; border-radius: 4px; color: var(--gold-bright); }
.admin-status { min-height: 22px; margin-top: 12px; font-size: 13px; }
.admin-status.ok { color: #9fd8ae; }
.admin-status.err { color: #ff9a8a; white-space: pre-wrap; }

.deck-section { margin-bottom: 26px; }
.card-table { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.card-row {
  display: grid; grid-template-columns: 1.3fr 56px 0.8fr 1.2fr 1.2fr 0.8fr 1.2fr 1.2fr 30px;
  gap: 6px; align-items: center;
  background: #0d1426; border: 1px solid var(--panel-edge); border-radius: 8px; padding: 7px 8px;
}
.card-row input, .card-row select {
  background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 6px;
  color: var(--ink); padding: 6px 7px; font-size: 12px; width: 100%; font-family: inherit;
}
.card-row .row-del { color: #ff9a8a; cursor: pointer; text-align: center; font-size: 15px; }
.card-head { display: grid; grid-template-columns: 1.3fr 56px 0.8fr 1.2fr 1.2fr 0.8fr 1.2fr 1.2fr 30px;
  gap: 6px; color: var(--ink-dim); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; padding: 0 8px; }

.campaign-component-editor {
  background: rgba(13, 20, 38, .7); border: 1px solid var(--panel-edge);
  border-radius: 10px; padding: 10px; margin-bottom: 12px;
}
.campaign-component-meta {
  display: grid; grid-template-columns: 1.15fr 2fr 110px 130px auto;
  gap: 8px; align-items: end; margin-bottom: 10px;
}

/* Breakout editor for the selected campaign component */
.component-detail {
  background: rgba(13, 20, 38, .7); border: 1px solid var(--gold-dim, var(--panel-edge));
  border-radius: 10px; padding: 12px; margin-bottom: 14px;
}
.component-detail-body {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start;
}
.component-detail-editor { min-width: 0; }
.component-detail-preview { min-width: 0; }
.component-card-preview {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start;
}
.component-card-preview .card { width: 118px; height: 164px; font-size: 11px; cursor: default; }

/* Library toolbar + paged list */
.component-toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px;
}
.component-toolbar #component-search { flex: 1 1 220px; }
.component-toolbar input, .component-toolbar select {
  background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 6px;
  color: var(--ink); font-family: inherit; font-size: 12px; padding: 7px 9px;
}
/* Sortable column-header bar shared by the StarMap Encounters, AI Opponents,
   and Campaign Components list panels (see admin-sort.js). Not a real
   <table> — the rows below are div/button lists, so this is just a strip of
   click-to-sort buttons roughly aligned over their columns. */
.admin-sort-head { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 8px; }
.admin-sort-btn {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--ink-dim); font-family: inherit; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; padding: 5px 9px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; transition: border-color .12s, color .12s;
}
.admin-sort-btn:hover { border-color: var(--panel-edge); color: var(--ink); }
.admin-sort-btn.active { color: var(--gold-bright); border-color: var(--panel-edge); }
.admin-sort-arrow { font-size: 9px; }
@media (max-width: 560px) { .admin-sort-head { gap: 2px; } .admin-sort-btn { padding: 5px 7px; } }

.component-library {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 60vh; overflow-y: auto; padding: 2px;
}
.component-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: #0d1426; border: 1px solid var(--panel-edge); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; transition: border-color .12s, background .12s;
}
.component-row:hover { border-color: var(--gold-dim, #5a6a94); }
.component-row.selected { border-color: var(--gold-bright); background: rgba(40, 32, 12, .5); }
.component-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.component-row-name { font-weight: 600; color: var(--ink); }
.component-row-card { color: var(--gold-bright); font-size: 12px; }
.component-row-faces {
  color: var(--ink-dim); font-size: 11px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 46ch;
}
.component-row-tags { display: flex; gap: 6px; flex: 0 0 auto; }
.component-tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 7px; border-radius: 999px; border: 1px solid var(--panel-edge); color: var(--ink-dim);
}
.component-tag.tag-engine { border-color: #3f6fb0; color: #8fbaf0; }
.component-tag.tag-weapon { border-color: #b05a3f; color: #f0a98f; }
/* Static-effect components: one badge colour for the family, plus the
   magnitude they grant. */
.component-tag.tag-static { border-color: #7a5ab0; color: #c9aef0; }
.component-tag.tag-magnitude { border-color: var(--gold-dim, #7a6a3a); color: var(--gold-bright); }
.component-tag.tag-tier { border-color: #5a7f5a; color: #a8e0a8; }
.component-empty { color: var(--ink-dim); font-size: 12px; padding: 12px; text-align: center; }
.component-pager {
  display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 10px;
}
.component-page-info { color: var(--ink-dim); font-size: 12px; }
@media (max-width: 720px) {
  .component-detail-body { grid-template-columns: minmax(0, 1fr); }
  .component-row-faces { display: none; }
}
.campaign-component-meta label {
  color: var(--ink-dim); display: flex; flex-direction: column; font-size: 10px;
  gap: 4px; letter-spacing: .05em; text-transform: uppercase;
}
.campaign-component-meta input, .campaign-component-meta select {
  background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 6px;
  color: var(--ink); font-family: inherit; font-size: 12px; padding: 6px 7px; width: 100%;
}
.campaign-card-label {
  color: var(--gold-bright); font-size: 11px; font-weight: 700;
  letter-spacing: .06em; margin: 2px 8px 6px; text-transform: uppercase;
}

/* Ship-sprite picker: the select with its live art preview beside it. The
   swatch box is a fixed height so cycling frames (and the taller engine
   plumes) can't make the meta row jump. */
.campaign-component-meta label:has(.sprite-field) { grid-column: span 2; }
.sprite-field { align-items: center; display: flex; gap: 8px; }
.sprite-field select { flex: 1 1 auto; min-width: 0; }
/* Tall enough to hold the whole sprite INCLUDING what it emits at both ends —
   a firing beam or a full-burn plume runs well past the mount, and those are
   the frames worth seeing. Centred rather than mount-anchored so the muzzle
   end and the aft end both stay in view. */
.sprite-swatch {
  align-items: center; background: #070c18; border: 1px solid var(--panel-edge);
  border-radius: 6px; display: flex; flex: 0 0 auto; height: 82px; justify-content: center;
  overflow: visible; position: relative; width: 74px;
}
/* Never scaled, only cropped if something overflows: `pixelated` at a
   fractional scale deletes pixels rather than dimming them. */
.sprite-swatch canvas { flex: 0 0 auto; image-rendering: pixelated; max-width: 100%; }
.sprite-swatch-shot {
  position: absolute;
  left: calc(50% + 14px);
  top: 50%;
  width: 230px;
  height: 3px;
  border-radius: 999px;
  transform: translateY(-50%);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--shot-core, #fff), var(--shot-glow, #73f6ff) 30%, rgba(115,246,255,0));
  box-shadow: 0 0 8px var(--shot-glow, #73f6ff);
  pointer-events: none;
  animation: spriteSwatchShotFly 520ms ease-out forwards;
}
@keyframes spriteSwatchShotFly {
  from { opacity: 1; clip-path: inset(0 100% 0 0); }
  18% { clip-path: inset(0 0 0 0); }
  to { opacity: 0; clip-path: inset(0 0 0 0); }
}
.sprite-swatch-empty {
  color: var(--ink-dim); font-size: 8px; letter-spacing: 0; line-height: 1.2;
  padding: 0 4px; text-align: center; text-transform: none;
}
.component-tag.tag-sprite { background: rgba(122, 163, 217, .22); color: #cfe0f5; }

.kw-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: #0d1426; border: 1px solid var(--panel-edge); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 6px;
}
.kw-row .kw-meta { min-width: 0; }
.kw-row .kw-name { font-weight: 600; }
.kw-row .kw-pattern { color: var(--gold-bright); font-family: monospace; font-size: 12px; }
.kw-row .kw-problem { color: #ff9a8a; font-size: 11px; }
.kw-row .kw-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.keyword-editor {
  border: 1px solid var(--gold); border-radius: 10px; padding: 16px; margin-top: 16px;
  background: #0d1426; display: flex; flex-direction: column; gap: 10px;
}
.keyword-editor label { display: flex; flex-direction: column; gap: 4px; color: var(--ink-dim); font-size: 12px; }
.keyword-editor input, .keyword-editor textarea {
  background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 6px;
  color: var(--ink); padding: 8px 10px; font-family: "Cascadia Code", monospace; font-size: 13px;
}
.kw-test-row { display: flex; gap: 8px; }
.kw-test-row input { flex: 1; }
.kw-test-result {
  background: #060a14; border-radius: 6px; padding: 8px 10px; font-size: 12px;
  color: #9fd8ae; max-height: 160px; overflow: auto; white-space: pre-wrap;
}
.battle-controls, .battle-crew { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.battle-controls label { display: flex; align-items: center; gap: 6px; color: var(--ink-dim); font-size: 13px; }
.battle-controls select, .battle-controls input, .battle-crew select, .battle-history-head input {
  background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 6px;
  color: var(--ink); padding: 8px 10px;
}
.battle-controls input { width: 92px; }
.battle-result {
  border: 1px solid var(--panel-edge); border-radius: 10px; padding: 12px 14px;
  margin-top: 14px; background: #0d1426;
}
.battle-result tr.winner td { color: var(--gold-bright); font-weight: 700; }
#battle-running { color: var(--ink-dim); margin-left: 10px; }
.battle-history-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; }
.battle-history-head input { min-width: 280px; }
.battle-table-wrap { overflow: auto; border: 1px solid var(--panel-edge); border-radius: 8px; background: #081020; }
.battle-history { width: 100%; min-width: 980px; }
.battle-history th { cursor: pointer; user-select: none; white-space: nowrap; }
.battle-history td { white-space: nowrap; }
.battle-history .muted { color: var(--ink-dim); font-size: 12px; }
.battle-history .winner-cell { color: var(--gold-bright); font-weight: 700; }
.battle-detail-overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(3, 6, 14, .72);
  display: grid; place-items: center; padding: 24px;
}
.battle-detail-overlay.hidden { display: none; }
.battle-detail {
  width: min(1040px, 96vw); max-height: 88vh; overflow: auto;
  background: #0b1222; border: 1px solid var(--gold); border-radius: 8px; padding: 18px;
  box-shadow: 0 22px 80px rgba(0,0,0,.55);
}
.battle-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 12px; }
.battle-detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.battle-stat {
  background: #101a30; border: 1px solid var(--panel-edge); border-radius: 8px; padding: 8px 10px;
}
.battle-stat b { display: block; color: var(--gold-bright); font-size: 18px; }
.battle-stat span { color: var(--ink-dim); font-size: 11px; text-transform: uppercase; }
.battle-detail table { width: 100%; margin-top: 10px; }
.battle-detail pre {
  background: #050914; border: 1px solid var(--panel-edge); border-radius: 8px;
  padding: 10px; color: var(--ink); overflow: auto; max-height: 260px; font-size: 12px;
}
.feedback-admin-grid {
  display: grid; grid-template-columns: minmax(420px, 1fr) minmax(320px, .8fr);
  gap: 14px; align-items: start;
}
.feedback-table { min-width: 620px; }
.feedback-row { cursor: pointer; }
.feedback-row.bug-report td {
  background: rgba(201,80,62,.12);
  border-top-color: rgba(201,80,62,.45);
}
.feedback-row:hover td { background: rgba(212,167,72,.08); }
.feedback-row.bug-report:hover td { background: rgba(201,80,62,.18); }
.bug-pill {
  display: inline-block;
  border: 1px solid rgba(255,154,138,.75);
  border-radius: 999px;
  color: #ffb0a2;
  background: rgba(201,80,62,.14);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 1px 6px;
  vertical-align: middle;
}
.feedback-rating { color: var(--gold-bright); letter-spacing: 1px; white-space: nowrap; }
/* Pending StarMap reset-request count on the tab button itself, so it's
   visible without opening the tab. */
#starmap-tab-badge {
  display: inline-block; margin-left: 6px;
  border: 1px solid rgba(255,154,138,.75); border-radius: 999px;
  color: #ffb0a2; background: rgba(201,80,62,.14);
  font-size: 10px; font-weight: 700; padding: 1px 6px; vertical-align: middle;
}
.feedback-detail {
  background: #0d1426; border: 1px solid var(--panel-edge); border-radius: 8px;
  margin-top: 43px; max-height: 68vh; overflow: auto; padding: 12px;
}
.feedback-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.feedback-detail-head .panel-sub { margin: 0; }
.feedback-entry {
  border: 1px solid rgba(42,53,84,.8); border-radius: 8px;
  background: #081020; color: var(--ink); margin-bottom: 10px; padding: 10px 12px;
}
.feedback-entry-head { display: flex; justify-content: space-between; gap: 10px; color: var(--ink-dim); font-size: 12px; }
.feedback-entry-actions { align-items: center; display: flex; gap: 8px; }
.feedback-context { color: var(--ink-dim); font-size: 11px; margin-top: 3px; }
.feedback-entry h4 { color: var(--gold); font-size: 11px; margin: 10px 0 3px; text-transform: uppercase; letter-spacing: .06em; }
.feedback-entry p { white-space: pre-wrap; line-height: 1.45; margin: 0; }
.feedback-screenshot-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 8px; }
.feedback-screenshot-frame { background: #050914; height: min(64vh, 720px); width: 100%; }
.feedback-screenshot-missing { color: var(--ink-dim); font-style: italic; }
.feedback-game-log {
  background: #050914;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.45;
  max-height: 340px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
}
.changelog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.ai-changelog {
  background: #050914;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
  max-height: 68vh;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.deck-set-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.deck-set-bar select, .deck-set-bar input {
  background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 6px;
  color: var(--ink); padding: 7px 9px;
}
.deck-set-bar input[type="file"] {
  max-width: 220px; font-size: 12px;
}
.deck-import-active {
  display: flex; align-items: center; gap: 5px; color: var(--ink-dim); font-size: 12px;
}
.deck-import-active input { accent-color: var(--gold); }
.deck-set-sep { color: var(--panel-edge); }
.deck-set-meta {
  color: var(--ink-dim); font-size: 12px; margin: -2px 0 10px;
}

.site-settings { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.setting-row { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.setting-row textarea {
  width: 100%; background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 6px;
  color: var(--ink); padding: 8px 10px; font-family: inherit; margin-top: 6px;
}
.setting-row select {
  background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 6px;
  color: var(--ink); font: inherit; padding: 8px 10px; margin-top: 6px;
}
.setting-row input[type="checkbox"] { accent-color: var(--gold); width: 17px; height: 17px; }
.setting-row .setting-number {
  width: 76px; background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 6px;
  color: var(--ink); font: inherit; padding: 6px 8px; margin-left: auto;
}
.setting-check-list {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}
.setting-check-list label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
}

.pw-form { display: flex; gap: 10px; flex-wrap: wrap; }
.pw-form input {
  background: #0a1020; border: 1px solid var(--panel-edge); border-radius: 8px;
  color: var(--ink); padding: 10px 12px;
}

@media (max-width: 980px) {
  .admin-grid {
    display: flex;
    flex-direction: column;
    padding: 10px;
  }

  .admin-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .admin-tab {
    min-height: 38px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .admin-body {
    min-height: 0;
  }

  .card-table,
  .card-head {
    min-width: 900px;
  }

  .deck-section {
    overflow-x: auto;
  }

  .battle-history-head,
  .kw-test-row,
  .pw-form {
    align-items: stretch;
    flex-direction: column;
  }

  .battle-history-head input,
  .kw-test-row input {
    min-width: 0;
    width: 100%;
  }

  .feedback-admin-grid { grid-template-columns: 1fr; }
  .feedback-detail { margin-top: 0; }
}

/* ── accounts tab ─────────────────────────── */
.illegal-names { display: flex; flex-wrap: wrap; gap: 8px; }
.illegal-name-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(197, 62, 62, 0.14); border: 1px solid rgba(197, 62, 62, 0.5);
  border-radius: 999px; padding: 2px 6px 2px 12px;
}
.accounts-table td { white-space: nowrap; }

.ship-asset-toolbar { display: flex; gap: 8px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.ship-asset-toolbar input[type="text"],
.ship-asset-toolbar input:not([type]) { min-width: 200px; }
.ship-asset-table td { white-space: nowrap; vertical-align: middle; }
.ship-asset-thumb {
  width: 40px; height: 40px; object-fit: cover; border-radius: 4px;
  image-rendering: pixelated; display: block;
}
.ship-asset-name { min-width: 160px; }
.ship-asset-actions { display: flex; gap: 6px; white-space: nowrap; }

/* AI Opponents library detail form: ship-creation shortcuts. */
.ai-opponent-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.ai-opponent-actions .btn[disabled] { opacity: .45; cursor: not-allowed; }

/* Security panel: admin roster, active sessions, audit trail. */
.admin-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 14px; }
.admin-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; border: 1px solid #1e2b45; border-radius: 6px;
  background: #0a1020; font-size: 13px;
}
.admin-row .deck-set-meta { display: block; margin-top: 2px; }
