.mancala-page {
    min-height: calc(100vh - var(--main-nav-height, 88px));
    padding-inline: clamp(1rem, 3vw, 2.5rem);
    padding-bottom: clamp(1.25rem, 3vw, 2.5rem);
    background:
        radial-gradient(circle at 16% 18%, rgba(230, 230, 250, 0.34), transparent 26rem),
        linear-gradient(135deg, #f8faf7 0%, #eef4ed 46%, #fbf7eb 100%);
}

html.mancala-intro-open,
body.mancala-intro-open {
    overflow: hidden;
}

.mancala-intro {
    position: fixed;
    inset: var(--main-nav-height, 0px) 0 0;
    z-index: 90;
    display: grid;
    place-items: safe center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    background:
        radial-gradient(circle at 20% 18%, rgba(244, 206, 98, 0.35), transparent 22rem),
        linear-gradient(135deg, #f8faf7, #fbf7eb);
    transition: opacity 200ms ease, transform 200ms ease;
}

.mancala-intro.is-leaving {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.mancala-intro-panel {
    display: none;
    width: min(34rem, 100%);
    text-align: center;
    margin: auto 0;
}

.mancala-intro-panel.is-active {
    display: block;
    animation: mancalaModalIn 200ms ease-out both;
}

.mancala-intro-panel h1,
.mancala-intro-panel h2 {
    margin: 0;
    color: #2c2118;
    font-size: clamp(2.5rem, 10vw, 4.5rem);
    font-weight: 900;
    line-height: 1;
    word-break: keep-all;
}

.mancala-intro-panel h2 {
    font-size: clamp(2rem, 8vw, 3rem);
}

.mancala-intro-panel h1:focus,
.mancala-intro-panel h2:focus {
    outline: none;
}

.mancala-intro-panel > p:not(.mancala-intro-kicker) {
    margin: 1rem 0 0;
    color: #4f5b43;
    font-size: clamp(1.05rem, 3vw, 1.3rem);
    font-weight: 800;
    word-break: keep-all;
}

.mancala-intro-kicker {
    margin: 0 0 0.75rem;
    color: #3d6540;
    font-size: 0.9rem;
    font-weight: 900;
}

.mancala-intro-panel button {
    width: 100%;
    min-height: 3.4rem;
    margin-top: 1.5rem;
    border: 0;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, #3d6540, #2f7d44);
    color: #fff;
    font-size: 1.08rem;
    font-weight: 900;
    box-shadow: 0 16px 32px rgba(47, 125, 68, 0.24);
}

.mancala-intro-panel .mancala-intro-back {
    width: auto;
    min-height: 2.75rem;
    margin-top: 0.6rem;
    padding: 0.5rem 1rem;
    background: transparent;
    color: #4f5b43;
    box-shadow: none;
}

.mancala-intro-panel .mancala-intro-quick-start {
    width: auto;
    min-height: 2.2rem;
    margin-top: 0.5rem;
    padding: 0.4rem 1rem;
    background: transparent;
    color: #4f5b43;
    box-shadow: none;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.mancala-intro-panel .mancala-intro-quick-start:hover {
    color: #1f502c;
}

.mancala-intro-example {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    margin: 1.25rem 0;
    padding: 0.85rem 1.2rem;
    border-radius: 1rem;
    background: #fdfbf7;
    border: 1.5px solid #e7dec9;
    box-shadow: 0 8px 24px rgba(56, 41, 25, 0.08);
}

.mancala-example-pit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #d5c4a1;
}

.mancala-pit-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #7a6345;
}

.mancala-seeds-beads {
    color: #673ab7;
    font-size: 1.2rem;
    letter-spacing: 2px;
}

.mancala-example-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: #2f7d44;
    font-size: 1.1rem;
}

.mancala-example-arrow span {
    font-size: 0.72rem;
    font-weight: 800;
}

.mancala-intro-example strong {
    color: #5a3d00;
    font-size: 0.95rem;
    font-weight: 800;
    background: #fef3c7;
    padding: 3px 8px;
    border-radius: 6px;
}

.mancala-intro-panel ol {
    display: grid;
    gap: 0.7rem;
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
}

.mancala-intro-panel li {
    padding: 0.9rem 1rem;
    border-radius: 0.75rem;
    background: #fff;
    color: #374151;
    font-weight: 800;
    word-break: keep-all;
}

.mancala-stage {
    width: min(1180px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-rows: auto auto auto minmax(340px, 1fr) auto;
    gap: clamp(0.75rem, 1.8vw, 1.1rem);
}

.mancala-toolbar {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) auto minmax(260px, 1fr);
    align-items: center;
    gap: 1rem;
    padding-top: clamp(0.25rem, 1.4vw, 0.75rem);
}

.mancala-title-wrap {
    min-width: 0;
}

.mancala-kicker {
    margin: 0 0 0.1rem;
    color: #3d6540;
    font-size: 0.82rem;
    font-weight: 900;
}

.mancala-title-wrap h1 {
    margin: 0;
    color: #2c2118;
    font-size: clamp(1.8rem, 5vw, 3.7rem);
    font-weight: 900;
    line-height: 0.98;
}

.mancala-status {
    margin: 0;
    min-width: 9rem;
    padding: 0.72rem 1rem;
    border: 1px solid rgba(70, 56, 38, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    color: #2f3a26;
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    font-weight: 900;
    text-align: center;
    box-shadow: 0 12px 30px rgba(56, 41, 25, 0.08);
}

.mancala-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 0;
}

.mancala-icon-button {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.48rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid rgba(53, 44, 34, 0.18);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.78);
    color: #2c2118;
    font-weight: 900;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(56, 41, 25, 0.08);
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.mancala-icon-button:hover,
.mancala-icon-button:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(61, 101, 64, 0.42);
    background: #ffffff;
    outline: none;
}

