/* ============================================
   race.css — Styles für Rennseite (race.html); eigenständig mit CSS-Variablen.
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ---- Variables ---- */
:root {
    --color-bg:         #eef4fb;
    --color-white:      #ffffff;
    --color-black:      #111111;
    --color-blue:       #1a6aff;
    --color-blue-light: #4d8fff;
    --color-blue-dark:  #0047d4;
    --color-blue-grad:  linear-gradient(135deg, #1a6aff, #0047d4);
    --color-orange:     #ff8c00;
    --color-text:       #1a1a2e;
    --color-text-muted: #7a8aaa;
    --color-border:     #c8d8ee;
    --color-card-bg:    #ffffff;
    --color-dark-card:  #111827;

    --space-sm:  8px;
    --space-md:  16px;
    --space-lg:  24px;
    --space-xl:  40px;

    --radius-md:   16px;
    --radius-lg:   24px;
    --radius-pill: 999px;

    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'DM Mono', monospace;

    --font-size-xs:  11px;
    --font-size-sm:  13px;
    --font-size-md:  15px;
    --font-size-lg:  18px;
    --font-size-xl:  24px;
    --font-size-2xl: 36px;
    --font-size-3xl: 56px;
}

/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
svg { display: block; max-width: 100%; }

/* ---- Base ---- */
body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    font-size: var(--font-size-md);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---- Page shell ---- */
.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-lg) var(--space-xl);
}

/* ---- Badge ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--color-blue-grad);
    color: var(--color-white);
    font-size: var(--font-size-sm);
    font-weight: 600;
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge svg { width: 16px; height: 16px; min-width: 16px; flex-shrink: 0; }

/* ---- Button ---- */
.btn {
    width: 100%;
    padding: 17px var(--space-lg);
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: var(--font-size-lg);
    font-weight: 700;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    text-decoration: none;
    transition: transform 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-danger-outline {
    background: var(--color-white);
    color: #e02020;
    border: 2px solid #e02020;
}

/* ---- Bottom actions ---- */
.bottom-actions {
    margin-top: auto;
    padding-top: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* ---- Race: top bar ---- */
.race-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.timer-block { text-align: right; }

.timer-block__label {
    font-size: var(--font-size-xs);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.timer-block__value {
    font-family: var(--font-mono);
    font-size: var(--font-size-2xl);
    font-weight: 500;
    color: var(--color-blue);
    line-height: 1.1;
}

/* ---- Race: opponent wait panel ---- */
.opponent-wait {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    padding: var(--space-lg) var(--space-md);
    background: var(--color-white);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(26, 106, 255, 0.08);
}

.opponent-wait[hidden] {
    display: none;
}

.opponent-wait__icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e8f0ff;
    color: var(--color-blue);
    margin-bottom: 4px;
}

.opponent-wait__title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-text);
}

.opponent-wait__countdown {
    font-family: var(--font-mono);
    font-size: var(--font-size-3xl);
    font-weight: 500;
    color: var(--color-blue);
    line-height: 1;
}

.opponent-wait__hint {
    max-width: 28ch;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    line-height: 1.45;
}

.race-page--opponent-wait .race-bar,
.race-page--opponent-wait .gauge-container,
.race-page--opponent-wait .race-cards {
    opacity: 0.45;
    pointer-events: none;
}

.race-page--opponent-wait .race-status {
    color: var(--color-blue);
}

/* ---- Race: status line ---- */
.race-status {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    margin: -6px 0 var(--space-md);
}

/* ---- Race: progress bar ---- */
.race-bar {
    height: 8px;
    background: #dde8f8;
    border-radius: var(--radius-pill);
    margin: 28px 0 var(--space-md);
    overflow: visible;
    position: relative;
}

.race-bar__fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    border-radius: var(--radius-pill);
    background: var(--color-blue-grad);
    transition: width 0.1s linear;
    pointer-events: none;
}

.race-bar__track {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-pill);
    overflow: visible;
}

.race-bar__bike {
    width: 32px;
    height: 32px;
    background: var(--color-blue);
    color: white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 2%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.1s linear;
    box-shadow: 0 2px 8px rgba(26, 106, 255, 0.35), 0 0 0 3px white, 0 0 0 5px var(--color-blue-light);
    z-index: 2;
}

/* ---- Race: cards grid ---- */
.race-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

/* ---- Stat card ---- */
.stat-card {
    background: var(--color-card-bg);
    border: 2px solid var(--color-black);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.stat-card--dark {
    background: var(--color-dark-card);
    border-color: var(--color-dark-card);
    color: white;
}

.stat-card__label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.stat-card--dark .stat-card__label { color: #6b7a99; }

.stat-card__value {
    font-family: var(--font-mono);
    font-size: var(--font-size-3xl);
    font-weight: 500;
    color: var(--color-blue);
    line-height: 1;
}

.stat-card__unit { font-size: var(--font-size-md); color: var(--color-text-muted); margin-top: 4px; }

.stat-card__meta {
    display: flex;
    gap: var(--space-xl);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
}

.stat-card__meta-label { font-size: var(--font-size-xs); color: var(--color-text-muted); margin-bottom: 2px; }
.stat-card__meta-value { font-size: var(--font-size-md); font-weight: 600; color: var(--color-text); }

/* ---- Duel rows (dark card) ---- */
.duel-lead { font-size: var(--font-size-sm); font-weight: 700; color: var(--color-blue); }

.duel-row { margin-bottom: var(--space-md); }
.duel-row:last-child { margin-bottom: 0; }

.duel-row__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: var(--font-size-sm);
    color: #cdd5e0;
}

.duel-row__distance { font-weight: 600; color: white; }

.duel-bar { height: 6px; border-radius: var(--radius-pill); background: #2a3444; overflow: hidden; }
.duel-bar__fill { height: 100%; border-radius: var(--radius-pill); transition: width 0.5s ease; }
.duel-bar__fill--b { background: var(--color-blue); }
.duel-bar__fill--a { background: #555; }

.duel-bar__fill--opponent { background: var(--color-blue); }

.duel-card--opponent-a .duel-bar__fill--opponent {
    background: var(--color-orange);
}

.duel-card--opponent-b .duel-bar__fill--opponent {
    background: var(--color-blue);
}

/* ---- Mini stats row ---- */
.mini-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.mini-stat { background: #f0f5fc; border-radius: var(--radius-md); padding: var(--space-md) var(--space-lg); }
.mini-stat__label {
    font-size: var(--font-size-xs);
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}
.mini-stat__value { font-size: var(--font-size-xl); font-weight: 700; color: var(--color-text); }


.gauge-container {
    position: relative;
    width: 300px;
    height: 150px;
    overflow: hidden;
    margin: 20px auto;
}

.gauge-label {
    position: absolute;
    top: 8px;
    z-index: 12;
    font-size: var(--font-size-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--color-text);
}

.gauge-label--a {
    left: 24px;
}

.gauge-label--b {
    right: 24px;
}

.gauge-background {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: linear-gradient(to right, var(--color-orange) 50%, var(--color-blue) 50%);
}

.needle {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 4px;
    height: 140px;
    background: #333;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(0deg); /* Start at center (Vertical) */
    
    /* This makes the 1-second update look smooth */
    transition: transform 1s linear; 
    z-index: 10;
}

.gauge-center {
    position: absolute;
    bottom: -15px;
    left: 50%;
    width: 30px;
    height: 30px;
    background: #333;
    border-radius: 50%;
    transform: translateX(-50%);
    z-index: 11;
}