/* Learn to Play: lesson pages (docs/reference/learn-to-play.md). Loads after the static
   theme (arcane-pages.css, arcane-pages-content.css) and uses only its tokens. */

/* The hero's one-line answer to the lesson's question. */
.learn-page .hero-lead {
    max-width: 680px;
    margin: 10px 0 0;
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
}

/* ── Layout: the series rail beside the lesson ─────────────────────────── */

/* A lesson is wider than an article: the rail, the prose and the boards share the row, and
   the shared 1180px shell left the rail cramped beside wide margins. The hero matches so
   the two line up. */
body.amx-static-page.learn-page .site-shell,
body.amx-static-page.learn-page .hero-grid-minimal {
    width: min(1480px, calc(100% - 48px));
    max-width: 1480px;
}

/* The static theme's `main` hides its overflow, which makes it a scroll container and stops
   every sticky element inside it (the scenario's narration). `clip` clips the same without
   becoming one. */
body.amx-static-page.learn-page main {
    overflow: clip;
}

.learn-layout {
    display: grid;
    grid-template-columns: minmax(0, 290px) minmax(0, 1fr);
    gap: 40px;
    align-items: start;
    padding-top: 28px;
    padding-bottom: 56px;
}

.learn-article {
    min-width: 0;
}

.learn-article > section {
    margin-top: 40px;
}

.learn-article > section:first-child {
    margin-top: 0;
}

body.amx-static-page .learn-article h2 {
    margin: 0 0 12px;
    font-size: 1.45rem;
}

/* Prose paragraphs, but never a card tile's (the app's tile sizes its own text, and its
   paragraphs inherit from it). */
.learn-article p:not(.card-tile *),
.learn-article li:not(.card-tile *) {
    color: var(--text-color);
    font-size: 1rem;
    line-height: 1.7;
}

.learn-article .section-lead {
    color: var(--text-secondary);
}

/* "You'll need": the recap a reader from a search can follow without the earlier lessons. */
.learn-needs {
    margin: 0 0 32px;
    padding: 16px 18px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
}

body.amx-static-page .learn-needs h2 {
    margin: 0 0 6px;
    font-size: 0.9rem;
    color: var(--accent-light);
}

.learn-needs p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* A plain-language callout inside the prose. */
.learn-tip {
    margin: 20px 0;
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--accent-bg);
    border: 1px solid var(--accent-hover);
}

.learn-tip p {
    margin: 0;
}

.learn-tip strong:first-child {
    color: var(--accent-light);
}

/* ── The series rail ───────────────────────────────────────────────────── */

.learn-rail {
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 16px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--panel-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    scrollbar-gutter: stable;
}

.learn-rail::-webkit-scrollbar {
    width: 8px;
}

.learn-rail::-webkit-scrollbar-track {
    background: transparent;
}

.learn-rail::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--border-color) padding-box;
}

.learn-rail::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted) padding-box;
}

.learn-rail-title {
    display: block;
    margin: 0 0 4px;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 700;
}

.learn-rail-note {
    min-height: 1.2em;
    margin: 0 0 12px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.learn-rail-note a {
    color: var(--accent-light);
}

.learn-rail ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

.learn-rail-unit {
    margin-top: 14px;
}

.learn-rail-unit-name {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 4px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
}

.learn-rail-lesson a {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.35;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.learn-rail-lesson a:hover,
.learn-rail-lesson a:focus-visible {
    background: var(--entry-hover-bg);
    color: var(--text-color);
}

.learn-rail-lesson a[aria-current="page"] {
    background: var(--accent-bg);
    color: var(--accent-light);
    font-weight: 600;
}

.learn-rail-code {
    flex: 0 0 auto;
    min-width: 1.9em;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* The check: a finished lesson, or a unit whose lessons are all finished. */
.learn-check {
    display: inline-block;
    flex: 0 0 auto;
    width: 0.95em;
    height: 0.95em;
    border-radius: 999px;
    background: var(--success-color);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm-1.6 16L5 11.6l1.8-1.8 3.6 3.6 6.8-6.8L19 8.4z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm-1.6 16L5 11.6l1.8-1.8 3.6 3.6 6.8-6.8L19 8.4z'/%3E%3C/svg%3E") center / contain no-repeat;
    vertical-align: -0.12em;
}

.learn-rail-lesson .learn-check,
.learn-rail-unit-name .learn-check {
    visibility: hidden;
}

.learn-rail-lesson.is-done .learn-check,
.learn-rail-unit.is-done > .learn-rail-unit-name .learn-check {
    visibility: visible;
}

.learn-rail-lesson.is-done a {
    color: var(--text-color);
}

/* ── Previous, next and the lesson's foot ──────────────────────────────── */

.learn-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.learn-foot-done {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--success-color);
    font-weight: 600;
}

.learn-foot-note {
    margin: 0;
    color: var(--text-secondary);
}

.learn-foot-note a {
    color: var(--accent-light);
}

.learn-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 24px;
}

.learn-pager a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-color);
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.learn-pager a:hover,
.learn-pager a:focus-visible {
    border-color: var(--accent-hover);
    background: var(--entry-hover-bg);
}

.learn-pager small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.learn-pager-next {
    grid-column: 2;
    text-align: right;
}

/* "Take it further": the hand-offs into the app. */
.learn-further ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.learn-further a {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-color);
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.learn-further a:hover,
.learn-further a:focus-visible {
    border-color: var(--accent-hover);
    background: var(--entry-hover-bg);
}

.learn-further a strong {
    color: var(--accent-light);
}

.learn-further a span {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.learn-quiet-btn {
    padding: 6px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.learn-quiet-btn:hover:not(:disabled),
.learn-quiet-btn:focus-visible {
    background: var(--accent-bg);
    color: var(--accent-light);
}

.learn-quiet-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

/* ── Glossary terms ────────────────────────────────────────────────────── */

.learn-term {
    position: relative;
    border-bottom: 1px dotted var(--accent-hover);
    cursor: help;
}

/* A card named in the prose: underlined like a glossary word, its picture on hover. */
.learn-cardref {
    border-bottom: 1px dotted var(--accent-hover);
    cursor: zoom-in;
}

.learn-cardref:hover,
.learn-cardref:focus-visible {
    border-bottom-style: solid;
    color: var(--accent-light);
}

.learn-term:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 3px;
}

.learn-term-pop {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: max-content;
    /* Never wider than the screen less the 8px either side placeTerm keeps clear. */
    max-width: min(320px, calc(100vw - 16px));
    padding: 10px 12px;
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    background: var(--panel-bg-opaque);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    color: var(--text-color);
    font-size: 0.88rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    white-space: normal;
    cursor: auto;
}

/* The 8px between the word and its definition still counts as the word, so the pointer can
   cross it to reach the link without the definition closing. */
.learn-term-pop::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 10px;
}

/* No room below the word: it opens above, the bridge to the word beneath it. */
.learn-term-pop.is-above {
    top: auto;
    bottom: calc(100% + 8px);
}

.learn-term-pop.is-above::before {
    bottom: auto;
    top: 100%;
}

.learn-term-pop strong {
    color: var(--accent-light);
}

.learn-term-pop a {
    color: var(--accent-light);
    font-size: 0.8rem;
}

/* ── Card pictures and the text tile ───────────────────────────────────── */

.learn-pic {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 488 / 680;
    border-radius: 4.75% / 3.5%;
    overflow: hidden;
    background: var(--bg-tertiary);
}

/* The tile is sized in container units against the picture's width: the box is the
   container, so the tile's own padding and spine scale with it too. */
.learn-pic.is-tile {
    container-type: inline-size;
}

.learn-pic-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

/* A card held to read: a battle's front, a split card or a room sits landscape, its picture
   turned inside the wider box; a flip card or an aftermath half turns in place. */
.learn-pic.is-landscape {
    aspect-ratio: 680 / 488;
}

.learn-pic.is-landscape .learn-pic-img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: calc(100% * 488 / 680);
    height: calc(100% * 680 / 488);
    transform: translate(-50%, -50%) rotate(var(--view-rot, 90deg));
}

.learn-pic.is-turned .learn-pic-img {
    transform: rotate(var(--view-rot, 0deg));
}

/* A card held landscape takes two columns of a card row, and twice a figure's width; turned
   upright (its other face, or rotated) it keeps a card's width, centered. */
.learn-card.is-wide {
    max-width: 460px;
}

.learn-card-row > .learn-card.is-wide {
    grid-column: span 2;
}

.learn-card.is-wide .learn-pic:not(.is-landscape) {
    width: calc(50% - 8px);
    margin: 0 auto;
}

