/* =================================================================================
 * COSMIC SERENITY - Odyssey UI AAA layer (legacy base)
 * ---------------------------------------------------------------------------------
 * What is left of the old Odyssey layer: the navigator's show/hide base and the
 * in-game HUD's layout. The Keystone look for every Odyssey surface lives in
 * keystone-overlays.css; the old preview/results/level-card rules are gone with the
 * markup they styled. .winner-label, .host-hint and .match-results-winner style the
 * multiplayer match results and move with that surface.
 * ============================================================================== */

.odyssey-level-select,
#odyssey-hud {
    --cs-accent: var(--cs-violet);
    --cs-accent-rgb: var(--cs-violet-rgb);
    --cs-accent-2: var(--cs-indigo);
    --ody-success: var(--cs-teal);
    --ody-success-rgb: var(--cs-teal-rgb);
    --ody-danger: #ff8f9a;
    --ody-danger-rgb: 255, 143, 154;
    --ody-gold: var(--cs-gold);
    --ody-gold-rgb: var(--cs-gold-rgb);
    --ody-panel: rgba(10, 13, 27, 0.76);
    --ody-panel-strong: rgba(8, 10, 23, 0.90);
    --ody-border: rgba(var(--cs-soft-rgb), 0.18);
    --ody-muted: rgba(211, 219, 245, 0.58);
    --ody-text: var(--cs-ink);
    font-family: 'Orbitron', 'Segoe UI', sans-serif;
    color: var(--ody-text);
}

.odyssey-level-select {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    background:
        radial-gradient(90% 62% at 50% -10%, rgba(var(--cs-accent-rgb), 0.18), transparent 62%),
        radial-gradient(80% 72% at 8% 4%, rgba(127, 220, 255, 0.08), transparent 64%),
        linear-gradient(180deg, rgba(9, 11, 24, 0.98), rgba(4, 6, 16, 0.985));
}

.odyssey-level-select.is-visible {
    display: flex;
    animation: ody-surface-in 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.odyssey-level-select::before {
    content: '';
    position: absolute;
    inset: 18px;
    border: 1px solid rgba(var(--cs-accent-rgb), 0.18);
    border-radius: 24px;
    pointer-events: none;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 0 72px rgba(var(--cs-accent-rgb), 0.08);
}

.chapter-progress {
    padding: 16px;
    border: 1px solid rgba(var(--cs-soft-rgb), 0.12);
    border-radius: 14px;
    background: rgba(5, 8, 20, 0.42);
}

.odyssey-hud .progress-track {
    height: 8px;
    margin: 12px 0 14px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.36);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.34);
}

.level-stars {
    height: 24px;
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 10px;
}

.level-name {
    margin: 0 0 8px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#odyssey-hud::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(var(--cs-accent-rgb), 0.55), rgba(255, 255, 255, 0.04) 38%, rgba(127, 220, 255, 0.24) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.72;
    z-index: 1;
}

#odyssey-hud > * {
    position: relative;
    z-index: 2;
}

.winner-label,
.host-hint {
    color: rgba(var(--cs-accent-rgb), 0.78);
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.match-results-winner {
    border: 1px solid rgba(var(--cs-soft-rgb), 0.14);
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(8, 10, 23, 0.46)),
        rgba(5, 8, 20, 0.38);
    color: rgba(232, 237, 255, 0.74);
}

