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

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes rgbShift {
    0% { 
        background: linear-gradient(-45deg, #e8d5ff, #d5e8ff, #e0b3ff, #b3d9ff);
    }
    14% { 
        background: linear-gradient(-45deg, #b3d9ff, #bae1ff, #c9baff, #ffb3ff);
    }
    28% { 
        background: linear-gradient(-45deg, #ffb3ff, #e8d5ff, #d5e8ff, #e0b3ff);
    }
    42% { 
        background: linear-gradient(-45deg, #e0b3ff, #b3d9ff, #bae1ff, #c9baff);
    }
    56% { 
        background: linear-gradient(-45deg, #c9baff, #ffb3ff, #e8d5ff, #d5e8ff);
    }
    70% { 
        background: linear-gradient(-45deg, #d5e8ff, #e0b3ff, #b3d9ff, #bae1ff);
    }
    84% { 
        background: linear-gradient(-45deg, #bae1ff, #c9baff, #ffb3ff, #e8d5ff);
    }
    100% { 
        background: linear-gradient(-45deg, #e8d5ff, #d5e8ff, #e0b3ff, #b3d9ff);
    }
}

@keyframes rgbBorder {
    0% { border-color: #b3d9ff; box-shadow: 0 0 20px #b3d9ff; }
    20% { border-color: #bae1ff; box-shadow: 0 0 20px #bae1ff; }
    40% { border-color: #c9baff; box-shadow: 0 0 20px #c9baff; }
    60% { border-color: #e0b3ff; box-shadow: 0 0 20px #e0b3ff; }
    80% { border-color: #ffb3ff; box-shadow: 0 0 20px #ffb3ff; }
    100% { border-color: #b3d9ff; box-shadow: 0 0 20px #b3d9ff; }
}

@keyframes rgbGlow {
    0% { 
        box-shadow: 0 0 30px #b3d9ff, 0 0 60px #b3d9ff, 0 0 90px #b3d9ff;
    }
    20% { 
        box-shadow: 0 0 30px #bae1ff, 0 0 60px #bae1ff, 0 0 90px #bae1ff;
    }
    40% { 
        box-shadow: 0 0 30px #c9baff, 0 0 60px #c9baff, 0 0 90px #c9baff;
    }
    60% { 
        box-shadow: 0 0 30px #e0b3ff, 0 0 60px #e0b3ff, 0 0 90px #e0b3ff;
    }
    80% { 
        box-shadow: 0 0 30px #ffb3ff, 0 0 60px #ffb3ff, 0 0 90px #ffb3ff;
    }
    100% { 
        box-shadow: 0 0 30px #b3d9ff, 0 0 60px #b3d9ff, 0 0 90px #b3d9ff;
    }
}

@keyframes textRgb {
    0% { color: #b3d9ff; text-shadow: 0 0 20px #b3d9ff; }
    20% { color: #bae1ff; text-shadow: 0 0 20px #bae1ff; }
    40% { color: #c9baff; text-shadow: 0 0 20px #c9baff; }
    60% { color: #e0b3ff; text-shadow: 0 0 20px #e0b3ff; }
    80% { color: #ffb3ff; text-shadow: 0 0 20px #ffb3ff; }
    100% { color: #b3d9ff; text-shadow: 0 0 20px #b3d9ff; }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.3),
                    0 0 40px rgba(102, 126, 234, 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 255, 255, 0.5),
                    0 0 60px rgba(102, 126, 234, 0.4);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes winPulse {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.1);
        filter: brightness(1.3);
    }
}

@keyframes hintPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
        border-color: rgba(76, 175, 80, 0.5);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(76, 175, 80, 0),
                    0 0 30px rgba(76, 175, 80, 0.5);
        border-color: rgba(76, 175, 80, 1);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(-45deg, #e8d5ff, #d5e8ff, #e0b3ff, #b3d9ff, #bae1ff, #c9baff, #ffb3ff);
    background-size: 400% 400%;
    animation: rgbShift 15s ease infinite;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 20% 20%, rgba(232, 213, 255, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(179, 217, 255, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(186, 225, 255, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 179, 255, 0.3) 0%, transparent 50%);
    animation: rgbShift 12s ease-in-out infinite alternate;
    pointer-events: none;
}

.container {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 25px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.6);
    animation: fadeIn 0.6s ease, rgbGlow 5s ease-in-out infinite;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 1;
    border: 3px solid transparent;
}

h1 {
    background: linear-gradient(135deg, #b3d9ff 0%, #c9baff 50%, #ffb3ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 25px;
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 2px;
    animation: slideUp 0.6s ease, textRgb 5s linear infinite;
    filter: drop-shadow(0 0 10px rgba(179, 217, 255, 0.5));
}

.status {
    font-size: 1.8rem;
    margin-bottom: 25px;
    color: #333;
    font-weight: 700;
    min-height: 40px;
    animation: slideUp 0.6s ease 0.1s backwards;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 130px);
    grid-template-rows: repeat(3, 130px);
    gap: 15px;
    margin: 0 auto 35px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    animation: slideUp 0.6s ease 0.2s backwards;
    border: 3px solid #b3d9ff;
    animation: slideUp 0.6s ease 0.2s backwards, rgbBorder 5s linear infinite;
}

.cell {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 4px solid transparent;
    background-clip: padding-box;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.6);
    position: relative;
    overflow: hidden;
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cell:hover:not(.filled)::before {
    opacity: 1;
}

.cell:hover:not(.filled) {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 25px rgba(179, 217, 255, 0.5),
                0 0 30px rgba(201, 186, 255, 0.4),
                0 0 40px rgba(255, 179, 255, 0.3);
    border-color: #b3d9ff;
    animation: rgbBorder 2s linear infinite;
}

.cell.filled {
    cursor: not-allowed;
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cell.x {
    color: #b3d9ff;
    animation: textRgb 3s linear infinite, popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cell.o {
    color: #c9baff;
    animation: textRgb 3s linear infinite 1.5s, popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cell.winner {
    animation: winPulse 0.6s ease infinite;
    background: linear-gradient(145deg, #ffd700, #ffed4e);
    border-color: #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6),
                0 0 60px rgba(255, 215, 0, 0.4);
}

.cell.hint {
    animation: hintPulse 1.5s ease-in-out 3;
    background: linear-gradient(145deg, #e8f5e9, #c8e6c9);
    border: 4px solid #4caf50;
}

.cell.hint::after {
    content: '?';
    position: absolute;
    font-size: 5rem;
    color: rgba(76, 175, 80, 0.3);
    font-weight: 900;
    animation: pulse 1s ease-in-out infinite;
}

.button-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.hint-btn,
.restart-btn {
    padding: 18px 40px;
    font-size: 1.2rem;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 1px;
    text-transform: uppercase;
    animation: slideUp 0.6s ease 0.3s backwards;
    position: relative;
    overflow: hidden;
}

.hint-btn {
    background: linear-gradient(135deg, #bae1ff 0%, #b3d9ff 100%);
    box-shadow: 0 4px 15px rgba(186, 225, 255, 0.4);
    animation: slideUp 0.6s ease 0.3s backwards, rgbGlow 5s ease-in-out infinite 0.5s;
}

.hint-btn:disabled {
    background: linear-gradient(135deg, #9e9e9e 0%, #757575 100%);
    cursor: not-allowed;
    opacity: 0.6;
    animation: none;
}

.hint-btn.shake {
    animation: shake 0.5s ease;
}

.restart-btn {
    background: linear-gradient(135deg, #c9baff 0%, #e0b3ff 100%);
    box-shadow: 0 4px 15px rgba(201, 186, 255, 0.4);
    animation: slideUp 0.6s ease 0.3s backwards, rgbGlow 5s ease-in-out infinite;
}

.hint-btn::before,
.restart-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.hint-btn:hover::before,
.restart-btn:hover::before {
    width: 300px;
    height: 300px;
}

.hint-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(186, 225, 255, 0.8),
                0 0 50px rgba(186, 225, 255, 0.5);
}

.restart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(201, 186, 255, 0.8),
                0 0 50px rgba(224, 179, 255, 0.6);
}

.hint-btn:active:not(:disabled),
.restart-btn:active {
    transform: translateY(-1px);
}

.hint-btn span,
.restart-btn span {
    position: relative;
    z-index: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 30px 20px;
        max-width: 90%;
    }

    h1 {
        font-size: 2.5rem;
        margin-bottom: 20px;
    }

    .status {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    .board {
        grid-template-columns: repeat(3, 110px);
        grid-template-rows: repeat(3, 110px);
        gap: 12px;
        padding: 15px;
    }

    .cell {
        font-size: 3.5rem;
    }

    .hint-btn,
    .restart-btn {
        padding: 15px 35px;
        font-size: 1.1rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 25px 15px;
    }

    h1 {
        font-size: 2rem;
        margin-bottom: 15px;
    }

    .status {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }

    .board {
        grid-template-columns: repeat(3, 90px);
        grid-template-rows: repeat(3, 90px);
        gap: 10px;
        padding: 12px;
    }

    .cell {
        font-size: 3rem;
        border-width: 3px;
    }

    .cell.hint::after {
        font-size: 4rem;
    }

    .button-container {
        gap: 10px;
    }

    .hint-btn,
    .restart-btn {
        padding: 12px 25px;
        font-size: 1rem;
    }
}

@media (max-width: 400px) {
    .container {
        padding: 20px 10px;
    }

    h1 {
        font-size: 1.6rem;
        margin-bottom: 12px;
    }

    .status {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    .board {
        grid-template-columns: repeat(3, 75px);
        grid-template-rows: repeat(3, 75px);
        gap: 8px;
        padding: 10px;
    }

    .cell {
        font-size: 2.5rem;
        border-width: 2px;
        border-radius: 10px;
    }

    .cell.hint::after {
        font-size: 3rem;
    }

    .button-container {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .hint-btn,
    .restart-btn {
        padding: 12px 20px;
        font-size: 0.95rem;
        width: 100%;
    }
}

@media (max-width: 350px) {
    h1 {
        font-size: 1.4rem;
    }

    .status {
        font-size: 1rem;
    }

    .board {
        grid-template-columns: repeat(3, 65px);
        grid-template-rows: repeat(3, 65px);
        gap: 6px;
    }

    .cell {
        font-size: 2rem;
    }

    .cell.hint::after {
        font-size: 2.5rem;
    }
}

/* Landscape orientation optimization */
@media (max-height: 600px) and (orientation: landscape) {
    body {
        padding: 10px 0;
    }

    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }

    .status {
        font-size: 1rem;
        margin-bottom: 10px;
    }

    .board {
        grid-template-columns: repeat(3, 70px);
        grid-template-rows: repeat(3, 70px);
        gap: 8px;
        padding: 10px;
        margin-bottom: 15px;
    }

    .cell {
        font-size: 2.5rem;
    }

    .hint-btn,
    .restart-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}
