/* ============================================================
   DartCore Pro v3 — Stylesheet
   ============================================================ */

:root {
    --bg-core: #09090b;
    --bg-panel: #18181b;
    --bg-input: #27272a;
    --bg-card: #1c1c1f;
    --border: #333;
    --neon-green: #00E676;
    --neon-pink: #FF2E93;
    --neon-green-dim: rgba(0, 230, 118, 0.15);
    --neon-pink-dim: rgba(255, 46, 147, 0.15);
    --text-main: #FFFFFF;
    --text-muted: #A1A1AA;
    --danger: #EF4444;
    --radius: 10px;
    --font-stack: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: 0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: var(--font-stack);
    background: var(--bg-core);
    color: var(--text-main);
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes floatUp {
    0%   { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60px) scale(1.6); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%  { transform: translateX(-6px); }
    40%  { transform: translateX(6px); }
    60%  { transform: translateX(-4px); }
    80%  { transform: translateX(4px); }
}

@keyframes popIn {
    0%   { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(0, 230, 118, 0.3); }
    50%      { box-shadow: 0 0 20px rgba(0, 230, 118, 0.6); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.floating-score {
    position: absolute;
    left: 50%;
    top: 35%;
    transform: translateX(-50%);
    font-size: 5rem;
    font-weight: 900;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    z-index: 999;
    text-shadow: 0 0 25px currentColor;
}

.floating-score.p1 { color: var(--neon-green); }
.floating-score.p2 { color: var(--neon-pink); }

.shake { animation: shake 0.35s ease; }

/* ============================================================
   LOBBY SCREEN
   ============================================================ */
#lobbyScreen {
    position: absolute;
    inset: 0;
    background: var(--bg-core);
    z-index: 100;
    display: flex;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#lobbyScreen.hiding {
    opacity: 0;
    transform: scale(0.96);
}

.lobby-inner {
    width: 100%;
    max-width: 480px;
    padding-bottom: 30px;
}

.logo-area {
    text-align: center;
    margin-bottom: 24px;
}

.logo-svg {
    width: 64px;
    height: 64px;
    margin-bottom: 8px;
}

h1 {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -1px;
}

h1 span { color: var(--neon-green); }
h1 small { font-size: 0.9rem; color: var(--text-muted); font-weight: 600; }

.setup-card {
    background: var(--bg-panel);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.label {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 700;
}

.input-row {
    display: flex;
    gap: 10px;
}

input[type="text"],
input[type="number"] {
    background: var(--bg-input);
    border: 1px solid #444;
    color: #fff;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-stack);
    outline: none;
    transition: border-color var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus {
    border-color: var(--neon-green);
}

input[type="text"] { flex: 1; width: 100%; }

.btn-group {
    display: flex;
    background: var(--bg-input);
    border-radius: 8px;
    padding: 3px;
    flex: 1;
}

.btn-opt {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 9px 6px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-stack);
}

.btn-opt.active {
    background: var(--neon-green);
    color: #000;
}

.btn-opt:hover:not(.active) {
    color: #fff;
}

/* Format row */
.format-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.format-count-input {
    width: 64px;
    text-align: center;
    flex-shrink: 0;
}

/* Bot settings */
.bot-settings {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.bot-level-row {
    margin-bottom: 8px;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--neon-green);
    margin-top: 4px;
}

.bot-preview {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.bot-preview strong {
    color: var(--neon-green);
}

/* Start button */
.btn-start {
    display: block;
    width: 100%;
    padding: 16px;
    margin-top: 8px;
    background: var(--neon-green);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-stack);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-start:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

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

/* ============================================================
   GAME SCREEN
   ============================================================ */
#gameScreen {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.game-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0 8px;
}

/* Top bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px;
    gap: 8px;
    flex-shrink: 0;
}

.top-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-stack);
    white-space: nowrap;
}

.top-btn:hover { color: #fff; border-color: #555; }

.match-info, .leg-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.leg-info { color: var(--neon-green); }

/* ============================================================
   GAME GRID — 4 COLUMNS
   ============================================================ */
.game-grid {
    display: grid;
    grid-template-columns: minmax(70px, 120px) 1fr 1fr minmax(70px, 120px);
    gap: 6px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* History columns */
.history-col {
    background: var(--bg-panel);
    border-radius: var(--radius);
    padding: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
}

.history-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    margin-bottom: 6px;
    text-align: center;
}

.history-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    scrollbar-width: none;
}

.history-list::-webkit-scrollbar { display: none; }

.history-item {
    text-align: center;
    padding: 4px 2px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--bg-input);
    animation: slideIn 0.2s ease;
}

.history-item.bust {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.history-item.ton-plus {
    color: var(--neon-green);
    background: var(--neon-green-dim);
}

.history-item.max {
    color: #FFD700;
    background: rgba(255, 215, 0, 0.12);
}

/* Score panels */
.score-panel {
    background: var(--bg-panel);
    border-radius: var(--radius);
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.score-panel.active-turn {
    border-color: var(--neon-green);
    animation: pulseGlow 2s ease infinite;
}

.p2-panel.active-turn {
    border-color: var(--neon-pink);
    animation: none;
    box-shadow: 0 0 12px rgba(255, 46, 147, 0.3);
}

.player-name {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.p1-accent { color: var(--neon-green); }
.p2-accent { color: var(--neon-pink); }

.sets-legs-display {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.big-score {
    font-size: 4rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -2px;
    transition: color 0.2s;
}

.p1-panel .big-score { color: var(--neon-green); }
.p2-panel .big-score { color: var(--neon-pink); }

.darts-indicator {
    height: 16px;
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.dart-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid #555;
    transition: background 0.2s, border-color 0.2s;
}

.dart-dot.used {
    background: var(--neon-green);
    border-color: var(--neon-green);
}

.p2-panel .dart-dot.used {
    background: var(--neon-pink);
    border-color: var(--neon-pink);
}

.stats-row {
    display: flex;
    gap: 6px;
    width: 100%;
    margin-top: 4px;
}

.stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: var(--bg-input);
    border-radius: 6px;
    padding: 4px 2px;
}

.stat-label {
    font-size: 0.55rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.3px;
}

.stat-val {
    font-size: 0.85rem;
    font-weight: 800;
}

/* ============================================================
   CHECKOUT BAR
   ============================================================ */
.checkout-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-panel);
    border-radius: var(--radius);
    margin: 4px 0;
    border: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 32px;
}

.checkout-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.checkout-suggestion {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--neon-green);
    letter-spacing: 0.5px;
}

/* ============================================================
   INPUT DISPLAY
   ============================================================ */
.input-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px;
    flex-shrink: 0;
}

