/* Connect4 styles - Enhanced mobile-friendly and visually engaging */

/* Scoreboard - Enhanced with better mobile support */
.neon-scoreboard {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: clamp(8px, 2vw, 20px);
    padding: clamp(14px, 3vw, 20px) clamp(12px, 4vw, 28px);
    margin-bottom: clamp(12px, 3vw, 20px);
    background: linear-gradient(135deg, rgba(255, 23, 68, 0.12) 0%, rgba(255, 255, 0, 0.12) 100%);
    border: 2px solid;
    border-image: linear-gradient(135deg, #ff1744, #ffff00) 1;
    border-radius: 16px;
    box-shadow:
        0 0 25px rgba(255, 23, 68, 0.4),
        0 0 50px rgba(255, 255, 0, 0.25),
        inset 0 0 25px rgba(255, 23, 68, 0.08);
    font-weight: 600;
    font-size: clamp(12px, 1.8vw, 20px);
    font-family: 'Courier New', monospace;
    letter-spacing: clamp(1px, 0.2vw, 2px);
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}

.neon-scoreboard::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.scoreboard-player {
    display: flex;
    align-items: center;
    gap: clamp(6px, 1.5vw, 10px);
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    flex: 1;
    justify-content: center;
    min-width: 100px;
    padding: clamp(4px, 1vw, 8px);
    border-radius: 8px;
    transition: transform 0.2s ease, background 0.2s ease;
}

.scoreboard-player:active {
    transform: scale(0.95);
}

.scoreboard-player.opp {
    flex-direction: row-reverse;
}

.scoreboard-player.player-red {
    color: #ff1744;
    text-shadow: 0 0 12px rgba(255, 23, 68, 0.7), 0 0 24px rgba(255, 23, 68, 0.4);
}

.scoreboard-player.player-yellow {
    color: #ffff00;
    text-shadow: 0 0 12px rgba(255, 255, 0, 0.7), 0 0 24px rgba(255, 255, 0, 0.4);
}

.scoreboard-turn {
    color: #ffff00;
    text-shadow: 0 0 12px rgba(255, 255, 0, 0.6), 0 0 24px rgba(255, 255, 0, 0.3);
    font-size: clamp(11px, 1.5vw, 18px);
    letter-spacing: clamp(0.5px, 0.15vw, 1.5px);
    white-space: nowrap;
    transition: color 0.3s ease, text-shadow 0.3s ease, transform 0.2s ease;
    font-weight: 700;
    padding: clamp(4px, 1vw, 8px);
    border-radius: 8px;
    position: relative;
}

.scoreboard-turn.turn-red {
    color: #ff1744;
    text-shadow: 0 0 12px rgba(255, 23, 68, 0.6), 0 0 24px rgba(255, 23, 68, 0.3);
    animation: pulse-glow-red 2s ease-in-out infinite;
}

.scoreboard-turn.turn-yellow {
    color: #ffff00;
    text-shadow: 0 0 12px rgba(255, 255, 0, 0.6), 0 0 24px rgba(255, 255, 0, 0.3);
    animation: pulse-glow-yellow 2s ease-in-out infinite;
}

@keyframes pulse-glow-red {

    0%,
    100% {
        text-shadow: 0 0 12px rgba(255, 23, 68, 0.6), 0 0 24px rgba(255, 23, 68, 0.3);
    }

    50% {
        text-shadow: 0 0 20px rgba(255, 23, 68, 0.9), 0 0 40px rgba(255, 23, 68, 0.5);
    }
}

@keyframes pulse-glow-yellow {

    0%,
    100% {
        text-shadow: 0 0 12px rgba(255, 255, 0, 0.6), 0 0 24px rgba(255, 255, 0, 0.3);
    }

    50% {
        text-shadow: 0 0 20px rgba(255, 255, 0, 0.9), 0 0 40px rgba(255, 255, 0, 0.5);
    }
}

/* Mobile scoreboard adjustments */
@media (max-width: 480px) {
    .neon-scoreboard {
        flex-direction: column;
        gap: 12px;
        padding: 16px 12px;
        border-radius: 12px;
    }

    .scoreboard-player {
        width: 100%;
        gap: 8px;
        font-size: 14px;
        padding: 8px;
    }

    .scoreboard-turn {
        order: -1;
        margin-bottom: 4px;
        font-size: 13px;
        width: 100%;
    }
}

/* Enhanced Game Board */
.connect-board {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: clamp(6px, 1.5vw, 12px);
    width: min(560px, 95vw);
    aspect-ratio: 7 / 6;
    margin: clamp(12px, 3vw, 20px) auto;
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 23, 68, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 100%, rgba(255, 255, 0, 0.1) 0%, transparent 50%),
        rgba(255, 255, 255, 0.04);
    padding: clamp(10px, 2.5vw, 18px);
    border-radius: 20px;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.5),
        inset 0 0 50px rgba(255, 255, 255, 0.03),
        0 0 30px rgba(255, 23, 68, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.08);
    position: relative;
    overflow: visible;
}

