:root {
  --bg: #101219;
  --panel: #161a24;
  --panel-soft: #1f2634;
  --text: #e6ecff;
  --muted: #9da8c7;
  --border: #2d3852;
  --common: #8b93a8;
  --uncommon: #4cc26f;
  --rare: #4b8cff;
  --legendary: #e6bd4a;
  --corrupted: #ff4d5e;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(circle at top, #1b2030, var(--bg));
  color: var(--text);
}

.caps-app {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  height: 100%;
  padding: 16px;
}

.panel {
  background: linear-gradient(160deg, rgba(255,255,255,0.02), transparent), var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

h1, h2, h3 { margin: 0 0 10px; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1rem; color: var(--muted); font-weight: 600; }

.muted { color: var(--muted); }

.open-pack-btn {
  width: 100%;
  border: 1px solid #3f4f78;
  background: linear-gradient(180deg, #2a3760, #1d2745);
  color: var(--text);
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  margin-bottom: 10px;
}

.open-pack-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.pack-status {
  min-height: 24px;
  margin-bottom: 10px;
  color: #c5d3ff;
}

.reveal-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-height: 124px;
}

.reveal-item,
.cap-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 10px;
}

.cap-card {
  cursor: pointer;
}

.cap-card-title,
.reveal-name {
  font-weight: 650;
  margin-bottom: 5px;
}

.rarity {
  display: inline-block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 7px;
}

.rarity-common { color: var(--common); }
.rarity-uncommon { color: var(--uncommon); }
.rarity-rare { color: var(--rare); }
.rarity-legendary { color: var(--legendary); }
.rarity-corrupted {
  color: var(--corrupted);
  text-shadow: 1px 0 #50d0ff, -1px 0 #ff4d5e;
  animation: glitch 1s infinite steps(2, end);
}

@keyframes glitch {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(1px, -1px); }
  40% { transform: translate(-1px, 1px); }
  60% { transform: translate(1px, 0); }
  80% { transform: translate(-1px, 0); }
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 10px;
  max-height: calc(100vh - 130px);
  overflow: auto;
  padding-right: 4px;
}

.cap-image {
  height: 72px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px dashed #4a587e;
  background: linear-gradient(145deg, #2b3550, #192035);
  display: grid;
  place-items: center;
  color: #9aafd9;
  font-size: 0.7rem;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(4, 6, 12, 0.75);
  padding: 20px;
}

.modal[aria-hidden="false"] { display: grid; }

.modal-card {
  width: min(420px, 100%);
  background: #131b2b;
  border: 1px solid #394765;
  border-radius: 12px;
  padding: 16px;
}

.modal-close {
  margin-top: 12px;
  border: 1px solid #3f4f78;
  background: #1d2745;
  color: var(--text);
  padding: 8px 11px;
  border-radius: 8px;
  cursor: pointer;
}

@media (max-width: 900px) {
  .caps-app {
    grid-template-columns: 1fr;
    grid-auto-rows: auto 1fr;
  }

  .collection-grid {
    max-height: unset;
  }
}
