/* MCOC Helper: the night sky of the other helpers, with Marvel red, star gold and the six class colours. */
:root {
  --bg: #0b0c18;
  --bg-deep: #05060d;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef0ff;
  --muted: #a0a6c8;
  --faint: #6c7299;
  --red: #e23d3d;
  --red-soft: rgba(226, 61, 61, 0.16);
  --gold: #ffd166;
  --good: #7ee0b0;
  --warn: #ffb35c;
  --bad: #ff8a8a;
  --radius: 18px;
  --font-head: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  /* The game's class colours. */
  --Cosmic: #3fd8cf;
  --Mutant: #f5c935;
  --Mystic: #b979f5;
  --Science: #5fd36f;
  --Skill: #f2584a;
  --Tech: #5592fa;
}

* { box-sizing: border-box; }
/* Anything marked hidden stays hidden, whatever display its own style gives it. */
[hidden] { display: none !important; }
html { background: var(--bg-deep); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1100px 560px at 85% -12%, rgba(226, 61, 61, 0.2), transparent 62%),
    radial-gradient(800px 480px at -10% 20%, rgba(80, 110, 255, 0.13), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
.sky {
  position: fixed; inset: 0; pointer-events: none; opacity: 0.5;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 68% 8%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 40% 32%, #ffd9d9, transparent),
    radial-gradient(1px 1px at 88% 44%, #fff, transparent),
    radial-gradient(1px 1px at 22% 66%, #dfe3ff, transparent),
    radial-gradient(1.5px 1.5px at 76% 72%, #fff, transparent),
    radial-gradient(1px 1px at 52% 88%, #cfd6ff, transparent);
  background-size: 520px 520px;
}
.top, main {
  position: relative;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
button, input, select { font: inherit; color: inherit; }

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 28px; padding-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 44px; height: 44px; flex: none; filter: drop-shadow(0 0 14px rgba(226, 61, 61, 0.5)); }
.shield { fill: var(--red); }
.shield-star { fill: var(--gold); }
h1 { margin: 0; font-family: var(--font-head); font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.account {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 6px 6px 6px 14px; max-width: 100%;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--muted); font-size: 0.85rem;
}
.account[hidden] { display: none; }
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account button { flex: none; border: 0; border-radius: 999px; padding: 6px 12px; background: var(--panel-strong); cursor: pointer; }
.account button:hover { background: rgba(255, 255, 255, 0.12); }

/* Sign-in */
.auth-pending main, .auth-pending .gate, .signed-out main { display: none; }
body:not(.signed-out) .gate { display: none; }
.gate { position: relative; display: grid; place-items: center; padding: 8vh 16px 4vh; }
.gate-card {
  width: min(400px, 100%); padding: 34px 28px 26px; text-align: center;
  border: 1px solid var(--line); border-radius: 24px; background: rgba(16, 17, 34, 0.78);
  backdrop-filter: blur(14px); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.gate-mark { width: 52px; height: 52px; filter: drop-shadow(0 0 18px rgba(226, 61, 61, 0.55)); }
.gate-card h2 { margin: 12px 0 6px; font-family: var(--font-head); font-size: 1.4rem; font-weight: 600; }
.gate-text { margin: 0 0 22px; color: var(--muted); font-size: 0.9375rem; line-height: 1.5; }
.gate-btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 11px 20px; border: 0; border-radius: 999px;
  background: #fff; color: #1f2340; font-weight: 600; font-size: 0.95rem; cursor: pointer;
}
.gate-btn svg { width: 18px; height: 18px; }
.gate-btn:disabled { opacity: 0.6; cursor: default; }
.gate-error { min-height: 1.2em; margin: 14px 0 0; color: var(--bad); font-size: 0.875rem; line-height: 1.45; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-strong); font-weight: 600; font-size: 0.875rem; white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.13); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { border-color: transparent; background: linear-gradient(180deg, #ef4a4a, #c62a2a); color: #fff; box-shadow: 0 6px 20px rgba(226, 61, 61, 0.3); }
.btn-primary:hover { background: linear-gradient(180deg, #f75858, #d23131); }
.btn-danger { color: var(--bad); }

/* Summary: one tile per star level you own. */
.summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.summary:empty { display: none; }
.sum {
  display: flex; flex-direction: column; gap: 2px; min-width: 104px; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
}
.sum-stars { color: var(--gold); font-size: 0.8rem; letter-spacing: 0.08em; }
.sum-count { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; }
.sum-label { color: var(--faint); font-size: 0.75rem; }
.sum.total { background: var(--red-soft); border-color: rgba(226, 61, 61, 0.35); }
.sum.total .sum-stars { color: #ffb0b0; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.search {
  flex: 1 1 220px; min-width: 0; padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); outline: none;
}
.search:focus { border-color: rgba(226, 61, 61, 0.55); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); font-size: 0.8rem; color: var(--muted);
}
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.chip[aria-pressed='true'] { color: var(--text); background: color-mix(in srgb, var(--c) 18%, transparent); border-color: color-mix(in srgb, var(--c) 50%, transparent); }
.chip.stars::before { display: none; }
.chip.stars[aria-pressed='true'] { --c: var(--gold); }
.actions { display: flex; gap: 8px; margin-left: auto; }

.status { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }
.status:empty { display: none; }
.status.error { color: var(--bad); }

/* Roster grid */
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; padding-bottom: 56px; }
.tile {
  --c: var(--muted);
  position: relative; display: flex; flex-direction: column; align-items: stretch; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel); cursor: pointer; text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.tile:hover, .tile:focus-visible { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 60%, transparent); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45); outline: none; }
.tile-art {
  position: relative; aspect-ratio: 1; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--c) 35%, transparent), transparent 70%), rgba(0, 0, 0, 0.25);
  border-bottom: 2px solid var(--c);
}
.tile-art img { width: 88%; height: 88%; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5)); }
.tile-rank {
  position: absolute; top: 6px; right: 6px; padding: 2px 7px; border-radius: 8px;
  background: rgba(5, 6, 13, 0.82); font: 700 0.75rem var(--font-head); color: #fff;
}
.tile-sig { position: absolute; bottom: 6px; right: 6px; padding: 2px 6px; border-radius: 8px; background: rgba(5, 6, 13, 0.82); font-size: 0.68rem; color: var(--gold); }
.tile-body { display: flex; flex-direction: column; gap: 2px; padding: 8px 9px 10px; }
.tile-stars { color: var(--gold); font-size: 0.72rem; letter-spacing: 0.04em; line-height: 1; }
.tile-name { font-size: 0.8rem; font-weight: 600; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-class { color: var(--c); font-size: 0.7rem; }

.empty {
  grid-column: 1 / -1; display: grid; place-items: center; gap: 8px; padding: 56px 20px; text-align: center;
  border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--muted);
}
.empty strong { color: var(--text); font-family: var(--font-head); font-size: 1.1rem; }