/* Flip or rotate: the app's control (styles/cards.css `.card-action-bar` and its
   `.card-badge.card-flip-btn`, copied as card-preview.css does for the other static pages): a
   bar along the picture's bottom edge holding a 26px square badge, centered. */
.learn-card-frame {
    position: relative;
    border-radius: 4.75% / 3.5%;
    transition: transform 0.18s ease;
}

/* With the bar on it, the whole frame lifts on hover, so the badge moves with the picture. */
.learn-card.has-turn .learn-card-link:hover,
.learn-card.has-turn .learn-card-link:focus-visible {
    transform: none;
}

.learn-card.has-turn .learn-card-frame:hover {
    transform: translateY(-3px);
}

.learn-pic-bar {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.375rem;
    pointer-events: none;
}

.learn-pic-turn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    min-width: 26px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: white;
    cursor: pointer;
    pointer-events: auto;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.learn-pic-turn:hover,
.learn-pic-turn:focus-visible {
    border-color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.08);
}

.learn-pic-turn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
}

/* A flip in progress: the card turns as a whole, and the picture inside it does not turn on
   its own (that rotation, left running while the frame changed shape, was what clipped). */
.learn-card-frame.is-flipping {
    backface-visibility: hidden;
}

.learn-pic.is-swapping .learn-pic-img {
    transition: none;
}

.learn-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 230px;
    margin: 0;
}

.learn-card-link {
    display: block;
    border-radius: 4.75% / 3.5%;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.learn-card-link:hover,
.learn-card-link:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}

