/* Four in a Row */
#c4Game {
    --c4-frame: #1d4ed8;
    --c4-frame-dark: #1e40af;
    --c4-hole: #f8fafc;
    --c4-red: #e11d48;
    --c4-red-dark: #9f1239;
    --c4-yellow: #facc15;
    --c4-yellow-dark: #ca8a04;
    --c4-accent: #052c65;
}
[data-bs-theme="dark"] #c4Game {
    --c4-frame: #1e3a8a;
    --c4-frame-dark: #172554;
    --c4-hole: #0f172a;
    --c4-accent: #93c5fd;
}

.c4-status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font-weight: 600;
    font-size: 1.05rem;
    min-height: 1.75rem;
    text-align: center;
}

.c4-wrap {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
}

.c4-preview,
.c4-board {
    display: grid;
    grid-template-columns: repeat(var(--cols, 7), minmax(0, 1fr));
}

.c4-preview {
    padding: 0 8px;
    cursor: pointer;
    touch-action: manipulation;
}
.c4-slot {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.c4-colnum {
    position: absolute;
    bottom: 2px;
    font-size: .7rem;
    color: var(--bs-secondary-color, #6c757d);
    opacity: .7;
}
.c4-ghost {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .12s, transform .12s;
}
.c4-slot.c4-on .c4-ghost {
    opacity: .55;
    transform: none;
}
.c4-slot.c4-hint .c4-colnum {
    color: #16a34a;
    font-weight: 700;
    opacity: 1;
}
.c4-slot.c4-hint::after {
    content: "";
    position: absolute;
    inset: 6% 6% 6% 6%;
    border: 3px dashed #16a34a;
    border-radius: 50%;
}

.c4-board {
    position: relative;
    padding: 8px;
    background: linear-gradient(180deg, var(--c4-frame) 0%, var(--c4-frame-dark) 100%);
    border-radius: 14px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .25), inset 0 2px 0 rgba(255, 255, 255, .15);
    cursor: pointer;
    touch-action: manipulation;
    outline: none;
}
.c4-board:focus-visible {
    box-shadow: 0 0 0 3px var(--c4-accent), 0 8px 22px rgba(0, 0, 0, .25);
}
.c4-board.c4-locked {
    cursor: default;
}

.c4-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.c4-cell::before {
    content: "";
    position: absolute;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    background: var(--c4-hole);
    box-shadow: inset 0 3px 5px rgba(0, 0, 0, .35);
}
.c4-cell.c4-col-hover::before {
    box-shadow: inset 0 3px 5px rgba(0, 0, 0, .35), 0 0 0 2px rgba(255, 255, 255, .35);
}

.c4-disc,
.c4-ghost,
.c4-mini-disc {
    display: inline-block;
}
.c4-disc {
    position: relative;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    z-index: 1;
}
.c4-p1 {
    background: radial-gradient(circle at 35% 30%, #fb7185 0%, var(--c4-red) 45%, var(--c4-red-dark) 100%);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2);
}
.c4-p2 {
    background: radial-gradient(circle at 35% 30%, #fef08a 0%, var(--c4-yellow) 45%, var(--c4-yellow-dark) 100%);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15);
}
.c4-draw {
    background: linear-gradient(90deg, var(--c4-red) 50%, var(--c4-yellow) 50%);
}
.c4-mini-disc {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    flex: 0 0 auto;
}

.c4-drop {
    animation: c4-fall var(--dur, .4s) cubic-bezier(.45, 0, 1, 1);
}
@keyframes c4-fall {
    from { transform: translateY(calc(var(--fall, 1) * -125%)); }
    82% { transform: translateY(0); }
    91% { transform: translateY(-6%); }
    to { transform: translateY(0); }
}

.c4-cell.c4-last .c4-disc::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18%;
    height: 18%;
    margin: -9% 0 0 -9%;
    border-radius: 50%;
    background: rgba(255, 255, 255, .7);
}
.c4-board.c4-over .c4-cell:not(.c4-win) .c4-disc {
    opacity: .45;
}
.c4-cell.c4-win .c4-disc {
    animation: c4-pulse 1s ease-in-out infinite alternate;
    box-shadow: 0 0 0 3px #fff, 0 0 12px 4px rgba(255, 255, 255, .8);
}
@keyframes c4-pulse {
    from { transform: scale(1); }
    to { transform: scale(.86); }
}

.c4-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .5rem;
    text-align: center;
}
.c4-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    padding: .5rem .25rem;
    border-radius: 10px;
    background: var(--bs-tertiary-bg, #f8f9fa);
}
.c4-stat-val {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}
.c4-stat-lbl {
    font-size: .8rem;
    color: var(--bs-secondary-color, #6c757d);
    overflow-wrap: anywhere;
}

@media (max-width: 420px) {
    .c4-board { padding: 5px; border-radius: 10px; }
    .c4-preview { padding: 0 5px; }
    .c4-colnum { font-size: .6rem; }
}

@media (prefers-reduced-motion: reduce) {
    .c4-drop, .c4-cell.c4-win .c4-disc { animation: none; }
}
