/* =================================================================
   ULTIMATE TIC-TAC-TOE STYLES
   ================================================================= */

/* =================================================================
   BASE STYLES & RESET
   ================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #1E2233;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: Arial, sans-serif;
}

/* =================================================================
   GAME CONTAINER & LAYOUT
   ================================================================= */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 48px;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

/* Game state classes for turn tracking */
.x-turn {
    /* Class applied to body when it's X's turn */
}

.o-turn {
    /* Class applied to body when it's O's turn */
}

/* =================================================================
   GAME BOARD STYLES
   ================================================================= */
.main-board {
    display: grid;
    grid-template-columns: repeat(3, 112px);
    grid-template-rows: repeat(3, 112px);
    gap: 8px;
}

.mini-board {
    width: 112px;
    height: 112px;
    padding: 5px;
    box-shadow: inset 4px 4px 16px rgba(0, 0, 0, 0.18);
    display: grid;
    grid-template-columns: repeat(3, 32px);
    grid-template-rows: repeat(3, 32px);
    gap: 3px;
    border-radius: 8px;
    position: relative;
    border: 1px solid transparent;
    transition: border-color 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.6s, background-color 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.6s;
}

/* =================================================================
   BOARD STATES (Active/Inactive)
   ================================================================= */
/* Active mini-board styling */
.mini-board.active {
    background-color: #171926;
    transition: border-color 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.6s;
}

/* Active board border based on turn */
body.x-turn .mini-board.active {
    border: 1px solid #337AFF; /* 100% blue */
}

body.o-turn .mini-board.active {
    border: 1px solid #FF3333; /* 100% red */
}

.mini-board.active .cell {
    background-color: transparent;
}

.mini-board.active .cell::after {
    background-color: #373C54;
}

/* Inactive mini-board styling */
.mini-board.inactive {
    background-color: #1C2030;
}

.mini-board.inactive .cell {
    background-color: transparent;
}

.mini-board.inactive .cell::after {
    background-color: #2B3045;
}

/* =================================================================
   CELL STYLES
   ================================================================= */
.cell {
    width: 32px;
    height: 32px;
    position: relative;
    cursor: pointer;
}

/* Disable cursor for inactive mini-board cells */
.mini-board.inactive .cell {
    cursor: default;
}

/* Disable cursor for occupied cells */
.cell.x-mark,
.cell.o-mark {
    cursor: default;
}

/* Dot in the middle of each cell */
.cell::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: background-color 0.15s ease;
}

/* =================================================================
   HOVER EFFECTS (Desktop Only)
   ================================================================= */
@media (hover: hover) and (pointer: fine) {
    /* X's turn hover */
    body.x-turn .mini-board.active .cell:not(.x-mark):not(.o-mark):hover {
        box-shadow: inset 0 0 0 1px #2B3045;
        border-radius: 6px;
    }

    body.x-turn .mini-board.active .cell:not(.x-mark):not(.o-mark):hover::after {
        background-color: #337AFF;
        transition: background-color 0.15s ease;
    }

    /* O's turn hover */
    body.o-turn .mini-board.active .cell:not(.x-mark):not(.o-mark):hover {
        box-shadow: inset 0 0 0 1px #2B3045;
        border-radius: 6px;
    }

    body.o-turn .mini-board.active .cell:not(.x-mark):not(.o-mark):hover::after {
        background-color: #FF3333;
        transition: background-color 0.15s ease;
    }
}

/* =================================================================
   GAME PIECES (X & O Marks)
   ================================================================= */
/* X tile styling */
.cell.x-mark {
    background-color: #1E2233;
    border-radius: 6px;
    box-shadow: 6px 6px 8px rgba(0, 0, 0, 0.4);
    cursor: default;
    animation: tileScaleIn 0.6s cubic-bezier(0.87, 0, 0.13, 1) forwards;
}

