@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;700&display=swap');

* {
    box-sizing: border-box;
}

:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --accent: #e10600;
    --row-height: 50px;
    --gap: 10px;
}

body {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    position: fixed;
    height: 100%;
    width: 100%;
    overflow: hidden;
    /* Prevent scrolling during animation if possible */
}

.app-container {
    width: 100%;
    max-width: 800px;
    padding: 2px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-container.full-width {
    max-width: 100%;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

h1 {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.season-selector select {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid #333;
    /* Subtle border */
    font-family: inherit;
    font-size: 1rem;
    padding: 2px 5px;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.season-selector select:hover {
    border-color: #555;
}

.season-selector select:focus {
    outline: none;
    border-color: var(--accent);
}

h2 {
    font-size: 1.6rem;
    margin: 5px 0;
    font-weight: 700;
}

h3 {
    font-size: 1rem;
    margin: 5px 0 10px 0;
    font-weight: 300;
    color: var(--text-secondary);
}

.session-badge {
    display: inline-block;
    padding: 2px 8px;
    background-color: var(--accent);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

main {
    flex: 1;
    position: relative;
    /* Essential for absolute rows */
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    /* Crucial for flex box scrolling */
}

/* Scrollbar */
main::-webkit-scrollbar {
    width: 6px;
}

main::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 3px;
}

.driver-row {
    position: absolute;
    left: 0;
    height: 40px;
    width: 100%;
    display: flex;
    align-items: center;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.label-info {
    width: 220px;
    /* [FIX] Even more space for names */
    display: flex;
    align-items: center;
    flex-shrink: 0;
    z-index: 2;
    padding-right: 5px;
    /* Spacing before bar */
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
}

/* Navigation */
.main-nav {
    display: flex;
    gap: 20px;
    margin-top: 10px;
    justify-content: center;
}

.main-nav a {
    color: #888;
    text-decoration: none;
    font-size: 1.1em;
    padding-bottom: 5px;
    border-bottom: 2px solid transparent;
    transition: color 0.3s, border-color 0.3s;
}

.main-nav a:hover,
.main-nav a.active {
    color: white;
    border-bottom-color: #ff1801;
}

/* Rankings Chart Layout */
#rankings-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Hide outer scroll */
    padding: 0;
    background-color: #000;
}

.chart-wrapper {
    flex: 1;
    overflow: auto;
    /* Enable both scroll directions */
    background-color: #111;
    border-radius: 0;
    padding: 0;
}

/* Main Layout */
.container {
    max-width: 1400px;
    /* [FIX] Widen container */
    width: 100%;
    margin: 0 auto;
    padding: 10px 5px;
    /* [FIX] Minimized padding for mobile */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.chart-scroll-area {
    /* Height and Width set dynamically by JS */
    min-width: 100%;
    min-height: 100%;
}

.rank {
    width: 30px;
    text-align: right;
    font-weight: 700;
    margin-right: 10px;
    color: var(--text-secondary);
}

.name {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    text-align: right;
    /* [FIX] Right align */
}

.driver-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    justify-content: center;
    flex: 1;
    /* Take remaining space in label-info */
    align-items: flex-end;
    /* [FIX] Right align flex items */
}

.team-name {
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    font-weight: 400;
    margin-top: 2px;
    text-align: right;
    /* [FIX] Right align */
}

.bar-container {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    position: relative;
    margin-left: 5px;
}

.bar {
    height: 24px;
    background-color: #555;
    border-radius: 0 4px 4px 0;
    transition: width 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    position: relative;
    display: flex;
    align-items: center;
    min-width: 2px;
}

.bar-points {
    position: absolute;
    right: -40px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    width: 35px;
    transition: right 0.3s, color 0.3s;
}

.bar-points.inside {
    right: 5px;
    color: #fff;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
    text-align: right;
}

/* Team Colors */
.bar[data-team="Red Bull Racing"] {
    background-color: #3671C6;
}

.bar[data-team="Ferrari"] {
    background-color: #F91536;
}

.bar[data-team="Mercedes"] {
    background-color: #6CD3BF;
}

.bar[data-team="McLaren"] {
    background-color: #F58020;
}

.bar[data-team="Aston Martin"] {
    background-color: #358C75;
}

.bar[data-team="Alpine"] {
    background-color: #2293D1;
}

.bar[data-team="Williams"] {
    background-color: #37BEDD;
}

.bar[data-team="Haas F1 Team"] {
    background-color: #B6BABD;
}

.bar[data-team="Kick Sauber"] {
    background-color: #52E252;
}

.bar[data-team="RB"] {
    background-color: #6692FF;
}

footer {
    margin-top: 15px;
    flex-shrink: 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.progress-container {
    height: 6px;
    background-color: #333;
    margin-bottom: 0;
    border-radius: 3px;
}

.progress-bar {
    height: 100%;
    background-color: var(--text-primary);
    width: 0%;
    transition: width 0.2s;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

button {
    background: #333;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

button:hover:not(:disabled) {
    background: #444;
}

button:disabled {
    opacity: 0.3;
    cursor: default;
}

.step-indicator {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    font-size: 0.9rem;
}