:root {
    /* Color Palette */
    --primary: #4f46e5; /* Indigo 600 */
    --primary-hover: #4338ca; /* Indigo 700 */
    --background: #111e45; /* Slate 900 */
    --surface: #1e293b; /* Slate 800 */
    --text-main: #f8fafc; /* Slate 50 */
    --text-muted: #acadbd; /* Slate 400 */
    --accent: #ec4899; /* Pink 500 */
    --nav-bg: #0d1837;

    /* Spacing & Layout */
    --radius: 12px;
    --transition: 0.2s ease-in-out;
    --nav-height: 50px;
    --accent-red: #e72128;
}

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

body {
    font-family: "Bebas Neue", sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    padding-top: var(--nav-height);
    letter-spacing: 0.5px;
}

/* Top Navigation */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background-color: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 2000;
}

/* Branding */
.presented-by {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 50;
    pointer-events: none;
}

.presented-text {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
    margin-right: 0;
    letter-spacing: 1px;
    line-height: 1;
}

.brand-logo {
    width: 100px;
    height: auto;
}

/* Identity chip — a driver name plate, top-left opposite the "Presented by"
   logo. Shown only on the Trivia tab once the saved identity is loaded. */
.trivia-identity {
    position: absolute;
    top: 12px;
    left: 12px;
    display: none;
    align-items: center;
    gap: 8px;
    background: #0d1837;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-left: 3px solid #e72128;
    border-radius: 50px;
    padding: 4px 14px 4px 5px;
    z-index: 50;
    pointer-events: none;
    max-width: 55%;
}

#main-app.trivia-active .trivia-identity.show {
    display: flex;
}

/* Hidden on the board (its title + "Your Place" row would crowd it). */
#main-app.trivia-active.trivia-board .trivia-identity.show {
    display: none;
}

@media (prefers-reduced-motion: no-preference) {
    #main-app.trivia-active .trivia-identity.show {
        animation: fadeIn 0.3s ease-in-out;
    }
}

.trivia-identity-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.trivia-identity-name {
    font-family: "Bebas Neue", sans-serif;
    font-size: 14px;
    letter-spacing: 0.5px;
    color: #ffffff;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-content {
    padding: 8px;
    padding-top: 8px;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    min-height: calc(100vh - var(--nav-height));
}

h1,
h2,
h3,
.card-title,
.title {
    font-family: "Bebas Neue", sans-serif;
}

.nav-tab {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    cursor: pointer;
    transition: opacity var(--transition);
    position: relative;
    opacity: 0.5;
}

.nav-tab:hover {
    opacity: 0.8;
}

.nav-tab.active {
    opacity: 1;
}

.nav-tab svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.nav-tab svg path {
    fill: white;
}

.nav-tab.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 50%);
    width: 125.11px;
    max-width: 100%;
    height: 6.05px;
    background-color: var(--accent-red);
    border-radius: 100px;
}

/* Onboarding Pages */
.full-screen-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background);
    color: var(--text-main);
    z-index: 2000;
    display: none;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 2rem;
    padding-top: calc(50vh - 120px);
    text-align: center;
}

.full-screen-page.active {
    display: flex;
}

/* Centered Content Container */
.centered-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 400px;
}

.btn-large {
    width: 190px !important; /* Force width override */
    height: 48px;
    font-size: 1rem;
    padding: 0;
    letter-spacing: 0.5px;
    font-family: "Bebas Neue", sans-serif;
    background-color: #e72128 !important;
    border: 1px solid #ffffff !important;
    border-radius: 50px !important;
    color: white;
    text-transform: uppercase;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    max-width: none;
}

.btn-large:hover {
    background-color: #d61c23;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);
}

/* Spinner */
.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Generator Loading and Result alignment */
#generator-loading,
#generator-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Casino Reel Avatar Spinner */
.casino-container {
    width: 100vw;
    height: 120px;
    overflow: hidden;
    position: relative;
    margin: 0 auto 1.5rem auto;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
}

