/* General End Screen Styling */
#endScreen {
    display: none; /* Initially hidden */
    flex-direction: column;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0s 0.5s;
    overflow-y: auto; 
}

#endScreen.visible {
    display: flex;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease;
}

#endScreen h1 {
    font-size: clamp(2em, 8vw, 3.5em);
    margin-bottom: 10px;
    color: #FFC107;
}

/* All Time Holder Banner */
#allTimeFartHolder {
    background-color: #ffc107;
    color: #000;
    padding: 10px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-size: 1.2em;
    font-weight: bold;
    flex-shrink: 0; 
}

/* --- NEW: Final Stats Container --- */
#finalStatsContainer {
    display: flex;
    justify-content: space-around;
    width: 100%;
    max-width: 500px;
    margin: 15px 0 25px 0; /* Space around the stats */
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: clamp(0.7em, 2.5vw, 0.8em);
    color: #ccc;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stat-value {
    font-size: clamp(1.5em, 6vw, 2em);
    font-weight: 600;
    color: #fff;
}

/* --- CHANGE: Compacted Results Table --- */
#resultsTable {
    width: 100%;
    max-width: 600px;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: clamp(0.75em, 2.5vw, 0.9em); /* Slightly smaller font */
    flex-shrink: 0;
}

#resultsTable th, #resultsTable td {
    padding: 8px 6px; /* Reduced padding */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#resultsTable th {
    text-align: left;
    color: #ccc;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9em;
}

#resultsTable tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05);
}

#resultsTable th:first-child,
#resultsTable td:first-child {
    width: 50px; /* Reduced width */
    text-align: center;
    padding: 6px 0;
}

/* --- CHANGE: Compacted Gas Bubble --- */
.gas-bubble-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 30px; /* Smaller size */
    height: 30px; /* Smaller size */
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--bubble-highlight), var(--bubble-color));
    box-shadow: 0 0 4px var(--bubble-color), 0 0 6px var(--bubble-highlight);
    position: relative;
    vertical-align: middle;
    color: black;
    font-weight: bold;
    font-size: 12px; /* Smaller font */
    font-family: 'Poppins', sans-serif;
}

.gas-bubble-icon sub {
    font-size: 0.7em;
    top: 0.4em;
    margin-left: -2px;
}

#endScreenButtons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

/* Restart Button */
#restartButton, #shareButton {
    position: static;
    border: none;
    color: white;
    padding: 14px 28px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: clamp(1.2em, 5vw, 1.6em);
    cursor: pointer;
    border-radius: 12px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#restartButton {
    background-color: #4CAF50;
}

#shareButton {
    background-color: #008CBA;
}

#restartButton:hover {
    background-color: #45a049;
    transform: scale(1.05); 
}

#shareButton:hover {
    background-color: #007B9E;
    transform: scale(1.05);
}

#shareStatus {
    margin-top: 15px;
    font-size: 0.9em;
    color: #FFC107;
    min-height: 1.2em;
}

/* Scrolling Scores at Top */
#scrollingScoresContainer {
    position: fixed; 
    top: 0;
    left: 0;
    width: 100%;
    background-color: #333;
    color: white;
    overflow: hidden;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    z-index: 10; 
}

#scrollingScores {
    display: inline-block;
    padding: 10px;
    animation: scroll-left 40s linear infinite;
    font-family: 'Poppins', sans-serif;
    font-weight: bold;
}

@keyframes scroll-left {
    from { transform: translateX(60vw); }
    to { transform: translateX(-100%); }
}

/* Responsive adjustments for short, wide screens */
@media (max-height: 500px) and (orientation: landscape) {
    #endScreen h1 {
        font-size: 1.8rem;
        margin-top: 40px; 
        margin-bottom: 8px;
    }

    #allTimeFartHolder {
        font-size: 1rem;
        padding: 8px 15px;
        margin-bottom: 15px;
    }

    #resultsTable th,
    #resultsTable td {
        font-size: 0.8rem;
        padding: 4px;
    }
    
    /* Adjust new stats for small screens */
    .stat-label { font-size: 0.6em; }
    .stat-value { font-size: 1.2em; }
    #finalStatsContainer { margin: 10px 0 15px 0; }
}
