:root {
  --bg: #180014;
  --panel: rgba(72, 5, 21, 0.78);
  --panel-strong: rgba(120, 24, 28, 0.88);
  --card: #fff5db;
  --card-border: #28110b;
  --text: #fff7e8;
  --muted: #ffd178;
  --accent: #ffcc2f;
  --green: #8bd53b;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 58, 58, 0.25), transparent 28%),
    radial-gradient(circle at 85% 20%, rgba(255, 190, 60, 0.12), transparent 30%),
    linear-gradient(135deg, #390016 0%, #7c061b 45%, #2b0011 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image:
    radial-gradient(circle, #fff 1px, transparent 1px),
    radial-gradient(circle, #fff 1px, transparent 1px);
  background-size: 46px 46px, 80px 80px;
  background-position: 0 0, 20px 22px;
}

.app {
  position: relative;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 60px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 28px;
  border: 4px solid #1a0907;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 18px 0 rgba(0, 0, 0, 0.28);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.12em;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 4px 5px 0 #000;
}

.subtitle {
  margin-bottom: 0;
  color: #ffe0a1;
  font-size: 16px;
}

.tabs {
  display: flex;
  gap: 10px;
}

.tab {
  cursor: pointer;
  border: 3px solid #100605;
  border-radius: 14px;
  padding: 12px 22px;
  font-weight: 900;
  color: var(--text);
  background: #8d1e20;
  box-shadow: 0 7px 0 #120605;
}

.tab.active {
  background: var(--green);
  color: #111;
}

.view {
  display: none;
  margin-top: 28px;
}

.view.active {
  display: block;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 220px 190px;
  gap: 14px;
  padding: 18px;
  border: 3px solid #160806;
  border-radius: 18px;
  background: rgba(15, 4, 5, 0.52);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

input, select {
  min-height: 44px;
  border: 3px solid #1b0905;
  border-radius: 12px;
  padding: 0 14px;
  font: inherit;
  font-weight: 700;
  color: #2a100a;
  background: #fff3dc;
}

.result-count {
  margin: 20px 4px 12px;
  color: #ffd98a;
  font-weight: 800;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.card-item {
  position: relative;
  min-height: 320px;
  border: 5px solid var(--card-border);
  border-radius: 18px;
  padding: 14px;
  color: #23110c;
  background: var(--card);
  box-shadow: 0 12px 0 var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.card-item:hover {
  transform: translateY(-4px) rotate(-1deg);
  box-shadow: 0 18px 0 var(--shadow);
}

.card-media,
.detail-cover {
  display: grid;
  place-items: center;
  aspect-ratio: 5 / 5;
  width: 100%;
  border: 0;
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  background: #f8ead0;
}

.card-art {
  display: grid;
  place-items: center;
  aspect-ratio: 5 / 5;
  border: 0;
  border-radius: 12px;
  margin-bottom: 12px;
  color: #fff;
  font-weight: 900;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(255, 132, 50, 0.9), rgba(180, 24, 28, 0.92)),
    repeating-linear-gradient(-45deg, transparent, transparent 8px, rgba(255,255,255,.12) 8px, rgba(255,255,255,.12) 12px);
}

.card-item img,
.detail-cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.detail-cover {
  width: min(100%, 240px);
  margin-left: auto;
  margin-right: auto;
}

.card-name {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.05;
  text-transform: uppercase;
}

.card-effect {
  margin: 0 0 12px;
  min-height: 64px;
  color: #4b2419;
  font-weight: 700;
  line-height: 1.35;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 2px solid #1d0805;
  border-radius: 999px;
  padding: 4px 8px;
  background: #ffd35a;
  font-size: 12px;
  font-weight: 900;
}

.badge.deck {
  background: #9ee35a;
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.deck-intro,
.deck-item {
  border: 4px solid #160806;
  border-radius: 20px;
  padding: 20px;
  background: var(--panel-strong);
  box-shadow: 0 12px 0 var(--shadow);
}

.deck-item {
  cursor: pointer;
}

.deck-item h3 {
  margin-bottom: 8px;
  font-size: 26px;
}

.deck-item p {
  color: #ffe0a1;
}

.deck-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  color: var(--accent);
  font-weight: 900;
}

.detail-dialog {
  width: min(760px, calc(100% - 32px));
  border: 5px solid #130705;
  border-radius: 20px;
  padding: 0;
  background: #fff4de;
  color: #210c07;
  box-shadow: 0 22px 0 rgba(0, 0, 0, 0.42);
}

.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border: 3px solid #180805;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 900;
  background: #ffcf36;
}

.detail {
  padding: 28px;
}

.detail h2 {
  padding-right: 44px;
  font-size: 36px;
  text-transform: uppercase;
}

.detail-section {
  margin-top: 18px;
}

.detail-section h3 {
  margin-bottom: 8px;
  color: #841d17;
}

.audio-list {
  display: grid;
  gap: 12px;
}

.audio-item {
  padding: 12px;
  border: 2px solid #2c110b;
  border-radius: 14px;
  background: #ffe9b7;
}

.audio-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
  color: #5c2316;
}

.audio-meta strong {
  font-size: 15px;
}

.audio-meta span {
  font-size: 13px;
}

.audio-item audio {
  width: 100%;
}

.empty {
  padding: 38px;
  border: 3px dashed #ffd36b;
  border-radius: 18px;
  text-align: center;
  color: #ffe0a1;
}

@media (max-width: 780px) {
  .site-header {
    flex-direction: column;
    align-items: stretch;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .audio-meta {
    flex-direction: column;
  }
}
