/* Fun fonts from Google */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700&display=swap');

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS variables so colors are easy to change */
:root {
    --bg-start: #667eea;
    --bg-mid: #764ba2;
    --bg-end: #f093fb;
    --card-bg: rgba(255, 255, 255, 0.95);
    --x-color: #2196F3;       /* Blue for X */
    --o-color: #E91E63;       /* Pink for O */
    --win-color: #4CAF50;     /* Green for winning cells */
    --cell-border: #ccc;
    --text-dark: #333;
    --text-muted: #666;
}

body {
    font-family: 'Nunito', sans-serif;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-mid) 50%, var(--bg-end) 100%);
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Material Symbols filled style */
.material-symbols-rounded {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}

/* ===== Main Card Container ===== */
.game-container {
    max-width: 480px;
    width: 100%;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* ===== Header ===== */
.game-header {
    text-align: center;
    margin-bottom: 20px;
}

/* Back button - top left */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--bg-mid);
    font-weight: 700;
    font-size: 0.95em;
    margin-bottom: 12px;
    transition: opacity 0.2s;
}

.back-btn:hover {
    opacity: 0.7;
}

.game-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2em;
    color: var(--bg-mid);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.game-title .material-symbols-rounded {
    font-size: 36px;
}

/* ===== Difficulty Picker ===== */
.difficulty-picker {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.diff-btn {
    padding: 8px 20px;
    border: 2px solid var(--bg-mid);
    border-radius: 25px;
    background: white;
    color: var(--bg-mid);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn:hover {
    background: var(--bg-mid);
    color: white;
}

/* Active difficulty button */
.diff-btn.active {
    background: var(--bg-mid);
    color: white;
    box-shadow: 0 3px 10px rgba(118, 75, 162, 0.4);
}

/* ===== Score Display ===== */
.scoreboard {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 15px;
}

.score-item {
    text-align: center;
}

.score-label {
    font-weight: 700;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.score-label.x-label {
    color: var(--x-color);
}

.score-label.o-label {
    color: var(--o-color);
}

.score-label.draw-label {
    color: #9E9E9E;
}

.score-value {
    font-family: 'Fredoka One', cursive;
    font-size: 1.8em;
    color: var(--text-dark);
}

/* ===== Status Message ===== */
.status-message {
    text-align: center;
    font-family: 'Fredoka One', cursive;
    font-size: 1.3em;
    color: var(--bg-mid);
    margin-bottom: 15px;
    min-height: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.status-message .material-symbols-rounded {
    font-size: 24px;
}

/* ===== Tic Tac Toe Grid ===== */
.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
    max-width: 320px;
    margin: 0 auto 20px;
    aspect-ratio: 1;
}

/* Each cell is a button so it's accessible */
.cell {
    background: #f5f0ff;
    border: 2px solid var(--cell-border);
    border-radius: 12px;
    font-family: 'Fredoka One', cursive;
    font-size: 3em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    color: transparent;
    user-select: none;
    outline: none;
    position: relative;
}

.cell:hover:not(.taken):not(.win-cell) {
    background: #ede7f6;
    transform: scale(1.04);
    box-shadow: 0 2px 8px rgba(118, 75, 162, 0.2);
}

/* Keyboard focus style */
.cell:focus-visible {
    box-shadow: 0 0 0 3px var(--bg-mid), 0 0 0 5px rgba(118, 75, 162, 0.3);
    z-index: 1;
}

/* Cell with X mark */
.cell.x {
    color: var(--x-color);
}

/* Cell with O mark */
.cell.o {
    color: var(--o-color);
}

/* Taken cells don't show pointer */
.cell.taken {
    cursor: default;
}

/* Winning cells get a green highlight and grow */
.cell.win-cell {
    background: #e8f5e9;
    border-color: var(--win-color);
    animation: winPulse 0.6s ease-in-out;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

@keyframes winPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1.05); }
}

/* Place animation */
@keyframes placeMarker {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.cell.just-placed {
    animation: placeMarker 0.3s ease-out;
}

/* ===== Action Buttons ===== */
.actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.action-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 25px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.action-btn .material-symbols-rounded {
    font-size: 20px;
}

.new-game-btn {
    background: var(--bg-mid);
    color: white;
}

.reset-scores-btn {
    background: #f5f5f5;
    color: var(--text-muted);
    border: 1px solid #ddd;
}

/* ===== Footer ===== */
.game-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9em;
    padding-top: 10px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.game-footer .material-symbols-rounded {
    font-size: 18px;
    color: var(--o-color);
}

/* ===== Responsive ===== */
@media (max-width: 500px) {
    .game-container {
        padding: 20px 15px;
    }

    .game-title {
        font-size: 1.5em;
    }

    .board {
        max-width: 280px;
    }

    .cell {
        font-size: 2.4em;
    }

    .scoreboard {
        gap: 20px;
    }

    .difficulty-picker {
        gap: 6px;
    }

    .diff-btn {
        padding: 6px 14px;
        font-size: 0.85em;
    }
}
