.opening-detail-section {
  padding: 3rem 0 6rem;
}

.opening-detail-container {
  max-width: 1480px;
}

.opening-detail-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.detail-back-link {
  display: inline-flex;
  margin-bottom: 1.25rem;
  color: var(--gold);
  font-size: var(--font-size-sm);
  font-weight: 700;
}

.opening-title-row {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 2rem;
}

.opening-title-row > div:first-child {
  max-width: 850px;
}

.opening-title-row h1 {
  margin-bottom: 0.55rem;
  font-size: var(--font-size-4xl);
  font-weight: 900;
  line-height: 1.25;
}

.opening-title-row p {
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
}

.opening-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.45rem;
  max-width: 390px;
}

.opening-meta span {
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.opening-meta strong {
  color: var(--gold);
}

.opening-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 2rem;
  align-items: start;
}

.opening-study {
  min-width: 0;
}

.opening-board-section {
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.opening-board-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  width: min(100%, 760px);
  margin: 0 auto 1rem;
}

.opening-board-heading h2 {
  font-size: var(--font-size-xl);
  line-height: 1.35;
}

.opening-reference-line {
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--gold-light);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--font-size-sm);
  text-align: end;
}

.opening-board-wrap {
  width: min(100%, 760px);
  margin-inline: auto;
}

#opening-preview-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid #3f3328;
  border-radius: 8px;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.38);
}

#opening-preview-board .sq {
  position: relative;
  min-width: 0;
}

#opening-preview-board .piece {
  width: 92%;
  height: 92%;
}

#opening-preview-board.theme-walnut .sq-light {
  background: #d8bb8f;
}

#opening-preview-board.theme-walnut .sq-dark {
  background: #8d623d;
}

#opening-preview-board.theme-tournament .sq-light {
  background: #eeeed2;
}

#opening-preview-board.theme-tournament .sq-dark {
  background: #769656;
}

#opening-preview-board.theme-slate .sq-light {
  background: #d9e1e8;
}

#opening-preview-board.theme-slate .sq-dark {
  background: #5f7688;
}

#opening-preview-board.theme-marble .sq-light {
  background: #f4efe5;
}

#opening-preview-board.theme-marble .sq-dark {
  background: #9c9080;
}

#opening-preview-board.theme-blue .sq-light {
  background: #dee3e6;
}

#opening-preview-board.theme-blue .sq-dark {
  background: #8ca2ad;
}

#opening-preview-board.theme-green .sq-light {
  background: #ffffdd;
}

#opening-preview-board.theme-green .sq-dark {
  background: #86a666;
}

#opening-preview-board.theme-purple .sq-light {
  background: #e8dff5;
}

#opening-preview-board.theme-purple .sq-dark {
  background: #9b72cf;
}

#opening-preview-board.theme-red .sq-light {
  background: #f0d8d8;
}

#opening-preview-board.theme-red .sq-dark {
  background: #ba5546;
}

#opening-preview-board.theme-dark .sq-light {
  background: #cccccc;
}

#opening-preview-board.theme-dark .sq-dark {
  background: #555555;
}

#opening-preview-board.theme-ice .sq-light {
  background: #e0f0ff;
}

#opening-preview-board.theme-ice .sq-dark {
  background: #6ea8d9;
}

#opening-preview-board.theme-wood .sq-light {
  background: #e8c887;
}

#opening-preview-board.theme-wood .sq-dark {
  background: #a17a4a;
}

.opening-insights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.opening-insight {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(22, 27, 39, 0.78);
}

.opening-insight h2 {
  margin-bottom: 0.75rem;
  font-size: var(--font-size-lg);
  font-weight: 800;
}

.opening-insight p,
.opening-insight li {
  color: var(--text-secondary);
  line-height: 1.8;
}

.opening-ideas {
  grid-column: 1 / -1;
  border-top: 3px solid #46c98b;
}

.opening-ideas ol {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  list-style: none;
  counter-reset: idea;
}

.opening-ideas li {
  position: relative;
  padding-inline-start: 2rem;
  counter-increment: idea;
}

.opening-ideas li::before {
  content: counter(idea, decimal-leading-zero);
  position: absolute;
  inset-inline-start: 0;
  color: #46c98b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--font-size-xs);
  font-weight: 800;
}

.opening-plan {
  border-top: 3px solid var(--gold);
}

.opening-watch {
  border-top: 3px solid #ef6a73;
}

.opening-source-note {
  max-width: none;
  margin-top: 1rem;
}

.opening-index {
  position: sticky;
  top: 92px;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(22, 27, 39, 0.92);
}

.opening-index h2 {
  margin: 0.15rem 0 0.25rem;
  font-size: var(--font-size-xl);
}

.opening-index > p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.opening-index-list {
  display: grid;
}

.opening-index-list a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.opening-index-list a:last-child {
  border-bottom: 0;
}

.opening-index-list a:hover,
.opening-index-list a.active {
  color: var(--text-primary);
}

.opening-index-list a.active span {
  color: var(--gold);
  font-weight: 800;
}

.opening-index-list small {
  direction: ltr;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 1080px) {
  .opening-detail-layout {
    grid-template-columns: 1fr;
  }

  .opening-index {
    position: static;
  }

  .opening-index-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1rem;
  }
}

@media (max-width: 760px) {
  .opening-detail-section {
    padding: 2.25rem 0 4rem;
  }

  .opening-title-row,
  .opening-board-heading {
    align-items: start;
    flex-direction: column;
  }

  .opening-title-row h1 {
    font-size: var(--font-size-3xl);
  }

  .opening-meta {
    justify-content: start;
  }

  .opening-reference-line {
    text-align: start;
  }

  .opening-insights,
  .opening-ideas ol,
  .opening-index-list {
    grid-template-columns: 1fr;
  }
}