.mancala-icon-button.is-active {
    border-color: rgba(103, 58, 183, 0.45);
    background: #673ab7;
    color: #ffffff;
}

.mancala-icon-button--soft {
    border-color: rgba(61, 101, 64, 0.28);
    background: rgba(255, 252, 239, 0.86);
    color: #3b5835;
}

.mancala-icon-button:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    transform: none;
}

.mancala-scorebar {
    display: grid;
    grid-template-columns: minmax(96px, 1fr) auto minmax(96px, 1fr);
    align-items: center;
    gap: 0.75rem;
}

.mancala-score,
.mancala-turn-chip {
    min-height: 3rem;
    border: 1px solid rgba(70, 56, 38, 0.16);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 10px 22px rgba(56, 41, 25, 0.07);
}

.mancala-score {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.95rem;
}

.mancala-score span {
    color: #5f513d;
    font-size: 0.86rem;
    font-weight: 900;
}

.mancala-score strong {
    color: #2c2118;
    font-size: 1.35rem;
    font-weight: 900;
}

.mancala-score--ai strong {
    color: #673ab7;
}

.mancala-score--me strong {
    color: #2f7d44;
}

.mancala-turn-chip {
    min-width: 8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.9rem;
    color: #5a3d00;
    background: #f4ce62;
    font-weight: 900;
}

.mancala-goal-strip {
    min-height: 3.2rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.72rem 0.95rem;
    border: 1px solid rgba(61, 101, 64, 0.22);
    border-radius: 0.5rem;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.84), rgba(238, 247, 232, 0.88)),
        radial-gradient(circle at 92% 22%, rgba(244, 206, 98, 0.26), transparent 14rem);
    box-shadow: 0 10px 24px rgba(56, 41, 25, 0.08);
}

.mancala-goal-strip span,
.mancala-goal-strip strong {
    min-width: 0;
    font-weight: 900;
}

.mancala-goal-strip span {
    display: inline-flex;
    align-items: center;
    gap: 0.52rem;
    color: #27492e;
    font-size: clamp(0.95rem, 2vw, 1.08rem);
}

.mancala-goal-strip i {
    color: #5a3d00;
}

.mancala-goal-strip strong {
    justify-self: end;
    padding: 0.38rem 0.68rem;
    border-radius: 999px;
    background: rgba(47, 125, 68, 0.1);
    color: #2f7d44;
    font-size: 0.9rem;
    white-space: nowrap;
}