.casino-reel {
    display: flex;
    align-items: center;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    transition: left 2s cubic-bezier(0.1, 0, 0.1, 1);
    height: 100%;
}

.casino-reel .avatar-item {
    flex: 0 0 120px;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 10px;
    background: #e72128;
    border-radius: 50%;
    position: relative;
}

.casino-reel .avatar-item img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    image-rendering: auto;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.generating-text {
    font-size: 24px;
    margin-bottom: 0;
    color: white;
    font-family: "Bebas Neue", sans-serif;
    letter-spacing: 1px;
}

.result-name {
    font-size: 3.5rem;
    font-weight: 700;
    color: #e72128 !important; /* Red */
    margin-top: 1rem;
    font-family: "Bebas Neue", sans-serif; /* Correct Font */
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    line-height: 1;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.result-avatar {
    width: 120px;
    height: 120px;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
}

/* App Content */
.app-content {
    padding: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.page-section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.page-section.active {
    display: block;
}

/* Chat tab: let the WidgetBot embed fill the panel below the nav + Chat header.
   Mirrors the data tab's fill pattern (100vh - nav - presented-by bar). */
#chat.page-section.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--nav-height) - 100px);
}

.chat-embed {
    flex: 1 1 auto;
    min-height: 0;
}

.chat-embed widgetbot,
.chat-embed iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typography */
h1,
h2,
h3 {
    font-family: "Outfit", sans-serif;
    color: var(--text-main);
}

.title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-muted);
}

.header {
    margin-bottom: 2rem;
}

.header-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    margin-top: -8px;
    padding-top: 0;
    height: 44px;
    position: relative;
}

.header-inline .title {
    margin-bottom: 0;
    line-height: 1;
}

.dropdown-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
    z-index: 1001;
}

.dropdown-title {
    margin-bottom: 0;
    font-size: 1.5rem;
    line-height: 1;
}

.chevron-icon {
    transition: transform 0.3s ease;
}

.dropdown-container.active .chevron-icon {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background-color: #1a2a4a;
    border-radius: 8px;
    min-width: 160px;
    display: none;
    flex-direction: column;
    z-index: 1002;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    padding: 8px;
}

.dropdown-menu.active {
    display: flex;
}

.dropdown-item {
    font-family: "Bebas Neue", sans-serif;
    font-size: 16px;
    padding: 4px 8px 4px 20px;
    color: #8a9bb8;
    cursor: pointer;
    transition: color 0.2s ease;
    letter-spacing: 0.5px;
    position: relative;
}

.dropdown-item:hover {
    color: #ffffff;
}

.dropdown-item.active {
    color: #ffffff;
    font-weight: 500;
}

.dropdown-item.active::before {
    content: "✓";
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #ffffff;
}

/* Data Loading State */
.data-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100vh - var(--nav-height) - 100px);
    gap: 16px;
}

.data-loading-state svg {
    animation: pulse 1.5s ease-in-out infinite;
}

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

.loading-text {
    font-family: "Bebas Neue", sans-serif;
    font-size: 24px;
    color: #ffffff;
    letter-spacing: 0.5px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    outline: none;
    width: 100%;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

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

/* Message Box */
.message-box {
    background-color: rgba(79, 70, 229, 0.1);
    border: 1px solid rgba(79, 70, 229, 0.2);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
    color: #c7d2fe;
}

.hidden {
    display: none !important;
}

.mb-2 {
    margin-bottom: 0.5rem;
}
.mt-4 {
    margin-top: 2rem;
}
.mb-4 {
    margin-bottom: 2rem;
}

/* Welcome Screen Specifics */
.moto-logo {
    width: 200px;
    height: auto;
    margin-bottom: 3rem;
}

.welcome-branding {
    position: absolute;
    bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.8;
}

.welcome-main {
    margin-bottom: 80px;
}

.presented-text-stacked {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.brand-logo-stacked {
    width: 140px;
    height: auto;
}

/* Welcome Screen Positioning - REFACTORED TO SAFE FLEXBOX */
#onboarding-welcome {
    display: none; /* Inherits display:none from full-screen-page, but reinforcing it here isn't bad if not active. */
    /* When active, full-screen-page active makes it flex. */
    /* We need to override flex properties for specific alignment */
}

#onboarding-welcome.active {
    display: flex;
    justify-content: flex-start; /* Align from top, not center */
    padding-top: 0;
}

