:root {
  --bg-top: #1c1726;
  --bg-bottom: #3a2740;
  --ink: #ece7f2;
  --muted: #b3a6c4;
  --panel: #2a2335;
  --panel-edge: #4a3d59;
  --accent: #b98cd6;

  --white: #f4f0dc;
  --blue: #3eace8;
  --black: #9c61b7;
  --red: #dc5d68;
  --green: #3da471;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.home {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 22vh 24px 80px;
  text-align: center;
}

h1 {
  font-weight: 400;
  font-size: 2.2rem;
  line-height: 1.25;
  margin: 0 0 2rem;
}
h1 strong {
  font-weight: 700;
}

.search {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #211b2c;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 0 18px;
  height: 64px;
}
.search-home {
  display: inline-flex;
  flex-shrink: 0;
  line-height: 0;
}
.search-icon {
  width: 42px;
  height: 42px;
}
.search input {
  flex: 1;
  background: none;
  border: none;
  color: var(--ink);
  font-size: 1.1rem;
  outline: none;
}

.actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 18px 0 22px;
}
.actions button,
.actions a {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.actions button:hover:not(:disabled),
.actions a:hover {
  background: rgba(185, 140, 214, 0.25);
  border-color: var(--accent);
}
.actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- search tools (advanced search / syntax guide) ---- */
/* A <details> whose <summary> is styled like an action button. The panel is
   positioned below the whole button row (so opening one never reflows the other
   buttons); shared name="search-tools" keeps the two mutually exclusive, and a
   small script (search-tools.js) closes an open panel when any other control is
   used. */
.tool summary {
  display: inline-block;
  font-weight: 700;
  list-style: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.tool summary::-webkit-details-marker {
  display: none;
}
.tool summary:hover,
.tool[open] summary {
  background: rgba(185, 140, 214, 0.25);
  border-color: var(--accent);
}

.advanced,
.syntax {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: min(460px, 100%);
  margin-top: 12px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.advanced {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.advanced label {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  color: var(--muted);
}
.advanced input,
.advanced select {
  min-width: 0;
  font: inherit;
  color: var(--ink);
  background: #211b2c;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}
.advanced input:focus,
.advanced select:focus {
  border-color: var(--accent);
}
.advanced button {
  align-self: flex-end;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: rgba(185, 140, 214, 0.25);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.15s;
}
.advanced button:hover {
  background: rgba(185, 140, 214, 0.4);
}

.syntax {
  color: var(--muted);
  line-height: 1.5;
}
.syntax p {
  margin: 0 0 12px;
}
.syntax dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  align-items: baseline;
}
.syntax dt {
  white-space: nowrap;
}
.syntax dt span {
  font-weight: 400;
  opacity: 0.55;
  margin: 0 2px;
}
.syntax dd {
  margin: 0;
}
.syntax code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.85em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-edge);
  border-radius: 5px;
  padding: 1px 5px;
}
.syntax-example {
  margin: 14px 0 0;
}

.links {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--muted);
  line-height: 2.1;
}
.links a {
  color: var(--muted);
}
.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  background: linear-gradient(to right, var(--blue), var(--black), var(--red), var(--green));
  color: var(--white);
  border-radius: 5px;
  padding: 1px 7px;
  margin-right: 6px;
  vertical-align: middle;
}

/* ---- random card ---- */
.result:not(:empty) {
  margin: 36px 0;
}
.htmx-request#result {
  opacity: 0.5;
}

.no-results {
  margin: 0;
  color: var(--muted);
}

/* ---- 404 ---- */
.notfound-art {
  width: 140px;
  height: auto;
}
.notfound-text {
  font-size: 1.3rem;
  margin: 1.5rem 0 0.5rem;
}
.notfound a {
  color: var(--accent);
}

/* ---- search gallery ---- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 4px;
}
.gallery-item {
  display: block;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}
.gallery-item img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #181320;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}
.gallery-item:hover img,
.gallery-item:focus-visible img {
  border-color: var(--card-color, var(--accent));
  transform: translateY(-3px);
}

.card {
  position: relative;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-left: 6px solid var(--card-color, var(--accent));
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.card-back {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.card-back:hover {
  color: var(--ink);
  background: rgba(185, 140, 214, 0.25);
  border-color: var(--accent);
}
.color-white {
  --card-color: var(--white);
}
.color-blue {
  --card-color: var(--blue);
}
.color-black {
  --card-color: var(--black);
}
.color-red {
  --card-color: var(--red);
}
.color-green {
  --card-color: var(--green);
}

.card-art {
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #181320;
  object-fit: contain;
}
.card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  /* Leave the top-right corner clear for the absolutely-positioned back button. */
  padding-right: 36px;
}
.card-head h2 {
  margin: 0;
  font-size: 1.5rem;
}
.reminder {
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #2a1f33;
  font-size: 0.9rem;
}

.value {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.die {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border-radius: 6px;
  font-weight: 700;
  background: #f4f0dc;
  color: #2a1f33;
}
.value.variable .die {
  background: #3a3340;
  color: #f4f0dc;
  border: 1px solid #6c6076;
}
.value-sep {
  color: var(--muted);
  margin: 0 2px;
}

.meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill {
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-edge);
  border-radius: 20px;
  padding: 3px 10px;
  color: var(--muted);
}
.pill.timing {
  color: var(--ink);
}

.effect {
  margin: 0;
  line-height: 1.5;
}
.effect em,
.notes em {
  color: var(--muted);
  font-style: italic;
}

.notes summary {
  cursor: pointer;
  color: var(--muted);
}
.notes ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.card-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--panel-edge);
  padding-top: 10px;
}

/* ---- footer ---- */
.site-footer {
  background: #181320;
  border-top: 1px solid var(--panel-edge);
  text-align: left;
}
.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 48px;
}
.footer-cols {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 56px;
  margin-bottom: 32px;
}
.footer-col h2 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--panel-edge);
  padding-bottom: 8px;
  margin: 0 0 12px;
}
.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  line-height: 2;
}
.footer-col a {
  color: var(--ink);
  opacity: 0.8;
  text-decoration: none;
  cursor: pointer;
}
.footer-col a:hover {
  color: var(--accent);
  opacity: 1;
}
.footer-col .soon {
  color: var(--muted);
  opacity: 0.5;
}
.footer-tool-link {
  font: inherit;
  color: var(--ink);
  opacity: 0.8;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.footer-tool-link:hover {
  color: var(--accent);
  opacity: 1;
}
.footer-legal {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
  opacity: 0.7;
}
.footer-legal p {
  margin: 0 0 12px;
}

@media (max-width: 560px) {
  .card {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 2rem;
  }
}