.mancala-board-shell {
    position: relative;
    overflow: hidden;
    min-height: clamp(320px, 50vh, 540px);
    border: 1px solid rgba(72, 51, 31, 0.18);
    border-radius: 0.5rem;
    background: linear-gradient(180deg, #c99b5d 0%, #86512f 100%);
    box-shadow: 0 24px 70px rgba(45, 32, 19, 0.19);
}

.mancala-board-shell canvas {
    display: block;
    width: 100%;
    height: 100%;
    min-height: inherit;
    touch-action: manipulation;
}

.mancala-pit-actions {
    display: grid;
    gap: 0.55rem;
}

.mancala-pit-actions p {
    margin: 0;
    color: #4f5b43;
    font-size: 0.86rem;
    font-weight: 800;
    text-align: center;
}

.mancala-pit-actions > div {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.5rem;
}

.mancala-pit-actions button {
    min-height: 3rem;
    padding: 0.55rem 0.35rem;
    border: 1px solid rgba(47, 125, 68, 0.32);
    border-radius: 0.65rem;
    background: rgba(255, 255, 255, 0.88);
    color: #27492e;
    font-size: 0.86rem;
    font-weight: 900;
    word-break: keep-all;
}

.mancala-pit-actions button.is-recommended {
    border-color: #f4ce62;
    background: #fff2b7;
    color: #5a3d00;
    box-shadow: 0 0 0 3px rgba(244, 206, 98, 0.25);
}

.mancala-pit-actions button:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.mancala-pit-actions button:focus-visible {
    outline: 3px solid #673ab7;
    outline-offset: 2px;
}

.mancala-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #2c2118;
    font-weight: 900;
    background: rgba(255, 255, 255, 0.55);
    pointer-events: none;
}

.mancala-loading.is-hidden {
    display: none;
}

.mancala-tutor-burst {
    position: absolute;
    left: 50%;
    top: 48%;
    z-index: 4;
    min-height: 3.3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    background: linear-gradient(135deg, #f4ce62, #fff2b7);
    color: #2c2118;
    font-size: clamp(1.05rem, 2.8vw, 1.35rem);
    font-weight: 900;
    box-shadow: 0 18px 42px rgba(90, 61, 0, 0.26);
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.mancala-tutor-burst[hidden] {
    display: none;
}

.mancala-tutor-burst.is-visible {
    animation: mancalaTutorPop 780ms ease-out both;
}

.mancala-board-guides {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.mancala-board-guide {
    position: absolute;
    min-height: 1.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.34rem 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.56);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.76);
    color: #2c2118;
    font-size: 0.82rem;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(45, 32, 19, 0.14);
    backdrop-filter: blur(8px);
}

.mancala-board-guide--ai {
    top: 0.75rem;
    left: 50%;
    color: #673ab7;
    transform: translateX(-50%);
}

.mancala-board-guide--me {
    bottom: 0.75rem;
    left: 50%;
    color: #2f7d44;
    transform: translateX(-50%);
}

.mancala-board-guide--store {
    top: 50%;
    right: 0.75rem;
    color: #5a3d00;
    transform: translateY(-50%);
}

.mancala-culture {
    margin: 0;
    color: #4c5d3c;
    font-size: clamp(0.9rem, 2vw, 1rem);
    font-weight: 800;
    text-align: center;
}

.mancala-modal[hidden] {
    display: none;
}

.mancala-result-modal[hidden] {
    display: none;
}

.mancala-result-modal {
    position: fixed;
    inset: var(--main-nav-height, 0px) 0 0;
    z-index: 95;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.mancala-result-panel {
    position: relative;
    width: min(430px, 100%);
    padding: 2rem 1.5rem;
    border-radius: 1.25rem;
    background: #fff;
    text-align: center;
    box-shadow: 0 30px 90px rgba(31, 24, 16, 0.36);
    animation: mancalaModalIn 220ms ease-out both;
}

.mancala-result-seeds {
    color: #673ab7;
    font-size: 1.35rem;
    letter-spacing: 0.35rem;
}

.mancala-result-panel h2 {
    margin: 0.7rem 0 0;
    color: #2c2118;
    font-size: clamp(2rem, 8vw, 3rem);
    font-weight: 900;
    word-break: keep-all;
}

.mancala-result-panel h2:focus {
    outline: none;
}

.mancala-result-panel p {
    margin: 0.75rem 0 1.5rem;
    color: #4f5b43;
    font-size: 1.05rem;
    font-weight: 800;
}

.mancala-result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.mancala-result-actions button {
    min-height: 3.2rem;
    border: 0;
    border-radius: 0.7rem;
    background: #64748b;
    color: #fff;
    font-weight: 900;
}

.mancala-result-actions [data-result-restart] {
    background: linear-gradient(135deg, #3d6540, #2f7d44);
}

.mancala-modal {
    position: fixed;
    inset: var(--main-nav-height, 88px) 0 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: clamp(1rem, 4vw, 2rem);
}

.mancala-modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background:
        radial-gradient(circle at 34% 24%, rgba(244, 206, 98, 0.3), transparent 20rem),
        rgba(23, 25, 20, 0.46);
    backdrop-filter: blur(12px);
    cursor: pointer;
}

.mancala-modal-panel {
    position: relative;
    width: min(720px, 100%);
    max-height: min(720px, calc(100vh - var(--main-nav-height, 88px) - 2rem));
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.48);
    border-radius: 0.5rem;
    padding: clamp(1.25rem, 3.4vw, 2rem);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(251, 247, 235, 0.93)),
        radial-gradient(circle at 86% 14%, rgba(230, 230, 250, 0.85), transparent 15rem);
    box-shadow: 0 30px 90px rgba(31, 24, 16, 0.36);
    animation: mancalaModalIn 220ms ease-out both;
}

