/* Modern custom styles */
:root {
    --cell-size-desktop: 42px;
    --cell-size-tablet: 36px;
    --cell-size-mobile: 32px;
    --cell-size-small: 28px;
    --cell-size-tiny: 24px;
}

body {
    touch-action: manipulation; /* Prevents double-tap zoom on mobile */
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on mobile */
    overscroll-behavior: contain; /* Prevents pull-to-refresh */
}

#board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-gap: 3px;
    max-width: 500px;
    margin: 0 auto;
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10 and IE 11 */
    user-select: none; /* Standard syntax */
    width: 100%;
}

.board-container {
    padding: 8px;
    background: linear-gradient(135deg, #f0f4f8 0%, #d1deee 100%);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

#board div {
    height: var(--cell-size-desktop);
    width: var(--cell-size-desktop);
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-weight: 700;
    font-size: 20px;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.hidden {
    display: none !important;
}

/* Cell hover and active effects */
#board div:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

#board div:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Styling for X and O marks */
.text-blue-600 {
    color: #2563eb; /* blue-600 */
}

.text-red-600 {
    color: #dc2626; /* red-600 */
}

/* Animation for thinking state */
@keyframes thinking-pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

.thinking {
    animation: thinking-pulse 1.5s infinite ease-in-out;
}

/* Animation for winning */
@keyframes winner-glow {
    0% {
        box-shadow: 0 0 5px rgba(22, 163, 74, 0.6);
        transform: translateY(0);
    }
    50% {
        box-shadow: 0 0 15px rgba(22, 163, 74, 0.9);
        transform: translateY(-2px);
    }
    100% {
        box-shadow: 0 0 5px rgba(22, 163, 74, 0.6);
        transform: translateY(0);
    }
}

.winning-cell {
    animation: winner-glow 1.5s infinite;
    background-color: rgba(22, 163, 74, 0.15) !important;
    border: 2px solid rgba(22, 163, 74, 0.6) !important;
    z-index: 2;
}

/* Mark selection styling */
.mark-choice .choice-box {
    transition: all 0.3s ease;
}

.mark-choice input:checked + .choice-box {
    border-color: currentColor !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

/* Difficulty slider styling */
input[type="range"] {
    height: 8px;
    border-radius: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #d1d5db, #d1d5db);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #8b5cf6;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #8b5cf6;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.5);
}

/* Toast notification styling */
.toast {
    position: relative;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    margin-bottom: 1rem;
    max-width: 300px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: hidden;
}

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

.toast.success {
    border-left: 4px solid #16a34a;
}

.toast.warning {
    border-left: 4px solid #f59e0b;
}

.toast.info {
    border-left: 4px solid #0ea5e9;
}

/* Fade-out animation */
@keyframes fade-out {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

.fade-out {
    animation: fade-out 0.7s forwards;
}

/* Responsive styling */
@media (max-width: 768px) {
    #board {
        grid-gap: 2px;
        max-width: 400px;
    }
    
    #board div {
        height: var(--cell-size-tablet);
        width: var(--cell-size-tablet);
        font-size: 18px;
    }
    
    .board-container {
        padding: 6px;
    }
    
    /* Improve touch targets */
    #board div {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Better button spacing on mobile */
    button {
        min-height: 44px; /* iOS recommended touch target size */
    }
    
    /* Prevent zoom on input focus */
    input, select, textarea {
        font-size: 16px;
    }
}

@media (max-width: 640px) {
    #board {
        grid-gap: 2px;
        max-width: 360px;
    }
    
    #board div {
        height: var(--cell-size-mobile);
        width: var(--cell-size-mobile);
        font-size: 16px;
    }
    
    .difficulty-slider-container .flex {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    #board {
        grid-gap: 1px;
        max-width: 320px;
    }
    
    #board div {
        height: var(--cell-size-small);
        width: var(--cell-size-small);
        font-size: 14px;
        border-radius: 6px;
    }
    
    .board-container {
        padding: 4px;
    }
}

@media (max-width: 360px) {
    #board {
        grid-gap: 1px;
        max-width: 280px;
    }
    
    #board div {
        height: var(--cell-size-tiny);
        width: var(--cell-size-tiny);
        font-size: 12px;
        border-radius: 4px;
    }
    
    .board-container {
        padding: 3px;
    }
    
    .difficulty-slider-container .flex {
        font-size: 0.6rem;
    }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 320px) {
    #board {
        max-width: 260px;
    }
    
    #board div {
        height: 22px;
        width: 22px;
        font-size: 11px;
        border-radius: 3px;
    }
    
    .board-container {
        padding: 2px;
    }
    
    /* Make buttons smaller on tiny screens */
    button {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.75rem !important;
    }
    
    /* Compact layout */
    .p-3 {
        padding: 0.5rem !important;
    }
}

/* Landscape orientation on small devices */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 1rem;
    }
    
    .max-w-4xl {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    h1 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .mb-4, .mb-6 {
        margin-bottom: 0.75rem !important;
    }
}