@media (max-width: 600px) {
    .connect-board {
        width: min(92vw, 380px);
        /* a bit more forgiving than 85vw/320px */
        aspect-ratio: 7 / 6;
        gap: clamp(3px, 0.8vw, 6px);
        padding: clamp(6px, 1.5vw, 10px);
        margin: clamp(8px, 2vw, 12px) auto;
        border-radius: 14px;
        overflow: hidden;
        /* add this here too */
    }
}


.connect-board::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 20px;
    padding: 2px;
    background: linear-gradient(135deg, rgba(255, 23, 68, 0.3), rgba(255, 255, 0, 0.3));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

body.player-turn .connect-board::before {
    opacity: 1;
    animation: border-pulse 2s ease-in-out infinite;
}

@keyframes border-pulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.6;
    }
}

/* Enhanced Cells */
.connect-cell {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.1), transparent 50%),
        rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(255, 255, 255, 0.05);
    box-shadow:
        inset 0 3px 10px rgba(0, 0, 0, 0.6),
        0 2px 4px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.connect-cell::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.1), transparent 70%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.connect-cell:hover::before,
.connect-cell:active::before {
    opacity: 1;
}

.connect-cell:hover {
    transform: translateY(-6px) scale(1.05);
    background: rgba(255, 255, 255, 0.12);
    box-shadow:
        inset 0 3px 10px rgba(0, 0, 0, 0.4),
        0 6px 12px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(255, 255, 255, 0.2);
}

.connect-cell:active {
    transform: translateY(-2px) scale(1.02);
}

/* Column hover effect - enhanced */
.connect-cell.col-hover {
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2), transparent 50%),
        rgba(255, 255, 255, 0.15);
    box-shadow:
        inset 0 3px 10px rgba(0, 0, 0, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.3),
        0 0 25px rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
    animation: column-pulse 1.5s ease-in-out infinite;
}

@keyframes column-pulse {

    0%,
    100% {
        box-shadow:
            inset 0 3px 10px rgba(0, 0, 0, 0.3),
            0 4px 8px rgba(0, 0, 0, 0.3),
            0 0 25px rgba(255, 255, 255, 0.3);
    }

    50% {
        box-shadow:
            inset 0 3px 10px rgba(0, 0, 0, 0.3),
            0 4px 8px rgba(0, 0, 0, 0.3),
            0 0 35px rgba(255, 255, 255, 0.5);
    }
}

/* Enhanced Discs */
.disc {
    width: 88%;
    height: 88%;
    border-radius: 50%;
    animation: dropIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 1;
}

@keyframes dropIn {
    0% {
        transform: translateY(-400%) scale(0.8);
        opacity: 0;
    }

    60% {
        transform: translateY(5%) scale(1.05);
    }

    80% {
        transform: translateY(-2%) scale(0.98);
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.disc.red {
    background: linear-gradient(145deg, #ff6b6b, #ff3e3e, #ff1744);
    box-shadow:
        0 0 20px rgba(255, 62, 62, 0.5),
        0 0 40px rgba(255, 23, 68, 0.3),
        inset 0 -5px 10px rgba(0, 0, 0, 0.4),
        inset 0 5px 10px rgba(255, 255, 255, 0.4),
        inset -2px -2px 4px rgba(255, 23, 68, 0.2);
    position: relative;
}

.disc.red::after {
    content: "";
    position: absolute;
    inset: 15%;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4), transparent 70%);
    pointer-events: none;
}

.disc.yellow {
    background: linear-gradient(145deg, #fff89e, #ffdf00, #ffc107);
    box-shadow:
        0 0 20px rgba(255, 223, 0, 0.5),
        0 0 40px rgba(255, 193, 7, 0.3),
        inset 0 -5px 10px rgba(0, 0, 0, 0.4),
        inset 0 5px 10px rgba(255, 255, 255, 0.4),
        inset -2px -2px 4px rgba(255, 193, 7, 0.2);
    position: relative;
}

.disc.yellow::after {
    content: "";
    position: absolute;
    inset: 15%;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4), transparent 70%);
    pointer-events: none;
}

.disc.last-move {
    border: 3px solid white;
    box-shadow:
        0 0 25px 5px rgba(255, 255, 255, 0.8),
        inset 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Column buttons - hidden on mobile, shown on desktop */
.col-btn {
    padding: clamp(8px, 1.5vw, 12px) clamp(6px, 1vw, 8px);
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    min-width: 0;
    width: 100%;
    border-radius: 6px;
    opacity: 0.7;
    transition: all 0.2s ease;
    font-weight: 600;
    margin-bottom: 8px;
}

.col-btn:hover {
    opacity: 1;
    transform: translateY(-2px);
}

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

/* Mobile-specific improvements */
@media (max-width: 600px) {
    .connect-board {
        gap: clamp(3px, 0.8vw, 6px);
        padding: clamp(6px, 1.5vw, 10px);
        width: min(85vw, 320px);
        margin: clamp(8px, 2vw, 12px) auto;
        border-radius: 14px;
    }

    .connect-cell {
        border-width: 1.5px;
        min-height: 40px;
        /* Force minimum size */
    }

    .connect-cell:hover {
        transform: translateY(-3px) scale(1.03);
    }

    .disc {
        width: 90%;
        height: 90%;
    }

    .game-modes {
        flex-direction: column;
        gap: 16px;
    }

    /* Hide column buttons on mobile - use direct cell taps instead */
    #board-controls {
        display: none !important;
    }
}