.mancala-modal-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 2.4rem;
    height: 2.4rem;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(70, 56, 38, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    color: #2c2118;
    box-shadow: 0 10px 22px rgba(56, 41, 25, 0.1);
}

.mancala-modal-close:hover,
.mancala-modal-close:focus-visible,
.mancala-guide-play:hover,
.mancala-guide-play:focus-visible {
    outline: none;
    transform: translateY(-1px);
}

.mancala-modal-seeds {
    display: flex;
    gap: 0.42rem;
    margin-bottom: 1rem;
}

.mancala-modal-seeds span {
    width: 0.78rem;
    height: 0.78rem;
    border-radius: 999px;
    box-shadow: 0 7px 16px rgba(56, 41, 25, 0.16);
    animation: mancalaSeedFloat 2.2s ease-in-out infinite;
}

.mancala-modal-seeds span:nth-child(1) {
    background: #e6e6fa;
}

.mancala-modal-seeds span:nth-child(2) {
    background: #673ab7;
    animation-delay: 120ms;
}

.mancala-modal-seeds span:nth-child(3) {
    background: #f4ce62;
    animation-delay: 240ms;
}

.mancala-modal-header {
    padding-right: 2.6rem;
}

.mancala-guide-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    background: rgba(61, 101, 64, 0.11);
    color: #3d6540;
    font-size: 0.76rem;
    font-weight: 900;
}

.mancala-modal-header h2 {
    margin: 0.7rem 0 0.35rem;
    color: #2c2118;
    font-size: clamp(1.8rem, 4.4vw, 2.7rem);
    font-weight: 900;
    line-height: 1;
}

.mancala-modal-header p,
.mancala-guide-grid p,
.mancala-guide-culture {
    margin: 0;
}

.mancala-modal-header p {
    color: #4f5b43;
    font-size: 1rem;
    font-weight: 800;
}

.mancala-guide-goal {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
    padding: 0.82rem 0.95rem;
    border: 1px solid rgba(61, 101, 64, 0.16);
    border-radius: 0.5rem;
    background: rgba(238, 247, 232, 0.8);
    color: #27492e;
    font-weight: 900;
}

.mancala-guide-goal i {
    color: #2f7d44;
}

.mancala-guide-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1.15rem;
}

.mancala-guide-grid article {
    min-height: 8.8rem;
    padding: 0.95rem;
    border: 1px solid rgba(70, 56, 38, 0.14);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.76);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88), 0 12px 24px rgba(56, 41, 25, 0.08);
}

