/* Super Formula — slog (na osnovi /shared/mg.css) */
:root {
    --sf-red: #ef4444;
    --sf-orange: #f97316;
    --sf-grad: linear-gradient(135deg, #ef4444, #f97316);
}
html, body { height: 100%; }
body { overflow: hidden; background: var(--mg-bg); overscroll-behavior: none; }

/* ---- zasloni ---- */
.screen { position: fixed; inset: 0; display: none; overflow: hidden; }
.screen.active { display: block; }
.screen:not(.game) { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sf-bg {
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(1200px 600px at 15% -10%, rgba(239, 68, 68, .18), transparent 60%),
        radial-gradient(900px 500px at 100% 20%, rgba(249, 115, 22, .12), transparent 60%),
        radial-gradient(800px 600px at 50% 110%, rgba(124, 92, 255, .12), transparent 60%),
        var(--mg-bg);
}
.sf-bg::after {
    content: ''; position: absolute; inset: 0; opacity: .35;
    background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 75%);
}

/* rdeči gumbi */
.mg-btn.sf-red { background: var(--sf-grad); box-shadow: 0 6px 18px rgba(239, 68, 68, .35); }
.mg-btn.sf-red:hover { box-shadow: 0 10px 24px rgba(239, 68, 68, .5); }

/* ---- lobby ---- */
.lobby-wrap { max-width: 1100px; margin: 0 auto; padding: 72px 20px 32px; min-height: 100%; display: flex; flex-direction: column; }
.lobby-hero { text-align: center; margin-bottom: 28px; }
.sf-logo { display: inline-flex; align-items: center; gap: 16px; }
.sf-logo h1 {
    font-size: clamp(38px, 7vw, 66px); font-weight: 800; line-height: .95; text-align: left;
    background: linear-gradient(135deg, #fff 0%, #fecaca 45%, #ef4444 100%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 24px rgba(239, 68, 68, .35));
}
.sf-logo h1 span { display: block; font-size: .62em; letter-spacing: .28em; -webkit-text-fill-color: var(--mg-text); background: none; }
.sf-logo-flag {
    width: 52px; height: 52px; border-radius: 12px; flex: 0 0 auto; transform: skewX(-8deg);
    background:
        conic-gradient(#fff 25%, #111 0 50%, #fff 0 75%, #111 0);
    background-size: 50% 50%; border: 2px solid rgba(255,255,255,.25); box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.lobby-tag { color: var(--mg-muted); margin: 12px 0 14px; font-size: 15px; }
.lobby-badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.lobby-badges .mg-badge { cursor: pointer; padding: 6px 12px; font-size: 13px; }
.lobby-badges .mg-badge:hover { border-color: var(--mg-border-strong); color: var(--mg-text); }
.online-badge { color: #86efac; }

.lobby-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; align-items: start; }
.lobby-main { display: flex; flex-direction: column; gap: 14px; }
.lobby-side { display: flex; flex-direction: column; gap: 14px; }
.nick-card .mg-row .mg-input { flex: 1; }
.code-card .mg-row .mg-input { flex: 1; text-transform: uppercase; }
.code-card .mg-row .mg-input::placeholder { text-transform: none; }

.play-btn {
    display: flex; align-items: center; gap: 18px; width: 100%; padding: 22px 26px; border: 0; cursor: pointer;
    border-radius: 20px; color: #fff; text-align: left; position: relative; overflow: hidden;
    background: var(--sf-grad); box-shadow: 0 14px 40px rgba(239, 68, 68, .35), inset 0 1px 0 rgba(255,255,255,.25);
    transition: transform .15s, box-shadow .15s;
}
.play-btn::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: repeating-linear-gradient(-45deg, rgba(255,255,255,.08) 0 14px, transparent 14px 28px);
    mask-image: linear-gradient(90deg, transparent 55%, #000); -webkit-mask-image: linear-gradient(90deg, transparent 55%, #000);
}
.play-btn:hover { transform: translateY(-3px); box-shadow: 0 20px 50px rgba(239, 68, 68, .5), inset 0 1px 0 rgba(255,255,255,.25); }
.play-btn:active { transform: translateY(0); }
.play-icon { font-size: 44px; line-height: 1; }
.play-text { display: flex; flex-direction: column; }
.play-text strong { font-family: var(--mg-font-display); font-size: 34px; letter-spacing: .06em; line-height: 1; }
.play-text small { opacity: .9; font-size: 14px; margin-top: 4px; font-weight: 500; }
.lobby-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.lobby-actions .mg-btn { padding-left: 10px; padding-right: 10px; }

.stats-card h3, .top3-card h3 { font-size: 16px; margin-bottom: 12px; color: var(--mg-text); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: rgba(255,255,255,.04); border: 1px solid var(--mg-border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.stat-v { font-family: var(--mg-font-display); font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--mg-muted); font-size: 12px; margin-top: 2px; }
.current-car { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--mg-border); }
.current-car canvas { width: 130px; height: 84px; border-radius: 12px; background: radial-gradient(ellipse at 50% 100%, rgba(255,255,255,.08), transparent 70%); flex: 0 0 auto; }
.cc-name { font-weight: 800; font-size: 17px; margin: 2px 0 8px; }
.top3-card .mg-lb li { padding: 8px 10px; font-size: 14px; }
.lobby-foot { text-align: center; color: var(--mg-dim); font-size: 12px; margin-top: 28px; }

/* ---- podstrani ---- */
.sub-wrap { max-width: 1100px; margin: 0 auto; padding: 72px 20px 40px; }
.sub-wrap.narrow { max-width: 720px; }
.sub-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.sub-head h2 { flex: 1; font-size: 28px; }
.sub-intro { font-size: 14px; margin: 0 0 20px; line-height: 1.5; }
.sec-title { font-size: 18px; margin: 22px 0 12px; color: var(--mg-text); }
.fuel-badge { font-size: 15px; padding: 8px 14px; }
.garage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.car-card {
    background: var(--mg-surface); border: 1px solid var(--mg-border); border-radius: 16px; padding: 14px;
    display: flex; flex-direction: column; gap: 8px; transition: transform .15s, border-color .15s, box-shadow .15s; position: relative;
}
.car-card:hover { transform: translateY(-3px); border-color: var(--mg-border-strong); box-shadow: var(--mg-shadow); }
.car-card.selected { border-color: var(--sf-red); box-shadow: 0 0 0 1px var(--sf-red), 0 10px 30px rgba(239,68,68,.25); }
.car-card.locked { opacity: .82; }
.car-card canvas { width: 100%; height: auto; aspect-ratio: 5/3; border-radius: 12px; background: radial-gradient(ellipse at 50% 100%, rgba(255,255,255,.08), transparent 70%), rgba(0,0,0,.25); }
.car-card .car-name { font-weight: 800; font-size: 15px; }
.car-card .car-desc { color: var(--mg-muted); font-size: 12px; min-height: 30px; line-height: 1.35; }
.car-card .car-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.car-card .price { font-weight: 800; color: var(--mg-gold); font-size: 14px; }
.car-card .price.free { color: var(--mg-success); }
.car-card .tag { position: absolute; top: 10px; right: 10px; }
.upgrades .car-card .car-desc { min-height: 44px; }
.upg-icon { font-size: 40px; text-align: center; padding: 10px 0; }
.upg-level { display: flex; gap: 4px; margin-bottom: 4px; }
.upg-level i { flex: 1; height: 6px; border-radius: 3px; background: var(--mg-surface-3); }
.upg-level i.on { background: var(--sf-grad); }

/* ---- igra ---- */
.screen.game { background: #000; touch-action: none; }
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.pause-btn {
    position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 20;
    width: 42px; height: 42px; border-radius: 12px; border: 1px solid rgba(255,255,255,.2); background: rgba(10,14,30,.55);
    color: #fff; font-size: 14px; cursor: pointer; backdrop-filter: blur(6px);
}
.touch-controls {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 15; display: none; pointer-events: none;
    padding: 0 max(12px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right));
    justify-content: space-between; align-items: flex-end;
}
.touch .touch-controls { display: flex; }
.tc-btn {
    pointer-events: auto; border: 1px solid rgba(255,255,255,.28); background: rgba(10,14,30,.42); color: #fff;
    backdrop-filter: blur(4px); user-select: none; -webkit-user-select: none; touch-action: none; font-weight: 800; letter-spacing: .05em;
}
.tc-btn:active, .tc-btn.on { background: rgba(239,68,68,.55); border-color: rgba(255,255,255,.5); }
.tc-col { display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.tc-left, .tc-right { width: min(26vw, 140px); height: min(24vw, 130px); border-radius: 26px; font-size: 40px; }
.tc-nitro { width: min(26vw, 140px); height: 48px; border-radius: 14px; font-size: 14px; background: rgba(34,211,238,.28); border-color: rgba(34,211,238,.6); }
.tc-nitro:active, .tc-nitro.on { background: rgba(34,211,238,.6); }
.tc-brake { width: min(26vw, 140px); height: 40px; border-radius: 12px; font-size: 12px; }

.overlay {
    position: absolute; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: 16px;
    background: rgba(5, 8, 18, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.overlay.show { display: flex; }
.overlay.countdown { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; pointer-events: none; }
.cd-num {
    font-family: var(--mg-font-display); font-size: clamp(90px, 22vw, 200px); font-weight: 800; color: #fff;
    text-shadow: 0 10px 40px rgba(239,68,68,.7), 0 0 4px #000; animation: cdPop .9s ease-out infinite;
}
@keyframes cdPop { 0% { transform: scale(1.4); opacity: 0 } 25% { transform: scale(1); opacity: 1 } 100% { transform: scale(.85); opacity: 0 } }
.cd-num.go { color: #4ade80; animation: cdPop 1s ease-out 1 forwards; }
.ov-box { width: 100%; max-width: 420px; padding: 24px; border-radius: 22px; text-align: center; animation: mg-pop .25s both; }
.ov-box h2 { font-size: 26px; margin-bottom: 16px; }
.ov-actions { display: flex; flex-direction: column; gap: 10px; }
.ov-actions.row { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.ov-actions.row .mg-btn { flex: 1 1 120px; }
.opt-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 14px; color: var(--mg-muted); font-size: 14px; cursor: pointer; }
.opt-row input { width: 18px; height: 18px; accent-color: var(--sf-red); }
.results { max-width: 480px; }
.res-title { font-family: var(--mg-font-display); font-size: 30px; font-weight: 800; }
.res-dist { font-family: var(--mg-font-display); font-size: clamp(56px, 12vw, 80px); font-weight: 800; line-height: 1.05; margin: 6px 0 2px; font-variant-numeric: tabular-nums;
    background: linear-gradient(135deg, #fff, #fecaca 60%, #f97316); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.res-dist small { font-size: .35em; -webkit-text-fill-color: var(--mg-muted); }
.res-record { color: var(--mg-gold); font-weight: 800; margin-bottom: 8px; display: none; animation: mg-pulse 1.2s infinite; }
.res-record.show { display: block; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.res-grid > div { background: rgba(255,255,255,.05); border: 1px solid var(--mg-border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; }
.res-v { font-family: var(--mg-font-display); font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.res-l { font-size: 11px; color: var(--mg-muted); margin-top: 2px; }
.res-note { font-size: 13px; min-height: 18px; margin-bottom: 12px; }

/* kako igrati */
.how-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; margin-top: 8px; }
.how-grid div { background: rgba(255,255,255,.04); border: 1px solid var(--mg-border); border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.5; }
.how-grid b { color: var(--mg-text); }
.how-list { text-align: left; padding-left: 18px; line-height: 1.7; margin: 8px 0 0; }

/* ---- odzivnost ---- */
@media (max-width: 900px) {
    .lobby-grid { grid-template-columns: 1fr; }
    .lobby-actions { grid-template-columns: 1fr 1fr; }
    .lobby-actions .mg-btn:last-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
    .lobby-wrap, .sub-wrap { padding: 64px 14px 28px; }
    .sf-logo { gap: 10px; }
    .sf-logo-flag { width: 40px; height: 40px; }
    .play-btn { padding: 18px 20px; gap: 14px; }
    .play-text strong { font-size: 28px; }
    .stat-v { font-size: 19px; }
    .res-grid { gap: 6px; }
    .how-grid { grid-template-columns: 1fr; }
    .lobby-badges .mg-badge { font-size: 12px; }
    .sub-head h2 { font-size: 22px; }
}
@media (max-height: 460px) and (orientation: landscape) {
    .tc-left, .tc-right { width: 90px; height: 80px; font-size: 30px; }
    .tc-nitro { height: 40px; }
    .tc-brake { height: 34px; }
    .ov-box { padding: 14px; }
    .res-dist { font-size: 44px; }
    .res-grid { margin: 8px 0; }
}