/* O tile styling */
.cell.o-mark {
    background-color: #1E2233;
    border-radius: 6px;
    box-shadow: 6px 6px 8px rgba(0, 0, 0, 0.4);
    cursor: default;
    animation: tileScaleIn 0.6s cubic-bezier(0.87, 0, 0.13, 1) forwards;
}

/* Hide the dot when cell has X or O */
.cell.x-mark::after,
.cell.o-mark::after {
    display: none;
}

/* X mark cross */
.cell.x-mark::before,
.cell.x-mark .cross-2 {
    content: '';
    position: absolute;
    width: 24px;
    height: 6px;
    background-color: #337AFF;
    top: 50%;
    left: 50%;
}

.cell.x-mark::before {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.cell.x-mark .cross-2 {
    transform: translate(-50%, -50%) rotate(45deg);
}

/* O mark circle */
.cell.o-mark::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 6.5px solid #FF3333;
    background-color: transparent;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
}

/* =================================================================
   LAST PLAYED HIGHLIGHTING
   ================================================================= */
/* Last played tile with outline only */
.cell.x-mark.last-played {
    box-shadow: 6px 6px 8px rgba(0, 0, 0, 0.4);
    animation: tileScaleIn 0.6s cubic-bezier(0.87, 0, 0.13, 1) forwards;
    outline: 1px solid #337AFF;
    outline-offset: -1px;
}

.cell.o-mark.last-played {
    box-shadow: 6px 6px 8px rgba(0, 0, 0, 0.4);
    animation: tileScaleIn 0.6s cubic-bezier(0.87, 0, 0.13, 1) forwards;
    outline: 1px solid #FF3333;
    outline-offset: -1px;
}

/* Last played pulse animations */
@keyframes lastPlayedPulseX {
    0%, 100% {
        background-color: rgba(51, 122, 255, 0.15);
    }
    50% {
        background-color: rgba(51, 122, 255, 0.2);
    }
}

@keyframes lastPlayedPulseO {
    0%, 100% {
        background-color: rgba(255, 51, 51, 0.15);
    }
    50% {
        background-color: rgba(255, 51, 51, 0.2);
    }
}

/* =================================================================
   BIG TILES (Won Board Overlays)
   ================================================================= */
/* Big tile container for won mini-boards */
.mini-board {
    position: relative;
}

/* Big X tile styling (for won mini-boards) */
.big-x {
    position: absolute;
    width: 102px;
    height: 102px;
    background-color: #1E2233;
    border-radius: 6px;
    box-shadow: 6px 6px 8px rgba(0, 0, 0, 0.4);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    animation: bigTileScaleIn 0.6s cubic-bezier(0.87, 0, 0.13, 1) forwards;
}

/* Big X cross */
.big-x::before,
.big-x::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 76.5px;
    background-color: #337AFF;
    top: 50%;
    left: 50%;
}