.mancala-guide-grid article span {
    color: #673ab7;
    font-size: 0.76rem;
    font-weight: 900;
}

.mancala-guide-grid article strong {
    display: block;
    margin-top: 0.42rem;
    color: #2c2118;
    font-size: 1.08rem;
    font-weight: 900;
}

.mancala-guide-grid article p {
    margin-top: 0.55rem;
    color: #5d513f;
    font-size: 0.92rem;
    font-weight: 800;
    line-height: 1.42;
}

.mancala-guide-culture {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.8rem;
    padding: 0.82rem 0.95rem;
    border-radius: 0.5rem;
    background: rgba(244, 206, 98, 0.24);
    color: #4d4323;
    font-weight: 900;
}

.mancala-guide-culture i {
    color: #3d6540;
}

.mancala-guide-play {
    width: 100%;
    min-height: 3rem;
    margin-top: 1rem;
    border: 0;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, #3d6540, #2f7d44);
    color: #ffffff;
    font-weight: 900;
    box-shadow: 0 14px 28px rgba(47, 125, 68, 0.24);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

@keyframes mancalaModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes mancalaSeedFloat {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-0.22rem);
    }
}

@keyframes mancalaTutorPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.82);
    }
    18% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.08);
    }
    78% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.94);
    }
}

