/* ── Ball Pool — Royal Purple Felt ── */
:root {
    --bp-accent: #7C3AED;
    --bp-accent-light: #A78BFA;
    --bp-accent-dark: #4C1D95;
    --bp-glow: rgba(167, 139, 250, 0.55);
    --bp-bg: #0B0820;
    --bp-surface: #16112E;
    --bp-surface-light: #221A40;
    --bp-text: #ECE9FA;
    --bp-text-dim: #9C8FCC;
    --bp-gold: #FBBF24;
    --bp-felt: #0F4C3A;
    --bp-felt-light: #14633C;
}

.bp-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(--bp-surface);
    border: 1px dashed var(--bp-text-dim);
    display: flex; align-items: center; justify-content: center;
    color: var(--bp-text-dim); font-size: 12px; border-radius: 8px;
}
#ballpool-app { flex: 1; max-width: 860px; min-width: 320px; color: var(--bp-text); }

.screen { display: none; }
.screen.active { display: block; animation: bpFade 0.3s ease; }
@keyframes bpFade { from {opacity:0; transform:translateY(8px);} to {opacity:1; transform:translateY(0);} }

.bp-header { text-align: center; padding: 36px 0 24px; }
.bp-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.bp-ball-stack { position: relative; width: 90px; height: 60px; }
.bp-ball {
    position: absolute; width: 36px; height: 36px; border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6),
        inset -6px -8px 12px rgba(0,0,0,0.3),
        inset 4px 4px 10px rgba(255,255,255,0.3);
}
.bp-ball:nth-child(1) { left: 0; top: 0; animation: bpRoll 3s ease-in-out infinite; }
.bp-ball:nth-child(2) { left: 28px; top: 14px; animation: bpRoll 3s ease-in-out infinite 0.5s; }
.bp-ball:nth-child(3) { left: 54px; top: 4px; animation: bpRoll 3s ease-in-out infinite 1s; }
@keyframes bpRoll {
    0%,100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-4px) rotate(180deg); }
}
.bp-header h1 {
    font-family: 'Syne', sans-serif; font-size: 2.4rem; font-weight: 800;
    color: var(--bp-accent-light); letter-spacing: 4px; margin: 0;
    text-shadow: 0 0 24px var(--bp-glow);
}
.subtitle { color: var(--bp-text-dim); font-size: 1rem; margin-top: 8px; }

.card {
    background: var(--bp-surface); border-radius: 14px; padding: 20px;
    margin-bottom: 16px; border: 1px solid var(--bp-surface-light);
}
.card__title {
    font-family: 'Syne', sans-serif; font-size: 0.85rem;
    text-transform: uppercase; letter-spacing: 2px;
    color: var(--bp-accent-light); margin-bottom: 14px;
}
.difficulty-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.diff-btn {
    background: var(--bp-surface-light); border: 1.5px solid transparent;
    color: var(--bp-text); padding: 14px 8px; border-radius: 10px;
    cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    font-family: 'DM Sans', sans-serif; font-size: 0.85rem;
}
.diff-btn:hover { transform: translateY(-2px); border-color: var(--bp-accent); }
.diff-btn.selected {
    background: linear-gradient(135deg, var(--bp-accent-dark), var(--bp-accent));
    border-color: var(--bp-accent-light); box-shadow: 0 0 16px var(--bp-glow);
}
.diff-icon {
    font-family: 'JetBrains Mono', monospace; font-size: 0.9rem;
    font-weight: 700; color: var(--bp-accent-light); letter-spacing: 1.5px;
}
.diff-btn.selected .diff-icon { color: #fff; }
.diff-desc { font-size: 0.72rem; color: var(--bp-text-dim); }
.diff-btn.selected .diff-desc { color: rgba(255,255,255,0.85); }

.bp-rules { margin: 0; padding-left: 1.1rem; color: var(--bp-text-dim);
    font-size: 0.92rem; line-height: 1.6; }
.bp-rules li + li { margin-top: 6px; }

.btn {
    font-family: 'DM Sans', sans-serif; font-weight: 600; border-radius: 10px;
    border: none; cursor: pointer; padding: 12px 22px;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
    font-size: 0.95rem;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary {
    background: linear-gradient(135deg, var(--bp-accent), var(--bp-accent-light));
    color: #fff; box-shadow: 0 6px 18px rgba(124,58,237,0.4);
}
.btn--outline {
    background: transparent; border: 1.5px solid var(--bp-accent);
    color: var(--bp-accent-light);
}
.btn--outline:hover { background: rgba(124,58,237,0.12); }
.btn--ghost { background: transparent; color: var(--bp-text-dim); }
.btn--ghost:hover { color: var(--bp-accent-light); }
.btn--lg { padding: 16px 36px; font-size: 1.05rem; }
.btn--sm { padding: 8px 14px; font-size: 0.85rem; }

.menu-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 18px; }

#game-hud {
    display: grid; grid-template-columns: repeat(4,1fr); gap: 10px;
    background: var(--bp-surface); padding: 14px; border-radius: 12px;
    border: 1px solid var(--bp-surface-light); margin-bottom: 18px;
}
.hud__cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud__label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px;
    color: var(--bp-text-dim);
}
.hud__value {
    font-family: 'JetBrains Mono', monospace; font-size: 1.4rem;
    font-weight: 700; color: var(--bp-accent-light);
}

