* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-main: #0b0f19;
    --board-blue: #1d4ed8;
    --board-border: #1e40af;
    --red-disc: linear-gradient(135deg, #ef4444, #b91c1c);
    --yellow-disc: linear-gradient(135deg, #facc15, #d97706);
    --empty-slot: #0f172a;
    --accent: #38bdf8;
    --accent-gradient: linear-gradient(135deg, #0ea5e9, #6366f1);
    --text: #f8fafc;
    --text-muted: #94a3b8;
}

body {
    background: radial-gradient(circle at 50% 15%, #1e1b4b, var(--bg-main) 75%);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 75px; /* Space for bottom banner ad */
}

/* Header & HUD */
header {
    width: 100%;
    max-width: 500px;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    z-index: 50;
}

.title-group h1 {
    font-size: 1.2rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-turn-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}

.turn-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.turn-dot.red {
    background: #ef4444;
    box-shadow: 0 0 12px #ef4444;
}

.turn-dot.yellow {
    background: #facc15;
    box-shadow: 0 0 12px #facc15;
}

/* Score Bar */
.score-bar {
    width: 100%;
    max-width: 480px;
    display: flex;
    justify-content: space-around;
    padding: 8px 12px;
    gap: 10px;
}

.score-card {
    flex: 1;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 6px 8px;
    text-align: center;
}

.score-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.score-val {
    font-size: 1.1rem;
    font-weight: 800;
}

.score-card.red .score-val { color: #f87171; }
.score-card.yellow .score-val { color: #fde047; }
.score-card.draw .score-val { color: #94a3b8; }

/* Control Toolbar */
.toolbar {
    width: 100%;
    max-width: 480px;
    padding: 4px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pill-btn {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pill-btn:hover {
    color: #fff;
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
}

.pill-btn.active {
    background: var(--accent-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.4);
}

/* Board Outer Wrapper */
.board-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    width: 100%;
    max-width: 500px;
}

/* Drop Column Hover / Guide Bar */
.drop-guide-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    width: 100%;
    max-width: 420px;
    height: 32px;
    margin-bottom: 6px;
}

.drop-arrow-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.drop-indicator-disc {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    opacity: 0;
    transform: translateY(-8px);
    transition: all 0.18s ease;
}

.drop-arrow-cell:hover .drop-indicator-disc,
.drop-arrow-cell.active-touch .drop-indicator-disc {
    opacity: 0.85;
    transform: translateY(0);
}

.drop-indicator-disc.red { background: var(--red-disc); box-shadow: 0 0 8px #ef4444; }
.drop-indicator-disc.yellow { background: var(--yellow-disc); box-shadow: 0 0 8px #facc15; }

/* 7x6 Connect Four Board */
.connect-board {
    background: linear-gradient(145deg, var(--board-blue), #1e3a8a);
    border: 4px solid var(--board-border);
    border-radius: 20px;
    padding: 10px;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.6), inset 0 2px 6px rgba(255, 255, 255, 0.2);
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 7 / 6;
}

/* Individual Slot & Dropped Disc */
.slot {
    position: relative;
    background: var(--empty-slot);
    border-radius: 50%;
    width: 100%;
    height: 100%;
    aspect-ratio: 1;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.9), 0 1px 2px rgba(255, 255, 255, 0.15);
    cursor: pointer;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.disc {
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.4), inset 0 -3px 6px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.5);
    animation: dropDisc 0.38s cubic-bezier(0.34, 1.35, 0.64, 1);
}

.disc.red {
    background: var(--red-disc);
    border: 2px solid #f87171;
}

.disc.yellow {
    background: var(--yellow-disc);
    border: 2px solid #fef08a;
}

.disc.winner {
    animation: winPulse 0.8s infinite alternate ease-in-out;
    box-shadow: 0 0 16px #fff, inset 0 0 8px #fff;
    border-color: #ffffff;
    z-index: 10;
}

@keyframes dropDisc {
    0% {
        transform: translateY(-300px);
        opacity: 0.3;
    }
    70% {
        transform: translateY(0);
        opacity: 1;
    }
    85% {
        transform: translateY(-8px);
    }
    100% {
        transform: translateY(0);
    }
}

@keyframes winPulse {
    from {
        transform: scale(0.92);
        filter: brightness(1.2);
    }
    to {
        transform: scale(1.08);
        filter: brightness(1.6);
    }
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-box {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-box h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.win-title {
    color: #facc15;
    text-shadow: 0 0 15px rgba(250, 204, 21, 0.5);
}

.modal-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.action-btn {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.6);
}

.action-btn:active {
    transform: translateY(1px);
}
