:root {
  color-scheme: dark;
  --ink: #14110f;
  --ink-2: #1c1815;
  --panel: #231e1a;
  --line: rgba(224, 177, 90, 0.32);
  --brass: #e0b15a;
  --brass-deep: #8a6424;
  --cream: #f6efe4;
  --cream-dim: #cbbba6;
  --muted: #9a8d7e;
  --card-face: #3b261e;
  --card-face-2: #2a1a15;
  --paper: #f3e6cf;
  --paper-2: #dcc7a6;
  --ink-text: #2a2118;
  --font-ui: "Segoe UI", "Helvetica Neue", sans-serif;
  --font-card: Georgia, "Palatino Linotype", Palatino, serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
}

button, input { font: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  display: flex;
  height: 100%;
  min-height: 0;
}

body.is-locked .app,
.app[hidden] { display: none !important; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(224, 177, 90, 0.14), transparent 55%),
    radial-gradient(700px 520px at 100% 100%, rgba(110, 36, 48, 0.28), transparent 50%),
    var(--ink);
}

body:not(.is-locked) .gate,
.gate[hidden] { display: none !important; }

.gate-panel {
  width: min(100%, 380px);
  padding: 32px 28px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.gate-panel h1 {
  margin: 0 0 12px;
  font-family: var(--font-card);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.gate-copy {
  margin: 0 0 18px;
  color: var(--cream-dim);
}

.gate-panel input {
  width: 100%;
  margin-bottom: 12px;
  padding: 11px 12px;
  color: var(--cream);
  background: #100e0c;
  border: 1px solid rgba(246, 239, 228, 0.16);
  border-radius: 8px;
}

.gate-panel button {
  width: 100%;
  padding: 11px 12px;
  color: #24180c;
  background: var(--brass);
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.gate-error {
  margin: 12px 0 0;
  color: #f0b4b4;
}

.sidebar {
  width: 252px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 18px 16px;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(224, 177, 90, 0.08), transparent 160px),
    var(--panel);
  border-right: 1px solid var(--line);
}

.brand {
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(224, 177, 90, 0.22);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brass);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-card);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.search { position: relative; }

.search input {
  width: 100%;
  padding: 10px 34px 10px 12px;
  color: var(--cream);
  background: #100e0c;
  border: 1px solid rgba(246, 239, 228, 0.14);
  border-radius: 8px;
}

.search input::placeholder { color: var(--muted); }

.clear-search {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
  color: var(--cream-dim);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
}

.filter h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pills, .checks { display: flex; flex-wrap: wrap; gap: 6px; }

.pills button, .sort-btn {
  color: var(--cream);
  background: transparent;
  border: 1px solid rgba(224, 177, 90, 0.35);
  border-radius: 999px;
  padding: 6px 11px;
}

.pills button[aria-pressed="true"], .sort-btn[aria-pressed="true"] {
  color: #24180c;
  background: var(--brass);
  border-color: var(--brass);
}

.cost-pills { flex-wrap: nowrap; }

.cost-pills button {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 0;
  border-radius: 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.checks { display: grid; gap: 2px; }

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
}

.checks input { accent-color: var(--brass); width: 15px; height: 15px; }

.rarity-label.common { color: #ddd4c8; }
.rarity-label.uncommon { color: #8fd0cb; }
.rarity-label.rare { color: #e6c27a; }
.rarity-label.other { color: #e0b7ef; }

.sort-btn { width: 100%; border-radius: 8px; text-align: left; }

.reset {
  margin-top: auto;
  padding: 8px 0 0;
  color: var(--brass);
  background: none;
  border: 0;
  text-align: left;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(224, 177, 90, 0.09), transparent 55%),
    radial-gradient(700px 520px at 100% 100%, rgba(110, 36, 48, 0.2), transparent 50%),
    var(--ink);
}

.grid-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.grid-wrap::-webkit-scrollbar { width: 12px; }
.grid-wrap::-webkit-scrollbar-thumb {
  background: #5c4633;
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
.grid-wrap::-webkit-scrollbar-track { background: transparent; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 196px);
  justify-content: start;
  gap: 18px;
  padding: 22px 22px 32px;
}

.countbar {
  flex: none;
  padding: 8px 22px 14px;
  text-align: right;
  border-top: 1px solid rgba(246, 239, 228, 0.06);
}

.countbar p {
  margin: 0;
  color: var(--cream-dim);
  letter-spacing: 0.04em;
}

.empty {
  grid-column: 1 / -1;
  max-width: 46ch;
  margin: 12px 0;
  color: var(--cream-dim);
  line-height: 1.55;
}

.empty code {
  color: var(--cream);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92em;
}

.shot {
  display: block;
  width: 196px;
  padding: 0;
  overflow: hidden;
  color: var(--cream);
  background: #000;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.shot img {
  display: block;
  width: 100%;
  height: auto;
}

.shot:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.55);
}

.shot-missing {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  aspect-ratio: 2 / 3;
  padding: 16px;
  background: radial-gradient(circle at 50% 40%, #4a342c, #1a1210 72%);
}

.shot-missing span {
  font-family: var(--font-card);
  font-size: 28px;
}

.lightbox {
  display: block;
  width: auto;
  max-width: min(92vw, 680px);
  max-height: min(86vh, 980px);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 6, 5, 0.74);
}

.modal[hidden] { display: none; }

.modal-card { position: relative; }

.modal-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 36px;
  height: 36px;
  color: var(--ink-text);
  background: var(--paper);
  border: 0;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.file-id, .nav-hint {
  margin: 10px 0 0;
  color: var(--cream-dim);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-align: center;
}

.nav-hint { margin-top: 4px; }

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

@media (max-width: 800px) {
  body { height: auto; overflow: auto; }
  .app { display: block; height: auto; }
  .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .main { display: block; }
  .grid-wrap { overflow: visible; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .shot { width: auto; }
}