#currentPlayerLabel {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.input-value {
    font-size: 2rem;
    font-weight: 900;
    min-width: 80px;
    text-align: center;
    color: var(--text-main);
    letter-spacing: 2px;
}

/* ============================================================
   NUMPAD
   ============================================================ */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 4px 0 12px;
    flex-shrink: 0;
    max-width: 360px;
    margin: 0 auto;
    width: 100%;
}

.num-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 1.3rem;
    font-weight: 700;
    padding: 14px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-stack);
    -webkit-tap-highlight-color: transparent;
}

.num-btn:hover { background: var(--bg-input); }
.num-btn:active { transform: scale(0.95); }

.del-btn {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
    font-size: 1rem;
}

.enter-btn {
    background: var(--neon-green-dim);
    color: var(--neon-green);
    border-color: rgba(0, 230, 118, 0.3);
    font-size: 1.5rem;
}

.enter-btn:hover { background: rgba(0, 230, 118, 0.25); }
.del-btn:hover { background: rgba(239, 68, 68, 0.25); }

/* ============================================================
   MODAL OVERLAYS
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 20px;
}

.modal-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    width: 100%;
    max-width: 380px;
    animation: popIn 0.25s ease;
}

.modal-card h2 {
    font-size: 1.4rem;
    margin-bottom: 8px;
}

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

.modal-btn-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-btn {
    background: var(--neon-green);
    color: #000;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-stack);
    min-width: 60px;
}

.modal-btn:hover { filter: brightness(1.1); }
.modal-btn:active { transform: scale(0.96); }

.modal-btn.secondary {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border);
}

/* Win card */
.win-card .win-icon {
    font-size: 3.5rem;
    margin-bottom: 8px;
}

.win-stats {
    margin: 16px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 0.8rem;
    text-align: left;
}

.win-stat-item {
    background: var(--bg-input);
    padding: 8px 10px;
    border-radius: 6px;
}

.win-stat-item .ws-label {
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
}

.win-stat-item .ws-val {
    font-weight: 800;
    font-size: 0.95rem;
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 640px) {
    .game-grid {
        grid-template-columns: 1fr 1fr;
    }

    .history-col {
        display: none;
    }

    .big-score {
        font-size: 3rem;
    }

    .numpad {
        max-width: 100%;
    }

    .num-btn {
        padding: 12px;
        font-size: 1.1rem;
    }

    .stats-row {
        gap: 4px;
    }

    .stat {
        padding: 3px 1px;
    }

    .stat-val {
        font-size: 0.75rem;
    }
}

