/* SCTMG Cards — beta embed (beta.html). Plain CSS, no build step. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #0b1220; color: #e2e8f0; font: 13px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: #93c5fd; }
code { background: #111827; border: 1px solid #334155; border-radius: 4px; padding: 0 4px; }

.b-beta { font-size: 10px; font-weight: 800; letter-spacing: .06em; color: #fde68a; background: rgba(220, 38, 38, .85); border-radius: 999px; padding: 2px 8px; vertical-align: middle; }
.b-muted { color: #94a3b8; }
.b-small { font-size: 11px; }
.b-pill { font-size: 11px; background: #1e293b; border: 1px solid #334155; border-radius: 999px; padding: 0 8px; }
.b-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; }
.b-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.b-spacer { flex: 1; }

.b-btn { background: #1f2937; color: #e5e7eb; border: 1px solid #475569; border-radius: 6px; padding: 6px 12px; font-weight: 700; font-size: 12px; cursor: pointer; }
.b-btn:hover { background: #334155; }
.b-btn:disabled { opacity: .45; cursor: not-allowed; }
.b-btn.primary { background: #2563eb; border-color: #3b82f6; color: #fff; }
.b-btn.primary:hover { background: #3b82f6; }
.b-btn.danger { background: #7f1d1d; border-color: #b91c1c; color: #fff; }
.b-btn.sm { padding: 3px 8px; font-size: 11px; }
input[type=text], input[type=search], select { background: #0f172a; color: #e5e7eb; border: 1px solid #334155; border-radius: 6px; padding: 6px 8px; font-size: 12px; }
input:focus, select:focus { outline: none; border-color: #60a5fa; }

/* Install page */
.b-install { max-width: 760px; margin: 40px auto; padding: 24px; background: #111827; border: 1px solid #334155; border-radius: 12px; }
.b-install h1 { margin-top: 0; font-size: 22px; }
.b-install h2 { font-size: 15px; color: #93c5fd; margin-top: 24px; }
.b-install li { margin: 8px 0; }
.b-bookmarklet { display: inline-block; margin-left: 6px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff !important; text-decoration: none; font-weight: 800; padding: 6px 14px; border-radius: 999px; border: 1px solid #60a5fa; cursor: grab; }
.b-flavours { list-style: none; padding-left: 0; margin: 8px 0; }
.b-flavours li { margin: 10px 0; }
.b-flavours .b-bookmarklet { margin-left: 0; }
.b-install h3.b-feature { font-size: 13px; margin: 14px 0 2px; color: #e2e8f0; }
.b-install h3.b-feature + p { margin-top: 2px; }

/* Army import: saved lists (read from the host, memory only) */
.b-saved { margin-bottom: 14px; padding: 8px 10px; background: #0f172a; border: 1px solid #1f2937; border-radius: 8px; }
.b-saved-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.b-saved-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.b-saved-row:hover { background: #111827; }
.b-saved-row code { color: #86efac; letter-spacing: .04em; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-saved-label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; }
.b-saved-label .b-small { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.b-saved-name { color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.b-saved-id { font-size: 10px; opacity: .75; max-width: 25% !important; }
.b-saved-input { flex: 1; min-width: 0; }
.b-saved-err { color: #fca5a5; font-size: 11px; margin: 4px 6px 0; }

/* Front / Back preview toggle */
.b-seg { display: inline-flex; }
.b-seg .b-btn { border-radius: 0; }
.b-seg .b-btn:first-child { border-radius: 6px 0 0 6px; }
.b-seg .b-btn:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.b-seg .b-btn.active { background: #2563eb; border-color: #3b82f6; color: #fff; }
.b-official-preview { display: block; max-width: 100%; max-height: 640px; margin: 10px auto; border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); }
.b-disabled { opacity: .45; pointer-events: none; }

/* App */
.b-app { display: flex; flex-direction: column; height: 100%; }
.b-header { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: #0f172a; border-bottom: 1px solid #1f2937; }
.b-title { font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 15px; }
.b-status { color: #94a3b8; font-size: 12px; }
.b-status.ok { color: #86efac; }
.b-status.err { color: #fca5a5; }
.b-notice { margin: 8px 14px 0; padding: 8px 12px; border-radius: 8px; background: rgba(127, 29, 29, .35); border: 1px solid #b91c1c; color: #fecaca; }
.b-changes { margin: 8px 14px 0; padding: 10px 12px; border-radius: 8px; background: rgba(120, 53, 15, .35); border: 1px solid #b45309; color: #fde68a; }
.b-changes ul { margin: 6px 0; padding-left: 18px; }
.b-main { flex: 1; display: flex; gap: 12px; padding: 12px 14px; min-height: 0; }
.b-content { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.b-tabs { display: flex; gap: 4px; border-bottom: 1px solid #1f2937; margin-bottom: 10px; flex-wrap: wrap; }
.b-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: #94a3b8; padding: 8px 12px; font-weight: 700; cursor: pointer; }
.b-tabs button.active { color: #93c5fd; border-bottom-color: #60a5fa; }
.b-pane { flex: 1; min-height: 0; overflow: auto; }
.b-filters { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; position: sticky; top: 0; background: #0b1220; padding-bottom: 6px; z-index: 2; }
.b-filters input[type=search] { flex: 1; min-width: 160px; }

.b-split { display: flex; gap: 12px; align-items: flex-start; }
.b-list { width: 240px; flex-shrink: 0; display: flex; flex-direction: column; gap: 3px; max-height: calc(100vh - 190px); overflow: auto; }
.b-list button { text-align: left; background: #111827; border: 1px solid #1f2937; color: #e2e8f0; border-radius: 6px; padding: 6px 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 6px; }
.b-list button.active { border-color: #60a5fa; background: rgba(59, 130, 246, .15); }
.b-list .b-tag { font-size: 10px; color: #94a3b8; }
.b-detail { flex: 1; min-width: 0; }
.b-upgrades { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; margin: 8px 0; }
.b-upgrades label { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; cursor: pointer; }
.b-upgrades .cost { color: #93c5fd; font-weight: 700; margin-left: auto; white-space: nowrap; }
.b-preview { background: #0f172a; border: 1px solid #1f2937; border-radius: 8px; padding: 10px; overflow: hidden; }
.b-preview-inner { transform-origin: top left; }

.b-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.b-grid.tall { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.b-grid.wide { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.b-tile { background: #111827; border: 1px solid #1f2937; border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.b-tile img, .b-tile .ph { width: 100%; border-radius: 4px; background: #1e293b; display: block; }
.b-tile .ph { aspect-ratio: 63 / 88; position: relative; display: flex; align-items: center; justify-content: center; }
.b-tile .ph::after { content: ''; width: 22px; height: 22px; border: 2.5px solid rgba(148, 163, 184, .25); border-top-color: #60a5fa; border-radius: 50%; animation: b-spin .75s linear infinite; }
.b-grid.tall .b-tile .ph { aspect-ratio: 70 / 120; }
.b-grid.wide .b-tile .ph { aspect-ratio: 88 / 63; }

@keyframes b-spin { to { transform: rotate(360deg); } }
.b-spin { width: 13px; height: 13px; border: 2px solid rgba(147, 197, 253, .3); border-top-color: #60a5fa; border-radius: 50%; display: inline-block; animation: b-spin .75s linear infinite; flex-shrink: 0; }
.b-render-spinner { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: rgba(30, 58, 138, .45); border: 1px solid #3b82f6; color: #bfdbfe; font-size: 11px; font-weight: 700; white-space: nowrap; }
.b-tile .name { font-weight: 700; font-size: 12px; }
.b-tile .meta { font-size: 11px; color: #94a3b8; }
.b-tile .b-btn { width: 100%; }

.b-army { max-width: 640px; }
.b-army input[type=text] { flex: 1; min-width: 260px; font-family: monospace; text-transform: uppercase; }
.b-checks { border: 0; padding: 0; }
.b-checks label { display: flex; gap: 4px; align-items: center; }

.b-queue { width: 320px; flex-shrink: 0; background: #111827; border: 1px solid #1f2937; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; min-height: 0; }
.b-queue h3 { margin: 0 0 8px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.b-queue-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 4px; min-height: 80px; }
.b-qitem { display: flex; gap: 6px; align-items: center; background: #0b1220; border: 1px solid #1f2937; border-radius: 6px; padding: 4px; }
.b-qitem.changed { border-color: #b45309; }
.b-qitem img { width: 34px; height: 46px; object-fit: contain; background: #1e293b; border-radius: 3px; }
.b-qitem .q-name { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-qitem .q-sub { font-size: 10px; color: #94a3b8; }
.b-qitem .q-qty { display: flex; align-items: center; gap: 2px; }
.b-qitem .q-qty span { min-width: 18px; text-align: center; font-weight: 700; }
.b-print-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; font-size: 11px; color: #94a3b8; }
.b-print-opts label { display: flex; flex-direction: column; gap: 2px; }
.b-print-opts label.b-check { flex-direction: row; align-items: center; gap: 6px; }
.b-print-opts select { width: 100%; }
.b-tile img { cursor: zoom-in; }
.b-thumb-wrap { position: relative; width: 100%; }
.b-flip-btn { position: absolute; top: 6px; right: 6px; z-index: 4; width: 28px; height: 28px; border-radius: 999px; background: rgba(15, 23, 42, .85); border: 1px solid rgba(148, 163, 184, .45); color: #e2e8f0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .55); transition: background .15s, border-color .15s, transform .15s; }
.b-flip-btn:hover { background: rgba(37, 99, 235, .95); border-color: #93c5fd; color: #fff; transform: scale(1.08); }
.b-flip-btn.is-flipped { background: rgba(37, 99, 235, .9); border-color: #60a5fa; color: #fff; }
.b-lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(2, 6, 23, .9); display: flex; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
.b-lightbox img { max-width: 100%; max-height: 100%; box-shadow: 0 10px 40px rgba(0, 0, 0, .8); border-radius: 6px; }
.b-beta.public { background: #1e3a8a; color: #bfdbfe; }
.b-modal { position: fixed; inset: 0; z-index: 120; background: rgba(2, 6, 23, .85); display: flex; align-items: center; justify-content: center; padding: 20px; }
/* Army reference sheet modal */
.b-rs-modal { position: fixed; inset: 0; z-index: 110; background: rgba(2, 6, 23, .9); display: flex; flex-direction: column; align-items: center; padding: 12px; overflow: auto; }
.b-rs-bar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; background: #1e293b; border: 1px solid #475569; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; max-width: 100%; color: #e2e8f0; }
.b-rs-bar2 { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.b-rs-bar select, .b-rs-bar input { background: #0f172a; color: #fff; border: 1px solid #475569; border-radius: 6px; padding: 4px 8px; font-size: 12px; }
.b-modal-box { background: #111827; border: 1px solid #475569; border-radius: 10px; max-width: 520px; width: 100%; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.b-modal-box.danger { border-color: #dc2626; }
.b-modal-box h3 { margin: 0 0 10px; font-size: 16px; }
.b-modal-box p { margin: 0 0 10px; line-height: 1.5; }
.b-modal-box .b-row { justify-content: flex-end; margin-top: 14px; }

@media (max-width: 1000px) {
  .b-main { flex-direction: column; }
  .b-queue { width: 100%; }
  .b-split { flex-direction: column; }
  .b-list { width: 100%; max-height: 220px; }
}
