.guide-site {
  min-height: 100vh;
  background: radial-gradient(ellipse at 75% 0, #463451 0, transparent 44rem) #191827;
}
.guide-site main.wrap { max-width: 82rem; padding-block: clamp(16px,3vw,32px) 3rem; }
.guide-site :is([id],summary) { scroll-margin-top: calc(var(--chess-bar) + 1rem); }
.guide-site [hidden] { display: none !important; }
.guide-hero {
  --hero-color: #493753;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(70px,20%,164px);
  align-items: center;
  gap: clamp(6px, 2.4vw, 30px);
  overflow: hidden;
  min-height: 165px;
  padding: clamp(14px, 3.2vw, 38px);
  margin-block-end: clamp(22px, 4vw, 40px);
  border: 1px solid #906f9b;
  border-radius: 12px;
  box-shadow: inset 0 1px #f7d7ef33, 0 5px #15111f;
  background: radial-gradient(ellipse at 86% 50%, var(--hero-color), transparent 58%), #2b233b;
}
.guide-hero::before {
  content: "";
  position: absolute;
  inset: 0 -4% -60% 33%;
  z-index: -1;
  background: conic-gradient(#d0b2df30 25%,transparent 0 50%,#d0b2df30 0 75%,transparent 0) 0 0 / 48px 48px;
  transform: perspective(420px) rotateX(43deg) rotateZ(-10deg);
  mask-image: radial-gradient(ellipse at 65% 38%,black 10%,transparent 65%);
  pointer-events: none;
}
.guide-hero h1 { margin: 0; font-size: clamp(1.9rem,4.7vw,4.4rem); letter-spacing: -.045em; }
.guide-hero p { max-width: 58ch; margin: .55rem 0 0; color: #e5d4e8; font-size: clamp(.94rem,1.5vw,1.13rem); overflow-wrap: anywhere; }
.guide-article-hero { margin-block-end: .8rem; }
.guide-article-hero h1 span { color: #e3c8f6; }
.guide-article-hero .creator-line { margin-top: .7rem; }
.guide-crest {
  display: grid;
  place-items: center;
  width: min(100%, 136px);
  aspect-ratio: 1;
  justify-self: end;
  border-radius: 8px;
  background: linear-gradient(145deg,#6b4f62,#342a44);
  border: 1px solid #c5a082;
  box-shadow: inset 0 0 0 5px #e2bc9033, 0 3px #291d36;
}
.guide-crest > img { width: 74%; height: auto; filter: drop-shadow(4px 6px #291a34); transition: transform .38s cubic-bezier(.18,.78,.25,1); }
.guide-hero:hover .guide-crest > img { transform: translateY(-4px) rotate(-6deg); }
.guide-links { display: flex; gap: .5rem .85rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.guide-links a, .guide-links > span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid #9f7ba2;
  border-radius: 99px;
  padding: .3rem .75rem;
  font-size: .9rem;
  font-weight: 700;
  color: var(--paper);
}
.guide-links a { text-decoration: none; background: #4d3856; }
.guide-links a:hover { color: var(--gold); background: #603e62; }
.guide-links > span { border-color: #786086; color: var(--muted); }
.guide-emblem {
  display: inline-grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border: 1px solid #a782a9;
  border-radius: 6px;
  background: #44324e;
  box-shadow: inset 0 0 0 3px #2d233c;
  color: var(--gold);
}
.guide-emblem svg { width: 20px; height: 20px; }
.guide-section { margin-block: 1.7rem 2rem; }
.guide-section h2, .directory-heading h2 { margin: 0 0 .8rem; font-size: clamp(1.25rem,2vw,1.68rem); text-align: start; }
.guide-section > p { max-width: 65ch; color: var(--muted); }
.guide-card-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,244px),1fr)); gap: 12px; }
.guide-card {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 90px;
  padding: clamp(10px,1.8vw,18px);
  border: 1px solid #675477;
  border-radius: 9px;
  background: linear-gradient(135deg,#342a46,#282237);
  color: var(--paper);
  text-decoration: none;
  box-shadow: 0 3px #171323;
  transition: transform .22s ease, background-color .22s, border-color .22s, box-shadow .22s;
}
.guide-card:hover { color: var(--paper); border-color: #c894bb; transform: translateY(-2px); box-shadow: 0 6px 14px #130d27b8; }
.guide-card strong { display: block; font-family: 'Chakra Petch', system-ui, sans-serif; overflow-wrap: anywhere; line-height: 1.2; }
.guide-card span span { display: block; color: var(--muted); font-size: .87rem; line-height: 1.4; margin-top: .25rem; }
.guide-card > span:last-child { color: var(--gold); }
.directory-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .8rem 1rem; margin-bottom: 1rem; }
.directory-heading h2 { margin: 0; }
.directory-heading label { display: grid; gap: .3rem; max-width: 100%; color: var(--muted); font-size: .86rem; }
#opening-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); grid-template-rows: auto 1fr; gap: 14px; align-items: start; }
.opening-group { overflow: hidden; border: 1px solid #846b8b; border-radius: 8px; background: #272136; box-shadow: 0 4px #181324; }
.opening-group:first-child { grid-row: span 2; }
.opening-group h3 { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; margin: 0; padding: .85rem .9rem; color: #ffe4b2; background: #49364d; border-bottom: 1px solid #877086; }
.opening-group h3 code { color: #f5c991; font-size: .86rem; }
.opening-group ul { margin: 0; padding: 0; list-style: none; }
.opening-group li + li { border-top: 1px solid #564662; }
.opening-group a { display: grid; grid-template-columns: minmax(36px,auto) minmax(0,1fr) auto; align-items: center; gap: .7rem; min-height: 44px; padding: .46rem .75rem; color: var(--paper); text-decoration: none; transition: background-color .19s; }
.opening-group a:hover { background: #463550; }
.opening-group a:focus-visible { outline-offset: -3px; }
.opening-group a strong { font-weight: 650; overflow-wrap: anywhere; line-height: 1.32; }
.opening-group .eco-code { border: 1px solid #806286; border-radius: 4px; padding: .18rem .3rem; color: #e3c4ef; background: #372a45; font: .78rem/1.4 ui-monospace, monospace; text-align: center; }
.opening-group .line-arrow { color: var(--gold); font-size: 1.3rem; line-height: 1; }
.guide-site:has([data-study]) .guide-hero { min-height: 128px; padding-block: clamp(12px,2.5vw,24px); margin-block-end: 20px; }
.guide-site:has([data-study]) .guide-hero h1 { font-size: clamp(1.7rem,4vw,3.5rem); }
.guide-site:has([data-study]) .guide-hero .guide-links :is(a,span) { border-radius: 5px; }
.opening-line { margin: 0 0 1rem; }
.opening-line h2 { margin: 0 0 .35rem; font-size: 1.15rem; }
.opening-line p { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; }
.opening-line span { display: inline-block; padding: .25rem .48rem; background: #342a46; border: 1px solid #624e70; border-radius: 5px; font: 500 .87rem/1.4 ui-monospace, monospace; }
.opening-line [aria-current=step] { background: #f1ca95; border-color: #ffe5b5; color: #301e2c; }
.guide-credit { color: var(--muted); font-size: .87rem; }
.guide-site .guide-layout { max-width: 75rem; grid-template-columns: minmax(9.5rem,12rem) minmax(0,1fr); }
.guide-site .contents, .guide-site .guide-copy > section, .study-console {
  padding: clamp(13px,2.1vw,24px);
  background: linear-gradient(135deg,#302840,#242034);
  border: 1px solid #655472;
  border-radius: 9px;
}
.guide-site .contents { top: calc(var(--chess-bar) + 12px); }
.guide-site .contents a { text-decoration-thickness: 1px; }
.guide-site .guide-copy > section { margin-bottom: 1rem; }
.guide-site .guide-copy section > h2 { text-align: start; color: #f6d8ec; }
.guide-site .tactic-board { overflow: hidden; border: 2px solid #8f739f; border-radius: 6px; }
.guide-site .tactic-grid img { display: block; width: 90%; height: 90%; object-fit: contain; filter: drop-shadow(1px 2px #271b376b); }
.guide-site .rolls { margin: .8rem 0; }
.guide-site .rolls tbody th { text-align: center; }
.guide-site .rolls tbody th > span { display: inline-block; min-width: 2.2rem; border-radius: 999px; background: #503953; border: 1px solid #a481a3; padding: .18rem .32rem; }
.guide-site input[type=search] {
  max-width: 100%;
  min-height: 42px;
  padding: .45rem .65rem;
  font: inherit;
  color: var(--paper);
  background-color: #342a47;
  border: 1px solid #9a7da6;
  border-radius: 7px;
}
.guide-site :is(button,input,select,summary):focus-visible { outline: 2px solid var(--chess-focus); outline-offset: 3px; }
[data-study] { display: grid; grid-template-columns: minmax(0,34rem) minmax(320px,26rem); gap: clamp(14px,2.5vw,26px); align-items: start; }
.guide-site .study-board { width: 100%; border-color: #8a6c91; }
.study-board button { position: relative; }
.study-rank, .study-file { position: absolute; z-index: 1; pointer-events: none; color: #38283e; font: 700 clamp(.6rem,1.35vw,.75rem)/1 ui-monospace, monospace; }
.study-board .dark :is(.study-rank,.study-file) { color: #fff4f0; text-shadow: 0 1px #3a2b4a; }
.study-rank { inset: 3px auto auto 4px; }
.study-file { inset: auto 4px 3px auto; }
.study-console { min-width: 0; overflow: hidden; padding: 0; border-color: #8a6c91; }
.study-console-head { display: block; padding: .9rem 1rem; background: linear-gradient(110deg,#523d55,#372b44); border-bottom: 1px solid #816589; }
.study-console-head h2 { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: 1.22rem; }
.study-console-head svg, .study-die-section label svg { width: 19px; height: 19px; flex: none; color: var(--gold); }
.study-console-head p { margin: .45rem 0 0; font-size: .9rem; color: #f3d7b0; }
.study-section { padding: .75rem clamp(10px,2vw,16px); border-bottom: 1px solid #584966; }
.study-section h3 { margin: 0; font-size: 1.04rem; text-align: start; }
.study-section-heading { display: flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: center; justify-content: space-between; }
.study-section-heading > span { padding: .18rem .38rem; border: 1px solid #886587; border-radius: 4px; color: var(--gold); font: .78rem/1.3 ui-monospace, monospace; }
.study-command-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; margin-top: .48rem; }
.study-command-row button, .study-continuations button {
  display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; min-height: 42px; padding: .4rem .35rem;
  font: 650 .84rem/1.25 system-ui,sans-serif; color: var(--paper); background: #3f304e; border: 1px solid #85698f;
  border-radius: 5px; box-shadow: 0 2px #1c162b; cursor: pointer; transition: background-color .16s, border-color .16s, box-shadow .16s;
}
.study-command-row button span { min-width: 0; overflow-wrap: anywhere; }
.study-command-row button img { flex: none; width: 20px; height: 20px; }
.study-command-row .study-next { color: #302037; background: #edc69b; border-color: #ffe1ae; }
.study-command-row button:disabled { box-shadow: none; opacity: .57; cursor: default; }
.study-command-row button:not(:disabled):hover, .study-continuations button:hover { color: var(--gold); border-color: var(--gold); background: #55405e; }
.study-die-section, .study-level { display: grid; grid-template-columns: minmax(0,1fr) minmax(64px,auto); gap: .5rem; align-items: center; }
.study-die-section label { display: flex; align-items: center; gap: .45rem; font-weight: 700; }
.study-die-section select { font-variant-numeric: tabular-nums; }
.study-level { margin-top: .5rem; color: var(--muted); font-size: .9rem; }
.study-continuations { grid-column: 1 / -1; margin-top: 3px; }
.study-continuations > div { display: flex; flex-wrap: wrap; gap: 6px; margin-top: .4rem; }
.study-continuations button { padding-inline: .7rem; font-family: ui-monospace, monospace; }
.study-events { padding: .8rem 1rem; }
.study-events summary { cursor: pointer; color: var(--red); font-weight: 700; }
.study-events :is(p,ol) { margin-bottom: 0; color: var(--muted); }
.study-console .study-controls { padding-inline: 1rem; }
.guide-site #puzzle-workspace { grid-template-columns: minmax(0,36rem) minmax(0,23rem); }
.guide-site main:has(> #puzzle-workspace) .guide-hero { min-height: 138px; padding-block: clamp(12px,2vw,23px); margin-block-end: 22px; }
.guide-site main:has(> #puzzle-workspace) .guide-crest { width: min(100%,112px); }
.guide-site .puzzle-modes button { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; min-height: 42px; padding-inline: .55rem; }
.guide-site .puzzle-modes .retro-icon { --icon-size: 20px; }
.guide-site .puzzle-modes [aria-pressed=true] .retro-icon { filter: brightness(.48); }
.guide-site .puzzle-die { box-shadow: inset 0 0 0 2px #795360,0 2px #1b1329; border-radius: 5px; font-variant-numeric: tabular-nums; }
.guide-site .puzzle-actions button { border-radius: 8px; min-height: 42px; }
.guide-site :is(.puzzle-actions,.puzzle-modes) button:hover:not(:disabled) { color: var(--gold); background-color: #453450; }
.guide-site .puzzle-board button:not(:disabled):hover, .study-board button:not(:disabled):hover { filter: brightness(1.1); }
.guide-site .puzzle-pager { min-width: 0; }
@media (max-width: 820px) {
  [data-study], #opening-list { grid-template-columns: minmax(0,1fr); grid-template-rows: auto; }
  .opening-group:first-child { grid-row: auto; }
  .guide-site .study-board { width: min(100%,34rem); }
}
@media (max-width: 760px) {
  .guide-site #puzzle-workspace, .guide-site .guide-layout { grid-template-columns: minmax(0,1fr); }
  .guide-site .contents { position: static; }
}
@media (max-width: 420px) {
  .guide-site main.wrap { padding-inline: 12px; }
  .guide-hero { gap: .5rem; grid-template-columns: minmax(0,1fr) minmax(50px,18%); }
  .guide-hero h1 { font-size: 1.82rem; }
  .guide-site .rolls { font-size: .86rem; }
}
@media (prefers-reduced-motion: reduce) {
  .guide-hero:hover .guide-crest > img, .guide-card:hover { transform: none; }
  .guide-crest > img, .guide-card, .opening-group a, .study-command-row button, .study-continuations button { transition: none; }
}
