.wp-block-hustoj-edu-games-data-structure-lab,
.hustoj-data-structure-lab-block {
    width: min(var(--hustoj-shell-width, 1120px), calc(100% - (var(--hustoj-shell-padding-x, 1rem) * 2)));
    max-width: none;
    margin: 0 auto;
    box-sizing: border-box;
}

.oj-structure-shell {
    --structure-bg: #f6f8fb;
    --structure-ink: #172033;
    --structure-muted: #657186;
    --structure-line: #d7dee9;
    --structure-panel: #ffffff;
    --structure-primary: #1d6fd8;
    --structure-primary-dark: #154a90;
    --structure-green: #1f8a55;
    --structure-red: #d9483b;
    --structure-yellow: #f2b830;
    width: 100%;
    color: var(--structure-ink);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.oj-structure-shell * {
    box-sizing: border-box;
}

.oj-structure-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0 14px;
}

.oj-structure-kicker {
    margin: 0 0 4px;
    color: var(--structure-red);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.oj-structure-topbar h2 {
    margin: 0;
    font-size: clamp(1.7rem, 3vw, 2.6rem);
    line-height: 1.05;
}

.oj-structure-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.oj-structure-select,
.oj-structure-button,
.oj-structure-mode {
    min-height: 42px;
    border: 1px solid var(--structure-line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--structure-ink);
    font: inherit;
    font-weight: 900;
}

.oj-structure-select {
    padding: 0 34px 0 12px;
}

.oj-structure-button,
.oj-structure-mode {
    padding: 0 14px;
    cursor: pointer;
}

.oj-structure-button-primary,
.oj-structure-mode.is-active {
    border-color: var(--structure-primary);
    background: var(--structure-primary);
    color: #ffffff;
}

.oj-structure-modebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.oj-structure-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.oj-structure-stat {
    min-width: 0;
    min-height: 74px;
    padding: 12px;
    border: 1px solid var(--structure-line);
    border-radius: 8px;
    background: #ffffff;
}

.oj-structure-stat span {
    display: block;
    margin-bottom: 6px;
    color: var(--structure-muted);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.oj-structure-stat strong {
    display: block;
    font-size: 1.6rem;
    line-height: 1;
    text-align: right;
}

.oj-structure-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 12px;
    align-items: start;
}

.oj-structure-panel {
    min-width: 0;
    border: 1px solid var(--structure-line);
    border-radius: 8px;
    background: var(--structure-panel);
    overflow: hidden;
}

.oj-structure-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--structure-line);
    background: #f9fbfe;
}

.oj-structure-panel-head span {
    color: var(--structure-muted);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.oj-structure-panel-head h3 {
    margin: 3px 0 0;
    font-size: 1.1rem;
    line-height: 1.25;
}

.oj-structure-question {
    padding: 14px 16px;
    border-bottom: 1px solid var(--structure-line);
    background: #fff8e5;
    color: #6e4b00;
    font-weight: 850;
    line-height: 1.45;
}

.oj-structure-machine {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 12px;
    padding: 14px;
    background:
        linear-gradient(90deg, rgba(29, 111, 216, 0.06) 1px, transparent 1px),
        linear-gradient(0deg, rgba(29, 111, 216, 0.05) 1px, transparent 1px),
        var(--structure-bg);
    background-size: 30px 30px;
}

.oj-structure-operations {
    display: grid;
    gap: 8px;
}

.oj-structure-operation {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    min-height: 44px;
    border: 1px solid #cdd8e7;
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

.oj-structure-operation span {
    display: grid;
    height: 100%;
    place-items: center;
    background: #eaf3ff;
    color: var(--structure-primary-dark);
    font-weight: 900;
}

.oj-structure-operation code {
    padding: 0 11px;
    color: var(--structure-ink);
    font-family: Consolas, "SFMono-Regular", monospace;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.oj-structure-visual-card {
    display: grid;
    gap: 8px;
    min-height: 100%;
    place-items: center;
    padding: 18px;
    border: 1px solid #cdd8e7;
    border-radius: 8px;
    background: #ffffff;
    text-align: center;
}

.oj-structure-visual-card strong {
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    border-radius: 50%;
    background: var(--structure-primary);
    color: #ffffff;
    font-size: 2rem;
}

.oj-structure-visual-card span {
    font-size: 1.1rem;
    font-weight: 900;
}

.oj-structure-visual-card p {
    margin: 0;
    color: var(--structure-muted);
    font-weight: 800;
    line-height: 1.45;
}

.oj-structure-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 14px;
}

.oj-structure-option {
    min-height: 52px;
    padding: 8px 12px;
    border: 1px solid var(--structure-line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--structure-ink);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    text-align: left;
}

.oj-structure-option.is-selected {
    border-color: var(--structure-yellow);
    background: #fff7d8;
    color: #5d4300;
}

.oj-structure-option.is-answer {
    border-color: var(--structure-green);
    background: #e9f8ef;
    color: #126238;
}

.oj-structure-submit-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px 14px;
}

.oj-structure-feedback {
    min-width: 0;
    margin: 0;
    color: var(--structure-green);
    font-weight: 900;
    line-height: 1.4;
}

.oj-structure-side {
    display: grid;
    gap: 12px;
    position: sticky;
    top: 24px;
}

.oj-structure-rules {
    display: grid;
    gap: 10px;
    padding: 12px;
}

.oj-structure-rules div {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid #e6ebf2;
    border-radius: 8px;
    background: #fbfcff;
}

.oj-structure-rules strong {
    font-weight: 900;
}

.oj-structure-rules span {
    color: var(--structure-muted);
    font-size: 0.85rem;
    font-weight: 800;
    line-height: 1.45;
}

.oj-structure-leaderboard {
    display: grid;
    gap: 6px;
    padding: 10px;
}

.oj-structure-rank-head,
.oj-structure-rank-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 66px;
    gap: 8px;
    align-items: center;
}

.oj-structure-rank-head {
    padding: 0 8px 4px;
    color: var(--structure-muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.oj-structure-rank-row {
    min-height: 40px;
    padding: 8px;
    border: 1px solid var(--structure-line);
    border-radius: 8px;
    background: #ffffff;
}

.oj-structure-rank-row.is-me {
    border-color: var(--structure-primary);
    background: #edf5ff;
}

.oj-structure-rank-row span {
    min-width: 0;
    overflow: hidden;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.oj-structure-rank-row b {
    color: var(--structure-primary-dark);
    text-align: right;
}

.oj-structure-rank-empty {
    min-height: 84px;
    display: grid;
    place-items: center;
    color: var(--structure-muted);
    font-weight: 800;
    text-align: center;
}

@media (max-width: 980px) {
    .oj-structure-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .oj-structure-side {
        position: static;
    }
}

@media (max-width: 760px) {
    .oj-structure-machine,
    .oj-structure-options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .wp-block-hustoj-edu-games-data-structure-lab,
    .hustoj-data-structure-lab-block {
        width: calc(100% - 12px);
    }

    .oj-structure-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .oj-structure-submit-row {
        align-items: stretch;
        flex-direction: column;
    }
}
