body {
    min-height: 100vh;
}

.game-container {
    max-width: 1180px;
}

.game-area,
.setup-screen {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.game-area {
    padding: 24px;
}

.setup-screen {
    text-align: center;
}

#back-to-modes,
#back-to-modes-from-setup {
    margin-top: 14px;
}

.bot-summary {
    margin: 0 0 18px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--background-color);
    color: var(--text-muted);
    font-weight: 600;
}

.status {
    min-height: 1.6em;
    margin: 0 0 14px;
    color: var(--secondary-color);
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
}

.wall-maze-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 22px;
    align-items: start;
}

.board-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.maze-legend {
    padding: 8px 14px;
    border-radius: 999px;
    background: #edf6ff;
    color: #24527a;
    font-weight: 700;
    font-size: 0.92rem;
}

.wall-maze-board {
    --cell-size: clamp(34px, 6vw, 54px);
    --wall-gap: clamp(7px, 1.25vw, 10px);
    display: grid;
    grid-template-columns: repeat(8, var(--cell-size) var(--wall-gap)) var(--cell-size);
    grid-template-rows: repeat(8, var(--cell-size) var(--wall-gap)) var(--cell-size);
    position: relative;
    padding: 10px;
    border: 3px solid #32475b;
    border-radius: 16px;
    background: #bbd7c3;
    box-shadow: inset 0 0 0 5px rgba(255,255,255,0.35), var(--shadow);
    touch-action: manipulation;
}

.maze-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border: 1px solid rgba(44, 62, 80, 0.2);
    border-radius: 9px;
    background: #f8fbf3;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}

.maze-cell:hover {
    transform: scale(1.04);
}

.maze-cell.goal-top { border-top: 4px solid #3498db; }
.maze-cell.goal-bottom { border-bottom: 4px solid #e74c3c; }
.maze-cell.goal-left { border-left: 4px solid #f39c12; }
.maze-cell.goal-right { border-right: 4px solid #27ae60; }

.maze-cell.legal-move {
    background: #dff7e8;
    box-shadow: inset 0 0 0 3px #27ae60, 0 0 0 2px rgba(39,174,96,0.2);
}

.maze-cell.jump-move::after {
    content: '↷';
    position: absolute;
    font-size: 0.85rem;
    color: #1e8449;
    transform: translate(12px, -12px);
}

.maze-cell.blocked-input {
    cursor: not-allowed;
}

.pawn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 74%;
    height: 74%;
    border: 3px solid rgba(255,255,255,0.82);
    border-radius: 50%;
    color: white;
    font-size: clamp(1rem, 2.6vw, 1.55rem);
    font-weight: 900;
    line-height: 1;
    box-shadow: 0 4px 10px rgba(0,0,0,0.24);
}

.player-p1 { background: #d94f4f; }
.player-p2 { background: #2f80d1; }
.player-p3 { background: #28a76f; }
.player-p4 { background: #d59a24; }

.wall-slot,
.placed-wall {
    width: 100%;
    height: 100%;
    border-radius: 999px;
}

.wall-slot {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, background 0.15s ease, transform 0.15s ease;
    z-index: 4;
}

.wall-slot:hover,
.wall-slot:focus-visible {
    transform: scale(1.08);
    outline: 2px solid #1f8f4d;
    outline-offset: 2px;
}

.wall-maze-board.wall-mode .wall-slot.visible {
    opacity: 0.42;
    pointer-events: auto;
}

.wall-maze-board.wall-mode .wall-slot.valid {
    background: #30c56c;
}

.wall-maze-board.wall-mode .wall-slot.invalid {
    background: #e74c3c;
    cursor: not-allowed;
}

.wall-maze-board.wall-mode .wall-slot.valid:hover,
.wall-maze-board.wall-mode .wall-slot.valid:focus-visible {
    opacity: 0.88;
}

.placed-wall {
    z-index: 3;
    background: #5c3824;
    border: 1px solid #3a2215;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    pointer-events: none;
}

.control-panel {
    display: grid;
    gap: 14px;
    text-align: left;
}

.turn-card,
.hint-box,
.players-panel,
.message-log {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #fbfcfd;
}

.turn-card {
    padding: 14px 16px;
}

.turn-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

#current-player-name {
    display: block;
    margin-top: 4px;
    color: var(--secondary-color);
    font-size: 1.25rem;
}

.action-controls,
.orientation-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.action-btn,
.orientation-btn {
    padding: 10px 12px;
    box-shadow: none;
}

.action-btn:not(.active),
.orientation-btn:not(.active) {
    background: var(--text-muted);
}

.orientation-controls.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.hint-box {
    padding: 12px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.players-panel {
    display: grid;
    gap: 8px;
    padding: 10px;
}

.player-card {
    display: grid;
    gap: 5px;
    padding: 10px;
    border: 2px solid transparent;
    border-radius: 10px;
    background: white;
}

.player-card.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.12);
}

.player-card.winner {
    border-color: var(--success-color);
    background: #effaf2;
}

.player-card-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-weight: 800;
}

.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.player-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.player-card small {
    color: var(--text-muted);
}

.message-log {
    min-height: 52px;
    padding: 12px;
    color: #5f4714;
    background: #fff8df;
    font-size: 0.92rem;
}

.game-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.online-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.opponent-name {
    color: var(--text-muted);
    font-weight: 700;
}

.celebrate {
    animation: celebratePulse 0.8s ease-in-out 3;
}

@keyframes celebratePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@media (max-width: 860px) {
    .wall-maze-layout {
        grid-template-columns: 1fr;
    }

    .control-panel {
        text-align: center;
    }
}

@media (max-width: 560px) {
    .game-area {
        padding: 14px;
    }

    .wall-maze-board {
        --cell-size: clamp(28px, 9vw, 38px);
        --wall-gap: 6px;
        padding: 7px;
        border-width: 2px;
    }

    .action-controls,
    .orientation-controls {
        grid-template-columns: 1fr;
    }

    .header {
        align-items: flex-start;
    }
}
