/* ── Connect Four Theme ── */
:root {
    --cf-accent: #EAB308;
    --cf-accent-light: #FACC15;
    --cf-accent-dark: #CA8A04;
    --cf-bg: #0F1923;
    --cf-surface: #1A2736;
    --cf-surface-light: #243447;
    --cf-text: #E2E8F0;
    --cf-text-dim: #94A3B8;
    --cf-board-blue: #1E40AF;
    --cf-board-dark: #1E3A5F;
    --cf-red: #EF4444;
    --cf-red-glow: #F87171;
    --cf-yellow: #EAB308;
    --cf-yellow-glow: #FDE047;
    --cf-success: #22C55E;
    --cf-danger: #EF4444;
}

/* ── Layout ── */
.cf-layout {
    display: flex;
    justify-content: center;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 80px);
}

.ad-slot { width: 160px; flex-shrink: 0; }
.ad-slot--left, .ad-slot--right { display: flex; align-items: flex-start; }
.ad-placeholder--vertical {
    width: 160px; height: 600px;
    background: var(--cf-surface);
    border: 1px dashed var(--cf-text-dim);
    display: flex; align-items: center; justify-content: center;
    color: var(--cf-text-dim); font-size: 12px; border-radius: 8px;
}

#connectfour-app {
    flex: 1;
    max-width: 700px;
    min-width: 320px;
}

/* ── Screens ── */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Header ── */
.cf-header {
    text-align: center;
    padding: 40px 0 30px;
}
.cf-logo { margin-bottom: 16px; }
.cf-logo-discs {
    display: flex;
    justify-content: center;
    gap: 8px;
}
.cf-disc-red, .cf-disc-yellow {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: inline-block;
}
.cf-disc-red { background: var(--cf-red); box-shadow: 0 0 12px rgba(239, 68, 68, 0.5); }
.cf-disc-yellow { background: var(--cf-yellow); box-shadow: 0 0 12px rgba(234, 179, 8, 0.5); }

.cf-header h1 {
    font-family: 'Syne', sans-serif;
    font-size: 3rem;
    font-weight: 800;
    color: var(--cf-accent);
    letter-spacing: 4px;
    margin: 0;
    text-shadow: 0 0 30px rgba(234, 179, 8, 0.3);
}
.subtitle {
    color: var(--cf-text-dim);
    font-size: 1rem;
    margin-top: 8px;
}

/* ── Cards ── */
.card {
    background: var(--cf-surface);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--cf-surface-light);
}
.card__title {
    font-family: 'Syne', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--cf-accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

/* ── Difficulty ── */
.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.diff-btn {
    background: var(--cf-bg);
    border: 2px solid var(--cf-surface-light);
    border-radius: 10px;
    padding: 14px 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    color: var(--cf-text);
}
.diff-btn:hover { border-color: var(--cf-accent); background: var(--cf-surface-light); }
.diff-btn.selected { border-color: var(--cf-accent); background: rgba(234, 179, 8, 0.15); }
.diff-icon { display: block; font-size: 1.4rem; margin-bottom: 4px; }
.diff-btn span:nth-child(2) { display: block; font-weight: 600; font-size: 0.9rem; }
.diff-desc { display: block; font-size: 0.75rem; color: var(--cf-text-dim); margin-top: 2px; }

/* ── Color Select ── */
.color-select {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.color-btn {
    background: var(--cf-bg);
    border: 2px solid var(--cf-surface-light);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    color: var(--cf-text);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.color-btn:hover { border-color: var(--cf-accent); }
.color-btn.selected { border-color: var(--cf-accent); background: rgba(234, 179, 8, 0.1); }
.color-disc { width: 20px; height: 20px; border-radius: 50%; display: inline-block; }
.color-disc--red { background: var(--cf-red); }
.color-disc--yellow { background: var(--cf-yellow); }

/* ── Buttons ── */
.menu-actions { text-align: center; margin-top: 24px; }
.btn {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}
.btn--primary {
    background: var(--cf-accent);
    color: #000;
    padding: 14px 40px;
    font-size: 1.1rem;
}
.btn--primary:hover { background: var(--cf-accent-light); transform: translateY(-2px); box-shadow: 0 4px 20px rgba(234, 179, 8, 0.4); }
.btn--lg { font-size: 1.1rem; }
.btn--sm { padding: 8px 16px; font-size: 0.8rem; }
.btn--outline {
    background: transparent;
    color: var(--cf-accent);
    border: 2px solid var(--cf-accent);
    padding: 8px 20px;
}
.btn--outline:hover { background: rgba(234, 179, 8, 0.1); }
.btn--ghost {
    background: transparent;
    color: var(--cf-text-dim);
    padding: 10px 20px;
}
.btn--ghost:hover { color: var(--cf-accent); }

/* ── HUD ── */
#game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--cf-surface);
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 16px;
    border: 1px solid var(--cf-surface-light);
}
.hud__cell { text-align: left; }
.hud__cell--center { text-align: center; }
.hud__cell--right { text-align: right; }
.hud__label { display: block; font-size: 0.7rem; color: var(--cf-text-dim); text-transform: uppercase; letter-spacing: 1px; }
.hud__value { font-family: 'JetBrains Mono', monospace; font-size: 1.2rem; font-weight: 700; color: var(--cf-text); }

/* ── Board ── */
.cf-board-area {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}
.cf-board-wrap { position: relative; }

.cf-preview-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 0 8px;
    margin-bottom: 4px;
    height: 40px;
}
.cf-preview-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}
.cf-preview-disc {
    width: 32px; height: 32px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s;
}
.cf-preview-disc.visible { opacity: 0.5; }
.cf-preview-disc.red { background: var(--cf-red); }
.cf-preview-disc.yellow { background: var(--cf-yellow); }

