@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap');

:root {
    --bg-color: #0d1117;
    --card-bg: rgba(30, 36, 44, 0.7);
    --card-bg-hover: rgba(40, 48, 58, 0.8);
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --success: #2ea043;
    --danger: #f85149;
    --border: rgba(240, 246, 252, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background: var(--bg-color);
    background-image: radial-gradient(circle at 10% 20%, rgba(88, 166, 255, 0.1) 0%, transparent 50%),
                      radial-gradient(circle at 90% 80%, rgba(46, 160, 67, 0.05) 0%, transparent 50%);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.stats-container {
    position: absolute;
    top: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    z-index: 10;
}

.streak-container {
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid var(--accent);
    padding: 0;
    height: 40px;
    width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--accent);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(88, 166, 255, 0.2);
    transition: transform 0.2s, background 0.3s;
}

.lives-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0;
    height: 40px;
    width: 120px;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--danger);
    border-radius: 9999px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(248, 81, 73, 0.2);
    transition: transform 0.2s;
}

.heart {
    width: 20px;
    height: 20px;
    fill: var(--danger);
    filter: drop-shadow(0 0 2px rgba(248, 81, 73, 0.5));
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.heart.lost {
    fill: #3e3e3e;
    opacity: 0.3;
    filter: grayscale(1);
    transform: scale(0.85);
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 3rem;
    width: 90%;
    max-width: 520px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

#loading {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* ── Baseball Field SVG ── */
.field-svg {
    width: 200px;
    height: 160px;
    margin: 0 auto 1.5rem;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

/* Runner icon smooth transition */
#runner-icon {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Question Row (pitcher + ball + typewriter text) ── */
.question-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 1.5rem;
    min-height: 48px;
    padding: 0.5rem 0;
}

.text-and-ball {
    flex: 1;
    text-align: left;
    display: block;
}

.pitcher-icon {
    width: 22px;
    height: 26px;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

.ball-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
    margin-bottom: 0.2rem;
    transition: opacity 0.3s ease;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

.ball-icon.ball-visible {
    opacity: 1;
    animation: ballBounce 0.4s ease-in-out infinite alternate;
}

.ball-icon.ball-hidden {
    opacity: 0;
    width: 0;
    transform: scale(0);
}

@keyframes ballBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-2px); }
}

.question-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.5;
    display: inline;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@keyframes ballBounce {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-3px) rotate(15deg); }
}

/* ── Options Grid ── */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.option-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--border);
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 0.85rem 0.5rem;
    line-height: 1.3;
    min-height: 3.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.option-btn:hover:not(:disabled) {
    background: rgba(88, 166, 255, 0.2);
    border-color: var(--accent);
    box-shadow: 0 4px 15px rgba(88, 166, 255, 0.2);
}

.option-btn.correct {
    background: rgba(46, 160, 67, 0.2);
    border-color: var(--success);
}

.option-btn.incorrect {
    background: rgba(248, 81, 73, 0.2);
    border-color: var(--danger);
}

button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 1rem 1.75rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(88, 166, 255, 0.3);
}

button:hover:not(:disabled) {
    background: #3182ce;
    box-shadow: 0 6px 20px rgba(88, 166, 255, 0.4);
}

button:active:not(:disabled) {
    transform: scale(0.96);
}

button:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none;
}

#next-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 2px solid var(--border);
    margin-top: 1rem;
    box-shadow: none;
}

#next-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.feedback {
    padding: 1.25rem;
    border-radius: 12px;
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback.success {
    background: rgba(46, 160, 67, 0.15);
    color: var(--success);
    border: 1px solid rgba(46, 160, 67, 0.4);
}

.feedback.success strong {
    color: #3fb950;
}

.feedback.error {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.4);
}

.feedback.error strong {
    color: #ff7b72;
}

.hidden {
    display: none !important;
}

.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.5s ease;
}

.win-card, .lose-card {
    background: var(--card-bg);
    border: 2px solid var(--accent);
    padding: 3rem;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 0 50px rgba(88, 166, 255, 0.3);
    max-width: 450px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lose-card {
    border-color: var(--danger);
    box-shadow: 0 0 50px rgba(248, 81, 73, 0.3);
}

.strikeout-text {
    font-size: 3rem;
    color: var(--danger);
    text-shadow: 0 0 20px rgba(248, 81, 73, 0.5);
    margin-bottom: 0;
}

#lose-reset-btn {
    background: var(--danger);
    box-shadow: 0 4px 15px rgba(248, 81, 73, 0.3);
}

#lose-reset-btn:hover {
    background: #cf3d36;
    box-shadow: 0 6px 20px rgba(248, 81, 73, 0.4);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 2px solid var(--border) !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
}

.win-card h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.win-card p {
    font-size: 1.5rem;
    margin-bottom: 2rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@media (max-width: 560px) {
    .card {
        padding: 2rem 1.25rem;
        width: 95%;
    }
    
    .options-grid {
        grid-template-columns: 1fr;
    }

    .option-btn {
        font-size: 1rem;
        padding: 1rem;
    }
    
    .question-text {
        font-size: 0.9rem;
    }
    
    button {
        width: 100%;
    }

    .field-svg {
        width: 170px;
        height: 136px;
    }
}
