/* Crit Happens - colours taken from the title painting: the plum shadows of the
   sunset, the gold of the logo, parchment light, and the goblins' red banners. */
:root {
  --night: #1a1322;
  --dusk: #2b1f35;
  --gold: #eaa53a;
  --gold-light: #f6c869;
  --parchment: #f2e6cf;
  --ash: #b8a88f;
  --banner: #a3342c;
  --line: rgba(242, 230, 207, 0.14);

  --display: "IM Fell English", Georgia, serif;
  --body: "Alegreya Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--night); }

body {
  margin: 0;
  background: var(--night);
  color: var(--parchment);
  font-family: var(--body);
  font-size: 1.125rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }

a { color: var(--gold-light); text-underline-offset: 0.18em; }
a:hover { color: var(--parchment); }

:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
  border-radius: 3px;
}

.wrap {
  width: min(1120px, 100% - 32px);
  margin-inline: auto;
}

h2, h3 {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.15;
  margin: 0 0 0.5em;
}

h2 { font-size: clamp(1.9rem, 1.4rem + 1.8vw, 2.7rem); }
h3 { font-size: 1.5rem; }

p { margin: 0 0 1em; max-width: 62ch; }

/* ------------------------------------------------------------------ hero */

.hero {
  position: relative;
  min-height: min(100svh, 1000px);
  display: grid;
  align-items: end;
  overflow: hidden;
  isolation: isolate;
}

.hero picture { position: absolute; inset: 0; z-index: -2; }

.hero-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
}

/* The painting fades into the night colour so the page continues out of it. */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, rgba(26, 19, 34, 0) 45%, rgba(26, 19, 34, 0.75) 72%, var(--night) 96%);
}

.hero-body {
  width: min(1120px, 100% - 32px);
  margin: 0 auto;
  padding-bottom: clamp(32px, 6vh, 72px);
  display: grid;
  justify-items: center;
  text-align: center;
}

.tagline {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.3rem);
  line-height: 1.2;
  margin: 0 0 22px;
  max-width: none;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.65);
}

.cta {
  display: flex;
  align-items: center;
  gap: 18px;
}

.cta-text { text-align: left; }