.bp-stage-area { display: flex; justify-content: center; padding: 8px 0; }
#bp-canvas {
    background: var(--bp-felt);
    border-radius: 14px; border: 8px solid #6B2C0F;
    box-shadow: 0 12px 36px rgba(0,0,0,0.5), inset 0 0 30px rgba(0,0,0,0.4);
    width: 100%; max-width: 780px; height: auto; cursor: crosshair;
    touch-action: none;
}
.bp-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.result-card, .lb-card {
    background: var(--bp-surface); border-radius: 16px; padding: 36px 28px;
    border: 1px solid var(--bp-surface-light); text-align: center;
    max-width: 480px; margin: 40px auto;
    box-shadow: 0 18px 36px rgba(0,0,0,0.4);
}
.result-card h2 {
    font-family: 'Syne', sans-serif; font-size: 2rem;
    color: var(--bp-accent-light); letter-spacing: 4px;
    margin: 0 0 12px; text-shadow: 0 0 24px var(--bp-glow);
}
.result-score {
    font-family: 'JetBrains Mono', monospace; font-size: 3rem;
    font-weight: 700; color: var(--bp-gold); margin: 8px 0;
}
.result-detail { color: var(--bp-text-dim); font-size: 0.95rem; margin-bottom: 18px; line-height: 1.6; }
#nickname {
    width: 100%; padding: 12px 14px; border-radius: 10px;
    background: var(--bp-bg); color: var(--bp-text);
    border: 1.5px solid var(--bp-surface-light);
    font-family: 'DM Sans', sans-serif; font-size: 0.95rem;
    margin-bottom: 12px; box-sizing: border-box;
}
#nickname:focus { outline: none; border-color: var(--bp-accent); }
.result-actions { display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }

.lb-card h2 {
    font-family: 'Syne', sans-serif; color: var(--bp-accent-light);
    letter-spacing: 4px; margin-bottom: 18px; text-shadow: 0 0 24px var(--bp-glow);
}
#leaderboard-list { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; counter-reset: lb; }
#leaderboard-list li {
    counter-increment: lb; display: flex; justify-content: space-between;
    padding: 10px 14px; background: var(--bp-bg); margin-bottom: 6px;
    border-radius: 8px; border: 1px solid var(--bp-surface-light);
    font-family: 'DM Sans', sans-serif;
}
#leaderboard-list li::before {
    content: counter(lb); color: var(--bp-accent-light);
    font-weight: 700; margin-right: 10px; min-width: 24px;
}
#leaderboard-list li:nth-child(1) { border-color: var(--bp-gold); }
#leaderboard-list li:nth-child(1)::before { color: var(--bp-gold); }
.lb-score { font-family: 'JetBrains Mono', monospace; color: var(--bp-accent-light); font-weight: 600; }

@media (max-width: 900px) {
    .bp-layout { flex-direction: column; padding: 12px; }
    .ad-slot { width: 100%; }
    .ad-placeholder--vertical { width: 100%; height: 90px; }
    .difficulty-grid { grid-template-columns: repeat(3,1fr); }
    .bp-header h1 { font-size: 1.8rem; letter-spacing: 2px; }
    #game-hud { grid-template-columns: repeat(2,1fr); }
}