.big-x::before {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.big-x::after {
    transform: translate(-50%, -50%) rotate(45deg);
}

/* Big O tile styling (for won mini-boards) */
.big-o {
    position: absolute;
    width: 102px;
    height: 102px;
    background-color: #1E2233;
    border-radius: 6px;
    box-shadow: 6px 6px 8px rgba(0, 0, 0, 0.4);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    animation: bigTileScaleIn 0.6s cubic-bezier(0.87, 0, 0.13, 1) forwards;
}

/* Big O circle */
.big-o::before {
    content: '';
    position: absolute;
    width: 76.5px;
    height: 76.5px;
    border-radius: 50%;
    border: 20px solid #FF3333;
    background-color: transparent;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
}

/* =================================================================
   TURN INDICATOR
   ================================================================= */
.turn-indicator {
    display: none;
    justify-content: center;
    align-items: center;
    background-color: transparent;
    width: auto;
    height: 36px; /* Set height to prevent layout shift */
    position: relative;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Only show turn indicator when game is active */
body:not(.splash-visible) .turn-indicator {
    display: flex;
}

/* Hide turn indicator on splash page */
body.splash-visible .turn-indicator {
    display: none !important;
}

/* Mini X tile in tooltip */
.turn-indicator .mini-x-tile {
    width: 32px;
    height: 32px;
    background-color: #337AFF;
    border-radius: 6px;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    position: relative;
}

/* Mini X cross */
.turn-indicator .mini-x-tile::before,
.turn-indicator .mini-x-tile::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 6px;
    background-color: #1E2233;
    top: 50%;
    left: 50%;
}

.turn-indicator .mini-x-tile::before {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.turn-indicator .mini-x-tile::after {
    transform: translate(-50%, -50%) rotate(45deg);
}

/* Mini O tile in tooltip */
.turn-indicator .mini-o-tile {
    width: 32px;
    height: 32px;
    background-color: #FF3333;
    border-radius: 6px;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    position: relative;
}

/* Mini O circle */
.turn-indicator .mini-o-tile::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 6.5px solid #1E2233;
    background-color: transparent;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
}

/* Turn indicator text */
.turn-indicator .turn-text {
    color: white;
    font-family: 'Lexend', sans-serif;
    font-weight: 400;
    font-size: 32px;
    margin-left: 16px;
}

/* =================================================================
   BUTTONS & CONTROLS
   ================================================================= */
/* Play again button */
.play-again {
    width: 182px;
    height: 64px;
    background-color: #2B3250;
    border-radius: 100px;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.play-again:hover {
    background-color: #384169;
}

.play-again-placeholder {
    height: 64px;
    visibility: hidden;
    position: relative;
}

.play-again-text {
    color: white;
    font-family: 'Lexend', sans-serif;
    font-weight: 400;
    font-size: 16px;
}

/* Show play again button on game over */
body.x-wins .play-again,
body.o-wins .play-again,
body.draw .play-again {
    display: flex;
}

body.x-wins .play-again-placeholder,
body.o-wins .play-again-placeholder,
body.draw .play-again-placeholder {
    visibility: visible;
}

/* Menu buttons */
.menu-button {
    width: 182px;
    height: 64px;
    background-color: #2B3250;
    border-radius: 100px;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: none;
    outline: none;
}

.menu-button:hover {
    background-color: #384169;
}

.menu-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.menu-button.disabled:hover {
    background-color: #2B3250;
}

.menu-button-text {
    color: white;
    font-family: 'Lexend', sans-serif;
    font-weight: 400;
    font-size: 16px;
}

/* =================================================================
   AI THINKING INDICATOR
   ================================================================= */
.ai-thinking {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 48px;
    background-color: #2B3250;
    padding: 20px 30px;
    border-radius: 100px;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    white-space: nowrap;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.ai-thinking.show {
    opacity: 1;
    visibility: visible;
}

.ai-thinking-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ai-thinking-text {
    color: white;
    font-family: 'Lexend', sans-serif;
    font-weight: 400;
    font-size: 16px;
}

.thinking-dots {
    display: inline-block;
}

@keyframes dotAnimation {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
    100% { content: '.'; }
}

.thinking-dots::after {
    content: '.';
    animation: dotAnimation 1.5s infinite;
}

/* =================================================================
   SPLASH PAGE
   ================================================================= */
/* Hide splash when game is visible and vice versa */
.splash-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

body:not(.splash-visible) .splash-page {
    display: none;
}

body.splash-visible .game-container {
    display: none;
}

body:not(.splash-visible) .game-container {
    display: flex;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Splash page tiles */
.splash-tiles {
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
}

.splash-x-tile,
.splash-o-tile {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    position: relative;
}

.splash-x-tile {
    background-color: #337AFF;
}

.splash-o-tile {
    background-color: #FF3333;
}

/* Splash X cross */
.splash-x-tile::before,
.splash-x-tile::after {
    content: '';
    position: absolute;
    width: 48px;
    height: 12px;
    background-color: #1E2233;
    top: 50%;
    left: 50%;
}

.splash-x-tile::before {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.splash-x-tile::after {
    transform: translate(-50%, -50%) rotate(45deg);
}

/* Splash O circle */
.splash-o-tile::before {
    content: '';
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 13px solid #1E2233;
    background-color: transparent;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
}

.splash-title {
    font-family: 'Lexend', sans-serif;
    font-weight: 600;
    font-size: 30px;
    color: white;
    margin: 0;
}

.splash-subtitle {
    font-family: 'Lexend', sans-serif;
    font-weight: 400;
    font-size: 16px;
    color: white;
    margin-top: 10px;
    width: 230px;
    text-align: center;
    line-height: 1.4;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 48px;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.button-group.fade-out {
    opacity: 0;
    transform: translateY(-20px);
}

.button-group.fade-in {
    opacity: 0;
    transform: translateY(20px);
}

/* =================================================================
   NAVIGATION BUTTONS
   ================================================================= */
/* Info button (shows on main splash only) */
.info-button {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    background-color: #2B3250;
    border-radius: 50%;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: none;
    outline: none;
    z-index: 100;
}

.info-button:hover {
    background-color: #384169;
}

.info-button svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Home button */
.home-button {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    background-color: #2B3250;
    border-radius: 50%;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: none;
    outline: none;
    z-index: 100;
}

.home-button:hover {
    background-color: #384169;
}

.home-button svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Share button */
.share-button {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: #2B3250;
    border-radius: 50%;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: none;
    outline: none;
    z-index: 100;
}

.share-button:hover {
    background-color: #384169;
}

.share-button svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Button visibility logic */
/* Show info button ONLY on main splash screen */
body.splash-visible:not(.ai-difficulty-visible) .info-button {
    display: flex;
}

/* Show home button during gameplay and AI difficulty menu */
body:not(.splash-visible) .home-button,
body.splash-visible.ai-difficulty-visible .home-button {
    display: flex;
}

/* Hide home button on main splash screen only */
body.splash-visible:not(.ai-difficulty-visible) .home-button {
    display: none !important;
}

/* Hide info button when NOT on main splash screen */
body:not(.splash-visible) .info-button,
body.splash-visible.ai-difficulty-visible .info-button {
    display: none !important;
}

/* =================================================================
   TOAST NOTIFICATIONS
   ================================================================= */
.toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background-color: #2B3250;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    font-family: 'Lexend', sans-serif;
    font-size: 14px;
    font-weight: 400;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* =================================================================
   HOW TO PLAY MODAL
   ================================================================= */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
}

.modal-content {
    background-color: #1E2233;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-title {
    font-family: 'Lexend', sans-serif;
    font-weight: 600;
    font-size: 24px;
    color: white;
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.modal-body h3 {
    font-family: 'Lexend', sans-serif;
    font-weight: 600;
    font-size: 18px;
    color: white;
    margin: 24px 0 12px 0;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body p {
    font-family: 'Lexend', sans-serif;
    font-weight: 400;
    font-size: 14px;
    color: #B8BCC8;
    line-height: 1.6;
    margin: 0 0 16px 0;
}

.modal-body a {
    color: white;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.modal-body a:hover {
    color: #B8BCC8;
    text-decoration: underline;
}

.modal-body ul {
    margin: 0 0 16px 0;
    padding-left: 20px;
}

.modal-body li {
    font-family: 'Lexend', sans-serif;
    font-weight: 400;
    font-size: 14px;
    color: #B8BCC8;
    line-height: 1.6;
    margin-bottom: 8px;
}

.modal-tldr {
    background-color: rgba(51, 122, 255, 0.1);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

.modal-tldr h3 {
    margin: 0 0 8px 0;
}

.modal-tldr p {
    margin: 0;
    color: white;
    font-size: 20px;
    font-weight: 500;
    line-height: 1.5;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.modal-button {
    width: 140px;
    height: 48px;
    background-color: #2B3250;
    border-radius: 100px;
    box-shadow: 
        4px 4px 6px rgba(0, 0, 0, 0.35),
        0px 12px 40px 3px rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: none;
    outline: none;
}

.modal-button:hover {
    background-color: #384169;
}

.modal-button-text {
    color: white;
    font-family: 'Lexend', sans-serif;
    font-weight: 400;
    font-size: 14px;
}

/* =================================================================
   ANIMATIONS & KEYFRAMES
   ================================================================= */
/* Scale animations */
@keyframes tileScaleIn {
    from {
        transform: scale(0.9);
        opacity: 0.8;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes bigTileScaleIn {
    from {
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 0.8;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Board fade in animation */
@keyframes boardFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.mini-board.fade-in {
    animation: boardFadeIn 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    opacity: 0;
}

/* Winning tile pulse animations */
@keyframes winPulseX {
    0%, 4.5% {
        background-color: #1E2233;
    }
    50%, 54.5% {
        background-color: #337AFF;
    }
    100% {
        background-color: #1E2233;
    }
}

@keyframes winPulseXCross {
    0%, 4.5% {
        background-color: #337AFF;
    }
    50%, 54.5% {
        background-color: #1E2233;
    }
    100% {
        background-color: #337AFF;
    }
}

@keyframes winPulseO {
    0%, 4.5% {
        background-color: #1E2233;
    }
    50%, 54.5% {
        background-color: #FF3333;
    }
    100% {
        background-color: #1E2233;
    }
}

@keyframes winPulseOCircle {
    0%, 4.5% {
        border-color: #FF3333;
    }
    50%, 54.5% {
        border-color: #1E2233;
    }
    100% {
        border-color: #FF3333;
    }
}

/* Winning tiles animation */
.big-x.winning {
    animation: bigTileScaleIn 0.6s cubic-bezier(0.87, 0, 0.13, 1) forwards,
              winPulseX 5.5s cubic-bezier(0.87, 0, 0.13, 1) infinite var(--pulse-delay, 0.25s);
}

.big-x.winning::before,
.big-x.winning::after {
    animation: winPulseXCross 5.5s cubic-bezier(0.87, 0, 0.13, 1) infinite var(--pulse-delay, 0.25s);
}

.big-o.winning {
    animation: bigTileScaleIn 0.6s cubic-bezier(0.87, 0, 0.13, 1) forwards,
              winPulseO 5.5s cubic-bezier(0.87, 0, 0.13, 1) infinite var(--pulse-delay, 0.25s);
}

.big-o.winning::before {
    animation: winPulseOCircle 5.5s cubic-bezier(0.87, 0, 0.13, 1) infinite var(--pulse-delay, 0.25s);
}

/* Won boards - hide cells */
.mini-board.won .cell {
    visibility: hidden;
}

/* Won mini-board styling */
.mini-board.won {
    background-color: #171926;
}

.mini-board.won .cell::after {
    background-color: #373C54;
}

/* =================================================================
   GAME STATE VISIBILITY
   ================================================================= */
body.x-turn .mini-o-tile {
    display: none;
}

body.o-turn .mini-x-tile {
    display: none;
}

/* Game over states */
body.x-wins .mini-o-tile,
body.o-wins .mini-x-tile {
    display: none;
}

/* Draw state - show both tiles */
body.draw .mini-x-tile,
body.draw .mini-o-tile {
    display: block !important;
}

body.draw .turn-indicator {
    gap: 3px;
}

/* =================================================================
   ACCESSIBILITY
   ================================================================= */
/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

/* =================================================================
   RESPONSIVE DESIGN
   ================================================================= */
/* Mobile adjustments */
@media (max-width: 600px) {
    .info-button,
    .home-button,
    .share-button {
        width: 36px;
        height: 36px;
        top: 16px;
    }

    .info-button,
    .home-button {
        left: 16px;
    }

    .share-button {
        right: 16px;
    }

    .info-button svg,
    .home-button svg,
    .share-button svg {
        width: 18px;
        height: 18px;
    }

    .toast {
        top: 68px;
        right: 16px;
    }

    /* Modal mobile optimizations */
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .modal-header {
        padding: 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-footer {
        padding: 20px;
    }

    .modal-title {
        font-size: 20px;
    }
}