@media (max-width: 820px) {
    .mancala-stage {
        gap: 0.65rem;
    }

    .mancala-toolbar {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 0.65rem;
    }

    .mancala-status {
        display: none;
    }

    .mancala-actions {
        justify-content: stretch;
    }

    .mancala-icon-button {
        flex: 1 1 0;
        padding-inline: 0.5rem;
    }

    .mancala-scorebar {
        grid-template-columns: minmax(70px, 1fr) minmax(92px, auto) minmax(70px, 1fr);
        gap: 0.45rem;
    }

    .mancala-turn-chip {
        grid-column: 2;
        grid-row: auto;
        min-width: 0;
    }

    .mancala-goal-strip {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .mancala-goal-strip strong {
        justify-self: start;
    }

    .mancala-board-shell {
        min-height: clamp(300px, 42vh, 380px);
    }

    .mancala-board-guide--store {
        display: none;
    }

    .mancala-guide-grid {
        grid-template-columns: 1fr;
    }

    .mancala-guide-grid article {
        min-height: auto;
    }

    .mancala-pit-actions > div {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 460px) {
    .mancala-page {
        padding-inline: 0.75rem;
    }

    .mancala-actions {
        gap: 0.35rem;
        flex-wrap: wrap;
    }

    .mancala-icon-button {
        flex: 1 1 calc(50% - 0.35rem);
    }

    .mancala-icon-button span {
        font-size: 0.78rem;
    }

    .mancala-score,
    .mancala-turn-chip {
        min-height: 2.75rem;
    }

    .mancala-score {
        padding-inline: 0.65rem;
    }

    .mancala-goal-strip {
        padding: 0.65rem 0.75rem;
    }

    .mancala-result-actions {
        grid-template-columns: 1fr;
    }

    .mancala-modal {
        padding: 0.75rem;
    }

    .mancala-modal-panel {
        padding: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mancala-intro,
    .mancala-intro-panel.is-active,
    .mancala-result-panel {
        animation: none;
        transition-duration: 1ms;
    }
}

/* Approved toy-desk design: real controls sit on generated artwork. */
.mancala-page { min-height: calc(100vh - var(--main-nav-height, 72px)); padding: 12px clamp(8px, 2vw, 28px) 24px; background: #e7a96f url("../images/toy-desk.8467a841a45f.webp") center top / cover fixed; }
.mancala-stage { width: min(1600px, 100%); display: flex; flex-direction: column; gap: 12px; }
.mancala-toolbar { display: flex; justify-content: space-between; gap: 12px; padding: 10px 20px; border: 4px solid #e9c394; border-radius: 32px; background: #78dec4; box-shadow: inset 0 0 0 3px #c9ffeb, 0 5px 0 #a86739; }
.mancala-title-wrap h1 { font-size: clamp(2rem, 4.3vw, 4rem); line-height: 1.15; color: #51301b; text-shadow: 1px 2px #fff7da; }
.mancala-kicker, .mancala-status { display: none; }
.mancala-actions { flex-wrap: wrap; }
.mancala-icon-button, .mancala-icon-button.is-active, .mancala-icon-button--soft { position: relative; isolation: isolate; border: 0; background: transparent; color: #143d36; box-shadow: none; padding: 12px 18px 16px; min-height: 56px; font-size: clamp(1rem, 1.4vw, 1.3rem); }
.mancala-icon-button::before { content: ''; position: absolute; inset: 0; z-index: -1; background: url("../images/toy-button.baa4c02d25fa.webp") center / 100% 100% no-repeat; }
.mancala-icon-button:hover, .mancala-icon-button:focus-visible { background: transparent; outline: 3px solid #33265e; outline-offset: 1px; }
.mancala-scorebar { display: grid; grid-template-columns: 1fr .9fr 1fr; gap: 12px; width: min(1160px, 88%); align-self: center; }
.mancala-score, .mancala-turn-chip { min-height: clamp(66px, 7vw, 108px); border: 4px solid #fff1ca; border-radius: 24px; box-shadow: 0 5px 0 #ad744b, inset 0 0 0 2px #ffffff80; }
.mancala-score { padding: 10px 18px; }
.mancala-score--ai { background: #ed7380; }
.mancala-score--me { background: #5bceb0; }
.mancala-score span { color: white; font-size: clamp(1.3rem, 3vw, 2.5rem); text-shadow: 1px 2px 2px #834847; }
.mancala-score strong, .mancala-score--ai strong, .mancala-score--me strong { min-width: 1.5em; padding: 0 .25em; border-radius: 14px; color: #512b17; background: #fff1d8; font-size: clamp(1.8rem, 4vw, 3.4rem); text-align: center; }
.mancala-turn-chip { background: #ffdc70; color: #5d330c; font-size: clamp(1.3rem, 2.8vw, 2.3rem); }
.mancala-goal-strip { min-height: auto; align-self: center; background: #fff5ddec; border: 0; border-radius: 99px; padding: .4rem 1rem; box-shadow: none; }
.mancala-goal-strip span { font-size: .95rem; }
.mancala-board-shell { width: 100%; min-height: 0; overflow: visible; border: 0; border-radius: 0; background: none; box-shadow: none; }
.mancala-board { position: relative; width: 100%; aspect-ratio: 2048 / 768; background: url("../images/toy-board.64ceeae7ccd4.webp") center / 100% 100% no-repeat; }
.toy-pit { position: absolute; transform: translate(-50%, -50%); width: 10.5%; aspect-ratio: 1; display: grid; place-items: center; padding: 0; border: 3px solid transparent; border-radius: 50%; background: transparent; cursor: pointer; }
.toy-pit:disabled { opacity: 1; cursor: default; }
.toy-pit.is-legal { border-color: #87ff96; box-shadow: 0 0 0 3px white, 0 0 13px #79fd88; }
.toy-pit.is-preview, .toy-pit.is-path { border-color: #ffe565; box-shadow: 0 0 0 3px white, 0 0 13px #ffdf4b; }
.toy-pit:focus-visible { outline: 4px solid #352570; outline-offset: 4px; }
.toy-pit--store { width: 9.7%; height: 74%; aspect-ratio: auto; border-radius: 48%; pointer-events: none; }
.toy-seeds { width: 63%; height: 63%; display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: minmax(0, 1fr); align-content: center; justify-content: center; }
.toy-pit--store .toy-seeds { height: 38%; }
.toy-marble { display: block; width: 100%; height: 100%; min-height: 0; background: url("../images/toy-marble.77c9f6a95502.webp") center / contain no-repeat; }
.toy-marble--green { filter: hue-rotate(245deg) saturate(1.2); }
.toy-marble--yellow { filter: hue-rotate(185deg) saturate(1.6); }
.toy-marble--red { filter: hue-rotate(140deg) saturate(1.3); }
.toy-marble--flying { position: absolute; z-index: 5; width: 3.3%; aspect-ratio: 1; height: auto; pointer-events: none; }
.toy-count { position: absolute; bottom: -4%; right: 0; min-width: 1.4em; padding: .1em .2em; border-radius: 1em; background: #fff8df; color: #583216; font-size: clamp(.7rem,1.2vw,1.1rem); font-weight: 900; line-height: 1.2; text-align: center; }
.mancala-pit-actions { padding: 0 8%; }
.mancala-pit-actions p { font-size: .95rem; color: #53331b; }
.mancala-pit-actions button { min-height: 44px; background: #fff8e7; }
.mancala-culture { margin: 0; text-align: center; color: #4e301d; }
@media (max-width: 760px) {
 .mancala-toolbar { align-items: flex-start; padding: 8px 10px; border-radius: 20px; }
 .mancala-actions { gap: 2px; }
 .mancala-icon-button, .mancala-icon-button.is-active, .mancala-icon-button--soft { padding: 9px 10px 13px; min-height: 44px; font-size: .85rem; }
 .mancala-scorebar { width: 100%; gap: 4px; }
 .mancala-score, .mancala-turn-chip { min-width: 0; min-height: 55px; border-width: 2px; border-radius: 15px; }
 .mancala-score { padding: 5px; gap: 3px; }
 .mancala-score span, .mancala-turn-chip { font-size: clamp(.9rem, 4vw, 1.2rem); }
 .mancala-score strong, .mancala-score--ai strong, .mancala-score--me strong { font-size: 1.3rem; }
 .mancala-goal-strip { display: flex; flex-wrap: wrap; justify-content: center; font-size: .85rem; }
 .mancala-pit-actions { padding: 0; }
 .mancala-pit-actions > div { grid-template-columns: repeat(3, minmax(0, 1fr)); }
 .toy-pit { border-width: 1px; }
 .toy-pit.is-legal { box-shadow: 0 0 0 1px white, 0 0 5px #79fd88; }
}
html[data-classroom-playing] .mancala-page .mancala-stage { display: flex; align-items: stretch; gap: 12px; }
html[data-classroom-playing] .mancala-page .mancala-toolbar { padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; }
html[data-classroom-playing] .mancala-page .mancala-toy-title { color: #4b2917; font-size: clamp(1.7rem, 4vw, 3.6rem); font-weight: 950; line-height: 1; text-shadow: 1px 2px #fff2d7; }
html[data-classroom-playing] .mancala-page .mancala-scorebar { display: grid; grid-template-columns: 1fr .9fr 1fr; }
html[data-classroom-playing] .mancala-page .mancala-turn-chip { grid-column: auto; grid-row: auto; }
html[data-classroom-playing] .mancala-page .mancala-board-shell { height: auto; }
html[data-classroom-playing] .mancala-page .mancala-goal-strip { display: flex; gap: .7rem; }
html[data-classroom-playing] .mancala-page .mancala-pit-actions > div { grid-template-columns: repeat(6,minmax(0,1fr)); }
@media (max-width:760px) {
 html[data-classroom-playing] .mancala-page .mancala-toolbar { flex-wrap: wrap; }
 html[data-classroom-playing] .mancala-page .mancala-pit-actions > div { grid-template-columns: repeat(3,minmax(0,1fr)); }
 html[data-classroom-playing] .mancala-page .mancala-goal-strip { flex-wrap: wrap; }
}
.toy-pit.is-recommended::after { content: '추천'; position: absolute; top: -9%; left: 50%; transform: translateX(-50%); padding: .15em .5em; border-radius: 1em; background: #ffe279; color: #583216; font-size: clamp(.65rem, 1vw, .9rem); font-weight: 900; white-space: nowrap; }
.mancala-score::before { content: ''; flex: 0 0 clamp(38px, 6vw, 85px); height: clamp(38px, 6vw, 85px); background: center / contain no-repeat; }
.mancala-score--ai::before { background-image: url("../images/toy-robot.622fa406000e.webp"); }
.mancala-score--me::before { background-image: url("../images/toy-child.b4c75ebf15dd.webp"); }
.mancala-score span { margin-right: auto; }
.mancala-icon-button[data-undo]::before { filter: hue-rotate(55deg); }
.mancala-icon-button[data-ai-toggle]::before { filter: hue-rotate(115deg); }
.toy-marble--yellow { filter: hue-rotate(198deg) saturate(1.8); }
@media (max-width:760px) { .mancala-score::before { display: none; } }
@media (min-width: 1000px) {
 html[data-classroom-playing] .mancala-page .mancala-stage { position: relative; }
 html[data-classroom-playing] .mancala-page .mancala-toolbar { min-height: 84px; }
 html[data-classroom-playing] .mancala-page .mancala-actions { position: absolute; top: 96px; right: 2%; width: 175px; display: flex; flex-direction: column; gap: 0; }
 html[data-classroom-playing] .mancala-page .mancala-scorebar { width: calc(100% - 220px); align-self: flex-start; margin-left: 2%; }
}
html[data-classroom-playing] .mancala-page .mancala-toy-title { display: block; width: clamp(165px, 23vw, 330px); height: 62px; font-size: 0; background: url("../images/toy-title.43d900d2685f.webp") left center / contain no-repeat; }
@media (max-width: 760px) { html[data-classroom-playing] .mancala-page .mancala-toy-title { width: 125px; height: 44px; } }
@media (min-width: 1000px) {
 html[data-classroom-playing] .mancala-page .mancala-scorebar { width: calc(100% - 240px); margin-left: 0; }
 html[data-classroom-playing] .mancala-page .mancala-actions { right: 0; }
 html[data-classroom-playing] .mancala-page .mancala-toy-title { width: 380px; height: 66px; }
}
.toy-marble--yellow { background-image: url("../images/toy-marble-yellow.bf2243f02f09.webp"); filter: none; }
.mancala-score, .mancala-turn-chip { border: 0; border-radius: 0; box-shadow: none; background-position: center; background-size: 100% 100%; background-repeat: no-repeat; }
.mancala-score--ai { background-image: url("../images/score-pink.82e029eae878.webp"); }
.mancala-score--me { background-image: url("../images/score-mint.df95fcf50c1d.webp"); }
.mancala-turn-chip { background-image: url("../images/score-yellow.84a98764ab05.webp"); }
@media (min-width:1000px) {
 html[data-classroom-playing] .mancala-page .mancala-actions { width: 200px; }
 html[data-classroom-playing] .mancala-page .mancala-scorebar { width: calc(100% - 255px); }
 html[data-classroom-playing] .mancala-page .mancala-toy-title { height: 76px; }
}
.mancala-score--ai, .mancala-score--me, .mancala-turn-chip { background-color: transparent; }
.mancala-score strong, .mancala-score--ai strong, .mancala-score--me strong { font-size: clamp(1.7rem, 3.5vw, 3rem); line-height: 1.12; }

/* Keep the shared play bar as the only header. */
html[data-classroom-playing] .mancala-page .mancala-toolbar { display: contents; }
html[data-classroom-playing] .mancala-page .mancala-toy-title { display: none; }
html[data-classroom-playing] .mancala-page .mancala-scorebar { order: -2; }
html[data-classroom-playing] .mancala-page .mancala-actions { order: -1; }
@media (min-width: 1000px) {
 html[data-classroom-playing] .mancala-page .mancala-actions { top: 0; }
}
@media (max-width: 999px) {
 html[data-classroom-playing] .mancala-page .mancala-actions { justify-content: flex-end; }
}
/* Pit selection is already provided by accessible buttons on the board. */
html[data-classroom-playing] .mancala-page .mancala-pit-actions { display: none; }
@media (max-width: 600px) {
 html[data-classroom-playing] .mancala-page .mancala-pit-actions { display: block; }
 .mancala-pit-actions summary { width: fit-content; margin: 0 auto; padding: .65rem 1rem; border: 1px solid #bd8a50; border-radius: 999px; background: #fff7e4; color: #51351c; font-size: 1rem; font-weight: 800; cursor: pointer; }
 .mancala-pit-actions summary:focus-visible { outline: 3px solid #352570; outline-offset: 3px; }
 .mancala-pit-actions[open] > div { margin-top: .5rem; }
}
