/* ===================================================================
   STEBARTO // PIT STOP — dark carbon + racing red
   =================================================================== */

:root {
    --bg: #0a0a0c;
    --bg-2: #101014;
    --carbon-a: #0d0d10;
    --carbon-b: #131318;
    --panel: #15151a;
    --line: #26262e;
    --red: #e10600;
    --red-bright: #ff2d23;
    --white: #f2f2f2;
    --muted: #8a8a96;
    --font-display: "Titillium Web", "Segoe UI", sans-serif;
    --font-hud: "Chakra Petch", "SF Mono", monospace;
}

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

html { scroll-behavior: smooth; }

body {
    background:
        repeating-linear-gradient(45deg, var(--carbon-a) 0 3px, var(--carbon-b) 3px 6px),
        var(--bg);
    color: var(--white);
    font-family: var(--font-display);
    font-size: 1.05rem;
    line-height: 1.6;
    overflow-x: clip;
}

::selection { background: var(--red); color: #fff; }

a { color: inherit; text-decoration: none; }

:focus-visible {
    outline: 2px solid var(--red-bright);
    outline-offset: 3px;
}

/* ============ Hero ============ */

.hero {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    overflow: clip;
}

#gl-hero {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: var(--bg);
}

.hero-grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px),
        radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

.topbar {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem clamp(1.2rem, 4vw, 2.5rem);
}

.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand img {
    width: 44px; height: 44px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.8));
}
.brand-name {
    font-weight: 900;
    font-size: 1.15rem;
    letter-spacing: 0.16em;
}
.brand-dot { color: var(--red-bright); }

.status-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.9rem;
    font-family: var(--font-hud);
    font-size: 0.68rem;
    letter-spacing: 0.16em;
    color: var(--white);
    background: rgba(10, 10, 12, 0.7);
    border: 1px solid var(--line);
    border-left: 3px solid var(--red);
    backdrop-filter: blur(6px);
}
.status-light {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--red-bright);
    box-shadow: 0 0 8px var(--red-bright);
    animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

.hero-inner {
    position: relative;
    z-index: 2;
    flex: 1;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem clamp(1.2rem, 4vw, 2.5rem) 4rem;
}

.hero-kicker {
    font-family: var(--font-hud);
    font-size: clamp(0.65rem, 1.5vw, 0.8rem);
    letter-spacing: 0.4em;
    color: var(--red-bright);
    margin-bottom: 1rem;
}

.hero-title {
    font-weight: 900;
    font-size: clamp(3.4rem, 11vw, 9rem);
    line-height: 0.96;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    font-style: italic;
}
.hero-line { display: block; }
.hero-line-red {
    color: var(--red-bright);
    text-shadow: 0 0 30px rgba(225, 6, 0, 0.45);
}
.hero-cursor {
    display: inline-block;
    width: 0.12em;
    height: 0.78em;
    margin-left: 0.08em;
    background: var(--red-bright);
    animation: blink 1s steps(2) infinite;
}

.hero-lead {
    margin-top: 1.4rem;
    max-width: 52ch;
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: #c9c9d2;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.hero-cta { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 2rem; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.8rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    border: 1px solid var(--line);
    background: rgba(16, 16, 20, 0.8);
    color: var(--white);
    cursor: pointer;
    clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }

.btn-red {
    background: var(--red);
    border-color: var(--red);
    box-shadow: 0 4px 22px rgba(225, 6, 0, 0.45);
}
.btn-red:hover {
    background: var(--red-bright);
    box-shadow: 0 6px 30px rgba(225, 6, 0, 0.65);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }

