body {
    background:
        linear-gradient(180deg, rgba(184, 50, 74, 0.08), transparent 260px),
        var(--bg);
}

.topbar {
    height: 64px;
    padding: 12px clamp(16px, 4vw, 34px);
    background: rgba(9, 10, 13, 0.78);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px) saturate(140%);
}

.topbar .icon {
    width: 38px;
    height: 38px;
}

.topbar > .tools-text {
    grid-column: 3;
    justify-self: end;
}

.wrap {
    position: relative;
    z-index: 2;
    min-height: calc(100vh - 64px);
    margin-top: 64px;
    padding: clamp(14px, 3vw, 28px);
}

.game,
.typing-game {
    color: var(--text);
}

.panel,
.board-area,
.text-display,
.results,
.shortcuts,
.game-info,
.how-to-play-content {
    background: rgba(21, 22, 27, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.board-area {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.panel h4,
.how-to-play-content h2,
.how-to-play-content h3,
.results-title,
.game-title,
.turn-indicator {
    color: var(--text);
}

.controls,
.overlay p,
.game-subtitle,
.stat-label,
.result-label,
.game-info,
.shortcuts,
.speed-value {
    color: var(--muted);
}

canvas,
#gameCanvas,
#holdCanvas,
#nextCanvas {
    background: #101116;
    border-color: rgba(224, 93, 111, 0.34);
}

.board-area canvas {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.btn,
.control-btn,
.passage-select,
input[type="text"],
.typing-input {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}

.btn:hover,
.btn:focus-visible,
.control-btn:hover,
.control-btn:focus-visible,
.passage-select:focus,
input[type="text"]:focus,
.typing-input:focus {
    color: #fff;
    background: rgba(184, 50, 74, 0.18);
    border-color: rgba(224, 93, 111, 0.48);
    outline: none;
}

.btn.primary,
.btn.active,
.control-btn.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent-2);
}

.overlay[hidden],
.how-to-play-modal[hidden] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    backdrop-filter: none !important;
}

.overlay:not(.with-background) {
    background: transparent;
    backdrop-filter: none;
}

.overlay,
.how-to-play-modal {
    border-color: rgba(224, 93, 111, 0.58);
}

.overlay.with-background,
.how-to-play-modal {
    background: rgba(9, 10, 13, 0.84);
    backdrop-filter: blur(12px) saturate(120%);
}

.lb-row {
    border-bottom-color: rgba(224, 93, 111, 0.22);
}

.stat-value,
.result-value,
.timer,
.control-key,
.difficulty-info,
.turn-indicator .current-player {
    color: var(--accent-2);
}

.char.correct {
    color: var(--text);
    background: rgba(184, 50, 74, 0.2);
}

.char.incorrect {
    color: #ffb7c0;
    background: rgba(224, 93, 111, 0.2);
}

.char.current {
    color: #fff;
    background: var(--accent);
}

.game-board,
.ultimate-board {
    background: rgba(9, 10, 13, 0.72);
    border-color: rgba(224, 93, 111, 0.34);
}

.cell,
.small-board,
.small-cell {
    background: rgba(255, 255, 255, 0.045);
    border-color: rgba(255, 255, 255, 0.1);
}

.cell,
.small-cell {
    min-height: 0;
}

.cell:hover:not(.occupied),
.small-cell:hover:not(.occupied):not(.disabled),
.small-board.active,
.small-cell.legal-move {
    background: rgba(184, 50, 74, 0.16);
    border-color: rgba(224, 93, 111, 0.54);
    box-shadow: 0 0 0 1px rgba(224, 93, 111, 0.16);
}

.cell.x,
.small-cell.x {
    color: var(--text);
}

.cell.o,
.small-cell.o {
    color: var(--accent-2);
}

.cell.winning,
.small-cell.winning {
    background: rgba(184, 50, 74, 0.28);
}

.small-board.won-x {
    background: rgba(244, 241, 234, 0.08);
    border-color: rgba(244, 241, 234, 0.42);
}

.small-board.won-o {
    background: rgba(184, 50, 74, 0.16);
    border-color: rgba(224, 93, 111, 0.48);
}

.small-board.draw {
    background: rgba(166, 172, 184, 0.08);
    border-color: rgba(166, 172, 184, 0.3);
}

@media (max-width: 720px) {
    .wrap {
        margin-top: 64px;
    }

    .leftbar,
    .rightbar {
        grid-template-columns: 1fr;
    }
}
