/* Enhanced 3D Tic-Tac-Toe Styles */
html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    line-height: 1.6;
}

/* UPDATED: Better contrast button colors - easier to read */
:root {
    --primary-color: #1e3a8a; /* Dark blue instead of light blue */
    --secondary-color: #6c757d;
    --success-color: #166534; /* Dark green instead of light green */
    --danger-color: #dc2626; /* Keep red as is */
    --warning-color: #ffc107;
    --info-color: #1e40af; /* Navy blue for info */
}

/* Enhanced Card Styling */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

    .card:hover {
        transform: translateY(-4px);
        box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
    }

.card-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3730a3 100%); /* Dark blue header */
    border: none;
    padding: 1.25rem 1.5rem;
    border-radius: 16px 16px 0 0;
    color: white;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

    .card-header.bg-primary {
        background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); /* Dark blue primary */
    }

    .card-header.bg-success {
        background: linear-gradient(135deg, #166534 0%, #15803d 100%); /* Dark green success */
    }

    .card-header.bg-info {
        background: linear-gradient(135deg, #1e40af 0%, #3730a3 100%); /* Navy blue info */
    }

.card-body {
    padding: 2rem;
}

/* UPDATED: Enhanced Button Styling with better contrast */
.btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: none;
    letter-spacing: 0.025em;
    position: relative;
    overflow: hidden;
}

    .btn::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: left 0.5s;
    }

    .btn:hover::before {
        left: 100%;
    }

/* UPDATED: Dark blue primary buttons - much better contrast */
.btn-primary {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(30, 58, 138, 0.4);
}

    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(30, 58, 138, 0.6);
        background: linear-gradient(135deg, #1e40af 0%, #3730a3 100%);
        color: white;
    }

    .btn-primary:focus {
        color: white;
        box-shadow: 0 0 0 0.2rem rgba(30, 58, 138, 0.5);
    }

