/* ============================================
   BUFFALO TIC-TAC-TOE — Pure CSS Styles
   ============================================ */

/* --- Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a73e8;
    --primary-dark: #1558b0;
    --accent: #00c9a7;
    --accent-light: #b2f5ea;
    --purple: #7c3aed;
    --orange: #ff8c00;
    --bg: #f0f7f4;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.10);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
    --radius: 1rem;
    --cell-size: 100px;
    --board-gap: 6px;
    --board-size: calc(var(--cell-size) * 3 + var(--board-gap) * 2);
}

html { min-height: 100%; }

body {
    min-height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(160deg, #e0f2fe 0%, #f0fdf4 50%, #fef3c7 100%);
    color: var(--text);
    line-height: 1.6;
}

/* ============ GAME CONTAINER ============ */
#game-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 1.5rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ============ HEADER ============ */
.game-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.header-emoji {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 0.3rem;
    animation: bob 2.5s ease-in-out infinite;
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.game-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ============ PANELS ============ */
.panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-md);
    text-align: center;
    width: 100%;
    max-width: 400px;
}

.panel h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
}

/* ============ BUTTONS ============ */
.game-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1.3rem;
    padding: 0.9rem 1.6rem;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-sm);
}

.game-btn span {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.85;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.game-btn:active {
    transform: translateY(0);
}

.btn-sm {
    font-size: 0.95rem;
    padding: 0.55rem 1.1rem;
}

.btn-secondary {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

.mode-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============ GAME AREA ============ */
#game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    max-width: 400px;
}

/* ============ STATUS BAR ============ */
#status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    background: var(--surface);
    border-radius: 2rem;
    padding: 0.5rem 1.2rem;
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 340px;
}

#player-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    font-size: 1rem;
}

.turn-emoji {
    font-size: 1.5rem;
    transition: transform 0.2s;
}

.turn-emoji.bounce {
    animation: emoji-bounce 0.35s ease;
}

@keyframes emoji-bounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.mode-tag {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.6rem;
    border-radius: 2rem;
    background: var(--accent-light);
    color: #065f46;
}

/* ============ PLAYER SELECTOR (2P) ============ */
#player-selector {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.player-sel-btn {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.35rem 0.9rem;
    border: 2px solid #e2e8f0;
    border-radius: 2rem;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.player-sel-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
}

.player-sel-btn:hover {
    border-color: var(--primary);
}

/* ============ BOARD ============ */
#board {
    display: grid;
    grid-template-columns: repeat(3, var(--cell-size));
    grid-template-rows: repeat(3, var(--cell-size));
    gap: var(--board-gap);
    background: var(--text);
    border-radius: 12px;
    padding: var(--board-gap);
    box-shadow: var(--shadow-lg);
    position: relative;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: var(--surface);
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    user-select: none;
    position: relative;
}

.cell:hover:not(.taken) {
    background: #f0fdf4;
    transform: scale(1.04);
}

.cell.taken {
    cursor: default;
}

.cell.pop {
    animation: cell-pop 0.3s ease;
}

@keyframes cell-pop {
    0% { transform: scale(0.5); opacity: 0.5; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.cell.win-cell {
    background: #d1fae5;
    animation: win-glow 0.8s ease infinite alternate;
}

@keyframes win-glow {
    0% { background: #d1fae5; }
    100% { background: #a7f3d0; }
}

.cell.draw-cell {
    opacity: 0.5;
}

/* ============ WIN LINE SVG ============ */
#win-line {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--board-size);
    height: var(--board-size);
    pointer-events: none;
    /* Center over the board */
    z-index: 5;
    display: none;
}

#win-line.visible {
    display: block;
}

#strike {
    stroke: var(--accent);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    filter: drop-shadow(0 2px 6px rgba(0,201,167,0.5));
}

#strike.animate {
    animation: draw-line 0.5s ease forwards;
}

@keyframes draw-line {
    to { stroke-dashoffset: 0; }
}

/* Board wrapper for overlaying SVG */
#game-area {
    position: relative;
}

/* Position the SVG over the board */
#board {
    position: relative;
}

#win-line {
    position: absolute;
    /* We position it via JS, so these are defaults */
}

/* ============ RESULT ============ */
#result {
    font-size: 1.3rem;
    font-weight: 800;
    padding: 0.5rem 1.2rem;
    border-radius: 2rem;
    text-align: center;
    animation: result-in 0.4s ease;
}

@keyframes result-in {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

#result.win-p1 {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #065f46;
}

#result.win-p2 {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e3a8a;
}

#result.draw {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #78350f;
}

/* ============ SCOREBOARD ============ */
#scoreboard {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    width: 100%;
    max-width: 340px;
}

.score-cell {
    flex: 1;
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 0.5rem 0.3rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.score-icon {
    font-size: 1.4rem;
}

.score-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.score-val {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
}

/* ============ ACTION BUTTONS ============ */
.action-buttons {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
}

/* ============ BACK NAV ============ */
.back-nav {
    text-align: center;
    padding: 0.8rem 1rem 1.5rem;
}

.back-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: color 0.2s;
}

.back-nav a:hover {
    color: var(--primary);
}

/* ============ UTILITY ============ */
.hidden {
    display: none !important;
}

/* ============ BMC (BUY ME A COFFEE) ============ */
.bmc-inline {
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid #e2e8f0;
}

.bmc-message {
    font-size: 0.85rem;
    color: #7a6835;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.bmc-btn-sm {
    display: inline-block;
    background: #ffdd00;
    color: #000;
    font-family: 'Cookie', cursive, 'Segoe UI', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.4rem 1.2rem;
    border-radius: 2rem;
    text-decoration: none;
    border: 2px solid #000;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.10);
}

.bmc-btn-sm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.16);
}

.bmc-nav-link {
    color: var(--primary) !important;
    font-weight: 700;
}

.bmc-nav-link:hover {
    color: var(--primary-dark, #1558b0) !important;
}

.back-nav-sep {
    color: #cbd5e1;
    margin: 0 0.4rem;
}

/* BMC in-game text link */
.bmc-game-prompt {
    text-align: center;
    margin-top: 0.3rem;
}

.bmc-text-link {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
}

.bmc-text-link:hover {
    opacity: 1;
    color: #7a6835;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 420px) {
    :root {
        --cell-size: 80px;
    }

    .game-header h1 {
        font-size: 1.4rem;
    }

    .header-emoji {
        font-size: 2.4rem;
    }

    .cell {
        font-size: 2.4rem;
    }

    .game-btn {
        font-size: 1.1rem;
        padding: 0.7rem 1.2rem;
    }

    #scoreboard {
        gap: 0.5rem;
    }
}