.cf-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    background: var(--cf-board-blue);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 8px 32px rgba(30, 64, 175, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.cf-cell {
    width: 100%;
    aspect-ratio: 1;
    background: var(--cf-bg);
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.4);
}
.cf-cell:hover { background: var(--cf-surface-light); }
.cf-cell.disabled { cursor: default; }

.cf-cell .disc {
    position: absolute;
    inset: 8%;
    border-radius: 50%;
    transition: transform 0.1s;
}
.cf-cell .disc.red {
    background: radial-gradient(circle at 35% 35%, var(--cf-red-glow), var(--cf-red));
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
}
.cf-cell .disc.yellow {
    background: radial-gradient(circle at 35% 35%, var(--cf-yellow-glow), var(--cf-yellow));
    box-shadow: 0 2px 8px rgba(234, 179, 8, 0.5);
}

/* Drop animation */
.cf-cell .disc.dropping {
    animation: discDrop 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes discDrop {
    0% { transform: translateY(-500%); }
    60% { transform: translateY(5%); }
    80% { transform: translateY(-3%); }
    100% { transform: translateY(0); }
}

/* Winning glow */
.cf-cell.winning .disc {
    animation: winGlow 0.6s ease infinite alternate;
}
@keyframes winGlow {
    from { box-shadow: 0 0 8px rgba(34, 197, 94, 0.5); }
    to { box-shadow: 0 0 20px rgba(34, 197, 94, 0.9), 0 0 40px rgba(34, 197, 94, 0.4); }
}

/* ── Actions ── */
.cf-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* ── Result Card ── */
.result-card, .lb-card {
    background: var(--cf-surface);
    border-radius: 16px;
    padding: 40px 30px;
    text-align: center;
    border: 1px solid var(--cf-surface-light);
    max-width: 420px;
    margin: 60px auto;
}
.result-card h2, .lb-card h2 {
    font-family: 'Syne', sans-serif;
    font-size: 1.8rem;
    color: var(--cf-accent);
    margin: 0 0 20px;
    letter-spacing: 3px;
}
.result-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 3rem;
    font-weight: 700;
    color: var(--cf-text);
    margin-bottom: 8px;
}
.result-detail {
    color: var(--cf-text-dim);
    font-size: 0.9rem;
    margin-bottom: 20px;
}
#nickname {
    width: 100%;
    max-width: 280px;
    padding: 10px 16px;
    background: var(--cf-bg);
    border: 2px solid var(--cf-surface-light);
    border-radius: 8px;
    color: var(--cf-text);
    font-size: 1rem;
    text-align: center;
    outline: none;
    margin-bottom: 16px;
}
#nickname:focus { border-color: var(--cf-accent); }
.result-actions { display: flex; justify-content: center; gap: 12px; margin-bottom: 12px; }

/* ── Leaderboard ── */
#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}
#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--cf-surface-light);
    color: var(--cf-text);
    font-family: 'JetBrains Mono', monospace;
}
#leaderboard-list li:first-child { color: var(--cf-accent); font-weight: 700; }

/* ── Responsive ── */
@media (max-width: 900px) {
    .ad-slot--left, .ad-slot--right { display: none; }
    .cf-layout { padding: 10px; }
}
@media (max-width: 500px) {
    .cf-header h1 { font-size: 2rem; }
    .difficulty-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .diff-btn { padding: 10px 4px; }
    .color-select { gap: 6px; }
    .color-btn { font-size: 0.8rem; padding: 10px 6px; }
    #game-hud { padding: 8px 12px; }
    .hud__value { font-size: 1rem; }
    .cf-board { padding: 4px; gap: 3px; }
}
