:root {
  color-scheme: dark;
  --bg: #071014;
  --panel: rgba(4, 13, 17, 0.91);
  --panel-soft: rgba(8, 20, 25, 0.82);
  --line: rgba(0, 238, 238, 0.55);
  --line-soft: rgba(180, 205, 210, 0.24);
  --accent: #20e6e6;
  --text: #f2f5f5;
  --muted: #b7c3c5;
  --warning: #ffcb4d;
  --danger: #ff6b79;
  --shadow: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  padding: 72px 24px 48px;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: #0a1115;
  line-height: 1.62;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(circle at 50% 0%, rgba(27, 86, 91, 0.22), transparent 50%),
    linear-gradient(rgba(4, 11, 14, 0.73), rgba(4, 11, 14, 0.9));
}

.snow-effect {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0.28;
  background: url("images/effects/snowfall.gif") center / cover no-repeat;
}

.rulebook-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
}

.back-to-hub {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(4, 13, 17, 0.88);
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 8px 24px var(--shadow);
  backdrop-filter: blur(8px);
}
.back-to-hub:hover,
.back-to-hub:focus-visible { border-color: var(--accent); box-shadow: 0 0 18px rgba(32, 230, 230, 0.28); }

.hero,
.section,
.toc {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 50px var(--shadow);
  backdrop-filter: blur(8px);
}

.hero {
  padding: 44px clamp(22px, 5vw, 58px);
  border-radius: 18px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .26em;
  text-transform: uppercase;
}

h1, h2, h3 { margin-top: 0; line-height: 1.17; }
h1 {
  margin-bottom: 14px;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(2.6rem, 8vw, 5.6rem);
  font-weight: 900;
  letter-spacing: .025em;
  text-transform: uppercase;
  text-shadow: 0 4px 12px #000;
}
h2 {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
  font-size: clamp(1.65rem, 3vw, 2.2rem);
}
h3 { margin-top: 28px; font-size: 1.2rem; color: #e6ffff; }

.lede { max-width: 780px; margin: 0 auto; color: var(--muted); font-size: 1.08rem; }
.public-note { margin: 18px auto 0; color: #aafdfd; font-size: .92rem; }

.toc {
  position: sticky;
  top: 12px;
  z-index: 40;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 18px 0 28px;
  padding: 10px;
  border-radius: 12px;
  scrollbar-width: thin;
}
.toc a {
  flex: 0 0 auto;
  padding: 8px 11px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
}
.toc a:hover,
.toc a:focus-visible { color: #001315; background: var(--accent); }

.section {
  margin: 0 0 24px;
  padding: clamp(22px, 4vw, 38px);
  border-radius: 14px;
  scroll-margin-top: 90px;
}
.section p:last-child,
.section ul:last-child,
.section ol:last-child { margin-bottom: 0; }
.section-intro { color: var(--muted); }

ul, ol { padding-left: 1.35rem; }
li + li { margin-top: 7px; }

code {
  padding: .1rem .42rem;
  border: 1px solid rgba(32, 230, 230, .25);
  border-radius: 5px;
  color: #dfffff;
  background: rgba(0, 0, 0, .42);
  font-family: Consolas, "Courier New", monospace;
  font-size: .95em;
}

.callout {
  margin-top: 20px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 7px;
  color: #d9ffff;
  background: rgba(10, 44, 48, .42);
}
.callout.warning { border-left-color: var(--warning); color: #fff3c7; background: rgba(68, 48, 6, .35); }

.rule-grid,
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}
.rule-grid article,
.type-grid article {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--panel-soft);
}
.rule-grid article { display: flex; flex-direction: column; gap: 3px; }
.rule-grid span,
.type-grid span { color: var(--muted); font-size: .9rem; }
.rule-grid strong { font-size: 1.35rem; color: #fff; }
.type-grid article { display: flex; flex-direction: column; gap: 5px; }
.type-grid strong { color: #dcffff; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}
table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: rgba(0, 0, 0, .25);
}
th, td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
th { color: #dfffff; background: rgba(23, 43, 48, .8); font-size: .92rem; }
tbody tr:last-child td { border-bottom: 0; }
td { color: #e2e9ea; }

summary {
  cursor: pointer;
  padding: 13px 0;
  color: #e8ffff;
  font-weight: 750;
}
details + details { border-top: 1px solid var(--line-soft); }
details p { margin-top: 0; color: var(--muted); }

.footer { padding: 10px 0 18px; text-align: center; }
.footer a { color: var(--accent); font-weight: 800; }

.audio-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  width: 46px;
  height: 46px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: #fff;
  background: rgba(4, 13, 17, .92);
  cursor: pointer;
  box-shadow: 0 8px 24px var(--shadow);
  backdrop-filter: blur(8px);
}
.audio-toggle:hover,
.audio-toggle:focus-visible { box-shadow: 0 0 16px rgba(32, 230, 230, .32); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 800px) {
  body { padding: 68px 12px 36px; }
  .hero { padding: 32px 18px; }
  .section { padding: 22px 18px; }
  .rule-grid,
  .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toc { top: 8px; }
}

@media (max-width: 520px) {
  .back-to-hub { left: 10px; top: 10px; }
  .rule-grid,
  .type-grid { grid-template-columns: 1fr; }
  .toc { margin-top: 12px; }
  h1 { font-size: 2.65rem; }
}

@supports (padding: max(0px)) {
  .audio-toggle {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .snow-effect { display: none; }
}
.footer p { margin: 10px auto 0; max-width: 760px; color: var(--muted); font-size: .8rem; }