.learn-card figcaption {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.learn-card-name {
    color: var(--text-color);
    font-size: 0.88rem;
    font-weight: 600;
}

.learn-card-sub {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.learn-card-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.learn-card-row--small {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}

/* A held card must not raise the phone's own image menu over the closer look. */
.learn-pic[data-learn-preview] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ── A closer look: the card larger ────────────────────────────────────── */

/* Just over the sticky site header (site-header.css, 110). */
.learn-preview {
    z-index: 120;
}

/* Desktop: beside the hovered card, never under the pointer (it would steal the hover). */
.learn-preview--float.is-landscape {
    width: min(440px, 50vw);
}

.learn-preview--float {
    position: fixed;
    display: grid;
    gap: 8px;
    justify-items: center;
    width: min(320px, 40vw);
    pointer-events: none;
    animation: learn-preview-in 0.25s ease-out;
}

.learn-preview--float .learn-preview-pic {
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

/* What a click does, under the card where it covers nothing. */
.learn-preview-caption {
    padding: 6px 10px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    background: var(--panel-bg-opaque);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    color: var(--text-color);
    font-size: 0.8rem;
    text-align: center;
}

@keyframes learn-preview-in {
    from { opacity: 0; transform: scale(0.97); }
}

/* Touch: the card over a dimmed page, with Close and a way into the app beneath it. */
.learn-preview--sheet {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: color-mix(in srgb, var(--bg-color) 86%, transparent);
}

.learn-preview-card {
    display: grid;
    gap: 14px;
    width: min(380px, 100%);
    max-height: 100%;
}

.learn-preview--sheet .learn-preview-pic {
    width: min(100%, calc((100vh - 120px) * 488 / 680));
    margin: 0 auto;
}

.learn-preview--sheet .learn-preview-pic.is-landscape {
    width: 100%;
}

/* The text tile is never turned: a card showing it keeps the upright shape. */
.learn-pic.is-landscape.is-tile {
    aspect-ratio: 488 / 680;
}

.learn-preview-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.learn-preview-actions .button {
    min-height: 40px;
}

[data-learn-card] {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.learn-sym {
    display: inline-block;
    width: 1.05em;
    height: 1.05em;
    margin: 0 0.06em;
    vertical-align: -0.16em;
}

/* The tile: the card drawn from its data, in ArcaneMetriX's own frame: a black border,
   wide on the left where a spine in the card's colors runs. Sized against its own width. */
.learn-tile {
    --spine: #8b949e;
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
    padding: 5cqw 5cqw 6cqw 9cqw;
    background:
        linear-gradient(90deg, var(--spine) 0, var(--spine) 3cqw, transparent 3cqw) no-repeat,
        #0b0e13;
    color: #e6edf3;
    font-family: inherit;
}

.learn-tile--w { --spine: #f3ecd0; }
.learn-tile--u { --spine: #4c8fd6; }
.learn-tile--b { --spine: #8c7f86; }
.learn-tile--r { --spine: #d9573c; }
.learn-tile--g { --spine: #3f9b5a; }
.learn-tile--gold { --spine: #d2a64a; }
.learn-tile--colorless { --spine: #a5adb7; }

.learn-tile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2cqw;
    padding: 1.6cqw 2.6cqw;
    border: 0.5cqw solid color-mix(in srgb, var(--spine) 60%, #30363d);
    border-radius: 2cqw;
    background: #161b22;
}

.learn-tile--legendary .learn-tile-head {
    border-width: 0.9cqw;
    box-shadow: 0 0 0 0.6cqw color-mix(in srgb, var(--spine) 30%, transparent);
}

.learn-tile-name {
    overflow: hidden;
    font-size: 6.2cqw;
    font-weight: 700;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.learn-tile-cost {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 0.6cqw;
}

.learn-tile .learn-sym--cost {
    width: 6cqw;
    height: 6cqw;
    margin: 0;
    vertical-align: 0;
}

.learn-tile-sub {
    padding: 0.8cqw 2.6cqw 0;
    color: #8b949e;
    font-size: 4.6cqw;
}

.learn-tile-art {
    margin: 2.4cqw 0;
    border-radius: 1.6cqw;
    background:
        radial-gradient(circle, color-mix(in srgb, var(--spine) 35%, transparent) 0.5cqw, transparent 0.6cqw) 0 0 / 5cqw 5cqw,
        linear-gradient(160deg, color-mix(in srgb, var(--spine) 22%, #0d1117), #0d1117);
    overflow: hidden;
}

.learn-tile-stars {
    display: block;
    width: 100%;
    height: 100%;
}

.learn-tile-stars polyline {
    fill: none;
    stroke: color-mix(in srgb, var(--spine) 70%, #ffffff);
    stroke-width: 0.5;
    opacity: 0.7;
}

.learn-tile-stars circle {
    fill: #ffffff;
    opacity: 0.85;
}

.learn-tile-type {
    overflow: hidden;
    padding: 1.4cqw 2.6cqw;
    border-radius: 1.6cqw;
    background: #161b22;
    font-size: 4.8cqw;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.learn-tile-rules {
    min-height: 26cqw;
    margin-top: 2cqw;
    padding: 2.2cqw 2.6cqw;
    border-radius: 1.6cqw;
    background: #161b22;
    font-size: 4.6cqw;
    line-height: 1.3;
    overflow: hidden;
}

.learn-tile-rules.is-long {
    font-size: 3.8cqw;
}

.learn-tile-rules p {
    margin: 0 0 1.4cqw;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
}

.learn-tile .learn-sym {
    width: 1em;
    height: 1em;
}

.learn-tile-pt {
    justify-self: end;
    margin-top: -3cqw;
    padding: 0.8cqw 3cqw;
    border: 0.5cqw solid color-mix(in srgb, var(--spine) 60%, #30363d);
    border-radius: 2cqw;
    background: #161b22;
    font-size: 6cqw;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.learn-tile-notice {
    margin-top: 1.4cqw;
    color: #7d8590;
    font-size: 3cqw;
    text-align: center;
}

/* ── Widgets: shared ───────────────────────────────────────────────────── */

.learn-widget {
    margin: 24px 0;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--panel-bg);
}

.learn-widget-title,
.learn-widget > h3 {
    margin: 0 0 6px;
    font-size: 1rem;
}

.learn-widget-intro {
    margin: 0 0 14px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.learn-widget-fallback {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.learn-widget-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

/* Label and value pairs (style rules 9: no badges for data). */
.learn-facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 6px 16px;
    margin: 12px 0 0;
}

.learn-facts dt {
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.learn-facts dd {
    margin: 0;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 600;
}

/* ── Scenario player ───────────────────────────────────────────────────── */

.learn-scn-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px 16px;
}

.learn-scn-title {
    margin: 0;
    font-size: 1rem;
}

.learn-scn-goal {
    flex: 1 1 100%;
    order: 3;
    margin: 4px 0 0;
    color: var(--text-color);
}

.learn-scn-goal strong {
    color: var(--accent-light);
}

.learn-scn-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.learn-scn-hints {
    margin: 12px 0 0;
    padding: 10px 14px 10px 32px;
    border-radius: 10px;
    background: var(--accent-bg);
    color: var(--text-color);
}

.learn-scn-hints li {
    font-size: 0.9rem;
}

/* "Hover over any card": one quiet line under the title, so a reader knows the cards open up. */
.learn-scn-look {
    flex: 1 1 100%;
    order: 4;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* The board reads top to bottom: the opponent's panel, the turn, your panel. Each panel is
   laid out the same way, so learning to read one is learning to read both. */
/* A question-only puzzle draws no board (learn-scenario.js). */
.learn-scn-table[hidden] {
    display: none;
}

.learn-scn-table {
    --scn-card: 88px;
    --scn-card-small: 48px;
    --scn-card-tiny: 34px;
    position: relative;
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.learn-scn-side {
    display: grid;
    gap: 12px;
    padding: 12px 14px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: color-mix(in srgb, var(--bg-tertiary) 80%, transparent);
}

/* The player whose turn it is: the panel lifts a little, its name takes the accent. */
.learn-scn-side.is-active {
    border-color: var(--accent-hover);
}

.learn-scn-area {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: stretch;
}

/* A zone: a small name over the cards in it, on a slightly sunken surface. */
.learn-scn-zone {
    min-width: 0;
    padding: 8px 10px 10px;
    border-radius: 10px;
    background: var(--card-bg);
}

.learn-scn-field {
    display: grid;
    gap: 10px;
    min-height: calc(var(--scn-card) * 680 / 488);
    align-content: start;
}

.learn-scn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    min-height: 0;
}

.learn-scn-empty {
    align-self: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.learn-scn-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 14px;
}

.learn-scn-player {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    padding: 4px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    font: inherit;
}

button.learn-scn-player {
    cursor: pointer;
}

button.learn-scn-player:hover,
button.learn-scn-player:focus-visible {
    border-color: var(--accent-hover);
}

.learn-scn-player-name {
    font-size: 1rem;
}

.learn-scn-player.is-active .learn-scn-player-name {
    color: var(--accent-light);
}

.learn-scn-life {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.learn-scn-life-n {
    color: var(--text-color);
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.learn-scn-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.learn-scn-fact {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
}

button.learn-scn-fact {
    cursor: pointer;
}

button.learn-scn-fact:hover,
button.learn-scn-fact:focus-visible {
    border-color: var(--accent-hover);
}

.learn-scn-fact strong {
    color: var(--text-color);
}

.learn-scn-piles {
    display: grid;
    gap: 12px;
    align-content: start;
    min-width: 132px;
    max-width: 216px;
}

.learn-scn-pile-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.learn-scn-row--pile {
    gap: 6px;
}

/* A card on the table: tapped turns sideways, a fresh arrival sits a little dim. */
.learn-scn-card {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: var(--scn-card);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    text-align: center;
}

.learn-scn-card.is-small {
    width: var(--scn-card-small);
}

button.learn-scn-card {
    cursor: pointer;
}

.learn-scn-card .learn-pic {
    border-radius: 6px;
    transition: transform 0.45s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

button.learn-scn-card:hover .learn-pic,
button.learn-scn-card:focus-visible .learn-pic {
    box-shadow: 0 0 0 2px var(--accent-color);
}

button.learn-scn-card:focus-visible {
    outline: none;
}

button.learn-scn-card:focus-visible .learn-pic {
    outline: 2px solid var(--accent-color);
    outline-offset: 3px;
}

/* Turned sideways, a card needs the width of its height: the margins hold that room. */
.learn-scn-card.is-tapped {
    margin: 0 calc(var(--scn-card) * 0.2);
}

.learn-scn-card.is-small.is-tapped {
    margin: 0 calc(var(--scn-card-small) * 0.2);
}

.learn-scn-card.is-tapped .learn-pic {
    transform: rotate(90deg) scale(0.86);
}

.learn-scn-card.is-sick .learn-pic {
    opacity: 0.72;
}

.learn-scn-card.is-attacking .learn-pic {
    box-shadow: 0 0 0 2px var(--danger-color);
}

.learn-scn-card.is-blocking .learn-pic {
    box-shadow: 0 0 0 2px var(--info-color);
}

.learn-scn-card.is-highlight .learn-pic,
.learn-scn-player.is-highlight,
.learn-scn-fact.is-highlight,
.learn-scn-stack-item.is-highlight {
    box-shadow: 0 0 0 2px var(--warning-color), 0 0 14px color-mix(in srgb, var(--warning-color) 55%, transparent);
    animation: learn-glow 1.6s ease-in-out infinite;
}

@keyframes learn-glow {
    50% { box-shadow: 0 0 0 2px var(--warning-color), 0 0 4px color-mix(in srgb, var(--warning-color) 30%, transparent); }
}

.learn-scn-note {
    max-width: 100%;
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.25;
}

/* The turn, between the two panels: whose turn and the step in words, then the turn's five
   parts as one track, filled up to where the turn is. Parts with several steps carry a dot per
   step; the words say which. */
.learn-scn-middle {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px 24px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.learn-scn-when {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    min-width: 0;
}

.learn-scn-when strong {
    color: var(--accent-light);
    font-size: 0.9rem;
}

.learn-scn-when-step {
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 600;
}

.learn-scn-phases {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Ahead of the turn: readable but quiet. Behind it: dimmer, done. Here: the accent. (The
   doubled class outranks `.learn-article li`, which colors every list item in a lesson.) */
.learn-scn-phase.learn-scn-phase {
    color: var(--text-secondary);
}

.learn-scn-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    min-height: 44px;
    padding: 6px 4px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    text-align: center;
}

.learn-scn-phase.learn-scn-phase.is-past {
    color: var(--text-muted);
}

.learn-scn-phase.learn-scn-phase.is-current {
    background: var(--accent-bg);
    box-shadow: inset 0 0 0 1px var(--accent-hover);
    color: var(--accent-light);
}

.learn-scn-phase-name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.learn-scn-phase-dots {
    display: flex;
    gap: 4px;
}

.learn-scn-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--border-color);
}

.learn-scn-dot.is-past {
    background: var(--text-muted);
}

.learn-scn-dot.is-current {
    background: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-bg);
}

.learn-scn-stack-box {
    grid-column: 1 / -1;
}

/* ── Card backs: libraries and hands you cannot see ─────────────────────── */

.learn-back {
    display: grid;
    place-items: center;
    border: 1px solid var(--border-primary);
    background:
        radial-gradient(circle at 50% 45%, var(--accent-bg) 0 30%, transparent 62%),
        linear-gradient(160deg, var(--bg-tertiary), var(--bg-color));
    box-shadow: inset 0 0 0 3px var(--bg-color), inset 0 0 0 4px var(--border-color);
}

.learn-back-mark {
    width: 46%;
    aspect-ratio: 1;
    background: var(--accent-light);
    opacity: 0.8;
    -webkit-mask: url("/public/assets/brand/arcane-metrix-mark.svg") center / contain no-repeat;
    mask: url("/public/assets/brand/arcane-metrix-mark.svg") center / contain no-repeat;
}

/* A library: three backs offset up and to the right, so it reads as a pile. */
.learn-backs-pile {
    position: relative;
    display: block;
    width: var(--scn-card-small, 60px);
    aspect-ratio: 488 / 680;
    margin: 0 6px 6px 0;
}

.learn-backs-pile .learn-back {
    position: absolute;
    inset: 0;
    transform: translate(calc(var(--pile-i, 0) * 3px), calc(var(--pile-i, 0) * -3px));
}

.learn-backs-pile.is-empty {
    border: 1px dashed var(--border-color);
    border-radius: 6px;
}

/* A hand you cannot see: backs overlapping, as a held hand. */
.learn-backs-fan {
    display: flex;
    padding-right: calc(var(--scn-card-small, 60px) * 0.55);
}

.learn-backs-fan .learn-back {
    flex: 0 0 auto;
    width: var(--scn-card-small, 60px);
    margin-right: calc(var(--scn-card-small, 60px) * -0.55);
    border-radius: 6px;
}

.learn-scn-library,
.learn-scn-hidden-hand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
}

button.learn-scn-library {
    cursor: pointer;
}

button.learn-scn-library:hover,
button.learn-scn-library:focus-visible {
    border-color: var(--accent-hover);
}

.learn-scn-library.is-highlight {
    box-shadow: 0 0 0 2px var(--warning-color), 0 0 14px color-mix(in srgb, var(--warning-color) 55%, transparent);
    animation: learn-glow 1.6s ease-in-out infinite;
}

.learn-scn-count {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.learn-scn-stack {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.learn-scn-stack-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    font: inherit;
    text-align: left;
}

button.learn-scn-stack-item {
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

button.learn-scn-stack-item:hover,
button.learn-scn-stack-item:focus-visible {
    border-color: var(--accent-color);
    background: var(--accent-bg);
}

.learn-scn-stack-item.is-top {
    border-color: var(--accent-hover);
}

.learn-scn-stack-item .learn-pic {
    flex: 0 0 auto;
}

.learn-scn-stack-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.learn-scn-stack-text small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.learn-pic--small {
    width: 100%;
}

.learn-pic--tiny {
    width: 34px;
}

/* The narration: above the board, in a panel of its own, and pinned under the site's bar
   while the reader scrolls the board, so what to do and Continue never leave the screen. */
.learn-scn-dialog {
    position: sticky;
    top: 68px;
    z-index: 6;
    margin-top: 14px;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--panel-bg-opaque);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.learn-scn-say--done .learn-check {
    margin-top: 0.3em;
}

.learn-scn-dialog > :last-child {
    margin-bottom: 0;
}

.learn-scn-say {
    margin: 0 0 10px;
    color: var(--text-color);
    line-height: 1.6;
}

.learn-scn-say--good {
    color: var(--text-color);
}

.learn-scn-say--retry {
    color: var(--warning-color);
}

.learn-scn-say--done {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--success-color);
    font-weight: 600;
}

.learn-scn-ask {
    margin: 0 0 10px;
    color: var(--accent-light);
}

.learn-scn-small {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.learn-scn-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}


/* ── Anatomy ───────────────────────────────────────────────────────────── */

.learn-anatomy {
    display: grid;
    grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.learn-anatomy-card {
    position: relative;
}

.learn-anatomy-boxes {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.learn-anatomy-box {
    position: absolute;
    border: 2px solid transparent;
    border-radius: 6px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.learn-anatomy-box.is-on {
    border-color: var(--warning-color);
    background: color-mix(in srgb, var(--warning-color) 18%, transparent);
}

.learn-anatomy-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.learn-anatomy-part,
.learn-scn-choice,
.learn-sorter-choice,
.learn-turn-step,
.learn-zone {
    padding: 7px 12px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    background: var(--button-bg);
    color: var(--button-text);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.learn-anatomy-part:hover,
.learn-anatomy-part:focus-visible,
.learn-scn-choice:hover:not(:disabled),
.learn-scn-choice:focus-visible,
.learn-anatomy-part[aria-pressed="true"],
.learn-sorter-choice:hover:not(:disabled),
.learn-sorter-choice:focus-visible,
.learn-turn-step:hover,
.learn-turn-step:focus-visible,
.learn-turn-step.is-current,
.learn-zone:hover,
.learn-zone:focus-visible,
.learn-zone[aria-pressed="true"] {
    border-color: var(--accent-color);
    background: var(--accent-bg);
    color: var(--accent-light);
}

.learn-anatomy-detail {
    margin: 0;
    line-height: 1.65;
}

/* ── Sorter ────────────────────────────────────────────────────────────── */

.learn-sorter {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 18px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.learn-sorter-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.learn-sorter-choices {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

.learn-sorter-choice {
    padding: 5px 9px;
    font-size: 0.8rem;
}

.learn-sorter-choice.is-right {
    border-color: var(--success-color);
    color: var(--success-color);
}

.learn-sorter-choice:disabled:not(.is-right) {
    opacity: 0.4;
    cursor: default;
}

.learn-sorter-note {
    min-height: 1.2em;
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.45;
    text-align: center;
}

.learn-sorter-item.is-placed .learn-sorter-note {
    color: var(--text-color);
}

.learn-sorter-status {
    margin: 16px 0 0;
    color: var(--text-secondary);
}

/* ── Turn ──────────────────────────────────────────────────────────────── */

.learn-turn {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.learn-turn-phase-name {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
}

.learn-turn-steps {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.learn-turn-step {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.8rem;
    text-align: left;
}

.learn-turn-detail {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.learn-turn-detail h4 {
    margin: 0 0 4px;
}

.learn-turn-detail p {
    margin: 0;
}

.learn-turn-where {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ── Curve ─────────────────────────────────────────────────────────────── */

.learn-curve {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
}

.learn-curve-chart {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    align-items: end;
    height: 180px;
}

.learn-curve-bar {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    gap: 4px;
}

.learn-curve-fill {
    width: 100%;
    min-height: 2px;
    border-radius: 6px 6px 2px 2px;
    background: var(--accent-gradient);
    transition: height 0.25s ease;
}

.learn-curve-n {
    order: -1;
    color: var(--text-color);
    font-size: 0.85rem;
    font-weight: 700;
}

.learn-curve-mv {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.learn-curve-sliders {
    display: grid;
    gap: 8px;
}

.learn-curve-field {
    display: grid;
    grid-template-columns: 3.5em minmax(0, 1fr) 2.2em;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.learn-curve-field output {
    color: var(--text-color);
    font-weight: 700;
    text-align: right;
}

.learn-curve-field--lands {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

/* ── Mulligan ──────────────────────────────────────────────────────────── */

.learn-mull-hand {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.learn-mull-card {
    padding: 0;
    border: 0;
    background: transparent;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

button.learn-mull-card {
    cursor: pointer;
}

button.learn-mull-card:hover .learn-pic,
button.learn-mull-card:focus-visible .learn-pic {
    box-shadow: 0 0 0 2px var(--accent-color);
}

.learn-mull-card.is-chosen {
    opacity: 0.45;
    transform: translateY(8px);
}

.learn-mull-info {
    margin: 14px 0 0;
}

/* ── Combat ────────────────────────────────────────────────────────────── */

.learn-combat {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.learn-combat-side {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.learn-combat-side legend {
    padding: 0 6px;
    color: var(--accent-light);
    font-weight: 700;
}

.learn-combat-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.learn-combat-num {
    display: grid;
    gap: 4px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.learn-combat-num input {
    width: 72px;
    padding: 6px 8px;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-color);
    font: inherit;
}

.learn-combat-kws {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 4px 10px;
}

.learn-combat-kw,
.learn-combat-blocked {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    font-size: 0.9rem;
}

.learn-combat-blocked {
    margin: 14px 0 0;
}

.learn-combat-result {
    margin-top: 14px;
}

.learn-combat-log {
    margin: 0;
    padding-left: 20px;
}

.learn-combat-illegal {
    margin: 0;
    color: var(--warning-color);
}

/* ── Stack ─────────────────────────────────────────────────────────────── */

.learn-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.learn-stack-palette,
.learn-stack-pile {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.learn-stack-add,
.learn-stack-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    font: inherit;
    text-align: left;
}

.learn-stack-add {
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.learn-stack-add:hover:not(:disabled),
.learn-stack-add:focus-visible {
    border-color: var(--accent-color);
    background: var(--accent-bg);
}

.learn-stack-add:disabled {
    opacity: 0.45;
    cursor: default;
}

.learn-stack-add span,
.learn-stack-item span {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.learn-stack-add small,
.learn-stack-item small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.learn-stack-item.is-top {
    border-color: var(--accent-hover);
}

.learn-stack-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.learn-stack-log {
    margin: 0;
    padding-left: 20px;
}

.learn-stack-log li {
    font-size: 0.9rem;
}

/* ── Layers ────────────────────────────────────────────────────────────── */

.learn-layers {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
}

.learn-layers-effects,
.learn-layers-steps {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.learn-layers-effect {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
}

.learn-layers-effect label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.learn-layers-effect label span {
    display: flex;
    flex-direction: column;
}

.learn-layers-effect small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.learn-layers-steps li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.9rem;
}

.learn-layers-steps strong {
    color: var(--accent-light);
    font-size: 0.8rem;
}

.learn-layers-result-title {
    margin: 14px 0 0;
}

/* ── Colors and zones ──────────────────────────────────────────────────── */

.learn-colors-wrap {
    display: grid;
    grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.learn-colors {
    position: relative;
    width: 240px;
    height: 240px;
    margin: 0 auto;
}

.learn-color {
    --angle: calc(var(--i) * 72deg - 90deg);
    position: absolute;
    left: calc(50% + cos(var(--angle)) * 88px - 34px);
    top: calc(50% + sin(var(--angle)) * 88px - 34px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 68px;
    padding: 6px 0;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.learn-color:hover,
.learn-color:focus-visible,
.learn-color[aria-pressed="true"] {
    border-color: var(--accent-hover);
    background: var(--accent-bg);
    color: var(--text-color);
}

.learn-colors-detail h4 {
    margin: 0 0 4px;
}

.learn-zones {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.learn-zones-detail {
    margin: 14px 0 0;
    line-height: 1.65;
}


/* ── The board, compact: a folded opponent, a hidden hand and mana in the bar ── */

.learn-scn-card.is-tiny {
    width: var(--scn-card-tiny);
}

/* The opponent on your turn: one strip. Hovering opens their whole side over the board. */
.learn-scn-side.is-folded {
    position: relative;
    gap: 8px;
    padding: 10px 14px;
}

.learn-scn-strip {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.learn-scn-strip .learn-scn-row {
    gap: 8px;
    align-items: center;
}

.learn-scn-strip-facts {
    display: flex;
    gap: 14px;
    margin-left: auto;
}

.learn-scn-side.is-pop {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 7;
    background: var(--panel-bg-opaque);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
    animation: learn-preview-in 0.25s ease-out;
}

.learn-scn-unfold {
    margin-left: 4px;
}

/* A hidden hand in its owner's bar: small backs and the count. */
.learn-scn-bar-hand {
    --scn-card-small: 22px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.learn-scn-bar-hand .learn-back {
    border-radius: 3px;
    box-shadow: none;
}

.learn-scn-bar-hand .learn-back-mark {
    width: 60%;
}

.learn-scn-facts {
    align-items: center;
}

/* The mana pool: where tapped lands' mana waits until a spell spends it. */
.learn-scn-pool {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
}

.learn-scn-pool-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.learn-scn-pool-syms {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-height: 22px;
}

.learn-scn-pool-syms .learn-sym {
    width: 20px;
    height: 20px;
}

.learn-scn-pool-syms.is-filling {
    animation: learn-scn-pulse 0.8s ease-out 0.5s;
}

/* ── Dragging a card where it goes ─────────────────────────────────────── */

.learn-scn-card.is-draggable {
    cursor: grab;
    touch-action: none;
}

.learn-scn-card.is-lifted .learn-pic {
    opacity: 0.35;
}

.learn-scn-drag {
    position: fixed;
    z-index: 130;
    pointer-events: none;
    transform: rotate(-4deg) scale(1.06);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

/* While a card is held, every place it could go is outlined; the one under it is lit. */
.learn-scn-table.is-dragging [data-drop] {
    outline: 2px dashed var(--accent-hover);
    outline-offset: -2px;
}

.learn-scn-table.is-dragging [data-drop].is-drop-over {
    outline-color: var(--accent-color);
    background: var(--accent-bg);
}

.learn-scn-middle {
    position: relative;
}

.learn-scn-stack-box.is-empty {
    display: none;
}

/* The empty stack appears over the turn track while a card is held, without moving anything. */
.learn-scn-table.is-dragging .learn-scn-stack-box.is-empty {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--panel-bg-opaque);
}

/* A spell passing the stack before the stack is taught: shown over the turn track for its
   quarter second there, so nothing below moves. */
.learn-scn-stack-box.is-transit {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 6px 12px;
    border-radius: 12px;
    background: var(--panel-bg-opaque);
}

.learn-scn-stack-box.is-transit .learn-scn-pile-label {
    margin: 0;
}

.learn-scn-stack-box.is-transit .learn-scn-stack {
    min-width: 220px;
}

.learn-scn-table.is-dragging .learn-scn-stack-box.is-empty .learn-scn-pile-label {
    margin: 0;
}

/* ── Movement: the board changes as it would at a table ───────────────── */

.learn-scn-float {
    position: fixed;
    z-index: 130;
    pointer-events: none;
}

/* Mana on its way from a tapped permanent to the pool (learn.js floatMana), and the pool's
   symbol settling as it lands. */
.learn-mana-float {
    position: fixed;
    z-index: 130;
    display: inline-flex;
    gap: 2px;
    pointer-events: none;
}

.learn-mana-float .learn-sym {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 0 6px var(--accent-color));
}

.learn-scn-pool-syms img.is-landing,
.learn-demo-pool img.is-landing {
    animation: learn-mana-land 0.35s ease-out;
}

@keyframes learn-mana-land {
    0% { scale: 1.5; filter: drop-shadow(0 0 8px var(--accent-color)); }
}

/* Tapping and untapping: an arrow over the card shows which way it turns. */
.learn-scn-cue {
    position: absolute;
    top: calc(var(--scn-card) * 680 / 488 / 2 - 20px);
    left: calc(50% - 20px);
    z-index: 3;
    width: 40px;
    height: 40px;
    padding: 6px;
    border-radius: 999px;
    background: var(--panel-bg-opaque);
    pointer-events: none;
    animation: learn-scn-cue 1s ease-out forwards;
}

.learn-scn-card.is-small .learn-scn-cue,
.learn-scn-card.is-tiny .learn-scn-cue {
    display: none;
}

.learn-scn-cue svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: var(--accent-light);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.learn-scn-cue--untap svg {
    transform: scaleX(-1);
}

@keyframes learn-scn-cue {
    0% { opacity: 0; transform: scale(0.7) rotate(-40deg); }
    25% { opacity: 1; transform: scale(1) rotate(0deg); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: scale(1) rotate(20deg); }
}

.learn-scn-cue--untap {
    animation-name: learn-scn-cue-back;
}

@keyframes learn-scn-cue-back {
    0% { opacity: 0; transform: scale(0.7) rotate(40deg); }
    25% { opacity: 1; transform: scale(1) rotate(0deg); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: scale(1) rotate(-20deg); }
}

/* An attack: the creature shoves toward the other player, then waits a little forward. */
.learn-scn-card.is-attacking .learn-pic {
    translate: 0 -8px;
}

.learn-scn-side--opponent .learn-scn-card.is-attacking .learn-pic {
    translate: 0 8px;
}

.learn-scn-card.is-charging .learn-pic {
    animation: learn-scn-charge 0.55s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.learn-scn-side--opponent .learn-scn-card.is-charging .learn-pic {
    animation-name: learn-scn-charge-down;
}

@keyframes learn-scn-charge {
    0% { translate: 0 0; }
    45% { translate: 0 -26px; }
    100% { translate: 0 -8px; }
}

@keyframes learn-scn-charge-down {
    0% { translate: 0 0; }
    45% { translate: 0 26px; }
    100% { translate: 0 8px; }
}

.learn-scn-card.is-stepping .learn-pic {
    animation: learn-scn-step 0.45s ease-out;
}

@keyframes learn-scn-step {
    40% { scale: 1.08; }
}

/* Damage: a red flash on the card. */
.learn-scn-card.is-hit .learn-pic {
    animation: learn-scn-hit 0.7s ease-out;
}

@keyframes learn-scn-hit {
    0%, 30% { box-shadow: 0 0 0 3px var(--danger-color), 0 0 18px var(--danger-color); }
}

/* A counter or a new power and toughness: the note pops (the cover has its own pulse). */
.learn-scn-card.is-changed .learn-scn-note {
    animation: learn-scn-pulse 0.7s ease-out;
}

.learn-scn-card.is-arriving .learn-pic {
    animation: learn-demo-arrive 0.45s ease-out;
}

@keyframes learn-scn-pulse {
    40% { scale: 1.25; }
}

/* Life: the figure blinks and pulses, red for a loss, green for a gain. */
.learn-scn-life-n {
    display: inline-block;
}

.learn-scn-life-n.is-loss {
    animation: learn-scn-loss 1.1s ease-out;
}

.learn-scn-life-n.is-gain {
    animation: learn-scn-gain 1.1s ease-out;
}

@keyframes learn-scn-loss {
    0%, 30%, 60% { color: var(--danger-color); scale: 1.35; }
    15%, 45% { color: var(--text-color); scale: 1.1; }
}

@keyframes learn-scn-gain {
    0%, 30%, 60% { color: var(--success-color); scale: 1.35; }
    15%, 45% { color: var(--text-color); scale: 1.1; }
}

/* A card dropped in the wrong place, back home: it shakes and flashes red. */
.learn-scn-card.is-rejected .learn-pic {
    animation: learn-scn-reject 0.6s ease-out;
}

@keyframes learn-scn-reject {
    0%, 60% { box-shadow: 0 0 0 3px var(--danger-color), 0 0 16px color-mix(in srgb, var(--danger-color) 60%, transparent); }
    30% { box-shadow: 0 0 0 1px var(--danger-color); }
    10% { translate: -7px 0; }
    25% { translate: 7px 0; }
    40% { translate: -5px 0; }
    55% { translate: 5px 0; }
    70% { translate: -2px 0; }
    85%, 100% { translate: 0 0; }
}

/* A new warning blinks as it appears, so the eye goes to it. */
.learn-scn-say--retry.is-new {
    border-radius: 6px;
    animation: learn-scn-note 1s ease-out;
}

@keyframes learn-scn-note {
    0%, 40% { background: color-mix(in srgb, var(--warning-color) 22%, transparent); }
    20%, 60% { background: transparent; }
}

/* Actions beside your hand (Go to Combat and the like): every play the step takes, in one
   place on the board. */
.learn-scn-actions {
    padding: 8px 10px 10px;
    border-radius: 10px;
    background: var(--card-bg);
}

.learn-scn-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* A line that can no longer work, and the way back to the start. */
.learn-scn-dead-end {
    display: grid;
    justify-items: start;
    gap: 8px;
    margin-top: 6px;
}

/* ── Ability cards: a triggered or activated ability waiting on the stack ── */

.learn-pic.learn-ability {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--accent-hover);
    border-radius: 6px;
    background: var(--panel-bg-opaque);
}

.learn-ability-art {
    position: relative;
    display: block;
    flex: 0 0 38%;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.learn-ability-art img,
.learn-ability-art svg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 22%;
}

.learn-ability-art svg {
    padding: 8%;
    fill: var(--accent-light);
    stroke: var(--accent-light);
}

.learn-ability-kind {
    padding: 0.35em 0.5em;
    background: var(--accent-bg);
    color: var(--accent-light);
    font-size: max(8px, 9cqw);
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

.learn-ability-source {
    padding: 0.3em 0.5em 0;
    color: var(--text-secondary);
    font-size: max(7px, 8cqw);
    line-height: 1.2;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.learn-ability-text {
    flex: 1 1 auto;
    padding: 0.35em 0.5em 0.5em;
    overflow: hidden;
    color: var(--text-color);
    font-size: max(7px, 9cqw);
    line-height: 1.3;
}

.learn-ability-text .learn-sym {
    width: 1em;
    height: 1em;
    vertical-align: -0.12em;
}

/* In a walkthrough's stack list, an ability's row is set apart from a spell's. */
.learn-scn-stack-item.is-ability {
    border-style: dashed;
}

.learn-pic--tiny.learn-ability .learn-ability-kind,
.learn-pic--tiny.learn-ability .learn-ability-source,
.learn-pic--tiny.learn-ability .learn-ability-text {
    display: none;
}

.learn-pic--tiny.learn-ability .learn-ability-art {
    flex-basis: 100%;
}

/* ── The stack as a pile, and spells pointing at their targets ─────────── */

/* Demos: each spell lies on the one before it, a quarter card lower and a little to the
   right, so every name shows and the top one (last in, first to resolve) is seen whole. */
.learn-demo-zone--stack .learn-demo-cards {
    --stack-step: calc(var(--demo-card) * 0.24);
    position: relative;
    display: block;
    min-width: calc(var(--demo-card) + 12px);
    min-height: calc(var(--demo-card) * 680 / 488 + (var(--stack-n, 1) - 1) * var(--stack-step) + 2.6em);
}

.learn-demo-card.is-stacked {
    position: absolute;
    top: calc(var(--stack-i, 0) * var(--stack-step));
    left: calc(var(--stack-i, 0) * 6px);
    margin: 0;
}

.learn-demo-card.is-buried .learn-demo-note {
    display: none;
}

.learn-demo-card.is-stacked .learn-demo-face {
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.45);
}

/* Walkthroughs: the stack's rows, bottom first, each stepped right and laid over the one
   below; the top row, last, is raised. */
.learn-scn-stack li {
    position: relative;
    z-index: var(--stack-i, 0);
    margin-left: calc(var(--stack-i, 0) * 14px);
}

.learn-scn-stack li + li {
    margin-top: -4px;
}

.learn-scn-stack-item {
    box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.35);
}

/* A target: an amber arrow from the spell, and an amber ring on what it points at. */
.learn-arrow--target {
    filter: drop-shadow(0 0 3px color-mix(in srgb, var(--warning-color) 55%, transparent));
}

.learn-arrow--target .learn-arrow-line {
    stroke: var(--warning-color);
}

.learn-arrow--target .learn-arrow-dot,
.learn-arrow--target .learn-arrow-head {
    fill: var(--warning-color);
}

/* An attack on a permanent: a red arrow from the attacker (its outline's color) and a red
   ring on the planeswalker or battle it goes at. */
.learn-arrow--attack {
    filter: drop-shadow(0 0 3px color-mix(in srgb, var(--danger-color) 55%, transparent));
}

.learn-arrow--attack .learn-arrow-line {
    stroke: var(--danger-color);
}

.learn-arrow--attack .learn-arrow-dot,
.learn-arrow--attack .learn-arrow-head {
    fill: var(--danger-color);
}

.learn-scn-card.is-attacked .learn-pic,
.learn-demo-card.is-attacked .learn-demo-face {
    box-shadow: 0 0 0 2px var(--danger-color), 0 0 14px color-mix(in srgb, var(--danger-color) 45%, transparent);
}

.learn-scn-card.is-targeted .learn-pic,
.learn-demo-card.is-targeted .learn-demo-face,
.learn-scn-player.is-targeted,
.learn-scn-stack-item.is-targeted {
    box-shadow: 0 0 0 2px var(--warning-color), 0 0 14px color-mix(in srgb, var(--warning-color) 50%, transparent);
}

/* ── Power and toughness as they stand, and block arrows ───────────────── */

/* A board card's picture is the container its cover is sized against. */
.learn-scn-card .learn-pic,
.learn-demo-face .learn-pic {
    container-type: inline-size;
}

/* Over the printed box (lower right of a modern frame), a little larger so it reads at board
   size: green above the printed value, red below (damage marked, or a creature shrunk). */
.learn-pt-cover {
    position: absolute;
    right: 3.5%;
    bottom: 5.5%;
    z-index: 2;
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    min-width: 24%;
    padding: 0.12em 0.4em;
    border: 1px solid var(--border-primary);
    border-radius: 0.4em;
    background: var(--panel-bg-opaque);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
    color: var(--text-color);
    font-size: max(10px, 14cqw);
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

/* Counters: badges sitting in the art box, the way players put dice on a card. */
.learn-counters {
    position: absolute;
    top: 22%;
    left: 50%;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25em;
    width: 84%;
    font-size: max(9px, 12cqw);
    transform: translateX(-50%);
    pointer-events: none;
}

.learn-counter {
    display: inline-flex;
    align-items: baseline;
    gap: 0.2em;
    padding: 0.15em 0.45em;
    border: 1px solid var(--border-primary);
    border-radius: 999px;
    background: var(--panel-bg-opaque);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    color: var(--text-color);
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.learn-counter.is-plus {
    border-color: var(--success-color);
    color: var(--success-color);
}

.learn-counter.is-minus {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.learn-counter-n {
    color: var(--text-color);
}

/* A +1/+1 and a -1/-1 meeting: they slide together over the art and burst. */
.learn-counter-cancel {
    position: absolute;
    top: 22%;
    left: 0;
    right: 0;
    z-index: 3;
    height: 2em;
    font-size: max(9px, 12cqw);
    pointer-events: none;
}

.learn-counter-cancel .learn-counter {
    position: absolute;
    top: 0;
}

.learn-counter--left {
    left: 4%;
    animation: learn-counter-in-left 0.55s ease-in forwards;
}

.learn-counter--right {
    right: 4%;
    animation: learn-counter-in-right 0.55s ease-in forwards;
}

@keyframes learn-counter-in-left {
    to { left: calc(50% - 2.6em); opacity: 0.2; scale: 0.8; }
}

@keyframes learn-counter-in-right {
    to { right: calc(50% - 2.6em); opacity: 0.2; scale: 0.8; }
}

.learn-counter-burst {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1em;
    height: 1em;
    border-radius: 999px;
    background: radial-gradient(circle, var(--warning-color), transparent 70%);
    opacity: 0;
    transform: translate(-50%, -50%);
    animation: learn-counter-burst 0.45s ease-out 0.5s forwards;
}

@keyframes learn-counter-burst {
    0% { opacity: 1; width: 0.5em; height: 0.5em; }
    100% { opacity: 0; width: 3.5em; height: 3.5em; }
}

.learn-counters.is-changing {
    animation: learn-pt-change 0.9s ease-out;
}

/* On a tapped card the cover turns with the card to where the box now is, then back upright,
   so the figures always read the right way up. */
.learn-scn-card.is-tapped .learn-pt-cover,
.learn-demo-card.is-tapped .learn-pt-cover {
    rotate: -90deg;
}

.learn-pt-cover--loyalty,
.learn-pt-cover--defense {
    min-width: 16%;
}

/* A planeswalker's loyalty reads like its printed shield: a little rounder. */
.learn-pt-cover--loyalty {
    border-radius: 0.5em 0.5em 0.9em 0.9em;
}

.learn-pt-slash {
    margin: 0 0.06em;
    color: var(--text-muted);
}

.learn-pt-n.is-up {
    color: var(--success-color);
}

.learn-pt-n.is-down {
    color: var(--danger-color);
}

.learn-pt-cover.is-changing {
    animation: learn-pt-change 0.9s ease-out;
}

@keyframes learn-pt-change {
    0%, 35% {
        scale: 1.35;
        box-shadow: 0 0 0 2px var(--warning-color), 0 0 12px var(--warning-color);
    }
}

/* A block: the blocker and the attacker it blocks wear the same blue outline (a highlight on
   either glows blue, not yellow), and an arrow in that blue runs from one to the other, so the
   three read as one thing. */
.learn-scn-card.is-blocking .learn-pic,
.learn-scn-card.is-blocked .learn-pic,
.learn-scn-card.is-blocking.is-highlight .learn-pic,
.learn-scn-card.is-blocked.is-highlight .learn-pic,
.learn-demo-card.is-blocking .learn-demo-face,
.learn-demo-card.is-blocked .learn-demo-face,
.learn-demo-card.is-blocking.is-highlight .learn-demo-face,
.learn-demo-card.is-blocked.is-highlight .learn-demo-face {
    box-shadow: 0 0 0 2px var(--info-color), 0 0 12px color-mix(in srgb, var(--info-color) 45%, transparent);
    animation: none;
}

.learn-arrows {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    overflow: visible;
    pointer-events: none;
    transition: opacity 0.18s ease-out;
}

/* A step is moving cards: the arrows go at once, the new ones draw when the cards settle. */
.learn-arrows.is-fading {
    opacity: 0;
}

.learn-arrow {
    filter: drop-shadow(0 0 3px color-mix(in srgb, var(--info-color) 55%, transparent));
}

.learn-arrow-line {
    fill: none;
    stroke: var(--info-color);
    stroke-width: 2;
    stroke-linecap: round;
}

.learn-arrow-dot,
.learn-arrow-head {
    fill: var(--info-color);
    stroke: none;
}

/* Drawn in: the line from the blocker, then the dot and the head. */
.learn-arrow.is-drawing .learn-arrow-line {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: learn-arrow-draw 0.45s ease-out forwards;
}

.learn-arrow.is-drawing .learn-arrow-head {
    opacity: 0;
    animation: learn-arrow-show 0.2s ease-out 0.4s forwards;
}

@keyframes learn-arrow-draw {
    to { stroke-dashoffset: 0; }
}

@keyframes learn-arrow-show {
    to { opacity: 1; }
}

/* ── Demos: a short animation that shows one action ───────────────────── */

.learn-demo {
    --demo-card: 84px;
    --scn-card-small: 52px;
    position: relative;
}

.learn-demo--large {
    --demo-card: 104px;
}

/* The title on the left; the step count and the controls fixed in the top right corner. */
.learn-demo-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
}

.learn-demo-title {
    margin: 0;
    font-size: 1rem;
}

.learn-demo-stage {
    position: relative;
    display: grid;
    grid-template-columns: var(--demo-cols, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

/* One cell per column per row (learn-demo.js): every row lines up under the one above, so
   the opponent's graveyard and yours are the same box in the same place. Only zones the demo
   uses are drawn; a battlefield stretches over a column its row lacks. */
.learn-demo-cell {
    grid-column: span var(--span, 1);
    display: flex;
    gap: 10px;
    min-width: 0;
}

.learn-demo-cell--wide,
.learn-demo-bar {
    grid-column: 1 / -1;
}

.learn-demo-cell--library,
.learn-demo-cell--graveyard,
.learn-demo-cell--exile {
    min-width: 120px;
}

/* The stack beside your battlefield: as wide as a card, growing when spells pile up. */
.learn-demo-cell--stack {
    min-width: calc(var(--demo-card) + 22px);
}

/* A player's slim bar: life, and for you the mana pool, on one short line. */
.learn-demo-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 22px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: color-mix(in srgb, var(--bg-tertiary) 80%, transparent);
}

.learn-demo-pool-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.learn-demo-label--inline {
    display: inline;
    margin: 0;
}

.learn-demo-zone {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: color-mix(in srgb, var(--bg-tertiary) 80%, transparent);
}

.learn-demo-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.learn-demo-cards {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    min-height: calc(var(--demo-card) * 680 / 488);
}

.learn-demo-zone--library .learn-demo-cards,
.learn-demo-zone--opp-library .learn-demo-cards,
.learn-demo-zone--opp-hand .learn-demo-cards {
    min-height: 0;
}

.learn-demo-empty {
    align-self: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.learn-demo-card {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: var(--demo-card);
    transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Attachments: an Equipment or Aura sits behind the card it is attached to, raised so its
   name bar shows above it, as players lay them out. The host makes room above for them. */
.learn-demo-card {
    --peek: calc(var(--demo-card) * 0.22);
    isolation: isolate;
    margin-top: calc(var(--attached, 0) * var(--peek));
}

.learn-demo-under {
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
    width: 100%;
}

.learn-demo-card.is-attached {
    position: absolute;
    top: calc(var(--attach-i, 1) * var(--peek) * -1);
    left: calc(var(--attach-i, 1) * 5px);
    width: 100%;
    margin: 0;
}

.learn-demo-card.is-attached .learn-demo-face {
    filter: brightness(0.85);
}

.learn-demo-face {
    display: block;
    width: 100%;
    transition: transform 0.45s ease, box-shadow 0.2s ease;
}

.learn-demo-face .learn-pic {
    border-radius: 6px;
}

/* Tapped: the card turns sideways, and the margins hold the room it now needs. */
.learn-demo-card.is-tapped {
    margin-right: calc(var(--demo-card) * 0.2);
    margin-left: calc(var(--demo-card) * 0.2);
}

.learn-demo-card.is-tapped .learn-demo-face {
    transform: rotate(90deg) scale(0.86);
}

.learn-demo-card.is-attacking .learn-demo-face {
    box-shadow: 0 0 0 2px var(--danger-color);
}

.learn-demo-card.is-attacking:not(.is-tapped) .learn-demo-face,
.learn-demo-card.is-attacking.is-tapped .learn-demo-face {
    translate: 0 -10px;
}

.learn-demo-card.is-blocking .learn-demo-face {
    box-shadow: 0 0 0 2px var(--info-color);
}

.learn-demo-card.is-highlight .learn-demo-face {
    box-shadow: 0 0 0 2px var(--warning-color), 0 0 14px color-mix(in srgb, var(--warning-color) 55%, transparent);
}

/* Turning over: the card narrows to its edge, and widens again showing its face. */
.learn-demo-card.is-turning .learn-demo-face {
    animation: learn-demo-turn 0.6s ease-in-out;
}

@keyframes learn-demo-turn {
    50% { transform: scaleX(0); }
}

.learn-demo-card.is-arriving {
    animation: learn-demo-arrive 0.5s ease-out;
}

@keyframes learn-demo-arrive {
    from { opacity: 0; transform: scale(0.6); }
}

.learn-demo-ghost {
    position: absolute;
    z-index: 2;
    pointer-events: none;
    transition: transform 0.6s ease-in, opacity 0.6s ease-in;
}

.learn-demo-note {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.25;
    text-align: center;
}

.learn-demo-hidden {
    display: flex;
    align-items: center;
    gap: 10px;
}

.learn-demo-n {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.learn-demo-life {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.learn-demo-life strong {
    color: var(--text-color);
}

.learn-demo-life-n {
    color: var(--text-color);
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.learn-demo-life-n.is-loss {
    animation: learn-demo-loss 0.9s ease-out;
}

.learn-demo-life-n.is-gain {
    animation: learn-demo-gain 0.9s ease-out;
}

@keyframes learn-demo-loss {
    0%, 40% { color: var(--danger-color); transform: scale(1.25); }
}

@keyframes learn-demo-gain {
    0%, 40% { color: var(--success-color); transform: scale(1.25); }
}

.learn-demo-pool {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 24px;
}

.learn-demo-pool .learn-sym {
    width: 22px;
    height: 22px;
}

.learn-demo-pool.is-new {
    animation: learn-demo-arrive 0.4s ease-out;
}

/* The narration under the cards, with the step count and the controls beside it. */
.learn-demo-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin-top: 12px;
}

.learn-demo-say {
    flex: 1 1 320px;
    min-height: 3.4em;
    margin: 0;
    color: var(--text-color);
    line-height: 1.6;
}

.learn-demo-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.learn-demo-count {
    margin-right: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.learn-demo-ctl {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.learn-demo-ctl:hover:not(:disabled),
.learn-demo-ctl:focus-visible {
    border-color: var(--accent-hover);
    background: var(--accent-bg);
    color: var(--text-color);
}

.learn-demo-ctl:disabled {
    opacity: 0.4;
    cursor: default;
}

.learn-demo-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.learn-demo-icon--play,
.learn-demo-icon--pause {
    fill: currentColor;
    stroke: none;
}

/* ── States every control shares ───────────────────────────────────────── */

/* Keyboard focus: the accent outline the app uses (site-header.css), on every control. */
.learn-article button:focus-visible,
.learn-article a:focus-visible,
.learn-article input:focus-visible,
.learn-rail a:focus-visible,
.learn-preview-actions .button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* The static theme's buttons have no disabled state of their own; the lessons are the first to
   disable them (Continue during an answer, Both Players Pass on an empty stack). */
.learn-article .button:disabled,
.learn-scn-choice:disabled,
.learn-sorter-choice:disabled:not(.is-right) {
    opacity: 0.45;
    cursor: default;
}

body.amx-static-page .learn-article .button:disabled:hover {
    border-color: var(--button-border);
    background: var(--button-bg);
    color: var(--button-text);
    filter: none;
}

body.amx-static-page .learn-article .button.primary:disabled:hover {
    border-color: transparent;
    background: var(--accent-gradient);
    color: var(--button-primary-text);
}

/* ── Phones ────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .learn-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    /* The rail follows the lesson: the series list at its foot. */
    .learn-rail {
        position: static;
        max-height: none;
        order: 2;
    }

    .learn-turn {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .learn-curve,
    .learn-stack,
    .learn-layers,
    .learn-colors-wrap,
    .learn-anatomy {
        grid-template-columns: minmax(0, 1fr);
    }

    .learn-anatomy-card {
        max-width: 260px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .learn-quiet-btn,
    .learn-scn-choice,
    .learn-sorter-choice,
    .learn-turn-step,
    .learn-anatomy-part,
    .learn-zone,
    button.learn-scn-fact,
    button.learn-scn-player,
    .learn-rail-lesson a {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
    }

    .learn-rail-lesson a {
        display: flex;
    }

    .learn-combat-kw,
    .learn-combat-blocked,
    .learn-layers-effect label {
        min-height: 40px;
    }
}

@media (max-width: 480px) {
    .learn-facts {
        grid-template-columns: minmax(0, 1fr);
        gap: 2px;
    }

    .learn-facts dd {
        margin-bottom: 8px;
    }
}

@media (max-width: 640px) {
    .learn-widget {
        padding: 14px;
    }

    .learn-combat {
        grid-template-columns: minmax(0, 1fr);
    }

    .learn-mull-hand {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .learn-scn-area {
        grid-template-columns: minmax(0, 1fr);
    }

    /* The graveyard (and exile) sit under the battlefield, side by side. */
    .learn-scn-piles {
        grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
        min-width: 0;
        max-width: none;
    }

    /* The compact board: a phone shows a whole side at once. Cards a size down (press and hold
       still shows one large), tighter gaps, tapped cards giving back the height they no longer
       use, and the library, graveyard and exile as one-line strips beside each other. Every
       part is still there and still a target or a drop; only the room around it shrinks. */
    .learn-scn-table {
        --scn-card: 54px;
        --scn-card-small: 34px;
        --scn-card-tiny: 26px;
        gap: 8px;
    }

    .learn-scn-side {
        gap: 8px;
        padding: 8px;
    }

    .learn-scn-area {
        gap: 8px;
    }

    .learn-scn-zone {
        padding: 6px 8px 8px;
    }

    .learn-scn-field {
        gap: 6px;
    }

    .learn-scn-row {
        gap: 6px;
    }

    .learn-scn-pile-label {
        margin-bottom: 4px;
    }

    /* Sideways, a card is as tall as it is wide: the room above and below it closes up, and
       the room beside it is just what the turn needs (0.86 x 680/488 of its width). */
    .learn-scn-card.is-tapped {
        margin: 0 calc(var(--scn-card) * 0.1);
    }

    .learn-scn-card.is-small.is-tapped {
        margin: 0 calc(var(--scn-card-small) * 0.1);
    }

    /* On the picture, not the card, so a note under a tapped card follows its visible edge.
       (A percentage margin is of the card's width, which is the picture's.) */
    .learn-scn-card.is-tapped .learn-pic {
        margin-block: -22%;
    }

    /* The row closes up as the card turns, not before. */
    .learn-scn-card .learn-pic {
        transition: transform 0.45s ease, margin 0.45s ease, box-shadow 0.15s ease, opacity 0.2s ease;
    }

    /* The bar on one line where it fits: name, life, then the hidden hand. */
    .learn-scn-bar {
        gap: 4px 10px;
    }

    .learn-scn-player {
        padding: 2px 6px;
    }

    .learn-scn-life-n {
        font-size: 1.15rem;
    }

    .learn-scn-facts {
        gap: 4px 10px;
        font-size: 0.8rem;
    }

    /* Whose turn and the step on one line, over the track. */
    .learn-scn-when {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 2px 8px;
    }

    .learn-scn-when-step {
        font-size: 0.9rem;
    }

    .learn-scn-phase {
        min-height: 34px;
        gap: 3px;
    }

    /* Library, graveyard, exile: the name beside the pile, not over it. */
    .learn-scn-piles {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 6px;
    }

    .learn-scn-pile {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 4px 8px;
    }

    .learn-scn-pile .learn-scn-pile-label {
        flex: none;
        margin: 0;
    }

    .learn-scn-pile .learn-scn-library {
        gap: 6px;
        padding: 2px;
    }

    .learn-scn-pile .learn-backs-pile {
        width: var(--scn-card-tiny);
        margin: 4px 4px 0 0;
    }

    .learn-scn-pile .learn-scn-row--pile {
        gap: 4px;
    }

    .learn-scn-pile .learn-scn-card.is-small {
        width: var(--scn-card-tiny);
    }

    .learn-scn-pile .learn-scn-empty,
    .learn-scn-pile .learn-scn-count {
        font-size: 0.8rem;
    }

    .learn-demo {
        --demo-card: 64px;
        --scn-card-small: 44px;
    }

    .learn-demo-ctl {
        width: 40px;
        height: 40px;
    }

    /* Too narrow for columns: each row's zones stack, a column's empty cell takes no room. */
    .learn-demo-stage {
        grid-template-columns: minmax(0, 1fr);
    }

    .learn-demo-cell:empty {
        display: none;
    }

    .learn-demo-cell--library,
    .learn-demo-cell--graveyard,
    .learn-demo-cell--exile,
    .learn-demo-cell--stack {
        min-width: 0;
    }

    /* Stacked on a phone, a cell's span means nothing. */
    .learn-demo-cell,
    .learn-demo-cell--wide,
    .learn-demo-bar {
        grid-column: auto;
    }

    .learn-demo--large {
        --demo-card: 76px;
    }

    /* The words above the track; the track's five parts keep one row. */
    .learn-scn-middle {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Each part as wide as its name needs, the track still one row. */
    .learn-scn-phases {
        display: flex;
        gap: 3px;
    }

    .learn-scn-phase {
        flex: 1 1 auto;
        padding: 6px 3px;
    }

    .learn-scn-middle {
        padding: 10px;
    }

    .learn-scn-phase-name {
        font-size: 0.75rem;
    }

    .learn-pager {
        grid-template-columns: minmax(0, 1fr);
    }

    .learn-pager-next {
        grid-column: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .learn-card-link,
    .learn-scn-card .learn-pic,
    .learn-mull-card,
    .learn-curve-fill {
        transition: none;
    }

    .learn-card-link:hover,
    .learn-card-link:focus-visible {
        transform: none;
    }

    .learn-preview--float {
        animation: none;
    }

    .learn-demo-card,
    .learn-demo-face,
    .learn-demo-ghost {
        transition: none;
    }

    .learn-scn-cue,
    .learn-scn-card.is-charging .learn-pic,
    .learn-scn-card.is-stepping .learn-pic,
    .learn-scn-card.is-hit .learn-pic,
    .learn-scn-card.is-changed .learn-scn-note,
    .learn-pt-cover.is-changing,
    .learn-scn-card.is-rejected .learn-pic,
    .learn-scn-say--retry.is-new,
    .learn-arrow.is-drawing .learn-arrow-line,
    .learn-arrow.is-drawing .learn-arrow-head,
    .learn-scn-card.is-arriving .learn-pic,
    .learn-scn-life-n.is-loss,
    .learn-scn-life-n.is-gain,
    .learn-scn-pool-syms.is-filling,
    .learn-scn-pool-syms img.is-landing,
    .learn-demo-pool img.is-landing,
    .learn-scn-side.is-pop {
        animation: none;
    }

    .learn-demo-card.is-turning .learn-demo-face,
    .learn-demo-card.is-arriving,
    .learn-demo-life-n.is-loss,
    .learn-demo-life-n.is-gain,
    .learn-demo-pool.is-new {
        animation: none;
    }

    .learn-scn-card.is-highlight .learn-pic,
    .learn-scn-player.is-highlight,
    .learn-scn-fact.is-highlight,
    .learn-scn-stack-item.is-highlight {
        animation: none;
    }

    .learn-mull-card.is-chosen {
        transform: none;
    }
}