/* UPDATED: Dark green success buttons - much better contrast */
.btn-success {
    background: linear-gradient(135deg, #166534 0%, #15803d 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(22, 101, 52, 0.4);
}

    .btn-success:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(22, 101, 52, 0.6);
        background: linear-gradient(135deg, #15803d 0%, #16a34a 100%);
        color: white;
    }

    .btn-success:focus {
        color: white;
        box-shadow: 0 0 0 0.2rem rgba(22, 101, 52, 0.5);
    }

/* UPDATED: Navy blue info buttons */
.btn-info {
    background: linear-gradient(135deg, #1e40af 0%, #3730a3 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(30, 64, 175, 0.4);
}

    .btn-info:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(30, 64, 175, 0.6);
        background: linear-gradient(135deg, #3730a3 0%, #4338ca 100%);
        color: white;
    }

    .btn-info:focus {
        color: white;
        box-shadow: 0 0 0 0.2rem rgba(30, 64, 175, 0.5);
    }

.btn-light {
    background: rgba(255, 255, 255, 0.9);
    color: #1e3a8a; /* Dark blue text on light buttons */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(30, 58, 138, 0.2);
}

    .btn-light:hover {
        background: rgba(255, 255, 255, 1);
        color: #1e40af;
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }

/* UPDATED: Outline buttons with better contrast */
.btn-outline-primary {
    border: 2px solid #1e3a8a;
    color: #1e3a8a;
    background: transparent;
}

    .btn-outline-primary:hover {
        background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
        border-color: transparent;
        color: white;
        transform: translateY(-2px);
    }

.btn-outline-success {
    border: 2px solid #166534;
    color: #166534;
    background: transparent;
}

    .btn-outline-success:hover {
        background: linear-gradient(135deg, #166534 0%, #15803d 100%);
        border-color: transparent;
        color: white;
        transform: translateY(-2px);
    }

.btn-outline-info {
    border: 2px solid #1e40af;
    color: #1e40af;
    background: transparent;
}

    .btn-outline-info:hover {
        background: linear-gradient(135deg, #1e40af 0%, #3730a3 100%);
        border-color: transparent;
        color: white;
        transform: translateY(-2px);
    }

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 16px;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
}

/* Game Board Enhancements */
.game-grid {
    display: grid;
    grid-gap: 16px;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    padding: 1rem;
}

.game-grid[style*="grid-template-columns"] {
    /* Ensure inline grid-template-columns works with our beautiful styling */
    max-width: 500px; /* Slightly smaller for multiplayer */
}

/* Alternative: Add specific classes for different board sizes */
.game-grid-3x3 {
    grid-template-columns: repeat(3, 1fr);
}

.game-grid-4x4 {
    grid-template-columns: repeat(4, 1fr);
}

.game-cell {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

    .game-cell::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(45deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.3));
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .game-cell:hover {
        transform: translateY(-4px) scale(1.02);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
        border-color: rgba(30, 58, 138, 0.5); /* Dark blue border on hover */
    }

        .game-cell:hover::before {
            opacity: 1;
        }

    .game-cell:active {
        transform: translateY(-2px) scale(1.01);
    }

.cell-x {
    color: #1e3a8a; /* Dark blue X */
    font-size: 2.5rem;
    text-shadow: 0 2px 8px rgba(30, 58, 138, 0.3);
    filter: drop-shadow(0 0 8px rgba(30, 58, 138, 0.4));
}

.cell-o {
    color: #dc2626; /* Red O for good contrast */
    font-size: 2.5rem;
    text-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
    filter: drop-shadow(0 0 8px rgba(220, 38, 38, 0.4));
}

.cell-coords {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 500;
    opacity: 0.7;
}

.winning-position {
    background: linear-gradient(135deg, #166534 0%, #15803d 100%); /* Dark green win */
    border-color: #166534;
    animation: pulseWin 2s infinite;
    color: white;
}

@keyframes pulseWin {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(22, 101, 52, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 8px 32px rgba(22, 101, 52, 0.6);
    }
}

/* Layer Overview Enhancements */
.layer-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 2px solid transparent;
    backdrop-filter: blur(10px);
}

    .layer-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
        border-color: rgba(30, 58, 138, 0.3); /* Dark blue border */
    }

.layer-active {
    border-color: #1e3a8a; /* Dark blue active */
    background: rgba(30, 58, 138, 0.1);
    box-shadow: 0 4px 20px rgba(30, 58, 138, 0.2);
}

.layer-header {
    text-align: center;
    font-weight: 600;
    margin-bottom: 12px;
    color: #495057;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.layer-grid {
    display: grid;
    grid-gap: 6px;
}

.layer-cell {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 6px;
    border: 1px solid rgba(233, 236, 239, 0.5);
    font-weight: bold;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

    .layer-cell:hover {
        background: rgba(30, 58, 138, 0.1); /* Dark blue hover */
        border-color: #1e3a8a;
    }

/* UPDATED: Alert Enhancements with better contrast */
.alert {
    border: none;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border-left: 4px solid;
}

.alert-primary {
    background: rgba(30, 58, 138, 0.1);
    color: #1e3a8a;
    border-left-color: #1e3a8a;
}

.alert-success {
    background: rgba(22, 101, 52, 0.1);
    color: #166534;
    border-left-color: #166534;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    color: #664d03;
    border-left-color: #ffc107;
}

.alert-danger {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    border-left-color: #dc2626;
}

.alert-info {
    background: rgba(30, 64, 175, 0.1);
    color: #1e40af;
    border-left-color: #1e40af;
}

/* Hero Section Enhancements */
.hero-section {
    background: linear-gradient(135deg, #1e3a8a 0%, #3730a3 100%); /* Dark blue hero */
    position: relative;
    overflow: hidden;
}

    .hero-section::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
        opacity: 0.3;
    }

.hero-content {
    position: relative;
    z-index: 2;
}

/* Game Preview Enhancements */
.game-preview-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    transform: perspective(1000px) rotateX(5deg) rotateY(-5deg);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

    .game-preview-card:hover {
        transform: perspective(1000px) rotateX(0deg) rotateY(0deg) scale(1.02);
    }

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 1.5rem;
}

.preview-cell {
    aspect-ratio: 1;
    background: rgba(248, 249, 250, 0.8);
    border: 2px solid rgba(233, 236, 239, 0.5);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

    .preview-cell.winner {
        background: linear-gradient(135deg, #166534 0%, #15803d 100%); /* Dark green win */
        border-color: #166534;
        animation: pulsePreview 3s infinite;
        color: white;
        box-shadow: 0 4px 20px rgba(22, 101, 52, 0.4);
    }

.preview-x {
    color: #1e3a8a; /* Dark blue X */
    filter: drop-shadow(0 0 4px rgba(30, 58, 138, 0.3));
}

.preview-o {
    color: #dc2626; /* Red O */
    filter: drop-shadow(0 0 4px rgba(220, 38, 38, 0.3));
}

@keyframes pulsePreview {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

/* Feature Cards */
.feature-card, .game-mode-card {
    padding: 2rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
}

    .feature-card:hover, .game-mode-card:hover {
        transform: translateY(-8px);
    }

.feature-icon {
    margin-bottom: 1.5rem;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.feature-card:hover .feature-icon {
    opacity: 1;
}

/* Form Enhancements */
.form-control {
    border-radius: 12px;
    border: 2px solid rgba(233, 236, 239, 0.5);
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

    .form-control:focus {
        border-color: #1e3a8a; /* Dark blue focus */
        box-shadow: 0 0 0 0.2rem rgba(30, 58, 138, 0.25);
        background: rgba(255, 255, 255, 1);
    }

.form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
}

/* UPDATED: Badge Enhancements with better contrast */
.badge {
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

    .badge.bg-success {
        background: linear-gradient(135deg, #166534 0%, #15803d 100%) !important; /* Dark green */
        box-shadow: 0 2px 8px rgba(22, 101, 52, 0.3);
        color: white !important;
    }

    .badge.bg-primary {
        background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%) !important; /* Dark blue */
        box-shadow: 0 2px 8px rgba(30, 58, 138, 0.3);
        color: white !important;
    }

    .badge.bg-warning {
        background: linear-gradient(135deg, #ffc107 0%, #ff8c00 100%) !important;
        box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
        color: #000 !important; /* Black text on yellow for better contrast */
    }

    .badge.bg-light {
        background: rgba(255, 255, 255, 0.9) !important;
        color: #1e3a8a !important; /* Dark blue text */
        border: 1px solid rgba(30, 58, 138, 0.2);
    }

/* Spinner Enhancements */
.spinner-border {
    border-width: 3px;
}

.spinner-border-sm {
    border-width: 2px;
}

/* UPDATED: Game Status Indicators with better contrast */
.current-player {
    padding: 1.25rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-left: 4px solid;
    backdrop-filter: blur(10px);
}

.player-x {
    border-left-color: #1e3a8a; /* Dark blue for X */
    background: rgba(30, 58, 138, 0.05);
}

.player-o {
    border-left-color: #dc2626; /* Red for O */
    background: rgba(220, 38, 38, 0.05);
}

/* Navigation Enhancements */
.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); /* Dark blue brand */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Responsive Enhancements */
@media (max-width: 992px) {
    .game-cell {
        font-size: 1.5rem;
    }

    .cell-x, .cell-o {
        font-size: 2rem;
    }

    .card-body {
        padding: 1.5rem;
    }

    .btn {
        padding: 0.65rem 1.25rem;
    }
}

@media (max-width: 768px) {
    .game-grid {
        grid-gap: 12px;
        padding: 0.5rem;
    }

    .game-cell {
        font-size: 1.2rem;
        border-radius: 8px;
    }

    .card {
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    .hero-section .display-4 {
        font-size: 2rem;
    }

    .game-preview-card {
        transform: none;
        padding: 1.5rem;
    }

    .preview-grid {
        gap: 8px;
    }
}

@media (max-width: 576px) {
    .game-cell {
        font-size: 1rem;
        border-radius: 6px;
    }

    .cell-x, .cell-o {
        font-size: 1.5rem;
    }

    .card {
        border-radius: 8px;
    }

    .card-body {
        padding: 0.75rem;
    }

    .layer-card {
        padding: 0.75rem;
        border-radius: 8px;
    }
}

/* 3D View Specific Enhancements */
.board-container {
    position: relative;
    width: 100%;
    height: 700px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.1);
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.start-message {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 90%;
}

/* Game Card Enhancements */
.game-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 2px solid transparent;
}

    .game-card:hover {
        border-color: rgba(30, 58, 138, 0.3); /* Dark blue hover */
        transform: translateY(-4px);
    }

    .game-card.disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

        .game-card.disabled:hover {
            transform: none;
            border-color: transparent;
        }

.game-card-readonly {
    border: 2px solid rgba(255, 193, 7, 0.2);
    background: rgba(255, 193, 7, 0.05);
}

/* Loading States */
.loading-shimmer {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 25%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0.1) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* UPDATED: Custom Scrollbar with dark blue theme */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); /* Dark blue scrollbar */
    border-radius: 4px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(135deg, #1e40af 0%, #3730a3 100%);
    }

/* Logo styling - Add this to your app.css file */

/* General logo styling */
.app-logo {
    object-fit: contain;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

    .app-logo:hover {
        opacity: 0.8;
        transform: scale(1.05);
    }

/* Navbar logo variations */
.navbar-logo {
    height: 32px;
    width: 32px;
    object-fit: contain;
}

.sidebar-logo {
    height: 28px;
    width: 28px;
    object-fit: contain;
    filter: brightness(0) invert(1); /* White logo for dark sidebar */
}

.hero-logo {
    height: 120px;
    width: 120px;
    object-fit: contain;
    filter: brightness(0) invert(1); /* White logo for dark hero section */
    margin-bottom: 1rem;
}

/* Logo loading states */
.logo-loading {
    opacity: 0.5;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.8;
    }
}

/* Responsive logo sizing */
@media (max-width: 768px) {
    .hero-logo {
        height: 80px;
        width: 80px;
    }

    .navbar-logo {
        height: 28px;
        width: 28px;
    }

    .sidebar-logo {
        height: 24px;
        width: 24px;
    }
}

@media (max-width: 576px) {
    .hero-logo {
        height: 60px;
        width: 60px;
    }

    .navbar-logo {
        height: 24px;
        width: 24px;
    }

    .sidebar-logo {
        height: 20px;
        width: 20px;
    }
}

/* Dark mode logo support (if you add dark mode later) */
@media (prefers-color-scheme: dark) {
    .navbar-logo {
        filter: brightness(0) invert(1);
    }
}

/* Logo for print media */
@media print {
    .hero-logo,
    .navbar-logo,
    .sidebar-logo {
        filter: none !important;
    }
}

/* Game Switcher Bar Styles */
.game-switcher-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.btn-group .btn {
    position: relative;
}

.btn-group .btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.6em;
}

/* =====================================================
   IPHONE-SPECIFIC IMPROVEMENTS FOR LAYER OVERVIEW
   ===================================================== */

/* Target iPhone devices specifically */
@media only screen 
and (device-width: 375px) 
and (device-height: 667px) 
and (-webkit-device-pixel-ratio: 2),
only screen 
and (device-width: 375px) 
and (device-height: 812px) 
and (-webkit-device-pixel-ratio: 3),
only screen 
and (device-width: 414px) 
and (device-height: 736px) 
and (-webkit-device-pixel-ratio: 3),
only screen 
and (device-width: 414px) 
and (device-height: 896px) 
and (-webkit-device-pixel-ratio: 2),
only screen 
and (device-width: 414px) 
and (device-height: 896px) 
and (-webkit-device-pixel-ratio: 3),
only screen 
and (device-width: 390px) 
and (device-height: 844px) 
and (-webkit-device-pixel-ratio: 3),
only screen 
and (device-width: 428px) 
and (device-height: 926px) 
and (-webkit-device-pixel-ratio: 3) {

    /* All Layers Overview Section - iPhone optimized */
    .status-card .card-body {
        padding: 1rem 0.75rem; /* Tighter padding for iPhone */
    }

    /* Layer cards container */
    .d-flex.flex-wrap.gap-4.justify-content-center {
        gap: 0.75rem !important; /* Reduce gap between layer cards */
        padding: 0 0.5rem; /* Add side padding */
    }

    /* Individual layer cards - iPhone optimized */
    .layer-card {
        min-width: 90px !important; /* Ensure minimum readable size */
        max-width: calc((100vw - 3rem) / 3) !important; /* Max 3 cards per row on iPhone */
        padding: 0.75rem 0.5rem !important; /* Optimized padding */
        margin-bottom: 0.5rem; /* Add bottom margin for stacking */
        border-radius: 10px !important; /* Slightly smaller border radius */
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important; /* Enhanced shadow for iPhone */
        backdrop-filter: blur(8px) !important; /* Stronger blur effect */
        background: rgba(255, 255, 255, 0.95) !important; /* More opaque background */
    }

    /* Layer header text - iPhone optimized */
    .layer-header {
        font-size: 0.75rem !important; /* Smaller but still readable */
        margin-bottom: 8px !important;
        font-weight: 700 !important; /* Bolder for better visibility */
        color: #1e3a8a !important; /* Dark blue for better contrast */
        text-transform: uppercase;
        letter-spacing: 0.08em !important; /* Increased letter spacing */
    }

    /* Layer grid - iPhone optimized */
    .layer-grid {
        grid-gap: 3px !important; /* Tighter grid gaps */
        padding: 0; /* Remove any padding */
    }

    /* Individual layer cells - iPhone optimized */
    .layer-cell {
        min-height: 22px !important; /* Ensure minimum touch target */
        font-size: 0.7rem !important; /* Readable font size */
        font-weight: 700 !important; /* Bolder text */
        border-radius: 4px !important; /* Smaller border radius */
        border: 1.5px solid rgba(30, 58, 138, 0.2) !important; /* Stronger border */
        background: rgba(248, 249, 250, 0.95) !important; /* More opaque background */
        transition: all 0.25s ease !important; /* Smoother transitions */
        backdrop-filter: blur(5px) !important; /* Subtle blur */
    }

    /* X and O symbols in layer cells - iPhone optimized */
    .layer-cell .cell-x {
        color: #1e3a8a !important; /* Dark blue X */
        font-size: 0.7rem !important;
        font-weight: 900 !important; /* Extra bold */
        text-shadow: 0 1px 3px rgba(30, 58, 138, 0.4) !important;
    }

    .layer-cell .cell-o {
        color: #dc2626 !important; /* Red O */
        font-size: 0.7rem !important;
        font-weight: 900 !important; /* Extra bold */
        text-shadow: 0 1px 3px rgba(220, 38, 38, 0.4) !important;
    }

    /* Active layer highlighting - iPhone optimized */
    .layer-active {
        border-color: #1e3a8a !important; /* Dark blue border */
        background: rgba(30, 58, 138, 0.15) !important; /* More pronounced active state */
        box-shadow: 0 4px 16px rgba(30, 58, 138, 0.3) !important; /* Enhanced shadow */
        transform: scale(1.02) !important; /* Subtle scale effect */
    }

    .layer-active .layer-header {
        color: #1e3a8a !important; /* Dark blue text for active layer */
        font-weight: 800 !important; /* Extra bold for active layer */
    }

    .layer-active .layer-cell {
        border-color: rgba(30, 58, 138, 0.4) !important; /* Stronger border for active layer */
        background: rgba(255, 255, 255, 0.95) !important; /* More opaque background */
    }

    /* Hover states for iPhone touch */
    .layer-card:hover {
        transform: translateY(-2px) scale(1.02) !important; /* Reduced transform for iPhone */
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2) !important; /* Enhanced shadow on touch */
        border-color: rgba(30, 58, 138, 0.5) !important; /* Blue border on touch */
    }

    /* Winning positions in layer view - iPhone optimized */
    .layer-cell.winning-position {
        background: linear-gradient(135deg, #166534 0%, #15803d 100%) !important; /* Dark green */
        border-color: #166534 !important;
        box-shadow: 0 2px 8px rgba(22, 101, 52, 0.4) !important;
        animation: pulseWinLayer 1.5s infinite !important; /* Faster animation for iPhone */
    }

    /* Win animation for layer cells */
    @keyframes pulseWinLayer {
        0%, 100% {
            transform: scale(1);
            box-shadow: 0 2px 8px rgba(22, 101, 52, 0.4);
        }
        50% {
            transform: scale(1.1);
            box-shadow: 0 4px 12px rgba(22, 101, 52, 0.6);
        }
    }

    /* Ensure proper flex wrapping on iPhone */
    .d-flex.flex-wrap.gap-4 {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: flex-start !important;
    }

    /* For 3x3x3 boards - optimize for iPhone */
    .layer-grid[style*="repeat(3"] {
        grid-template-columns: repeat(3, minmax(18px, 1fr)) !important;
        max-width: 90px !important;
        margin: 0 auto !important;
    }

    /* For 4x4x4 boards - optimize for iPhone */
    .layer-grid[style*="repeat(4"] {
        grid-template-columns: repeat(4, minmax(16px, 1fr)) !important;
        max-width: 90px !important;
        margin: 0 auto !important;
    }

    /* For 5x5x5 boards - optimize for iPhone */
    .layer-grid[style*="repeat(5"] {
        grid-template-columns: repeat(5, minmax(14px, 1fr)) !important;
        max-width: 90px !important;
        margin: 0 auto !important;
    }

    /* Card header for All Layers Overview - iPhone optimized */
    .status-card .card-header h4 {
        font-size: 1.1rem !important; /* Slightly smaller header */
        margin-bottom: 0 !important;
    }

    /* Improve touch targets for layer cards */
    .layer-card {
        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(30, 58, 138, 0.3) !important; /* iOS tap highlight */
        user-select: none !important; /* Prevent text selection on touch */
    }

    /* Smooth scrolling for layer overview on iPhone */
    .status-card .card-body {
        -webkit-overflow-scrolling: touch !important;
        overflow-x: auto !important;
    }

    /* Ensure layer cards don't get too small */
    .layer-card {
        flex: 0 0 auto !important; /* Prevent flex shrinking */
        min-width: 85px !important; /* Absolute minimum width */
    }
}

/* Additional iPhone-specific improvements for landscape mode */
@media only screen 
and (device-width: 375px) 
and (device-height: 667px) 
and (-webkit-device-pixel-ratio: 2) 
and (orientation: landscape),
only screen 
and (device-width: 375px) 
and (device-height: 812px) 
and (-webkit-device-pixel-ratio: 3) 
and (orientation: landscape),
only screen 
and (device-width: 414px) 
and (device-height: 736px) 
and (-webkit-device-pixel-ratio: 3) 
and (orientation: landscape),
only screen 
and (device-width: 414px) 
and (device-height: 896px) 
and (-webkit-device-pixel-ratio: 2) 
and (orientation: landscape),
only screen 
and (device-width: 414px) 
and (device-height: 896px) 
and (-webkit-device-pixel-ratio: 3) 
and (orientation: landscape),
only screen 
and (device-width: 390px) 
and (device-height: 844px) 
and (-webkit-device-pixel-ratio: 3) 
and (orientation: landscape),
only screen 
and (device-width: 428px) 
and (device-height: 926px) 
and (-webkit-device-pixel-ratio: 3) 
and (orientation: landscape) {

    /* iPhone landscape optimizations */
    .layer-card {
        max-width: calc((100vw - 4rem) / 4) !important; /* 4 cards per row in landscape */
        min-width: 80px !important;
    }

    .d-flex.flex-wrap.gap-4.justify-content-center {
        gap: 0.5rem !important; /* Even tighter in landscape */
    }

    .status-card .card-body {
        padding: 0.75rem 0.5rem !important; /* Tighter padding in landscape */
    }
}