.moto-logo-welcome {
    width: 200px;
    height: auto;
    margin-top: 25vh; /* Push down 25% */
}

.btn-centered {
    margin-top: 10vh; /* Adjust spacing between logo and button to center it roughly */
    /* To be precise 50% from top:
       Logo Top (25%) + Logo Height -> Button
       We can approximate, or use calc().
       Let's use a cleaner safe layout.
    */
}

/* Landscape Warning */
#landscape-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background);
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

@media screen and (orientation: landscape) and (max-height: 600px) {
    #landscape-warning {
        display: flex;
    }
}

.onboarding-text {
    font-family: "Bebas Neue", sans-serif;
    letter-spacing: 1px;
    font-size: 24px;
    color: #ffffff !important; /* White */
}

/* Stream Ended Page */
#stream-ended {
    justify-content: flex-start;
    padding-top: 12vh;
}

#stream-ended .moto-logo {
    margin-bottom: 8vh;
}

.ended-text {
    text-align: center;
    margin-bottom: auto;
}

.ended-subtitle {
    font-family: "Bebas Neue", sans-serif;
    font-size: 24px;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.ended-title {
    font-family: "Bebas Neue", sans-serif;
    font-size: 36px;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 1px;
}

.rating-section {
    text-align: center;
    margin-bottom: 20vh;
}

.rating-label {
    font-family: "Bebas Neue", sans-serif;
    font-size: 18px;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.star-rating {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.star {
    font-size: 40px;
    cursor: pointer;
    color: transparent;
    -webkit-text-stroke: 2px #8a9bb8;
    transition: color 0.15s ease, -webkit-text-stroke 0.15s ease;
}

.star.active,
.star.hover {
    color: #ffbf00;
    -webkit-text-stroke: 0;
}

.star-rating.locked .star {
    cursor: default;
}

/* Race Results Styling */
.race-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 2rem;
    margin-left: -16px;
    margin-right: -16px;
}

.result-tile {
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: rgba(187, 187, 187, 0.1);
    border-radius: 8px;
    padding: 0 8px;
    height: 36px;
    width: 100%;
}

.position-number {
    font-family: "Bebas Neue", sans-serif;
    font-size: 22px;
    font-weight: bold;
    color: #ffffff;
    min-width: 20px;
    text-align: center;
}

.position-number.gold {
    color: #ffd700;
}

.position-number.silver {
    color: #c0c0c0;
}

.position-number.bronze {
    color: #cd7f32;
}

.driver-image {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.driver-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.driver-name {
    font-family: "Bebas Neue", sans-serif;
    font-size: 22px;
    letter-spacing: 0.5px;
    color: #ffffff;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.driver-time {
    font-family: "Bebas Neue", sans-serif;
    font-size: 18px;
    color: #ffffff;
    white-space: nowrap;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Results Card Expandable */
.results-card {
    background-color: rgba(187, 187, 187, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.results-card-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    height: 36px;
    width: 100%;
    cursor: pointer;
}

.results-chevron {
    flex-shrink: 0;
    margin-left: 4px;
    transition: transform 0.3s ease;
    transform: rotate(-90deg);
}

.results-card.active .results-chevron {
    transform: rotate(0deg);
}

.results-card-body {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    padding: 12px 16px 16px;
}

.results-card.active .results-card-body {
    display: grid;
}

.results-stat-label {
    font-family: "Bebas Neue", sans-serif;
    font-size: 14px;
    color: #8a9bb8;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.results-stat-value {
    font-family: "Bebas Neue", sans-serif;
    font-size: 22px;
    color: #ffffff;
    letter-spacing: 0.5px;
    font-weight: 700;
    line-height: 1.2;
}

/* Standings Styling */
.standings-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 2rem;
    margin-left: -16px;
    margin-right: -16px;
}

.standings-card {
    background-color: rgba(187, 187, 187, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.standings-card-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    height: 36px;
    width: 100%;
    cursor: pointer;
}

.driver-points {
    font-family: "Bebas Neue", sans-serif;
    font-size: 18px;
    color: #ffffff;
    white-space: nowrap;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.standings-chevron {
    flex-shrink: 0;
    margin-left: 4px;
    transition: transform 0.3s ease;
    transform: rotate(-90deg);
}

.standings-card.active .standings-chevron {
    transform: rotate(0deg);
}

.standings-card-body {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    padding: 12px 16px 16px;
}

.standings-card.active .standings-card-body {
    display: grid;
}

.standings-stat-label {
    font-family: "Bebas Neue", sans-serif;
    font-size: 14px;
    color: #8a9bb8;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.standings-stat-value {
    font-family: "Bebas Neue", sans-serif;
    font-size: 22px;
    color: #ffffff;
    letter-spacing: 0.5px;
    font-weight: 700;
}

/* Schedule Styling */
.schedule-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 2rem;
    margin-left: -16px;
    margin-right: -16px;
}

.schedule-card {
    background-color: rgba(187, 187, 187, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.schedule-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.schedule-card-header:hover {
    background-color: rgba(187, 187, 187, 0.05);
}

.schedule-info {
    flex: 1;
    min-width: 0;
}

.schedule-event {
    font-family: "Bebas Neue", sans-serif;
    font-size: 22px;
    color: #ffffff;
    letter-spacing: 0.5px;
    font-weight: 700;
    line-height: 1;
}

.schedule-details {
    font-family: "Bebas Neue", sans-serif;
    font-size: 16px;
    color: #8a9bb8;
    letter-spacing: 0.5px;
    line-height: 1;
    margin-top: -1px;
}

.schedule-chevron {
    flex-shrink: 0;
    margin-left: 12px;
    transition: transform 0.3s ease;
    transform: rotate(-90deg);
}

.schedule-card.active .schedule-chevron {
    transform: rotate(0deg);
}

.schedule-card-body {
    display: none;
    padding: 0 16px 16px;
}

.schedule-card.active .schedule-card-body {
    display: block;
}

.schedule-day {
    margin-top: 8px;
}

.schedule-day:first-child {
    margin-top: 8px;
}

.schedule-day-title {
    font-family: "Bebas Neue", sans-serif;
    font-size: 18px;
    color: #8a9bb8;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.schedule-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 1px 0;
}

.schedule-time {
    font-family: "Bebas Neue", sans-serif;
    font-size: 16px;
    color: #8a9bb8;
    letter-spacing: 0.5px;
    min-width: 90px;
    flex-shrink: 0;
}

.schedule-race {
    font-family: "Bebas Neue", sans-serif;
    font-size: 18px;
    color: #ffffff;
    letter-spacing: 0.5px;
    font-weight: 700;
}

/* Trivia Page Styles */
#trivia {
    position: relative;
}

.trivia-state {
    display: none;
    width: 100%;
    min-height: calc(100vh - var(--nav-height) - 100px);
}

.trivia-state.active {
    display: block;
}

/* Trivia Starting Soon */
.trivia-starting-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - var(--nav-height));
    position: relative;
}

.trivia-starting-text {
    font-family: "Bebas Neue", sans-serif;
    font-size: 30px;
    color: #ffffff;
    letter-spacing: 1px;
    text-align: center;
}

.trivia-starting-graphic {
    position: fixed;
    bottom: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    right: 0;
    line-height: 0;
    display: none;
    z-index: 1;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    pointer-events: none;
}

#main-app.trivia-starting .trivia-starting-graphic {
    display: block;
}

.trivia-starting-graphic svg {
    display: block;
    margin: 0;
    padding: 0;
    vertical-align: bottom;
}

.trivia-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(8px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background-color: #111e45;
    overflow: hidden;
    z-index: 1001;
    display: none;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.trivia-progress-fill {
    height: 8px;
    width: 0%;
    background: linear-gradient(90deg, #324974 0%, #e72128 100%);
}

/* Countdown bar shows only during a live quiz question, not polls/idle/board. */
#main-app.quiz-progress .trivia-progress-bar {
    display: block;
}

.trivia-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: calc(100vh - var(--nav-height) - 100px);
    padding: 2rem;
}

/* Trivia Question State */
#trivia-question {
    display: none;
    flex-direction: column;
    height: calc(100vh - var(--nav-height));
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

#trivia-question.active {
    display: flex;
}

.trivia-question-text {
    font-family: "Bebas Neue", sans-serif;
    font-size: 26px;
    color: #ffffff;
    text-align: center;
    line-height: 1.3;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 33.33%;
    padding: 0 1rem;
    margin: 0;
}

/* Running score badge — a lap counter by the question. */
.trivia-score {
    display: none;
    align-self: center;
    font-family: "Bebas Neue", sans-serif;
    font-size: 16px;
    letter-spacing: 1px;
    color: #ffffff;
    background: #0d1837;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    padding: 3px 16px;
    margin-bottom: 8px;
}

.trivia-score.show {
    display: inline-block;
}

@keyframes scorePop {
    0% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.15);
        background: #e72128;
    }
    100% {
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .trivia-score.pop {
        animation: scorePop 0.4s ease;
    }
}

.trivia-answers {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    padding: 0;
}

.trivia-answer {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #111e45;
    border: 1px solid #ffffff;
    border-radius: 50px;
    padding: 0;
    height: 48px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: center;
    font-family: "Bebas Neue", sans-serif;
    font-size: 1rem;
    color: white;
    text-transform: uppercase;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.trivia-answer:hover {
    background-color: rgba(231, 33, 40, 0.3);
}

.trivia-answer:active {
    transform: translateY(-2px);
}

.trivia-answer.selected {
    background-color: #e72128;
    border-color: #ffffff;
}

.trivia-answer.correct {
    background-color: #22c55e;
    border-color: #ffffff;
}

.trivia-answer.incorrect {
    background-color: #ef4444;
    border-color: #ffffff;
}

/* Live Poll answers — proportional fill bar + percentage (no right/wrong) */
.trivia-answer-poll {
    position: relative;
    justify-content: space-between;
    padding: 0 18px;
    overflow: hidden;
}
.trivia-answer-poll .trivia-answer-label,
.trivia-answer-poll .trivia-pct {
    position: relative;
    z-index: 1;
}
.trivia-answer-poll .trivia-pct {
    font-family: "Outfit", sans-serif;
    font-size: 0.95rem;
    opacity: 0.9;
}
.trivia-answer-poll .trivia-pct-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background-color: rgba(231, 33, 40, 0.35);
    transition: width 0.4s ease;
    z-index: 0;
}
.trivia-answer-poll.selected {
    background-color: #111e45;
    border-color: #e72128;
}
.trivia-answer-poll.selected .trivia-pct-bar {
    background-color: rgba(231, 33, 40, 0.6);
}

/* Neutral until the user votes: hide the % and keep every bar at zero so the
   live tally never biases the vote. The .voted class (set on first tap) reveals
   them and lets the bars sweep in. */
.trivia-answers:not(.voted) .trivia-answer-poll .trivia-pct {
    opacity: 0;
}
.trivia-answers.voted .trivia-answer-poll .trivia-pct {
    opacity: 0.9;
    transition: opacity 0.3s ease 0.25s;
}
/* "Your pick" tag on the chosen pill. */
.trivia-answers.voted .trivia-answer-poll.selected .trivia-answer-label::after {
    content: " · YOUR PICK";
    font-size: 0.7rem;
    letter-spacing: 1px;
    opacity: 0.7;
}

@keyframes lockIn {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.06);
    }
    100% {
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: no-preference) {
    /* The chosen pill "locks in" with a quick pop. */
    .trivia-answer-poll.lock-in {
        animation: lockIn 0.15s ease;
    }
    /* Bars sweep in top-down, like lap times populating a timing board. */
    .trivia-answers.voted .trivia-answer-poll:nth-child(2) .trivia-pct-bar {
        transition-delay: 70ms;
    }
    .trivia-answers.voted .trivia-answer-poll:nth-child(3) .trivia-pct-bar {
        transition-delay: 140ms;
    }
    .trivia-answers.voted .trivia-answer-poll:nth-child(4) .trivia-pct-bar {
        transition-delay: 210ms;
    }
}

