:root {
  color-scheme: dark;
  background: #080e24;
}

* { box-sizing: border-box }

body {
  margin: 0;
  color: #f5f3ee;
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.public-rulebook-sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.public-rulebook-sky canvas { display: block; width: 100%; height: 100% }

.public-rulebook-sky[data-scene="ready"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #080e248a;
}

.dialog.rulebook-dialog.public-rulebook {
  position: relative;
  height: auto;
  max-height: none;
  overflow: visible;
  margin: max(0px, calc((100dvh - 820px) / 2)) auto 0;
}

.public-rulebook .rulebook-header {
  flex-direction: column;
  margin-bottom: 40px;
}

.public-rulebook .rulebook-header h1 {
  margin: 0;
  color: #fff;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -.5px;
}

.public-rulebook-title { position: relative }

.public-rulebook-language {
  position: absolute;
  top: 50%;
  left: calc(100% + 12px);
  transform: translateY(-50%);
}

.public-rulebook-brand { margin-bottom: 26px }

.public-rulebook-brand img {
  display: block;
  width: clamp(88px, 13vw, 124px);
  height: auto;
}

.public-rulebook .rulebook-header .join-back { padding-top: 12px }

.public-rulebook :is(.public-rulebook-brand, .join-back, .public-rulebook-play):focus-visible {
  outline: 2px solid #beffe9;
  outline-offset: 3px;
}

.public-rulebook .rulebook-mode {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.public-rulebook-mode > summary { display: none }
.public-rulebook-mode > .rulebook-layout { scroll-margin-top: calc(300px + max(0px, (100dvh - 820px) / 2)) }
.public-rulebook .rulebook-content { overflow: visible }

.public-rulebook .rulebook-nav {
  position: sticky;
  top: 20px;
  align-self: start;
  max-height: calc(100dvh - 40px);
}

.public-rulebook:has(.public-rulebook-mode[open] > #duel) [href="#duel"],
.public-rulebook:has(.public-rulebook-mode[open] > #ffa3) [href="#ffa3"],
.public-rulebook:has(.public-rulebook-mode[open] > #ffa4) [href="#ffa4"],
.public-rulebook:has(.public-rulebook-mode[open] > #teams) [href="#teams"],
.public-rulebook:has(.public-rulebook-mode[open] > #faq) [href="#faq"] {
  --mode-underline: #a4e6dc;
  background: #80ded51c;
  color: #effffb;
  font-weight: 650;
}

.public-rulebook .rulebook-mode::after {
  content: "";
  position: absolute;
  inset: auto 13px 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--mode-underline, transparent);
}

.public-rulebook .rulebook-layout:not(:has(.rulebook-section:target, .rulebook-section :target)) .rulebook-link:first-child,
.public-rulebook .rulebook-layout:has(.rulebook-section:nth-of-type(1):target, .rulebook-section:nth-of-type(1) :target) .rulebook-link:nth-child(1),
.public-rulebook .rulebook-layout:has(.rulebook-section:nth-of-type(2):target, .rulebook-section:nth-of-type(2) :target) .rulebook-link:nth-child(2),
.public-rulebook .rulebook-layout:has(.rulebook-section:nth-of-type(3):target, .rulebook-section:nth-of-type(3) :target) .rulebook-link:nth-child(3),
.public-rulebook .rulebook-layout:has(.rulebook-section:nth-of-type(4):target, .rulebook-section:nth-of-type(4) :target) .rulebook-link:nth-child(4),
.public-rulebook .rulebook-layout:has(.rulebook-section:nth-of-type(5):target, .rulebook-section:nth-of-type(5) :target) .rulebook-link:nth-child(5),
.public-rulebook .rulebook-layout:has(.rulebook-section:nth-of-type(6):target, .rulebook-section:nth-of-type(6) :target) .rulebook-link:nth-child(6),
.public-rulebook .rulebook-layout:has(.rulebook-section:nth-of-type(7):target, .rulebook-section:nth-of-type(7) :target) .rulebook-link:nth-child(7) {
  color: #effffb;
  background: #80ded522;
  box-shadow: inset 0 0 0 1px #a4e6dc33;
  font-weight: 600;
}

.public-rulebook footer {
  margin-top: 20px;
  text-align: center;
}

.public-rulebook-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 5px 12px;
  border: 1px solid #7b97a340;
  border-radius: 10px;
  background: #ffffff08;
  color: #d8e9ee;
  font-size: 12px;
  line-height: 1.2;
  text-decoration: none;
}

.public-rulebook-play:hover {
  border-color: #b3dae1;
  background: #ffffff15;
}

@media (max-width: 700px) {
  .dialog.rulebook-dialog.public-rulebook { margin-top: 0 }
  .public-rulebook .rulebook-nav {
    top: 0;
    z-index: 1;
    max-height: none;
    padding: 0 1px 8px;
    background: #080e24;
  }
  .public-rulebook :is(.rulebook-section, .rule-faction) { scroll-margin-top: 76px }
}

@media (max-width: 370px) {
  .dialog.rulebook-dialog.public-rulebook { width: 100% }
  .public-rulebook .rulebook-modes { gap: 5px }
  .public-rulebook .rulebook-mode { padding-inline: 3px }
}