.button {
  display: inline-block;
  padding: 15px 30px;
  background: var(--gold);
  color: #24170a;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  border-radius: 4px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 6px 24px rgba(234, 165, 58, 0.25);
}
.button:hover { background: var(--gold-light); color: #24170a; }

.download-meta {
  margin: 8px 0 0;
  font-size: 0.95rem;
  color: var(--ash);
}

/* The d20 rolls once when the page opens and lands on a natural 20. */
.die { width: 76px; height: 76px; flex: none; }
.die svg { width: 100%; height: 100%; overflow: visible; }
.die-edge { fill: rgba(26, 19, 34, 0.55); stroke: var(--gold); stroke-width: 3; stroke-linejoin: round; }
.die-face { fill: rgba(234, 165, 58, 0.14); stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; }
.die-lines { fill: none; stroke: var(--gold); stroke-width: 1.5; opacity: 0.55; }
.die-number { fill: var(--parchment); font-family: var(--display); font-size: 21px; }

.die.rolling svg { animation: tumble 0.16s linear infinite; }
.die.landed svg { animation: land 0.9s ease-out; }

@keyframes tumble {
  0% { transform: rotate(0deg) scale(0.94); }
  50% { transform: rotate(14deg) scale(1.02); }
  100% { transform: rotate(0deg) scale(0.94); }
}
@keyframes land {
  0% { transform: scale(1.18); filter: drop-shadow(0 0 0 rgba(246, 200, 105, 0)); }
  35% { filter: drop-shadow(0 0 16px rgba(246, 200, 105, 0.95)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(246, 200, 105, 0.35)); }
}

/* ------------------------------------------------------------------ sections */

main { padding-bottom: 40px; }

.intro {
  padding: 56px 0 72px;
}
.intro p {
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  line-height: 1.55;
  max-width: 44ch;
  margin-inline: auto;
  text-align: center;
}

.feature {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: clamp(24px, 4vw, 56px);
  align-items: center;
  padding: 36px 0;
}
.feature img {
  border-radius: 6px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.feature.flip picture { order: 2; }

.feature-text p { color: #e6d8bf; }

.start {
  margin-top: 64px;
  padding-top: 56px;
  border-top: 1px solid var(--line);
}

.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 28px 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}
.steps li { counter-increment: step; }
.steps li::before {
  content: counter(step);
  display: block;
  font-family: var(--display);
  font-size: 3.4rem;
  line-height: 1;
  color: var(--gold);
  margin-bottom: 10px;
}
.steps p { color: #e6d8bf; }

.controls {
  margin-top: 64px;
  padding-top: 56px;
  border-top: 1px solid var(--line);
}

.keys {
  margin: 24px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 48px;
}
.keys div {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.keys dt { color: var(--ash); }
.keys dd { margin: 0; }

kbd {
  display: inline-block;
  min-width: 1.9em;
  padding: 1px 7px;
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  color: var(--parchment);
  background: var(--dusk);
  border: 1px solid rgba(242, 230, 207, 0.22);
  border-bottom-width: 3px;
  border-radius: 4px;
}

footer {
  padding: 40px 0 56px;
  border-top: 1px solid var(--line);
  color: var(--ash);
  font-size: 1rem;
}
footer p { margin-bottom: 0.5em; }

/* ------------------------------------------------------------------ small screens */

@media (max-width: 860px) {
  .feature, .feature.flip { grid-template-columns: 1fr; padding: 24px 0; }
  .feature.flip picture { order: 0; }
  .steps { grid-template-columns: 1fr; gap: 20px; }
  .keys { grid-template-columns: 1fr; }
  .keys div { grid-template-columns: 9rem 1fr; }
}

/* Portrait screens: the whole painting (logo included) on top, the call to action below it. */
@media (max-width: 700px) {
  .hero { min-height: 0; display: block; }
  .hero picture { position: relative; inset: auto; z-index: auto; display: block; }
  .hero-art { height: auto; aspect-ratio: 16 / 9; }
  .hero::after { inset: auto 0 auto 0; top: 0; height: calc(100vw * 9 / 16); background: linear-gradient(to bottom, rgba(26, 19, 34, 0) 60%, var(--night) 100%); }
  .hero-body { padding-top: 20px; }
}

@media (max-width: 520px) {
  .cta { gap: 12px; }
  .die { width: 58px; height: 58px; }
  .button { padding: 13px 20px; font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  .die.rolling svg, .die.landed svg { animation: none; }
}

/* ------------------------------------------------------------------ site links (every page) */

.site-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
}
.site-links a { color: var(--ash); }
.site-links a:hover { color: var(--parchment); }

/* The account link over the hero on the front page. */
.top-link {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  z-index: 2;
  padding: 8px 16px;
  background: rgba(26, 19, 34, 0.7);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--parchment);
  text-decoration: none;
  font-weight: 500;
}
.top-link:hover { background: var(--dusk); color: var(--gold-light); }

/* ------------------------------------------------------------------ inner pages (account, legal) */

.bar {
  border-bottom: 1px solid var(--line);
  background: var(--night);
}
.bar .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 14px 0;
}
.brand {
  font-family: var(--display);
  font-size: 1.6rem;
  color: var(--gold-light);
  text-decoration: none;
}
.bar nav { display: flex; gap: 20px; flex-wrap: wrap; }
.bar nav a { color: var(--parchment); text-decoration: none; }
.bar nav a:hover, .bar nav a[aria-current="page"] { color: var(--gold-light); text-decoration: underline; }

.page { padding: 48px 0 72px; }
.page h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.1rem, 1.6rem + 2vw, 3rem);
  line-height: 1.1;
  margin: 0 0 0.4em;
  text-wrap: balance;
}
.lede { color: #e6d8bf; font-size: 1.2rem; }

/* ------------------------------------------------------------------ forms */

.panel {
  max-width: 560px;
  background: var(--dusk);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: clamp(20px, 4vw, 32px);
}
.panel + .panel { margin-top: 24px; }
.panel h2 { font-size: 1.7rem; }

.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field label, .field legend { font-weight: 500; }
.field .hint { color: var(--ash); font-size: 0.95rem; margin: 0; }
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  color: var(--parchment);
  background: var(--night);
  border: 1px solid rgba(242, 230, 207, 0.28);
  border-radius: 4px;
}
input:focus-visible { border-color: var(--gold-light); }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
.choices { display: flex; gap: 22px; flex-wrap: wrap; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; line-height: 1.45; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--gold); flex: none; }
.choices label { display: flex; gap: 8px; align-items: center; }
.choices input { width: 18px; height: 18px; accent-color: var(--gold); }