#odyssey-hud {
    position: absolute;
    width: clamp(210px, 17vw, 260px);
    max-height: calc(100vh - 120px);
    display: none;
    overflow: hidden;
    box-sizing: border-box;
    z-index: 10;
    padding: clamp(12px, 1.5vw, 18px);
    border: 1px solid rgba(var(--cs-accent-rgb), 0.26);
    border-radius: 18px;
    background:
        radial-gradient(100% 58% at 50% -18%, rgba(var(--cs-accent-rgb), 0.12), transparent 62%),
        linear-gradient(180deg, rgba(16, 20, 38, 0.90), rgba(8, 10, 23, 0.94));
    box-shadow:
        0 16px 44px rgba(0, 0, 0, 0.48),
        0 0 0 1px rgba(255, 255, 255, 0.04),
        0 0 60px rgba(var(--cs-accent-rgb), 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#odyssey-hud.is-visible {
    display: block;
    animation: ody-hud-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#odyssey-hud.is-victory-lap {
    --cs-accent: var(--cs-teal);
    --cs-accent-rgb: var(--cs-teal-rgb);
    --cs-accent-2: var(--cs-gold);
    box-shadow:
        0 16px 44px rgba(0, 0, 0, 0.48),
        0 0 0 1px rgba(255, 255, 255, 0.04),
        0 0 72px rgba(var(--cs-accent-rgb), 0.20),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.odyssey-hud .hud-section {
    margin-bottom: clamp(8px, 1vw, 12px);
    padding-bottom: clamp(6px, 0.8vw, 10px);
    border-bottom: 1px solid rgba(var(--cs-accent-rgb), 0.16);
}

.odyssey-hud .hud-section:last-child {
    margin-bottom: 0;
    border-bottom: 0;
}

.odyssey-hud .header-section {
    text-align: center;
}

.odyssey-hud .chapter-label,
.odyssey-hud .hud-label {
    color: rgba(211, 219, 245, 0.58);
    font-family: 'Space Mono', monospace;
    font-size: clamp(7px, 0.7vw, 9px);
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.odyssey-hud .level-name {
    margin: 4px 0 0;
    color: #fff;
    white-space: normal;
    font-size: clamp(12px, 1.2vw, 15px);
    text-shadow: 0 0 15px rgba(var(--cs-accent-rgb), 0.42);
}

.odyssey-hud .level-badge {
    display: inline-block;
    margin-top: 7px;
    padding: 3px 10px;
    border: 1px solid rgba(var(--cs-accent-rgb), 0.40);
    border-radius: 999px;
    background: rgba(var(--cs-accent-rgb), 0.13);
    color: var(--cs-accent);
    font-family: 'Space Mono', monospace;
    font-size: clamp(8px, 0.8vw, 10px);
    font-weight: 800;
}

.odyssey-hud .objective-text {
    margin: 5px 0 6px;
    color: var(--cs-cyan);
    font-size: clamp(10px, 1vw, 13px);
    font-weight: 800;
}

.odyssey-hud .progress-value {
    color: #fff;
    text-align: center;
    font-size: clamp(16px, 1.8vw, 22px);
    font-weight: 900;
    text-shadow: 0 0 15px rgba(var(--cs-cyan-rgb), 0.44);
}

.odyssey-hud .progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--cs-cyan), var(--cs-violet), var(--cs-pink));
    box-shadow: 0 0 12px rgba(var(--cs-accent-rgb), 0.54);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.24s ease, box-shadow 0.24s ease;
}

.odyssey-hud .progress-fill.is-complete,
#odyssey-hud.is-victory-lap .progress-fill {
    background: linear-gradient(90deg, var(--cs-teal), var(--cs-gold), var(--cs-teal));
    background-size: 200% 100%;
    animation: victoryLapShimmer 2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(var(--ody-success-rgb), 0.70);
}

.odyssey-hud .time-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.odyssey-hud .time-value {
    color: #fff;
    font-family: 'Space Mono', monospace;
    font-size: clamp(14px, 1.4vw, 18px);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.odyssey-hud .time-value.is-warning {
    color: var(--ody-gold);
    text-shadow: 0 0 10px rgba(var(--ody-gold-rgb), 0.46);
}

.odyssey-hud .time-value.is-danger {
    color: var(--ody-danger);
    text-shadow: 0 0 10px rgba(var(--ody-danger-rgb), 0.72);
}

.odyssey-hud .stars-list,
.odyssey-hud .bonuses-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 6px;
}

.odyssey-hud .star-row,
.odyssey-hud .bonus-item {
    display: flex;
    align-items: center;
    gap: 7px;
    color: rgba(211, 219, 245, 0.62);
    font-size: clamp(8px, 0.8vw, 10px);
    opacity: 0.56;
    transition: opacity 0.24s ease, color 0.24s ease, filter 0.24s ease;
}

.odyssey-hud .star-row.earned {
    color: #fff1bf;
    opacity: 1;
}

.odyssey-hud .star-row.earned .star-icon {
    filter: drop-shadow(0 0 7px rgba(var(--ody-gold-rgb), 0.76));
}

.odyssey-hud .star-icon path {
    fill: rgba(var(--ody-gold-rgb), 0.14);
    stroke: rgba(var(--ody-gold-rgb), 0.42);
}

.odyssey-hud .star-row.earned .star-icon path {
    fill: var(--ody-gold);
    stroke: #ffe9a8;
}

.odyssey-hud .bonus-empty {
    color: rgba(211, 219, 245, 0.42);
    font-size: clamp(9px, 0.9vw, 11px);
    font-style: italic;
}

.odyssey-hud .bonus-checkbox {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(var(--cs-accent-rgb), 0.45);
    border-radius: 5px;
    transition: border-color 0.24s ease, background 0.24s ease;
}

.odyssey-hud .bonus-item.is-complete {
    color: var(--ody-success);
    opacity: 1;
}

.odyssey-hud .bonus-item.is-complete .bonus-checkbox {
    border-color: rgba(var(--ody-success-rgb), 0.78);
    background: rgba(var(--ody-success-rgb), 0.18);
}

.finish-hint {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(var(--ody-success-rgb), 0.28);
    color: rgba(232, 237, 255, 0.72);
    text-align: center;
    font-size: clamp(9px, 0.9vw, 11px);
    animation: victoryLapPulse 2s ease-in-out infinite;
}

.finish-hint.is-visible {
    display: block;
}

@keyframes ody-surface-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ody-hud-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes victoryLapShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes victoryLapPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .odyssey-level-select.is-visible,
    #odyssey-hud.is-visible,
    .finish-hint,
    .odyssey-hud .progress-fill.is-complete,
    #odyssey-hud.is-victory-lap .progress-fill {
        animation: none !important;
    }
}