@media (max-width: 380px) {
    .big-score {
        font-size: 2.5rem;
    }

    .input-value {
        font-size: 1.5rem;
    }

    .num-btn {
        padding: 10px;
        font-size: 1rem;
    }
}

/* Medium screens — show history as small strip */
@media (min-width: 641px) and (max-width: 900px) {
    .game-grid {
        grid-template-columns: 80px 1fr 1fr 80px;
    }

    .history-col {
        padding: 6px;
    }

    .history-item {
        font-size: 0.7rem;
        padding: 3px 1px;
    }
}

/* ============================================================
   MATCH WIN — Crazy Animation
   ============================================================ */
@keyframes matchWinPulse {
    0%   { transform: scale(1);   color: var(--neon-green); text-shadow: 0 0 20px var(--neon-green); }
    25%  { transform: scale(1.15); color: var(--neon-pink);  text-shadow: 0 0 40px var(--neon-pink), 0 0 80px var(--neon-pink); }
    50%  { transform: scale(0.95); color: #FFD700;           text-shadow: 0 0 30px #FFD700, 0 0 60px #FFD700; }
    75%  { transform: scale(1.1);  color: var(--neon-green); text-shadow: 0 0 50px var(--neon-green), 0 0 100px var(--neon-green); }
    100% { transform: scale(1);   color: var(--neon-pink);  text-shadow: 0 0 20px var(--neon-pink); }
}

@keyframes matchWinBG {
    0%   { background: rgba(0, 0, 0, 0.85); }
    20%  { background: rgba(0, 230, 118, 0.15); }
    40%  { background: rgba(255, 46, 147, 0.15); }
    60%  { background: rgba(255, 215, 0, 0.12); }
    80%  { background: rgba(0, 230, 118, 0.12); }
    100% { background: rgba(0, 0, 0, 0.85); }
}

@keyframes confettiFall {
    0%   { background-position: 0% 0%; }
    100% { background-position: 0% 100%; }
}

@keyframes matchWinCardGlow {
    0%, 100% { border-color: var(--neon-green); box-shadow: 0 0 20px rgba(0, 230, 118, 0.4); }
    33%      { border-color: var(--neon-pink);  box-shadow: 0 0 30px rgba(255, 46, 147, 0.5); }
    66%      { border-color: #FFD700;           box-shadow: 0 0 30px rgba(255, 215, 0, 0.5); }
}

.match-win-crazy {
    animation: matchWinBG 1.5s ease infinite;
    background-image:
        radial-gradient(circle at 10% 20%, var(--neon-green) 1px, transparent 1px),
        radial-gradient(circle at 30% 60%, var(--neon-pink) 1.5px, transparent 1.5px),
        radial-gradient(circle at 50% 10%, #FFD700 1px, transparent 1px),
        radial-gradient(circle at 70% 40%, var(--neon-green) 1.5px, transparent 1.5px),
        radial-gradient(circle at 90% 80%, var(--neon-pink) 1px, transparent 1px),
        radial-gradient(circle at 20% 90%, #FFD700 1.5px, transparent 1.5px),
        radial-gradient(circle at 80% 15%, var(--neon-green) 1px, transparent 1px),
        radial-gradient(circle at 40% 75%, var(--neon-pink) 1px, transparent 1px),
        radial-gradient(circle at 60% 50%, #FFD700 1.5px, transparent 1.5px),
        radial-gradient(circle at 15% 45%, var(--neon-green) 1px, transparent 1px),
        radial-gradient(circle at 85% 55%, var(--neon-pink) 1.5px, transparent 1.5px),
        radial-gradient(circle at 45% 30%, #FFD700 1px, transparent 1px);
    background-size: 100% 300%;
    animation: matchWinBG 1.5s ease infinite, confettiFall 3s linear infinite;
}

.match-win-crazy .modal-card {
    animation: matchWinCardGlow 1.2s ease infinite;
    border-width: 2px;
    border-style: solid;
}

.match-win-crazy .modal-card h2 {
    animation: matchWinPulse 0.8s ease infinite;
    font-size: 2rem;
}

.match-win-crazy .win-icon {
    animation: matchWinPulse 0.6s ease infinite;
    font-size: 5rem;
}
