/**
 * Tic-Tac-Toe Game Component Styles
 * 
 * @author Sergey Smagin <mail@sergey.perm.ru>
 * @copyright 2026
 * @version 1.0.0
 */

:root {
    --tictactoe-cell-bg: #0f3460;
    --tictactoe-board-bg: #16213e;
    --tictactoe-overlay-opacity: 0.85;
    --tictactoe-message-bg: #1a1a2e;
    --tictactoe-line-color: #16213e;
}

.tictactoe-overlay {
    background: rgba(0, 0, 0, var(--tictactoe-overlay-opacity));
}

.tictactoe-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    background: var(--tictactoe-board-bg);
    border: 20px solid var(--tictactoe-board-bg);
    border-radius: 16px;
    width: min(70vw, 70vh);
    aspect-ratio: 1 / 1;
    flex-shrink: 1;
}

.tictactoe-cell {
    width: 100%;
    height: 100%;
    background: var(--tictactoe-cell-bg);
    border: none;
    border-radius: 8px;
    font-size: 15vmin;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #fff;
    aspect-ratio: 1 / 1;
}

.tictactoe-cell img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tictactoe-cell:hover:not(.disabled):not(:focus) {
    background: var(--tictactoe-cell-hover, #1a1a40);
    transform: scale(1.02);
}

.tictactoe-cell.x {
    color: #4cc9f0;
}

.tictactoe-cell.o {
    color: #e94560;
}

.tictactoe-cell.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.tictactoe-cell.win {
    background: var(--tictactoe-line-color, #16213e);
    animation: pulse 1s infinite;
}

.tictactoe-restart {
    padding: 12px 30px;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 20px;
    width: 100%;
    max-width: 300px;
    flex-shrink: 0;
}

.tictactoe-restart--image {
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
    font-size: 0;
    margin-top: 40px;
}

.tictactoe-restart--image img {
    width: 100%;
    max-width: 200px;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tictactoe-restart--image img:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3);
}

.tictactoe-restart--image:hover,
.tictactoe-restart--image img:hover {
    background: none;
    box-shadow: none;
}

.tictactoe-restart:not(.tictactoe-restart--image):hover:not(:focus) {
    background: #ff6b6b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3);
}

.tictactoe-restart:active {
    transform: translateY(0);
}

.tictactoe-restart--image:active,
.tictactoe-restart--image img:active {
    transform: none;
    background: none;
    box-shadow: none;
}

.tictactoe-restart:active,
.tictactoe-restart--image img:active {
    -webkit-tap-highlight-color: transparent;
}

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

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.tictactoe-cell.x::before,
.tictactoe-cell.o::before {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tictactoe-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.tictactoe-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.tictactoe-overlay-content {
    pointer-events: none;
    background: #1a1a2e;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    max-width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.tictactoe-overlay.active .tictactoe-overlay-content {
    transform: translateY(0);
}

.tictactoe-overlay-message {
    font-size: 32px;
    font-weight: bold;
    color: #fff;
    line-height: 1.4;
}

.tictactoe-overlay-message.winner-x {
    color: #4cc9f0;
    text-shadow: 0 0 20px rgba(76, 201, 240, 0.4);
}

.tictactoe-overlay-message.winner-o {
    color: #e94560;
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.4);
}

.tictactoe-overlay-message.draw {
    color: #fca311;
    text-shadow: 0 0 20px rgba(252, 163, 17, 0.4);
}

.tictactoe-overlay-btn {
    background: linear-gradient(135deg, #e94560, #ff6b6b);
    color: #fff;
    border: none;
    padding: 14px 32px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.4);
    pointer-events: all;
}

.tictactoe-overlay-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.5);
}

.tictactoe-overlay-btn:active {
    transform: translateY(0);
}

.tictactoe-overlay-btn--image {
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
    font-size: 0;
}

.tictactoe-overlay-btn--image img {
    width: 100%;
    max-width: 200px;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
    pointer-events: all;
}

.tictactoe-overlay-btn--image img:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3);
}

.tictactoe-overlay-btn--image:hover,
.tictactoe-overlay-btn--image img:hover {
    background: none;
    box-shadow: none;
}

.tictactoe-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    max-height: 100vh;
    max-width: 100%;
    overflow: hidden;
}

.tictactoe-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#game {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.tictactoe-cell,
.tictactoe-restart,
.tictactoe-overlay-message,
.tictactoe-overlay-btn {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

@media (max-width: 480px) {
    .tictactoe-overlay-content {
        padding: 20px;
    }

    .tictactoe-overlay-message {
        font-size: 24px;
    }

    .tictactoe-overlay-btn {
        padding: 12px 24px;
        font-size: 16px;
    }
}
