#game-root {
    color: var(--cg-ink);
    font-family: Inter, Arial, sans-serif;
}

.sd-game {
    max-width: 900px;
    margin: 0 auto;
    padding: 4px 0 28px;
}

.sd-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.sd-stats,
.sd-tools,
.sd-status,
.sd-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sd-stats > div,
.sd-status > div {
    min-width: 74px;
    padding: 8px 10px;
    border: 1px solid var(--cg-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
}

.sd-stats span,
.sd-status span {
    display: block;
    color: var(--cg-muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.sd-stats strong,
.sd-status strong {
    display: block;
    margin-top: 1px;
    font-size: 18px;
    line-height: 1.1;
}

.sd-icon-button,
.sd-share,
.sd-tab,
.sd-action,
.sd-pad-key,
.sd-cell {
    font: inherit;
}

.sd-icon-button,
.sd-share,
.sd-tab,
.sd-action {
    min-height: 44px;
    border: 1px solid var(--cg-line);
    border-radius: 8px;
    background: var(--cg-panel);
    color: var(--cg-ink);
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.sd-icon-button {
    width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sd-share,
.sd-action {
    padding: 0 13px;
    font-weight: 800;
}

.sd-share:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.sd-icon-button:hover,
.sd-share:not(:disabled):hover,
.sd-tab:hover,
.sd-action:hover,
.sd-pad-key:not(:disabled):hover {
    transform: translateY(-1px);
    border-color: rgba(49, 95, 157, 0.45);
}

.sd-icon-button:focus-visible,
.sd-share:focus-visible,
.sd-tab:focus-visible,
.sd-action:focus-visible,
.sd-pad-key:focus-visible,
.sd-cell:focus-visible {
    outline: 3px solid rgba(49, 95, 157, 0.32);
    outline-offset: 2px;
}

.sd-icon {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sd-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.sd-tab {
    padding: 0 12px;
    font-weight: 900;
}

.sd-tab.sd-is-active {
    border-color: var(--cg-green);
    background: rgba(29, 127, 98, 0.09);
    box-shadow: inset 0 0 0 2px rgba(29, 127, 98, 0.14);
}

.sd-status {
    justify-content: center;
    margin-bottom: 12px;
}

.sd-layout {
    display: grid;
    grid-template-columns: minmax(0, 560px) minmax(220px, 1fr);
    gap: 16px;
    align-items: start;
    justify-content: center;
}

.sd-board-shell {
    max-width: 560px;
    overflow-x: auto;
    padding-bottom: 2px;
    margin: 0 auto;
}

.sd-board-wrap {
    position: relative;
    width: min(100%, 560px);
    min-width: 396px;
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: var(--cg-shadow);
}

.sd-board {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    background: var(--cg-ink);
    border: 2px solid var(--cg-ink);
    border-radius: 8px;
    overflow: hidden;
}

.sd-cell {
    position: relative;
    min-width: 44px;
    min-height: 44px;
    border: 0;
    border-right: 1px solid var(--cg-line);
    border-bottom: 1px solid var(--cg-line);
    background: #fbfcf8;
    color: var(--cg-ink);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s ease, box-shadow 0.1s ease, color 0.1s ease;
}

.sd-cell.sd-box-top {
    border-top: 2px solid var(--cg-ink);
}

.sd-cell.sd-box-left {
    border-left: 2px solid var(--cg-ink);
}

.sd-cell.sd-box-right {
    border-right: 2px solid var(--cg-ink);
}

.sd-cell.sd-box-bottom {
    border-bottom: 2px solid var(--cg-ink);
}

.sd-cell.sd-is-given {
    background: #eef3ec;
    color: var(--cg-ink);
    font-weight: 900;
}

.sd-cell.sd-is-user {
    color: var(--cg-blue);
    font-weight: 800;
}

.sd-cell.sd-is-peer {
    background: #eef5f6;
}

.sd-cell.sd-is-match {
    background: #e3f1ec;
}

.sd-cell.sd-is-selected {
    background: #fff7e8;
    box-shadow: inset 0 0 0 3px rgba(196, 122, 23, 0.38);
    z-index: 2;
}

.sd-cell.sd-is-wrong {
    background: #fdeceb;
    color: var(--cg-red);
    animation: sd-shake 0.18s ease;
}

.sd-cell.sd-is-reveal {
    color: var(--cg-green);
}

.sd-value {
    font-size: clamp(22px, 6.4vw, 34px);
    line-height: 1;
}

.sd-notes {
    width: 86%;
    height: 86%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    align-items: center;
    justify-items: center;
    color: var(--cg-muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.sd-controls {
    display: grid;
    gap: 12px;
}

.sd-pad {
    display: grid;
    grid-template-columns: repeat(3, minmax(64px, 1fr));
    gap: 8px;
}

.sd-pad-key {
    min-height: 58px;
    border: 1px solid var(--cg-line);
    border-radius: 8px;
    background: var(--cg-panel);
    color: var(--cg-ink);
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.sd-pad-key strong {
    display: block;
    font-size: 24px;
    line-height: 1.1;
}

.sd-pad-key span {
    display: block;
    color: var(--cg-muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.sd-pad-key:disabled {
    cursor: not-allowed;
    opacity: 0.42;
}

.sd-actions {
    align-items: stretch;
}

.sd-action {
    flex: 1 1 120px;
}

.sd-action.sd-is-active {
    border-color: var(--cg-blue);
    background: rgba(49, 95, 157, 0.09);
    box-shadow: inset 0 0 0 2px rgba(49, 95, 157, 0.14);
}

.sd-board-cover {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 16px;
    border-radius: 8px;
    background: rgba(246, 247, 242, 0.86);
    backdrop-filter: blur(5px);
    z-index: 5;
}

.sd-board-cover[hidden],
.sd-modal[hidden] {
    display: none;
}

.sd-cover-card {
    width: min(260px, 90%);
    display: grid;
    gap: 10px;
    justify-items: center;
    padding: 18px;
    border: 1px solid var(--cg-line);
    border-radius: 8px;
    background: var(--cg-panel);
    box-shadow: var(--cg-shadow);
    text-align: center;
}

.sd-cover-card strong {
    font-size: 24px;
}

.sd-cover-card span {
    color: var(--cg-muted);
    font-weight: 700;
}

.sd-cover-card.sd-is-win {
    animation: sd-pop 0.24s ease;
}

.sd-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(30, 37, 40, 0.36);
}

.sd-modal-panel {
    width: min(420px, 100%);
    padding: 18px;
    border: 1px solid var(--cg-line);
    border-radius: 8px;
    background: var(--cg-panel);
    color: var(--cg-ink);
    box-shadow: var(--cg-shadow);
}

.sd-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.sd-modal-head strong {
    font-size: 20px;
}

.sd-modal-panel p {
    margin: 10px 0 0;
    color: var(--cg-muted);
    line-height: 1.45;
}

@keyframes sd-pop {
    0% {
        transform: scale(0.96);
        opacity: 0.4;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes sd-shake {
    0%, 100% {
        transform: translateX(0);
    }
    35% {
        transform: translateX(-2px);
    }
    70% {
        transform: translateX(2px);
    }
}

@media (max-width: 760px) {
    .sd-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .sd-stats {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .sd-tools {
        justify-content: flex-end;
    }

    .sd-layout {
        grid-template-columns: 1fr;
    }

    .sd-controls {
        max-width: 560px;
        margin: 0 auto;
    }

    .sd-pad {
        grid-template-columns: repeat(5, minmax(52px, 1fr));
    }
}

@media (max-width: 430px) {
    .sd-game {
        padding-bottom: 18px;
    }

    .sd-stats > div,
    .sd-status > div {
        min-width: 0;
        padding: 7px 8px;
    }

    .sd-stats strong,
    .sd-status strong {
        font-size: 16px;
    }

    .sd-tabs {
        gap: 6px;
    }

    .sd-tab,
    .sd-action,
    .sd-share {
        padding: 0 10px;
    }

    .sd-board-shell {
        margin-left: 0;
        margin-right: 0;
    }

    .sd-board-wrap {
        min-width: 0;
    }

    .sd-cell {
        min-width: 0;
        min-height: 0;
    }

    .sd-pad {
        grid-template-columns: repeat(3, minmax(74px, 1fr));
    }
}