.build-progress { margin-top: 3rem; max-width: 420px; }
.build-label {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-hud);
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    color: var(--muted);
    margin-bottom: 0.5rem;
}
.build-bar {
    height: 14px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.5);
    padding: 2px;
}
.build-fill {
    height: 100%;
    width: 0%;
    background: repeating-linear-gradient(45deg, var(--red) 0 8px, #a30400 8px 16px);
    transition: width 1.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.hero-bottom { position: relative; z-index: 2; }
.checker-strip, .checker-mini {
    height: 18px;
    background:
        repeating-conic-gradient(#e8e8e8 0% 25%, #0a0a0c 0% 50%) 0 0 / 18px 18px;
    opacity: 0.9;
}
.checker-mini { width: 72px; height: 12px; background-size: 12px 12px; }

/* ============ Sections ============ */

main { position: relative; z-index: 1; }

.section {
    max-width: 1120px;
    margin: 0 auto;
    padding: clamp(3.5rem, 9vh, 6rem) clamp(1.2rem, 4vw, 2.5rem) 0;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.6rem;
}
.section-num {
    font-family: var(--font-hud);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.6rem;
    background: var(--red);
    color: #fff;
}
.section-head h2 {
    font-weight: 900;
    font-style: italic;
    font-size: clamp(1.2rem, 3.4vw, 1.9rem);
    letter-spacing: 0.06em;
    white-space: nowrap;
}
.head-red { color: var(--red-bright); }
.section-rule {
    flex: 1;
    height: 3px;
    background: linear-gradient(90deg, var(--red), transparent);
}

/* ============ Game ============ */

.game-card {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.2rem;
    padding: 1.2rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 3px solid var(--red);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.game-stage {
    position: relative;
    background: #0c0f0c;
    border: 1px solid var(--line);
    overflow: hidden;
    /* no long-press selection/callout while driving on touch */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
#race-canvas {
    display: block;
    width: 100%;
    height: auto; /* keeps the canvas' own aspect, which adapts to the device */
    touch-action: none;
}

/* corner turbo buttons, one per player */
.corner-turbo {
    position: absolute;
    z-index: 6;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    width: 80px;
    height: 80px;
    padding: 0.3rem;
    overflow: hidden;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: rgba(10, 10, 12, 0.6);
    color: var(--white);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.corner-turbo.show { display: flex; }
.corner-turbo {
    --pc: #e10600;
    opacity: 0.8; /* dimmed while charging */
}
.corner-turbo.ready {
    opacity: 1;
    border-width: 3px;
    box-shadow: 0 0 22px var(--pc), inset 0 0 14px var(--pc);
    animation: turbo-pulse 0.7s ease-in-out infinite;
}
@keyframes turbo-pulse { 50% { transform: scale(1.1); } }
.c-bl { left: calc(10px + env(safe-area-inset-left, 0px)); bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
.c-br { right: calc(10px + env(safe-area-inset-right, 0px)); bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
.c-tl { left: calc(10px + env(safe-area-inset-left, 0px)); top: calc(10px + env(safe-area-inset-top, 0px)); }
.c-tr { right: calc(10px + env(safe-area-inset-right, 0px)); top: calc(10px + env(safe-area-inset-top, 0px)); }
.ct-fill {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 0%;
    background: linear-gradient(0deg, var(--pc), transparent);
    opacity: 0.4;
    pointer-events: none;
}
.corner-turbo.ready .ct-fill { opacity: 0.85; }
.ct-name {
    position: relative;
    font-family: var(--font-hud);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}
.ct-info {
    position: relative;
    font-family: var(--font-hud);
    font-size: 0.6rem;
    color: #c9c9d2;
}

/* fullscreen ("maxi") mode + rotation hint */
.game-stage.maxi {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0e160f; /* same night grass as the track, edge to edge */
    border: none;
}
.game-stage.maxi #race-canvas {
    width: 100%;
    height: auto;
    max-height: 100%;
}
html.gp-lock, html.gp-lock body { overflow: hidden; }

.maxi-exit {
    display: none;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 8;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: rgba(10, 10, 12, 0.6);
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
}
.game-stage.maxi .maxi-exit { display: block; }

.rotate-hint {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 20; /* above the game overlay: rotate first, then read the prompt */
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(5, 5, 7, 0.92);
    pointer-events: none;
}
.rotate-inner {
    font-family: var(--font-hud);
    font-size: 1.1rem;
    line-height: 1.9;
    color: var(--white);
}
.rotate-inner span { font-size: 0.75rem; color: var(--muted); }
@media (orientation: portrait) {
    .game-stage.maxi .rotate-hint { display: flex; }
}

.game-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    background: rgba(5, 5, 7, 0.78);
    backdrop-filter: blur(3px);
    transition: opacity 0.25s ease;
}
.game-overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-inner { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
.game-overlay { z-index: 10; }
.player-select { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
.player-select .btn { padding: 0.7rem 1.2rem; }
.overlay-kicker {
    font-family: var(--font-hud);
    font-size: 0.65rem;
    letter-spacing: 0.4em;
    color: var(--red-bright);
}
.overlay-inner h3 {
    font-weight: 900;
    font-style: italic;
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    letter-spacing: 0.05em;
}
.overlay-msg {
    font-family: var(--font-hud);
    font-size: 0.85rem;
    color: #c9c9d2;
}
.overlay-hint {
    font-family: var(--font-hud);
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.hud {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.8rem;
    font-family: var(--font-hud);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--white);
    text-shadow: 0 1px 3px #000;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.hud.on { opacity: 1; }

.game-side { display: flex; flex-direction: column; gap: 0.9rem; }

.stat {
    flex: 1;
    padding: 0.8rem 1rem;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line);
}
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.stat-label {
    font-family: var(--font-hud);
    font-size: 0.6rem;
    letter-spacing: 0.18em;
    color: var(--muted);
    margin-bottom: 0.35rem;
}
.stat-value {
    font-family: var(--font-hud);
    font-size: 1.25rem;
    font-weight: 700;
}
.stat-red { color: var(--red-bright); }

.controls-help {
    padding: 0.9rem 1rem;
    border: 1px dashed var(--line);
    background: var(--bg-2);
}
.controls-help h4 {
    font-family: var(--font-hud);
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    margin-bottom: 0.7rem;
}
.controls-help ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.88rem;
    color: #c9c9d2;
}
kbd {
    font-family: var(--font-hud);
    font-size: 0.7rem;
    background: #1d1d24;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    padding: 0.15rem 0.4rem;
    margin-right: 0.2rem;
}

/* ============ Contact ============ */

.contact-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    background: linear-gradient(105deg, var(--panel) 60%, #1d0a09);
    border: 1px solid var(--line);
    border-left: 4px solid var(--red);
}
.contact-card h3 {
    font-weight: 900;
    font-style: italic;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}
.contact-card p { color: #c9c9d2; max-width: 52ch; }

/* ============ Footer ============ */

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    max-width: 1120px;
    margin: 0 auto;
    padding: 3.5rem clamp(1.2rem, 4vw, 2.5rem) 2rem;
    font-family: var(--font-hud);
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    color: var(--muted);
}

/* ============ Responsive ============ */

@media (max-width: 880px) {
    .game-card { grid-template-columns: 1fr; }
    .contact-card { grid-template-columns: 1fr; text-align: left; }
    .status-chip { font-size: 0.56rem; }
    .section-head { flex-wrap: wrap; }
    .section-head h2 { white-space: normal; }
}

@media (max-width: 560px) {
    .topbar { flex-wrap: wrap; justify-content: center; }
    .game-overlay { padding: 0.7rem; }
    .overlay-inner { gap: 0.45rem; }
    .overlay-inner h3 { font-size: 1.25rem; }
    .overlay-msg { font-size: 0.72rem; }
    .overlay-kicker { font-size: 0.55rem; }
    .overlay-hint { font-size: 0.55rem; }
    .game-overlay .btn { padding: 0.6rem 1.4rem; font-size: 0.78rem; }
    .brand-name { font-size: 0.95rem; }
    .brand img { width: 36px; height: 36px; }
    .stat-row { grid-template-columns: 1fr 1fr; }
    .hero-cta .btn { flex: 1; justify-content: center; }
}

/* ============ Reduced motion ============ */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
