* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #080d18;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    color: #ffffff;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#gl-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.hidden {
    display: none !important;
}

/* World-space projected nameplates & offscreen ball indicator */
#world-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.nameplate {
    position: absolute;
    transform: translate(-50%, -100%);
    padding: 2px 8px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.nameplate.blue {
    background: rgba(25, 105, 235, 0.82);
}

.nameplate.orange {
    background: rgba(230, 105, 22, 0.82);
}

#ball-arrow {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    filter: drop-shadow(0 0 6px rgba(255, 220, 85, 0.65));
}

/* HUD */
#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.scoreboard {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    height: 52px;
    border-radius: 12px;
    overflow: hidden;
    border: 1.5px solid rgba(255, 255, 255, 0.32);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.score-team {
    width: 82px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
}

.score-blue {
    background: rgba(18, 95, 225, 0.9);
}

.score-orange {
    background: rgba(230, 108, 20, 0.9);
}

.score-clock-wrap {
    width: 122px;
    height: 100%;
    background: rgba(14, 20, 32, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.overtime-badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.8px;
    color: #ffd246;
    margin-bottom: -2px;
}

.match-clock {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.5px;
    font-variant-numeric: tabular-nums;
}

.match-clock.urgent {
    color: #ff6e5a;
}

.freeplay-banner {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 24px;
    border-radius: 12px;
    background: rgba(14, 20, 32, 0.84);
    border: 1px solid rgba(110, 210, 255, 0.4);
    color: #6ed2ff;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.4px;
}

/* Top-right controls */
.hud-topright {
    position: absolute;
    top: 14px;
    right: 16px;
    background: rgba(12, 18, 28, 0.74);
    border: 1px solid rgba(130, 175, 230, 0.25);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
    backdrop-filter: blur(4px);
}

.hud-topright-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #bed7f5;
}

.mini-btn {
    background: rgba(45, 65, 95, 0.72);
    border: 1px solid rgba(150, 195, 255, 0.35);
    color: #e6f1ff;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.mini-btn:hover {
    background: rgba(70, 105, 155, 0.9);
}

/* Bottom-left speed & camera */
.hud-bottomleft {
    position: absolute;
    left: 18px;
    bottom: 18px;
    background: rgba(12, 18, 28, 0.8);
    border: 1px solid rgba(130, 175, 230, 0.25);
    border-radius: 12px;
    padding: 10px 15px;
    min-width: 235px;
    pointer-events: auto;
    backdrop-filter: blur(4px);
}

.speed-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.speed-value {
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.speed-value.supersonic {
    color: #6ee6ff;
}

.supersonic-badge {
    font-size: 11px;
    font-weight: 800;
    color: #5fe1ff;
    letter-spacing: 0.8px;
    text-shadow: 0 0 8px rgba(95, 225, 255, 0.7);
}

.cam-toggle {
    margin-top: 6px;
    background: transparent;
    border: none;
    padding: 0;
    color: #5fe1ff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cam-toggle.car-cam {
    color: #c8d2e1;
}

.cam-toggle .key-hint {
    opacity: 0.75;
    font-size: 12px;
}

/* Bottom-right boost gauge */
.boost-gauge {
    position: absolute;
    right: 26px;
    bottom: 24px;
    width: 148px;
    height: 148px;
}

.boost-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.boost-bg-circle {
    fill: rgba(10, 15, 24, 0.85);
    stroke: rgba(255, 255, 255, 0.14);
    stroke-width: 1.5;
}

.boost-arc-track {
    stroke: #2d3748;
}

.boost-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 4px;
}

