.index-game {
    --game-bg: #101820;
    --game-panel: #17222b;
    --game-panel-2: #1f2e36;
    --game-line: #38515f;
    --game-text: #f4f7f6;
    --game-muted: #b8c7c1;
    --game-blue: #5aa9e6;
    --game-green: #7ccf8a;
    --game-amber: #f1c453;
    --game-red: #ef6f6c;
    --game-ink: #0b1216;
    max-width: 1120px;
    margin: 1.25rem auto;
    padding: clamp(0.85rem, 2vw, 1.25rem);
    border: 1px solid var(--game-line);
    border-radius: 8px;
    background: var(--game-bg);
    color: var(--game-text);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.24);
    direction: rtl;
}

.index-game * {
    box-sizing: border-box;
}

.index-game__topbar,
.index-game__controls,
.index-game__choices,
.index-game__feedback,
.index-game__legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.index-game__topbar {
    justify-content: space-between;
    margin-bottom: 0.8rem;
}

.index-game__title {
    margin: 0;
    color: var(--game-amber);
    font-size: clamp(1.08rem, 2vw, 1.32rem);
}

.index-game__score {
    min-width: 9rem;
    padding: 0.42rem 0.65rem;
    border: 1px solid var(--game-line);
    border-radius: 6px;
    background: var(--game-panel);
    color: var(--game-muted);
    text-align: center;
    font-weight: 700;
}

.index-game__layout {
    display: grid;
    grid-template-columns: minmax(20rem, 1fr) minmax(20rem, 0.92fr);
    gap: 1rem;
    align-items: start;
    direction: ltr;
}

.index-game__stage,
.index-game__mission {
    min-width: 0;
    border: 1px solid var(--game-line);
    border-radius: 8px;
    background: var(--game-panel);
    padding: clamp(0.8rem, 2vw, 1rem);
}

.index-game__stage {
    direction: rtl;
    text-align: right;
}

.index-game__mission {
    direction: rtl;
    text-align: right;
}

.index-game__story {
    min-height: 2.5rem;
    color: var(--game-muted);
    font-weight: 700;
}

.index-game__code {
    width: 100%;
    margin: 0.5rem 0 0.8rem;
    padding: 0.8rem;
    border: 1px solid #263944;
    border-radius: 6px;
    background: #0c1217;
    color: #dbe8e1;
    overflow-x: auto;
    white-space: pre;
    direction: ltr;
    text-align: left;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.95rem;
    line-height: 1.45;
}

.index-game__task {
    color: var(--game-text);
    font-size: 1.02rem;
    font-weight: 800;
    line-height: 1.5;
}

.index-game__visual {
    margin-top: 0.9rem;
}

.index-game__strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    direction: ltr;
    margin: 0.65rem 0;
}

.index-game__cell {
    width: clamp(3.4rem, 10vw, 4.7rem);
    min-height: 4.7rem;
    border: 2px solid var(--game-line);
    border-radius: 7px;
    background: var(--game-panel-2);
    color: var(--game-text);
    display: grid;
    grid-template-rows: 1.2rem 1fr;
    align-items: center;
    justify-items: center;
    cursor: pointer;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.index-game__cell:hover,
.index-game__cell:focus {
    transform: translateY(-2px);
    border-color: var(--game-blue);
    outline: none;
}

.index-game__cell.is-selected {
    border-color: var(--game-amber);
    background: #3a321b;
}

.index-game__cell.is-correct {
    border-color: var(--game-green);
    background: #203a29;
}

.index-game__cell.is-wrong {
    border-color: var(--game-red);
    background: #3d2021;
}

.index-game__index {
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--game-muted);
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.78rem;
    line-height: 1.2rem;
    text-align: center;
}

.index-game__value {
    padding: 0.15rem;
    font-family: Consolas, "Courier New", monospace;
    font-size: clamp(1rem, 2.8vw, 1.35rem);
    font-weight: 800;
    overflow-wrap: anywhere;
}

.index-game__cell--array {
    width: clamp(4.8rem, 13vw, 6.8rem);
}

.index-game__cell--wide {
    width: clamp(5.8rem, 16vw, 8.2rem);
}

.index-game__length-line,
.index-game__subline,
.index-game__feedback {
    color: var(--game-muted);
}

.index-game__length-line {
    margin-top: 0.4rem;
    text-align: center;
    direction: ltr;
    font-family: Consolas, "Courier New", monospace;
}

.index-game__subline {
    min-height: 1.5rem;
    margin-top: 0.5rem;
    text-align: center;
    font-weight: 700;
}

.index-game__feedback {
    min-height: 2.3rem;
    margin-top: 0.8rem;
    justify-content: center;
    font-weight: 800;
    text-align: center;
}

.index-game__feedback.is-good {
    color: var(--game-green);
}

.index-game__feedback.is-bad {
    color: var(--game-red);
}

.index-game__feedback.is-note {
    color: var(--game-amber);
}

.index-game__choices {
    margin-top: 0.75rem;
}

.index-game__btn {
    min-height: 2.45rem;
    border: 1px solid var(--game-line);
    border-radius: 6px;
    background: #243540;
    color: var(--game-text);
    padding: 0.45rem 0.85rem;
    font-weight: 800;
    cursor: pointer;
}

.index-game__btn:hover,
.index-game__btn:focus {
    border-color: var(--game-blue);
    outline: 2px solid rgba(90, 169, 230, 0.35);
    outline-offset: 1px;
}

.index-game__btn:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.index-game__btn--primary {
    background: var(--game-blue);
    color: var(--game-ink);
    border-color: #8fc9ef;
}

.index-game__btn--danger {
    background: #4b2425;
    border-color: var(--game-red);
}

.index-game__btn--success {
    background: #234b30;
    border-color: var(--game-green);
}

.index-game__controls {
    justify-content: center;
    margin-top: 1rem;
}

.index-game__sequence {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.5rem;
    margin-top: 0.7rem;
    direction: ltr;
}

.index-game__token {
    min-width: 2.15rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    background: #0c1217;
    border: 1px solid var(--game-line);
    color: var(--game-amber);
    text-align: center;
    font-family: Consolas, "Courier New", monospace;
    font-weight: 800;
}

.index-game__loop-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
    margin-top: 0.85rem;
    direction: rtl;
}

.index-game__loop-mode {
    min-height: 8rem;
    border: 1px solid var(--game-line);
    border-radius: 8px;
    background: #142029;
    padding: 0.75rem;
}

.index-game__loop-mode h4 {
    margin: 0 0 0.45rem;
    color: var(--game-amber);
    font-size: 1rem;
}

.index-game__loop-mode p {
    margin: 0.25rem 0;
    color: var(--game-muted);
}

.index-game__legend {
    justify-content: center;
    margin-top: 0.65rem;
    font-size: 0.9rem;
    color: var(--game-muted);
}

.index-game__swatch {
    width: 0.95rem;
    height: 0.95rem;
    border-radius: 4px;
    display: inline-block;
    vertical-align: middle;
}

.index-game__swatch--selected {
    background: #3a321b;
    border: 1px solid var(--game-amber);
}

.index-game__swatch--correct {
    background: #203a29;
    border: 1px solid var(--game-green);
}

@media (max-width: 860px) {
    .index-game__layout,
    .index-game__loop-panel {
        grid-template-columns: 1fr;
    }

    .index-game__stage {
        order: 2;
    }

    .index-game__mission {
        order: 1;
    }
}
