:root {
    --field-bg: #2d5a27;
    --strike-zone-border: rgba(255, 255, 255, 0.3);
    --ball-color: #fff;
    --bat-color: #8b4513;
    --base-color: rgba(255, 255, 255, 0.2);
    --runner-color: #f1c40f;
    --bg-dark: #0a0b0d;
}

body {
    margin: 0; padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; color: #fff;
}

#game-container {
    background-color: #1a1c20;
    padding: 1rem; border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    width: 100%; max-width: 480px;
    border: 1px solid #333; position: relative;
}

/* Scoreboard */
#scoreboard-container {
    background: #000; border-radius: 4px;
    padding: 2px; margin-bottom: 0.8rem;
    box-shadow: inset 0 0 10px rgba(255,255,255,0.1);
}

#line-score {
    width: 100%; border-collapse: collapse;
    font-size: 0.7rem; font-weight: bold;
}

#line-score th, #line-score td {
    padding: 4px 2px; border: 1px solid #222; text-align: center;
}

#line-score th { color: #888; background: #111; }
.team-name { text-align: left !important; padding-left: 6px !important; color: #aaa; width: 60px; }
.total-col { background: #222; color: #f1c40f !important; }
.total-val { background: #111; color: #f1c40f; }

/* Broadcast Bar */
#broadcast-bar {
    display: flex; justify-content: space-between; align-items: center;
    background: #2c3e50; padding: 0.5rem 1rem;
    border-radius: 4px; margin-bottom: 0.8rem;
    border-bottom: 3px solid #e67e22;
}

#inning-box { font-size: 1rem; font-weight: 900; letter-spacing: 1px; }
#count-box { display: flex; gap: 1rem; font-size: 0.9rem; font-weight: bold; }

#outs-dots { display: inline-flex; gap: 4px; vertical-align: middle; }
.out-dot { width: 10px; height: 10px; border-radius: 50%; background: #444; border: 1px solid #666; }
.out-dot.filled { background: #e74c3c; box-shadow: 0 0 8px #e74c3c; border-color: #ff7675; }

/* Batter Card */
#batter-card {
    background: linear-gradient(to right, #1e3c72, #2a5298);
    padding: 0.6rem; border-radius: 4px; margin-bottom: 0.8rem;
    text-align: left; border-left: 4px solid #f1c40f;
}

.batter-header { font-size: 0.6rem; opacity: 0.7; letter-spacing: 1px; }
#batter-name { font-size: 1.3rem; font-weight: 900; margin: 2px 0; }
#batter-stats { font-size: 0.8rem; font-weight: bold; color: #f1c40f; line-height: 1.2; }

/* Field */
#field {
    width: 100%; height: 280px;
    background-color: var(--field-bg);
    position: relative; overflow: hidden;
    border-radius: 6px; border: 4px solid #1a3a16;
    margin-bottom: 1rem;
}

#diamond { position: absolute; top: 20px; right: 20px; width: 50px; height: 50px; transform: rotate(45deg); }
.base { position: absolute; width: 10px; height: 10px; background: var(--base-color); border: 1px solid rgba(255,255,255,0.2); }
#base-1 { bottom: -5px; right: -5px; }
#base-2 { top: -5px; right: -5px; }
#base-3 { top: -5px; left: -5px; }
.base.occupied { background: var(--runner-color); box-shadow: 0 0 12px var(--runner-color); border-color: #fff; }

#strike-zone {
    width: 80px; height: 80px;
    border: 2px dashed var(--strike-zone-border);
    position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%);
}

#ball {
    width: 18px; height: 18px; background: #fff; border-radius: 50%;
    position: absolute; top: -30px; left: 50%; transform: translateX(-50%);
    box-shadow: 0 0 10px rgba(255,255,255,0.5); z-index: 5;
}

#bat {
    width: 60px; height: 14px;
    background: linear-gradient(to right, #8b4513, #5d2e0d);
    border-radius: 4px 8px 8px 4px;
    position: absolute; bottom: 10px; left: 50%;
    transform: translateX(-50%);
    transition: transform 0.1s cubic-bezier(0.15, 0.8, 0.2, 1);
    z-index: 10;
}

#bat.swinging {
    transform: translateX(-50%) translateY(-110px) rotate(-15deg);
}

/* Overlays */
#result-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); display: flex; justify-content: center; align-items: center;
    z-index: 20; pointer-events: none;
}

#result-text {
    font-size: 2.5rem; font-weight: 900; color: #fff; text-align: center;
    text-shadow: 0 0 20px rgba(0,0,0,1), 0 0 40px #f1c40f;
    animation: result-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes result-pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

#notification-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 100;
    display: flex; justify-content: center; align-items: center;
}

#notification-content {
    background: #fff; color: #333; padding: 2rem; border-radius: 12px; text-align: center;
    max-width: 80%; box-shadow: 0 0 30px #f1c40f;
}

#notification-content h2 { color: #e67e22; margin-top: 0; }
#notification-content button {
    margin-top: 1.5rem; padding: 1rem 2rem; background: #27ae60; color: #fff;
    border: none; border-radius: 6px; font-weight: bold; cursor: pointer;
}

#status-message { font-size: 1rem; font-weight: bold; margin-top: 0.5rem; color: #aaa; min-height: 1.2rem; }

#swing-btn {
    width: 100%; padding: 1.2rem; font-size: 1.5rem; font-weight: 900;
    background: #e67e22; color: #fff; border: none; border-radius: 8px;
    cursor: pointer; box-shadow: 0 4px 0 #d35400; transition: transform 0.05s;
}

#swing-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #d35400; }
#swing-btn:disabled { background: #444; box-shadow: 0 4px 0 #222; opacity: 0.5; }

#restart-btn {
    margin-top: 1rem; background: none; border: 1px solid #555; color: #888;
    padding: 0.4rem 1rem; border-radius: 4px; cursor: pointer; font-size: 0.7rem;
    transition: all 0.2s;
}
#restart-btn:hover { border-color: #e74c3c; color: #e74c3c; }

.hidden { display: none !important; }

@keyframes ball-pitch {
    0% { top: -30px; opacity: 0; transform: translateX(calc(-50% + var(--start-offset))) scale(0.4); }
    10% { opacity: 1; }
    100% { top: 360px; transform: translateX(calc(-50% + var(--end-offset))) scale(1.6); }
}
.pitching { animation: ball-pitch var(--duration) linear forwards; }
