* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #2d5016 0%, #1a3009 50%, #0d1804 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.game-wrapper {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
    color: #f5f0e6;
}

.game-header h1 {
    font-size: 1.8rem;
    margin-bottom: 6px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
    margin-bottom: 14px;
}

.mode-select {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.mode-btn {
    padding: 10px 20px;
    border: 2px solid rgba(255,255,255,0.4);
    background: rgba(0,0,0,0.3);
    color: #f5f0e6;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s, border-color 0.2s;
}

.mode-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.6);
}

.mode-btn.active {
    background: rgba(255,255,255,0.25);
    border-color: #c9a227;
    color: #fff;
}

.turn-info {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.turn-info .symbol-x { color: #1a1a1a; text-shadow: 0 0 8px rgba(255,255,255,0.3); }
.turn-info .symbol-o { color: #c9a227; text-shadow: 0 0 10px rgba(201,162,39,0.6); }

.new-game-btn {
    padding: 10px 24px;
    background: linear-gradient(180deg, #3d6b1f 0%, #2d5016 100%);
    border: 2px solid #5a8c2a;
    color: #f5f0e6;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.new-game-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
}

/* Дъска – тъмно зелена рамка (като от снимката) */
.board-frame {
    position: relative;
    display: inline-block;
    padding: 14px 14px 12px 12px;
    background: linear-gradient(145deg, #2d5016 0%, #1a3009 40%, #0f2006 100%);
    border-radius: 8px;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.15),
        inset 0 -2px 8px rgba(0,0,0,0.5),
        0 8px 24px rgba(0,0,0,0.5);
    border: 3px solid #1a3009;
}

.board-coords {
    position: absolute;
    color: #7a9c5c;
    font-size: 0.75rem;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    letter-spacing: 0.05em;
}

.board-coords-top {
    top: 4px;
    left: 38px;
    display: flex;
    gap: 0;
}

.board-coords-top span {
    width: 32px;
    text-align: center;
}

.board-coords-left {
    left: 8px;
    top: 38px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.board-coords-left span {
    height: 32px;
    display: flex;
    align-items: center;
}

.board-inner {
    margin-top: 20px;
    margin-left: 20px;
}

/* Решетка – каменни плочки */
.board-grid {
    display: grid;
    gap: 2px;
    background: #8b7355;
    padding: 4px;
    border-radius: 4px;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.3);
}

.cell {
    width: 32px;
    height: 32px;
    background: linear-gradient(145deg, #c4b59a 0%, #a8987a 50%, #8f7e60 100%);
    border-radius: 3px;
    box-shadow:
        inset 1px 1px 0 rgba(255,255,255,0.4),
        inset -1px -1px 0 rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}

.cell:hover {
    background: linear-gradient(145deg, #d4c4aa 0%, #b8a88a 100%);
    box-shadow: inset 0 0 0 2px rgba(201,162,39,0.4);
}

.cell:active {
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.3);
}

.cell.last-move {
    background: linear-gradient(145deg, #e8d858 0%, #d4c040 100%);
    box-shadow: inset 0 0 0 2px rgba(180,140,20,0.8);
}

.cell.win-cell {
    background: linear-gradient(145deg, #a0d050 0%, #80b030 100%);
    box-shadow: inset 0 0 0 2px rgba(60,100,20,0.9);
}

/* Символ X – черен, с лека сянка */
.cell.symbol-x {
    cursor: default;
}

.cell.symbol-x::after {
    content: 'X';
    font-size: 22px;
    font-weight: 900;
    color: #1a1a1a;
    text-shadow:
        1px 1px 0 rgba(0,0,0,0.5),
        0 0 4px rgba(0,0,0,0.3);
    line-height: 1;
}

/* Символ O – тъмно оранжев с дебел контур за добра видимост */
.cell.symbol-o {
    cursor: default;
}

.cell.symbol-o::after {
    content: 'O';
    font-size: 20px;
    font-weight: 900;
    color: #8b6914;
    -webkit-text-stroke: 1.5px #5c4509;
    text-stroke: 1.5px #5c4509;
    text-shadow:
        0 0 0 2px #2a2006,
        1px 1px 0 #1a1a1a,
        2px 2px 4px rgba(0,0,0,0.6),
        0 0 8px rgba(180,140,20,0.4);
    line-height: 1;
}

/* Game over overlay */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.game-over-overlay.hidden {
    display: none;
}

.game-over-box {
    background: linear-gradient(180deg, #3d6b1f 0%, #2d5016 100%);
    border: 3px solid #5a8c2a;
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    color: #f5f0e6;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}

.game-over-box h2 {
    margin-bottom: 12px;
    font-size: 1.8rem;
}

.game-over-box p {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* Мобилна версия */
@media (max-width: 600px) {
    .cell {
        width: 24px;
        height: 24px;
    }
    .cell.symbol-x::after { font-size: 16px; }
    .cell.symbol-o::after { font-size: 14px; }
    .board-coords-top span { width: 24px; }
    .board-coords-left span { height: 24px; }
    .board-coords { font-size: 0.65rem; }
    .board-inner { margin-top: 16px; margin-left: 16px; }
    .board-frame { padding: 10px 10px 8px 8px; }
}

@media (max-width: 420px) {
    .cell {
        width: 20px;
        height: 20px;
    }
    .cell.symbol-x::after { font-size: 14px; }
    .cell.symbol-o::after { font-size: 12px; }
    .board-coords-top span { width: 20px; }
    .board-coords-left span { height: 20px; }
}
