
.scene { position: relative; }
.scene-expand {
  position: absolute;
  z-index: 2;
  top: 0; 
  inset-inline-end: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  color: var(--sage);
  background: none;
  font: 500 .8125rem/1 var(--font);
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease, transform 150ms ease;
}
.scene-expand:hover { color: var(--ivory); background: var(--field); }
.scene-expand:active { transform: scale(.96); }
.scene-expand[hidden] { display: none; }
.scene-expand svg, .expanded-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.scene-placeholder { grid-area: scene; max-width: 100%; justify-self: center; pointer-events: none; }

.expanded-example {
  box-sizing: border-box;
  width: min(1240px, calc(100vw - 48px));
  max-width: none;
  height: min(920px, calc(100dvh - 32px));
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 24px;
  background: var(--field);
  color: var(--ivory);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .18);
  font: 400 1rem/1.5 var(--font);
  overscroll-behavior: contain;
}
.expanded-example[open] { display: flex; flex-direction: column; }
.expanded-example::backdrop { background: rgba(25, 25, 25, .42); backdrop-filter: blur(6px); }
@media (prefers-color-scheme: dark) { .expanded-example::backdrop { background: rgba(0, 0, 0, .66); } }

.expanded-header { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 16px 12px 32px; border-bottom: 1px solid var(--hair); }
.expanded-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.expanded-heading h2 { margin: 0; color: var(--ivory); font-size: 1.375rem; font-weight: 500; line-height: 1.2; letter-spacing: -.03em; text-wrap: balance; }
.expanded-heading #expanded-description { margin: 0; color: var(--sage); font-size: .8125rem; }
.expanded-close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--field); color: var(--ivory); cursor: pointer; transition: background-color 150ms ease, transform 150ms ease; }
.expanded-close:hover { background: var(--field-hover); }
.expanded-close:active { transform: scale(.96); }
.expanded-close svg { width: 20px; height: 20px; }
.expanded-content { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--hair) transparent; overscroll-behavior: contain; }
.expanded-example .scene-heading { display: none; }
.expanded-example .scene.is-expanded {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: 'stage panel';
  align-items: center;
  justify-items: center;
  gap: 0 32px;
  width: 100%;
  height: 100%;
  min-height: 500px;
  margin: 0;
  padding: 12px 32px 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.expanded-example .scene.is-expanded #stage { grid-area: stage; width: 100%; height: 100%; min-height: 430px; max-width: none; max-height: none; aspect-ratio: auto; margin: 0; }

.expanded-example .scene.is-expanded #panel { grid-area: panel; align-self: start; margin-top: 8vh; width: 100%; max-width: none; max-height: 100%; min-height: 0; overflow: auto; overscroll-behavior: contain; margin: 0; padding: 24px 22px; border-radius: 18px; background: var(--field-lift); animation: none; scrollbar-width: thin; scrollbar-color: var(--hair) transparent; }

.expanded-example .turn-arrow { display: none; }
.expanded-example .tray-more [hidden], .expanded-example .tray-more .pick-label[hidden], .expanded-example .tray-more .try-own[hidden] { display: none; }
.expanded-example .phases { font-size: .8125rem; }
.expanded-example .phases li { padding-inline-end: 6px; }
.expanded-example .caption { margin-top: 10px; text-align: left; font-size: 1rem; }
.expanded-example .controls { width: 100%; margin-top: 20px; gap: 16px; }
.expanded-example .branches { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.expanded-example .controls .branch { width: 100%; min-height: 46px; text-align: left; border-radius: 9px; }
.expanded-example .moves { width: 100%; flex-direction: column; gap: 4px; }
.expanded-example .moves button { width: 100%; justify-content: center; min-height: 46px; border-radius: 9px; }

.expanded-example .scene.is-expanded .steps:not(.loose) { position: relative; width: 100%; height: auto; max-width: none; margin: 22px 0 0; overflow: visible; clip: auto; white-space: normal; font-size: .8125rem; }
.expanded-example .steps .tag { padding-inline: 6px; font-size: .8125rem; }
.expanded-example .steps li { gap: 7px; }
.expanded-footer { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 16px; padding: 2px 32px; border-top: 1px solid var(--hair); color: var(--sage); font-size: .8125rem; }
.expanded-footer a { display: inline-flex; align-items: center; gap: 18px; min-height: 44px; color: var(--mint); font-size: .875rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.expanded-footer a:hover { text-decoration: underline; text-underline-offset: 4px; }

@media (max-width: 899px) {
  
  .scene-expand { left: auto; right: 0; }
  .expanded-example { width: calc(100vw - 20px); height: calc(100dvh - 20px); border-radius: 18px; }
  .expanded-header { gap: 12px; padding: 10px 10px 10px 18px; }
  .expanded-heading h2 { font-size: 1.1875rem; }
  .expanded-heading #expanded-description { max-width: 25ch; font-size: .8125rem; }
  .expanded-example .scene.is-expanded { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; grid-template-areas: 'stage' 'panel'; height: auto; min-height: 0; gap: 16px; padding: 0 16px 20px; }
  .expanded-example .scene.is-expanded #stage { width: 100%; height: min(90vw, 490px); min-height: 300px; }
  .expanded-example .scene.is-expanded #panel { max-width: 440px; max-height: none; overflow: visible; padding: 15px 10px; }
  .expanded-example .caption { text-align: center; font-size: .9375rem; margin-top: 4px; } 
  .expanded-example .phases { font-size: .8125rem; }
  .expanded-example .controls { margin-top: 10px; gap: 10px; }
  .expanded-example .branches { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
  .expanded-example .controls .branch { min-width: 0; min-height: 44px; padding-inline: 5px; text-align: center; font-size: .875rem; }
  .expanded-example .moves { flex-direction: row; flex-wrap: nowrap; }
  .expanded-example .moves button { width: auto; }
  .expanded-example .moves .find { flex: 1; }
  .expanded-example .scene.is-expanded .steps:not(.loose) { max-width: 29ch; margin-inline: auto; }
  .expanded-footer { gap: 12px; padding: 6px 18px; }
  .expanded-footer > span { max-width: 26ch; font-size: .8125rem; }
}

.expanded-example::backdrop { transition: opacity 420ms cubic-bezier(.16, 1, .3, 1); }
@starting-style { .expanded-example[open]::backdrop { opacity: 0; } }
.expanded-example.is-leaving::backdrop { opacity: 0; transition-duration: 300ms; }
@media (prefers-reduced-motion: reduce) {
  .scene-expand, .expanded-close { transition: none; }
  .expanded-example { transition: opacity 160ms ease-out; }
  @starting-style { .expanded-example[open] { opacity: 0; } }
  .expanded-example::backdrop { transition-duration: 160ms; }
}
@media print { .scene-expand, .expanded-example { display: none !important; } }
