/* Circuito Guardianes — kart 16-bit */
.kg-shell {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100%;
    background: #04060e;
    overflow: hidden;
    color: #e8fdff;
    font-family: "Segoe UI", sans-serif;
}
.kg-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}
.kg-hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}
.kg-faces {
    position: absolute;
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    display: flex;
    flex-direction: row;
    gap: 4px;
    z-index: 5;
    max-width: min(250px, 34vw);
}
.kg-face {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.25);
    position: relative;
    background: #071018;
}
.kg-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kg-face em {
    position: absolute;
    right: 2px;
    bottom: 1px;
    font-style: normal;
    font-size: 10px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 1px 2px #000;
}
.kg-face.is-me { border-color: #ffd54f; box-shadow: 0 0 10px rgba(255,213,79,.45); }
.kg-topbar {
    position: absolute;
    top: max(6px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 5;
    max-width: calc(100vw - 128px);
}
.kg-lap-big, .kg-time {
    font-weight: 900;
    letter-spacing: 0.06em;
    font-size: clamp(16px, 2.4vw, 22px);
    text-shadow: 0 2px 0 #000, 0 0 12px rgba(0,0,0,.6);
}
.kg-lap-big b { color: #ffd54f; }
.kg-item {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    border: 3px solid #111;
    outline: 2px solid #ffd54f;
    background: rgba(8, 12, 28, 0.92);
    display: grid;
    place-items: center;
    font-size: 26px;
}
.kg-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; display: block; }
.kg-item span {
    position: absolute;
    left: 50%;
    top: calc(100% + 4px);
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #fff;
    text-shadow: 0 1px 0 #000;
    white-space: nowrap;
}
.kg-item.is-empty { opacity: 0.4; }
.kg-place {
    position: static;
    font-size: clamp(22px, 3.1vw, 34px);
    font-weight: 900;
    color: #ffd54f;
    text-shadow: 2px 2px 0 #000, 0 0 12px rgba(255, 213, 79, 0.35);
    line-height: 0.9;
    z-index: 5;
}
.kg-place small { font-size: 0.42em; }
.kg-nitro {
    position: static;
    right: auto;
    top: auto;
    transform: none;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    z-index: 5;
    pointer-events: none;
    flex: 0 1 auto;
    min-width: 0;
}
.kg-nitro span {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.12em;
    color: #f4fff6;
    text-shadow: 0 1px 2px #000, 0 0 10px rgba(255, 90, 40, 0.45);
}
.kg-nitro-track {
    position: relative;
    width: clamp(64px, 14vw, 128px);
    height: 14px;
    border-radius: 999px;
    border: 2px solid rgba(255,255,255,0.72);
    background: linear-gradient(90deg, #1ed760 0%, #d6e23a 34%, #ff8a00 67%, #ff2a2a 100%);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.55), 0 0 16px rgba(255, 90, 30, 0.28);
    overflow: hidden;
}
.kg-nitro-track i {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background: rgba(5, 8, 16, 0.9);
    box-shadow: none;
}
.kg-nitro.is-full .kg-nitro-track {
    border-color: #fff;
    box-shadow: 0 0 18px rgba(255, 60, 40, 0.75), inset 0 1px 0 rgba(255,255,255,0.7);
}
.kg-nitro.is-on .kg-nitro-track {
    border-color: #fff6d6;
    box-shadow: 0 0 22px rgba(255, 80, 20, 0.9);
}
.kg-nitro.is-on .kg-nitro-track i {
    width: 0 !important;
}
.kg-mini {
    position: absolute;
    right: max(12px, env(safe-area-inset-right));
    bottom: 112px;
    width: 136px;
    height: 136px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
    z-index: 5;
    background: #101820;
}
.kg-card-wide { width: min(760px, 96vw); max-height: 92vh; overflow: auto; }
.kg-roster-lab {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.14em;
    color: #00e5ff;
    margin: 8px 0 6px;
}
.kg-roster-lab.is-f { color: #ff3d71; }
.kg-roster {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}
.kg-pilot {
    border: 1px solid rgba(0, 229, 255, 0.28);
    background: #070b16;
    border-radius: 14px;
    padding: 0 0 6px;
    color: #e8fdff;
    cursor: pointer;
    text-align: center;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.kg-pilot-shot {
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    background: #10182a;
}
.kg-pilot-shot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
    aspect-ratio: auto;
}
.kg-pilot b { display: block; margin-top: 6px; font-size: 12px; letter-spacing: 0.06em; }
.kg-pilot-stats { display: block; font-size: 9px; opacity: 0.75; margin-top: 2px; }
.kg-pilot-stats i {
    display: inline-block;
    width: var(--w, 50%);
    height: 3px;
    margin: 0 4px 0 2px;
    background: #00e5ff;
    vertical-align: middle;
    border-radius: 2px;
}
.kg-pilot.is-f .kg-pilot-stats i { background: #ff3d71; }
.kg-pilot.is-on {
    border-color: #ffd54f;
    box-shadow: 0 0 0 2px #ffd54f, 0 0 18px rgba(255, 213, 79, 0.45);
}
.kg-pilot.is-f.is-on {
    border-color: #ff4d8d;
    box-shadow: 0 0 0 2px #ff4d8d, 0 0 18px rgba(255, 77, 141, 0.4);
}
.kg-menu, .kg-end {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background:
        linear-gradient(180deg, rgba(4,8,18,0.55), rgba(4,8,18,0.88)),
        url("../img/missions/mission-kart.jpg") center / cover no-repeat;
}
.kg-menu[hidden], .kg-end[hidden] { display: none !important; }
.kg-card {
    width: min(520px, 94vw);
    background: linear-gradient(165deg, rgba(8,18,36,0.94), rgba(4,10,22,0.96));
    border: 1px solid rgba(0, 229, 255, 0.35);
    border-radius: 18px;
    padding: 18px 18px 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px rgba(0,229,255,0.12);
    pointer-events: auto;
}
.kg-card h2 {
    margin: 0 0 4px;
    font-size: clamp(1.4rem, 4vw, 2rem);
    letter-spacing: 0.04em;
}
.kg-card p { margin: 0 0 14px; color: rgba(200, 230, 255, 0.75); font-size: 0.92rem; }
.kg-tracks {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}
.kg-track {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(6, 14, 28, 0.7);
    color: #d6f6ff;
    font-weight: 800;
    cursor: pointer;
    text-align: left;
}
.kg-track small { display: block; font-weight: 600; opacity: 0.7; font-size: 11px; letter-spacing: 0.08em; }
.kg-track.is-on {
    border-color: #00e5ff;
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.28);
    background: linear-gradient(90deg, rgba(0, 229, 255, 0.18), rgba(124, 77, 255, 0.16));
}
.kg-teams { display: flex; gap: 8px; margin-bottom: 12px; }
.kg-team {
    flex: 1;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(6,14,28,0.7);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}
.kg-team.is-g.is-on { border-color: #00e5ff; background: rgba(0,80,110,0.55); }
.kg-team.is-f.is-on { border-color: #ff3d71; background: rgba(90,10,40,0.55); }
.kg-go, .kg-again {
    width: 100%;
    padding: 12px;
    border: 0;
    border-radius: 12px;
    font-weight: 900;
    letter-spacing: 0.14em;
    cursor: pointer;
    background: linear-gradient(90deg, #00e5ff, #7c4dff);
    color: #041018;
}
#kgMenuBack, #kgEndBack {
    margin-top: 8px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.22);
    color: #cfefff;
}
.kg-corner {
    position: absolute;
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    z-index: 8;
    pointer-events: none;
}
.kg-nav-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
}
.kg-nav-stack .runner-hud-nav {
    display: grid;
    width: 42px;
    height: 42px;
}
.kg-sign {
    position: absolute;
    right: calc(100% + 8px);
    top: 0;
    width: 42px;
    height: 42px;
    pointer-events: none;
}
.kg-sign.is-right { filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.65)); }
.kg-sign.is-left { filter: drop-shadow(0 0 10px rgba(255, 60, 180, 0.55)); }
.kg-back {
    position: relative;
    pointer-events: auto;
    border: 1px solid rgba(0,229,255,0.4);
    background: rgba(4,10,24,0.82);
    color: #e8fdff;
    font-weight: 900;
    font-size: 11px;
    letter-spacing: 0.08em;
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
}
.kg-count {
    position: absolute;
    left: 0;
    right: 0;
    top: 11%;
    z-index: 6;
    display: flex;
    justify-content: center;
    pointer-events: none;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    text-shadow: none;
}
.kg-count[hidden] { display: none !important; }
.kg-start {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.kg-start em {
    font-style: normal;
    letter-spacing: 0.28em;
    font-size: 11px;
    color: rgba(232, 253, 255, 0.72);
}
.kg-lights {
    display: flex;
    gap: 12px;
    padding: 14px 18px 12px;
    background:
        linear-gradient(180deg, #2a3142 0%, #121722 55%, #0b0e16 100%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 18px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.14) inset,
        0 18px 36px rgba(0, 0, 0, 0.45);
}
.kg-lights span {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 45%, #3a2226, #14080a 70%);
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.65), 0 0 0 3px #0a0c12;
}
.kg-lights span.is-on {
    background: radial-gradient(circle at 35% 32%, #ffd0cc, #ff2d3a 42%, #8d0010 78%);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.35),
        0 0 0 3px #0a0c12,
        0 0 18px rgba(255, 45, 58, 0.85);
}
.kg-lights.is-go span {
    background: radial-gradient(circle at 35% 32%, #e8fff1, #00e676 46%, #0b6b32 80%);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.4),
        0 0 0 3px #0a0c12,
        0 0 18px rgba(0, 230, 118, 0.9);
}
.kg-count b {
    min-height: 1.15em;
    font-size: 34px;
    letter-spacing: 0.22em;
    font-weight: 900;
}
.kg-count b.is-go {
    color: #d8ffe8;
    text-shadow: 0 0 22px rgba(0, 230, 118, 0.85);
}
@media (max-width: 720px) {
    .kg-lights { gap: 8px; padding: 10px 12px; }
    .kg-lights span { width: 26px; height: 26px; }
    .kg-count b { font-size: 28px; }
}
.kg-gboy {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 7;
    display: none;
    padding: 0 max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    pointer-events: none;
}
body.mobile-touch-device .kg-gboy:not([hidden]),
body.kg-compact-ui .kg-gboy:not([hidden]) { display: block; }
.kg-plate {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: end;
    pointer-events: none;
}
.kg-stick {
    width: clamp(108px, 26vh, 140px);
    height: clamp(108px, 26vh, 140px);
    border-radius: 50%;
    border: 2px solid rgba(0,229,255,0.4);
    background: radial-gradient(circle, rgba(10,22,44,0.35) 52%, rgba(0,229,255,0.1));
    position: relative;
    pointer-events: auto;
    touch-action: none;
    opacity: 0.55;
}
.kg-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #9af3ff, #0097b8 70%);
    pointer-events: none;
}
.kg-ab {
    display: flex;
    gap: 10px;
    align-items: end;
    pointer-events: auto;
}
.kg-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.45);
    color: #fff;
    font-weight: 900;
    font-size: 12px;
    pointer-events: auto;
}
.kg-btn-a { background: radial-gradient(circle at 35% 30%, #7af0ff, #0088aa 70%); width: 84px; height: 84px; }
.kg-btn-b { background: radial-gradient(circle at 35% 30%, #ffc266, #f06400 70%); }
.kg-btn-item { background: radial-gradient(circle at 35% 30%, #ffe082, #c9a227 70%); color: #1a1400; }
.kg-btn-r {
    background: radial-gradient(circle at 35% 30%, #ff8ad4, #c2185b 72%);
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
}
.kg-btn-r.is-on { transform: translateY(2px); filter: brightness(1.15); }
#kartGuardiansContainer .kg-gboy:not([hidden]) { display: block; }
.kg-end h2 { font-size: 2rem; margin: 0 0 8px; }
.kg-end .kg-rank { color: #ffd54f; font-weight: 900; margin-bottom: 12px; }
.kg-end {
    padding: 16px;
    background: #04060e;
    align-items: flex-end;
}
.kg-end-art {
    position: absolute;
    inset: 0;
    background: url("../img/kart/kg-end.jpg") center / cover no-repeat;
}
.kg-end .kg-card {
    position: relative;
    z-index: 1;
    width: min(460px, 94vw);
    margin-bottom: max(8px, env(safe-area-inset-bottom));
    background: linear-gradient(165deg, rgba(6, 10, 22, 0.84), rgba(4, 8, 18, 0.92));
}
.kg-end .kg-tip { color: #ffe082; font-weight: 700; }
.kg-end-actions { display: grid; gap: 8px; }
@media (orientation: landscape) {
    .kg-end-art { background-image: url("../img/kart/kg-end-wide.jpg"); }
    .kg-end { align-items: center; }
}
@media (orientation: landscape) and (max-height: 520px) {
    .kg-end .kg-card { width: min(520px, 68vw); padding: 10px 14px; }
    .kg-end .kg-card h2 { font-size: 1.25rem; margin: 0; }
    .kg-end .kg-card p { margin: 0 0 8px; font-size: 0.8rem; }
    .kg-end .kg-again { padding: 8px; }
}

@media (max-width: 720px) {
    .kg-roster { grid-template-columns: repeat(2, 1fr); }
    .kg-mini { width: 96px; height: 96px; }
}
body.kg-compact-ui .kg-place,
body.mobile-touch-device .kg-place { position: static; bottom: auto; }
body.kg-compact-ui .kg-mini,
body.mobile-touch-device .kg-mini { bottom: 128px; }

@media (orientation: landscape) {
    body.mobile-touch-device[data-active-section="kartGuardiansContainer"] .kg-gboy,
    body.kg-compact-ui[data-active-section="kartGuardiansContainer"] .kg-gboy {
        background: transparent;
    }
}

@media (orientation: portrait) and (max-width: 900px) {
    .kg-faces {
        max-width: calc(100% - 118px);
        gap: 3px;
    }
    .kg-face {
        width: 26px;
        height: 26px;
        flex-basis: 26px;
    }
    .kg-topbar {
        top: calc(max(6px, env(safe-area-inset-top)) + 32px);
        left: 8px;
        right: 58px;
        transform: none;
        width: auto;
        max-width: none;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 4px 8px;
    }
    .kg-lap-big,
    .kg-time { font-size: 13px; }
    .kg-place { font-size: 18px; }
    .kg-item { width: 40px; height: 40px; }
    .kg-nitro span { font-size: 9px; letter-spacing: 0.06em; }
    .kg-nitro-track { width: 72px; height: 10px; }
    .kg-back { font-size: 10px; padding: 6px 8px; }
    .kg-sign { width: 34px; height: 34px; }
    .kg-mini,
    body.mobile-touch-device .kg-mini,
    body.kg-compact-ui .kg-mini {
        width: 64px;
        height: 64px;
        right: max(8px, env(safe-area-inset-right));
        bottom: auto;
        top: calc(max(8px, env(safe-area-inset-top)) + 108px);
    }
    .kg-stick { width: 92px; height: 92px; }
    .kg-knob { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
    .kg-ab { gap: 6px; }
    .kg-btn { width: 50px; height: 50px; font-size: 10px; }
    .kg-btn-a { width: 58px; height: 58px; }
}

.kg-settings {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(2, 6, 16, 0.62);
}
.kg-settings[hidden] { display: none !important; }
.kg-settings-card {
    width: min(360px, 92vw);
    padding: 16px 16px 14px;
    border-radius: 16px;
    background: linear-gradient(165deg, rgba(8, 18, 36, 0.96), rgba(4, 8, 18, 0.98));
    border: 1px solid rgba(0, 229, 255, 0.4);
    box-shadow: 0 18px 50px rgba(0,0,0,0.5);
    position: relative;
}
.kg-settings-card h3 {
    margin: 0 0 12px;
    letter-spacing: 0.12em;
    font-size: 1rem;
}
.kg-settings-x {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: transparent;
    color: #fff;
    cursor: pointer;
}
.kg-settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    font-weight: 700;
}
.kg-settings-apply {
    width: 100%;
    margin-top: 6px;
    padding: 11px;
    border: 0;
    border-radius: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
    cursor: pointer;
    background: linear-gradient(90deg, #00e5ff, #7c4dff);
    color: #041018;
}
body.kg-play-fs[data-active-section="kartGuardiansContainer"] #gameScreen,
body.kg-play-fs[data-active-section="kartGuardiansContainer"] #kartGuardiansContainer,
body.kg-play-fs[data-active-section="kartGuardiansContainer"] .kg-shell {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    z-index: 80;
}
