.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%);
}

.mancala-stage {
    width: min(1180px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-rows: auto auto minmax(360px, 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-board-shell {
    position: relative;
    overflow: hidden;
    min-height: clamp(360px, 62vh, 650px);
    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-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-culture {
    margin: 0;
    color: #4c5d3c;
    font-size: clamp(0.9rem, 2vw, 1rem);
    font-weight: 800;
    text-align: center;
}

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

.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-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);
    }
}

@media (max-width: 820px) {
    .mancala-toolbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .mancala-status {
        width: 100%;
    }

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

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

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

    .mancala-turn-chip {
        grid-column: 1 / -1;
        grid-row: 1;
        width: 100%;
    }

    .mancala-board-shell {
        min-height: min(66vh, 500px);
    }

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

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

@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-modal {
        padding: 0.75rem;
    }

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