button {
  font: inherit;
  cursor: pointer;
}
.button { border: 0; }
.button[disabled] { opacity: 0.6; cursor: wait; }
.quiet {
  padding: 10px 18px;
  background: transparent;
  color: var(--parchment);
  border: 1px solid rgba(242, 230, 207, 0.35);
  border-radius: 4px;
}
.quiet:hover { border-color: var(--gold-light); color: var(--gold-light); }
.danger { background: var(--banner); color: var(--parchment); box-shadow: none; }
.danger:hover { background: #bd4237; color: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 6px; }

.note {
  padding: 12px 16px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: rgba(242, 230, 207, 0.06);
  margin: 0 0 18px;
  max-width: none;
}
.note.bad { border-color: rgba(214, 90, 77, 0.6); background: rgba(163, 52, 44, 0.18); }
.note.good { border-color: rgba(122, 176, 92, 0.6); background: rgba(80, 130, 60, 0.18); }

.facts { margin: 0 0 8px; display: grid; }
.facts div {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.facts dt { color: var(--ash); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 0.85rem; border: 1px solid currentColor; }
.badge.ok { color: #9fd07f; }
.badge.no { color: var(--gold-light); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.grid-2 .panel + .panel { margin-top: 0; }

/* ------------------------------------------------------------------ legal text */

.legal { max-width: 74ch; }
.legal h2 { font-size: 1.7rem; margin-top: 1.6em; }
.legal h3 { font-size: 1.3rem; margin-top: 1.2em; }
.legal p, .legal li { color: #e6d8bf; }
.legal ul { padding-left: 1.2em; }
.legal li { margin-bottom: 0.4em; }
.legal table { width: 100%; border-collapse: collapse; margin: 0 0 1em; font-size: 1rem; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.legal th { color: var(--ash); font-weight: 500; }
.table-scroll { overflow-x: auto; }
.updated { color: var(--ash); }
.fill { background: rgba(234, 165, 58, 0.22); padding: 0 4px; border-radius: 3px; }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .facts div { grid-template-columns: 1fr; gap: 2px; }
}

/* Headings get focus when a view opens (for screen readers); no ring for that. */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }

/* ------------------------------------------------------------------ footer (every page) */

.site-footer .site-links + .site-links { margin-top: 6px; }
.copyright { margin-top: 18px; font-size: 0.9rem; }
a[href^="mailto:"] { overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ 404 */

.lost { text-align: center; }
.lost h1, .lost .lede { margin-inline: auto; }
.lost .actions { justify-content: center; display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: center; max-width: none; }
.lost-roll {
  font-family: var(--display);
  font-size: 6rem;
  line-height: 1;
  color: var(--banner);
  margin: 0 auto 8px;
}
@media (max-width: 700px) { .site-links { gap: 12px 22px; } }