.boost-value {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.boost-label {
    margin-top: 4px;
    font-size: 11px;
    font-weight: 800;
    color: #ffc35a;
    letter-spacing: 1px;
}

/* Countdown & Goal Banners */
.countdown-overlay {
    position: absolute;
    top: 44%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 104px;
    font-weight: 900;
    color: #ffd74b;
    text-shadow: 0 6px 18px rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

.goal-banner {
    position: absolute;
    top: 45%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    padding: 22px 16px;
    text-align: center;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

.goal-banner.blue {
    background: linear-gradient(90deg, rgba(20, 110, 255, 0.9), rgba(10, 45, 120, 0.9));
}

.goal-banner.orange {
    background: linear-gradient(90deg, rgba(240, 110, 20, 0.9), rgba(120, 45, 10, 0.9));
}

.goal-title {
    font-size: 54px;
    font-weight: 900;
    letter-spacing: 1.5px;
    text-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.goal-sub {
    margin-top: 6px;
    font-size: 20px;
    font-weight: 700;
    color: #ebf5ff;
}

/* Modals (Menu, Pause, Match Over) */
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 14, 26, 0.62);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(3px);
}

.menu-card {
    width: min(760px, 100%);
    background: rgba(14, 22, 38, 0.93);
    border: 2px solid rgba(80, 175, 255, 0.6);
    border-radius: 22px;
    padding: 28px 32px 24px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
}

.menu-title {
    margin: 0;
    font-size: clamp(28px, 4.5vw, 44px);
    font-weight: 900;
    letter-spacing: 1px;
}

.title-blue {
    color: #46afff;
}

.title-orange {
    color: #ff912d;
}

.menu-subtitle {
    margin: 6px 0 20px;
    font-size: 15px;
    color: #b4c8e1;
}

.section-label {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #96b9e1;
    margin: 12px 0 8px;
}

.option-row {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.opt-btn {
    min-width: 158px;
    height: 42px;
    border-radius: 12px;
    border: 1.5px solid rgba(130, 160, 200, 0.4);
    background: #222e44;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s, border-color 0.15s;
}

.opt-btn:hover {
    background: #374866;
    border-color: rgba(255, 255, 255, 0.8);
}

.opt-btn.selected {
    background: #2382f5;
    border-color: rgba(255, 255, 255, 0.9);
}

.opt-btn.opt-orange.selected {
    background: #f0781e;
}

.play-btn {
    margin: 22px auto 18px;
    width: min(300px, 100%);
    height: 52px;
    border-radius: 14px;
    border: 2px solid rgba(255, 255, 255, 0.85);
    background: #1eaf64;
    color: #fff;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.6px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(30, 175, 100, 0.4);
    transition: transform 0.1s, background 0.15s;
}

.play-btn:hover {
    background: #25c874;
    transform: translateY(-1px);
}

.controls-box {
    background: rgba(20, 30, 48, 0.9);
    border-radius: 14px;
    padding: 14px 18px;
    text-align: left;
    border: 1px solid rgba(100, 175, 255, 0.22);
}

.controls-header {
    font-size: 13px;
    font-weight: 800;
    color: #64d2ff;
    margin-bottom: 8px;
    letter-spacing: 0.6px;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(265px, 1fr));
    gap: 7px 18px;
    font-size: 13px;
    color: #dce8f5;
}

/* Dialog cards (Pause / Match Over) */
.dialog-card {
    width: min(360px, 100%);
    background: rgba(16, 24, 40, 0.95);
    border: 2px solid rgba(90, 175, 255, 0.65);
    border-radius: 20px;
    padding: 24px 28px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
}

.dialog-card-wide {
    width: min(440px, 100%);
    border-color: rgba(255, 200, 75, 0.72);
}

.dialog-card h2 {
    margin: 0 0 6px;
    font-size: 30px;
    font-weight: 800;
}

.winner-blue {
    color: #4bafff;
}

.winner-orange {
    color: #ff9137;
}

.final-score {
    font-size: 44px;
    font-weight: 900;
    margin: 4px 0 8px;
}

.dialog-btn {
    height: 45px;
    border-radius: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.65);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s;
}

.dialog-btn:hover {
    filter: brightness(1.12);
}

.btn-green { background: #1eaf64; }
.btn-blue { background: #2d7de1; }
.btn-red { background: #b44632; }

/* Touch controls */
.touch-controls {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 94px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
}

.touch-left, .touch-right {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.touch-vert {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.touch-btn {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    background: rgba(18, 28, 48, 0.68);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    touch-action: none;
}

.touch-action, .touch-boost, .touch-jump {
    width: 68px;
    font-size: 12px;
}

.touch-boost {
    background: rgba(240, 125, 20, 0.75);
}

.touch-jump {
    background: rgba(35, 130, 245, 0.75);
}

@media (max-width: 720px) {
    .boost-gauge {
        width: 112px;
        height: 112px;
        right: 14px;
        bottom: 14px;
    }
    .boost-value { font-size: 26px; }
    .hud-bottomleft { min-width: 175px; padding: 8px 11px; }
    .goal-title { font-size: 36px; }
}