/* Import */
.import { margin-bottom: 22px; padding: 18px; border: 1px solid rgba(226, 61, 61, 0.35); border-radius: var(--radius); background: rgba(20, 12, 22, 0.7); }
.import[hidden] { display: none; }
.import-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.import-head h2 { margin: 0; font-family: var(--font-head); font-size: 1.15rem; }
.import-sub { margin: 4px 0 0; color: var(--muted); font-size: 0.875rem; }
.import-cost { color: var(--faint); font-size: 0.8rem; }
.import-shots { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.import-shots li { padding: 4px 10px; border-radius: 999px; background: var(--panel); font-size: 0.78rem; color: var(--muted); }
.import-shots li.done { color: var(--good); }
.import-shots li.failed { color: var(--bad); }
.import-shots li.busy::after { content: ' …'; }
.import-rows { display: flex; flex-direction: column; gap: 6px; }
.irow {
  display: grid; grid-template-columns: 44px minmax(160px, 1fr) 84px 84px 90px auto 32px; align-items: center; gap: 8px;
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
}
.irow.unsure { border-color: rgba(255, 179, 92, 0.5); background: rgba(255, 179, 92, 0.07); }
.irow.invalid { border-color: rgba(255, 138, 138, 0.55); background: rgba(255, 138, 138, 0.07); }
.irow img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: rgba(0, 0, 0, 0.3); }
.irow input, .irow select, .field input, .field select {
  width: 100%; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0, 0, 0, 0.3); outline: none;
}
.irow input:focus, .irow select:focus, .field input:focus, .field select:focus { border-color: rgba(226, 61, 61, 0.6); }
select option { background: #15162a; }
.irow-note { color: var(--warn); font-size: 0.75rem; line-height: 1.3; }
.irow.invalid .irow-note { color: var(--bad); }
.irow-x { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--faint); cursor: pointer; font-size: 1.1rem; }
.irow-x:hover { background: var(--panel-strong); color: var(--text); }
.import-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.import-note { margin: 0; color: var(--muted); font-size: 0.85rem; }
.import-buttons { display: flex; gap: 8px; margin-left: auto; }

@media (max-width: 760px) {
  .irow { grid-template-columns: 40px 1fr 32px; grid-template-areas: 'img name x' 'stars stars stars' 'note note note'; }
  .irow img { grid-area: img; width: 40px; height: 40px; }
  .irow .i-name { grid-area: name; }
  .irow .i-x { grid-area: x; }
  .irow .i-nums { grid-area: stars; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .irow .irow-note { grid-area: note; }
  .actions { margin-left: 0; width: 100%; }
  .actions .btn { flex: 1; justify-content: center; }
}
@media (min-width: 761px) { .irow .i-nums { display: contents; } }

/* Editor dialog */
.editor {
  width: min(460px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 22px;
  background: #12132a; color: var(--text); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
.editor::backdrop { background: rgba(3, 4, 10, 0.7); backdrop-filter: blur(4px); }
.editor form { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.editor h2 { margin: 0; font-family: var(--font-head); font-size: 1.2rem; }
.editor-champ { display: flex; align-items: flex-end; gap: 12px; }
.editor-champ img { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; background: rgba(0, 0, 0, 0.3); }
.editor-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.78rem; color: var(--muted); }
.grow { flex: 1; }
.editor-error { min-height: 1em; margin: 0; color: var(--bad); font-size: 0.85rem; }
.editor-error:empty { display: none; }
.editor-buttons { display: flex; align-items: center; gap: 8px; }

@media (prefers-reduced-motion: reduce) { .tile { transition: none; } .tile:hover { transform: none; } }