/* Trivia Result States */
.trivia-result-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.trivia-result-icon.correct {
    background-color: rgba(34, 197, 94, 0.2);
}

.trivia-result-icon.incorrect {
    background-color: rgba(239, 68, 68, 0.2);
}

.trivia-result-label {
    font-family: "Bebas Neue", sans-serif;
    font-size: 30px;
    color: #ffffff;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.trivia-result-answer-text {
    font-family: "Bebas Neue", sans-serif;
    font-size: 45px;
    color: #e72128;
    letter-spacing: 1px;
    margin: 0;
    line-height: 1.1;
}

/* Current user highlight in leaderboard */
.result-tile.current-user {
    border: 2px solid #dd232c;
}

/* Idle standings — a live grid, not a dead "starting soon" screen. The header
   gains a pulsing red dot + "Next question soon" via the .standings class. */
.standings-sub {
    display: none;
    align-items: center;
    gap: 6px;
    font-family: "Outfit", sans-serif;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: -6px;
    margin-bottom: 10px;
}

#trivia-leaderboard.standings .standings-sub {
    display: flex;
}

.standings-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e72128;
    flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
    #trivia-leaderboard.standings .standings-dot {
        animation: pulse 1.5s ease-in-out infinite;
    }
    /* Tiles cascade in like a grid filling up. */
    #trivia-leaderboard.standings .result-tile {
        animation: fadeIn 0.3s ease-in-out both;
    }
    #trivia-leaderboard.standings .result-tile:nth-child(2) {
        animation-delay: 60ms;
    }
    #trivia-leaderboard.standings .result-tile:nth-child(3) {
        animation-delay: 120ms;
    }
    #trivia-leaderboard.standings .result-tile:nth-child(4) {
        animation-delay: 180ms;
    }
    #trivia-leaderboard.standings .result-tile:nth-child(5) {
        animation-delay: 240ms;
    }
}

/* Your Place Box */
.your-place-box {
    background: linear-gradient(90deg, #e72128 0%, #e64521 100%);
    border-radius: 8px;
    padding: 6px 8px;
    margin-bottom: 8px;
    margin-left: -16px;
    margin-right: -16px;
    height: 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.your-place-label {
    font-family: "Bebas Neue", sans-serif;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

.your-place-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.your-place-row .position-number {
    font-family: "Bebas Neue", sans-serif;
    font-size: 22px;
    font-weight: bold;
    color: #ffffff;
    min-width: 20px;
    text-align: center;
}

.your-place-row .driver-image {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.your-place-row .driver-name {
    font-family: "Bebas Neue", sans-serif;
    font-size: 22px;
    color: #ffffff;
    letter-spacing: 0.5px;
}