/* Extra small mobile devices */
@media (max-width: 400px) {
    .connect-board {
        width: min(90vw, 300px);
        gap: clamp(2px, 0.6vw, 5px);
        padding: clamp(5px, 1.2vw, 8px);
        margin: clamp(6px, 1.5vw, 10px) auto;
    }
}

/* Touch-friendly improvements (mobile) */
@media (hover: none) and (pointer: coarse) {
    .connect-cell {
        min-height: 0;
        /* IMPORTANT: allow grid tracks to size correctly */
        touch-action: manipulation;
        /* better tap behavior on mobile */
    }

    .connect-board {
        overflow: hidden;
        /* prevent any spill/overlap from rounding/animation */
    }
}

/* Lobby Cards Layout - Enhanced */
.game-modes {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(16px, 3vw, 24px);
    justify-content: center;
    margin: clamp(20px, 4vw, 30px) 0;
}

.mode-card {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: clamp(18px, 3vw, 24px);
    flex: 1 1 250px;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.mode-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 243, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.mode-card:hover::before {
    left: 100%;
}

.mode-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 243, 255, 0.15);
    border-color: rgba(0, 243, 255, 0.4);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
}

.mode-card:active {
    transform: translateY(-4px) scale(1);
}

.mode-card h3 {
    margin: 0 0 8px 0;
    color: var(--primary);
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

.mode-desc {
    color: var(--text-dim);
    font-size: clamp(0.85rem, 1.5vw, 0.95rem);
    margin-bottom: clamp(12px, 2vw, 18px);
    line-height: 1.5;
}

/* Enhanced game message */
#game-msg {
    margin: clamp(16px, 3vw, 24px) auto;
    max-width: 90%;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    padding: clamp(16px, 3vw, 24px);
    border-radius: 16px;
    animation: messageAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes messageAppear {
    0% {
        transform: scale(0.5) rotate(-5deg);
        opacity: 0;
    }

    50% {
        transform: scale(1.1) rotate(2deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Win/Loss/Draw message enhancements */
.game-msg.win {
    background: linear-gradient(135deg, rgba(0, 243, 255, 0.25) 0%, rgba(0, 255, 136, 0.25) 100%);
    border: 2px solid var(--primary);
    color: var(--primary);
    text-shadow:
        0 0 20px var(--primary),
        0 0 40px rgba(0, 243, 255, 0.5);
    box-shadow:
        0 8px 32px rgba(0, 243, 255, 0.3),
        inset 0 0 20px rgba(0, 243, 255, 0.1);
    animation: winPulse 2s ease-in-out infinite, messageAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes winPulse {

    0%,
    100% {
        box-shadow:
            0 8px 32px rgba(0, 243, 255, 0.3),
            inset 0 0 20px rgba(0, 243, 255, 0.1);
    }

    50% {
        box-shadow:
            0 12px 48px rgba(0, 243, 255, 0.5),
            inset 0 0 30px rgba(0, 243, 255, 0.2);
    }
}

.game-msg.loss {
    background: linear-gradient(135deg, rgba(255, 0, 85, 0.25) 0%, rgba(255, 68, 0, 0.25) 100%);
    border: 2px solid #ff0055;
    color: #ff0055;
    text-shadow:
        0 0 20px #ff0055,
        0 0 40px rgba(255, 0, 85, 0.5);
    box-shadow:
        0 8px 32px rgba(255, 0, 85, 0.3),
        inset 0 0 20px rgba(255, 0, 85, 0.1);
}

.game-msg.draw {
    background: linear-gradient(135deg, rgba(189, 0, 255, 0.25) 0%, rgba(138, 43, 226, 0.25) 100%);
    border: 2px solid var(--secondary);
    color: var(--secondary);
    text-shadow:
        0 0 20px var(--secondary),
        0 0 40px rgba(189, 0, 255, 0.5);
    box-shadow:
        0 8px 32px rgba(189, 0, 255, 0.3),
        inset 0 0 20px rgba(189, 0, 255, 0.1);
}

/* Button improvements for mobile */
@media (max-width: 600px) {
    #game-screen .neon-btn {
        padding: 14px 20px;
        font-size: 0.95rem;
        min-height: 48px;
        /* Better touch target */
    }

    #game-screen>div:last-child {
        flex-direction: column;
        gap: 12px;
        width: 100%;
        max-width: 90%;
        margin: 0 auto;
    }

    #game-screen .neon-btn {
        width: 100%;
    }
}

/* Loading state for cells */
.connect-cell.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* Victory line animation (if you want to add this later) */
@keyframes victory-line {
    0% {
        stroke-dasharray: 0 1000;
    }

    100% {
        stroke-dasharray: 1000 0;
    }
}