:root {
  --spell-surface: #f7f3e7;
  --spell-surface-deep: #eee6d4;
  --spell-border: #c8b993;
  --spell-ink: #271f19;
  --spell-muted: #6b5f54;
  --spell-wine: #6f181b;
  --spell-gold: #b89a55;
  --spell-shadow: 0 16px 44px rgba(9, 8, 7, 0.22);
}

html {
  scroll-behavior: smooth;
}

.spells-shell {
  min-height: 100vh;
  color: #eee8dd;
  background:
    radial-gradient(circle at 18% 0%, rgba(111, 24, 27, 0.24), transparent 38rem),
    linear-gradient(180deg, #211d1a 0%, #302922 32rem, #211d1a 100%);
}

.spells-shell .site-bar {
  flex-wrap: wrap;
}

.spells-shell .site-bar a[aria-current="page"] {
  color: #fff2bd;
  text-decoration: none;
}

.spells-main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 52px 0 80px;
}

.spells-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  padding: 28px 0 36px;
}

.spells-hero .kicker {
  color: #d6bd7f;
  font-family: Arial, sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
}

.spells-hero h1 {
  max-width: 820px;
  color: #fff9ed;
  font-size: clamp(2.7rem, 7vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: -0.035em;
}

.spells-hero .lead {
  max-width: 760px;
  margin: 20px 0 0;
  color: #d8cfc1;
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.55;
}

.spell-count-mark {
  min-width: 126px;
  padding: 18px 16px;
  text-align: center;
  background: rgba(247, 243, 231, 0.08);
  border: 1px solid rgba(216, 191, 128, 0.42);
}

.spell-count-mark strong,
.spell-count-mark span {
  display: block;
}

.spell-count-mark strong {
  color: #efd99a;
  font-size: 2.2rem;
  line-height: 1;
}

.spell-count-mark span {
  margin-top: 5px;
  color: #cfc4b4;
  font-family: Arial, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spell-primer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 22px;
  overflow: hidden;
  color: var(--spell-ink);
  background: var(--spell-border);
  border: 1px solid var(--spell-border);
  box-shadow: var(--spell-shadow);
}

.spell-primer > div {
  padding: 19px 20px;
  background: var(--spell-surface);
}

.spell-primer strong {
  display: block;
  margin-bottom: 5px;
  color: var(--spell-wine);
  font-family: Arial, sans-serif;
  font-size: 0.73rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.spell-primer p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.spell-primer a {
  font-weight: 700;
}

.spell-tools {
  position: sticky;
  top: 50px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(210px, 0.42fr) auto;
  gap: 10px;
  align-items: end;
  margin: 0 0 22px;
  padding: 12px;
  color: var(--spell-ink);
  background: rgba(247, 243, 231, 0.97);
  border: 1px solid var(--spell-border);
  box-shadow: 0 10px 28px rgba(9, 8, 7, 0.2);
  backdrop-filter: blur(10px);
}

.spell-tools label > span {
  display: block;
  margin: 0 0 5px;
  color: var(--spell-muted);
  font-family: Arial, sans-serif;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.spell-tools input,
.spell-tools select,
.spell-tools button {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--spell-ink);
  background: #fffdf8;
  border: 1px solid #bcae8a;
  border-radius: 0;
  font: inherit;
}

.spell-tools button {
  width: auto;
  color: #fff8e7;
  background: var(--spell-wine);
  border-color: var(--spell-wine);
  cursor: pointer;
}

.spell-tools button:disabled {
  cursor: default;
  opacity: 0.45;
}

.spell-results {
  grid-column: 1 / -1;
  min-height: 1em;
  margin: -1px 2px 0;
  color: var(--spell-muted);
  font-family: Arial, sans-serif;
  font-size: 0.72rem;
}

.spell-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.spell-card {
  position: relative;
  scroll-margin-top: 154px;
  color: var(--spell-ink);
  background: var(--spell-surface);
  border: 1px solid var(--spell-border);
  box-shadow: var(--spell-shadow);
}

.spell-card:target {
  outline: 4px solid #d9b95f;
  outline-offset: 3px;
}

.spell-card[hidden] {
  display: none;
}

.spell-card__header {
  padding: 18px 54px 15px 19px;
  background: linear-gradient(130deg, #f9f5eb, #eee4cf);
  border-bottom: 1px solid var(--spell-border);
}

.spell-card__lore {
  margin: 0 0 5px;
  color: var(--spell-wine);
  font-family: Arial, sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spell-card h2 {
  color: #211913;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  line-height: 1.05;
}

.spell-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}

.spell-card__meta span {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  color: #51463c;
  background: rgba(184, 154, 85, 0.15);
  border: 1px solid rgba(146, 116, 52, 0.35);
  font-family: Arial, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
}

.spell-anchor {
  position: absolute;
  top: 14px;
  right: 13px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--spell-wine);
  text-decoration: none;
  background: rgba(255, 253, 248, 0.65);
  border: 1px solid rgba(111, 24, 27, 0.24);
  font-family: Arial, sans-serif;
  font-weight: 700;
}

.spell-anchor:hover,
.spell-anchor:focus-visible {
  color: #fff;
  background: var(--spell-wine);
}

.spell-card__body {
  padding: 18px 19px 20px;
}

.spell-flavour {
  margin: 0 0 13px;
  color: var(--spell-muted);
  font-style: italic;
  line-height: 1.4;
}

.spell-rules {
  font-size: 0.95rem;
  line-height: 1.52;
}

.spell-rules p {
  margin: 0 0 0.82em;
}

.spell-rules p:last-child {
  margin-bottom: 0;
}

.spell-rules strong {
  color: var(--spell-wine);
}

.spell-empty {
  margin: 18px 0 0;
  padding: 30px;
  color: #d8cfc1;
  text-align: center;
  border: 1px dashed rgba(216, 191, 128, 0.48);
}

.spell-empty[hidden] {
  display: none;
}

.spell-footer {
  margin-top: 38px;
  padding-top: 18px;
  color: #bfb4a4;
  border-top: 1px solid rgba(216, 191, 128, 0.32);
  font-size: 0.78rem;
  line-height: 1.5;
}

.spell-footer a {
  color: #efd99a;
}

@media (max-width: 850px) {
  .spells-shell .site-bar {
    position: static;
    gap: 0.55rem 0.9rem;
  }

  .spells-shell .site-bar .status {
    width: 100%;
    margin: 2px 0 0;
  }

  .spells-main {
    width: min(100% - 22px, 720px);
    padding-top: 26px;
  }

  .spells-hero {
    grid-template-columns: 1fr;
    padding-top: 22px;
  }

  .spell-count-mark {
    justify-self: start;
  }

  .spell-primer,
  .spell-grid {
    grid-template-columns: 1fr;
  }

  .spell-tools {
    top: 0;
    grid-template-columns: 1fr 1fr;
  }

  .spell-tools label:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .spell-tools {
    top: 0;
    grid-template-columns: 1fr;
  }

  .spell-tools label:first-child,
  .spell-results {
    grid-column: auto;
  }

  .spell-tools button {
    width: 100%;
  }

  .spell-card__header,
  .spell-card__body {
    padding-left: 15px;
    padding-right: 15px;
  }

  .spell-card__header {
    padding-right: 54px;
  }
}

@media print {
  .spells-shell,
  html {
    color: #000;
    background: #fff;
  }

  .spells-main {
    width: auto;
    padding: 0;
  }

  .spells-hero {
    padding: 0 0 18px;
  }

  .spells-hero h1,
  .spells-hero .lead,
  .spells-hero .kicker,
  .spell-footer,
  .spell-footer a {
    color: #000;
  }

  .spell-count-mark,
  .spell-tools,
  .spell-anchor,
  .spell-empty {
    display: none !important;
  }

  .spell-primer {
    box-shadow: none;
  }

  .spell-grid {
    display: block;
  }

  .spell-card,
  .spell-card[hidden] {
    display: block;
    margin: 0 0 12pt;
    box-shadow: none;
    break-inside: avoid;
  }
}
