/* In-game UI elements */
#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0s 0.5s;
}

#sigil-debug-container {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 170;
}

.sigil-debug-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--ds-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(162, 179, 214, 0.3);
    background: rgba(8, 12, 24, 0.78);
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.45);
    transition:
        border-color 0.34s ease,
        box-shadow 0.34s ease,
        background 0.34s ease,
        transform 0.3s ease;
}

.sigil-debug-icon img {
    width: 72%;
    height: 72%;
    object-fit: contain;
    filter: grayscale(1) brightness(0.46) contrast(0.92);
    opacity: 0.9;
    transition: filter 0.34s ease, opacity 0.34s ease;
}

.sigil-debug-icon.is-active {
    border-color: rgba(253, 223, 152, 0.8);
    background: radial-gradient(circle at 40% 28%, rgba(171, 109, 255, 0.78), rgba(68, 31, 120, 0.92));
    box-shadow:
        0 0 0 1px rgba(255, 225, 160, 0.34),
        0 0 14px rgba(236, 186, 83, 0.5),
        0 0 30px rgba(163, 100, 255, 0.35);
    transform: translateY(-1px);
}

.sigil-debug-icon.is-inactive {
    border-color: rgba(104, 114, 145, 0.32);
    background: rgba(6, 10, 20, 0.86);
}

.sigil-debug-icon.is-active img {
    filter: grayscale(0) brightness(1.07) saturate(1.2) drop-shadow(0 0 8px rgba(255, 225, 140, 0.45));
    opacity: 1;
}

#sigil-toast {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translate(-50%, -8px);
    padding: 8px 14px;
    border-radius: var(--ds-radius-pill);
    font-family: var(--ds-font-display);
    font-weight: 700;
    font-size: clamp(0.78rem, 1.15vw, 0.96rem);
    letter-spacing: 0.5px;
    color: rgba(245, 226, 181, 0.96);
    background: rgba(16, 22, 43, 0.75);
    border: 1px solid rgba(236, 201, 126, 0.36);
    box-shadow: 0 0 14px rgba(235, 188, 86, 0.14);
    opacity: 0;
    filter: blur(3px);
    pointer-events: none;
    transition: opacity 0.34s ease, transform 0.34s ease, filter 0.34s ease;
    white-space: nowrap;
}

#sigil-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
    filter: blur(0);
}

#now-playing-banner {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    --now-playing-fade-ms: 4000ms;
    z-index: 250;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 16px;
    padding: 4px 8px;
    border-radius: var(--ds-radius-pill);
    background: rgba(8, 14, 30, 0.52);
    border: 1px solid rgba(161, 184, 238, 0.28);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.35);
    opacity: 0;
    filter: blur(1.8px);
    transition: opacity 0.35s ease, filter 0.35s ease;
}

#now-playing-banner.is-visible {
    opacity: 1;
    filter: blur(0);
}

#now-playing-banner.is-visible.is-fading {
    opacity: 0;
    filter: blur(1.8px);
    transition: opacity var(--now-playing-fade-ms) linear, filter var(--now-playing-fade-ms) ease-out;
}

#now-playing-icon {
    color: rgba(220, 233, 255, 0.9);
    font-family: var(--ds-font-label);
    font-size: 10px;
    line-height: 1;
    text-shadow: 0 0 6px rgba(169, 194, 255, 0.4);
    display: inline-block;
    animation: now-playing-icon-pulse 1.45s ease-in-out infinite;
}

#now-playing-icon.is-pause {
    color: rgba(255, 236, 178, 0.96);
    text-shadow: 0 0 8px rgba(255, 224, 138, 0.5);
}

#now-playing-text {
    color: rgba(224, 234, 255, 0.92);
    font-family: var(--ds-font-label);
    font-size: 8px;
    letter-spacing: 0.35px;
    line-height: 1;
    white-space: nowrap;
    text-transform: uppercase;
}

.now-playing-char {
    display: inline-block;
    opacity: 0;
    animation: now-playing-char-reveal 0.34s ease forwards, now-playing-char-wash 2.8s ease-in-out infinite;
}

@keyframes now-playing-icon-pulse {
    0%, 100% {
        transform: translateY(0) scale(1);
        filter: brightness(0.98);
    }
    50% {
        transform: translateY(-1px) scale(1.08);
        filter: brightness(1.14);
    }
}

@keyframes now-playing-char-reveal {
    from {
        opacity: 0;
        filter: blur(2.4px);
        transform: translateY(2px);
    }
    to {
        opacity: 1;
        filter: blur(0);
        transform: translateY(0);
    }
}

@keyframes now-playing-char-wash {
    0%, 100% {
        color: rgba(208, 222, 255, 0.85);
        text-shadow: 0 0 0 rgba(232, 244, 255, 0);
    }
    42% {
        color: rgba(255, 249, 219, 0.98);
        text-shadow: 0 0 8px rgba(255, 235, 177, 0.5);
    }
}

#score, #combo {
    padding: 20px;
    font-size: 2em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
    display: none; /* Hide HUD elements by default */
}

#core-status {
    position: absolute;
    bottom: 20px;
    text-align: center;
    width: 100%;
    font-size: 1.5em;
    display: none; /* Hide HUD elements by default */
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
}

#level-progress {
    position: absolute;
    top: 18px;
    right: 16px;
    width: min(340px, 44vw);
    display: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#level-progress.is-visible {
    opacity: 1;
    transform: translateY(0);
}

#level-progress-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-family: var(--ds-font-label);
    font-size: clamp(0.42rem, 0.75vw, 0.56rem);
    letter-spacing: 0.24px;
    color: rgba(224, 236, 255, 0.92);
}

#level-progress-track {
    position: relative;
    width: 100%;
    height: 10px;
    border-radius: var(--ds-radius-pill);
    overflow: hidden;
    background: rgba(8, 12, 24, 0.7);
    border: 1px solid rgba(172, 190, 233, 0.36);
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.48);
}

#level-progress-wave,
#level-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    transition: width 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

#level-progress-wave {
    background: linear-gradient(90deg, rgba(84, 241, 214, 0.24), rgba(134, 255, 236, 0.28));
}

#level-progress-fill {
    background: linear-gradient(90deg, rgba(126, 174, 255, 0.92), rgba(188, 227, 255, 0.95));
    box-shadow: 0 0 10px rgba(130, 183, 255, 0.42);
}

/* Run-timer sits to the right of the 42×42 #sigil-debug-container at top:12/left:12.
   Push it past the icon (12 + 42 + 8 = 62) so the two HUD widgets don't visually
   stack on top of each other in the top-left corner. */
#run-timer {
    position: absolute;
    top: 12px;
    left: 64px;
    min-width: 130px;
    display: none;
    opacity: 0;
    transform: translateY(-4px);
    border-radius: var(--ds-radius-sm);
    border: 1px solid rgba(173, 194, 240, 0.38);
    background: rgba(7, 12, 24, 0.72);
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
    padding: 6px 8px 7px;
    transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

#run-timer.is-visible {
    opacity: 1;
    transform: translateY(0);
}

#run-timer-label {
    font-family: var(--ds-font-label);
    font-size: clamp(0.35rem, 0.52vw, 0.44rem);
    letter-spacing: 0.16px;
    color: rgba(194, 211, 245, 0.84);
}

#run-timer-value {
    margin-top: 3px;
    font-family: var(--ds-font-label);
    font-size: clamp(0.5rem, 0.72vw, 0.62rem);
    letter-spacing: 0.24px;
    color: rgba(232, 242, 255, 0.96);
}

#run-timer-target {
    margin-top: 4px;
    font-family: var(--ds-font-label);
    font-size: clamp(0.33rem, 0.44vw, 0.4rem);
    letter-spacing: 0.14px;
    color: rgba(174, 194, 234, 0.86);
}

#run-timer.is-over-target {
    border-color: rgba(255, 105, 122, 0.68);
    box-shadow: inset 0 0 12px rgba(126, 16, 36, 0.44), 0 0 10px rgba(228, 56, 85, 0.24);
}

#fps-monitor {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translate(-50%, -4px);
    min-width: 150px;
    text-align: center;
    display: block;
    opacity: 0;
    border-radius: var(--ds-radius-sm);
    border: 1px solid rgba(173, 194, 240, 0.36);
    background: rgba(6, 11, 22, 0.7);
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
    padding: 6px 12px 7px;
    pointer-events: auto;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    z-index: 50;
}

#fps-monitor.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

#fps-monitor.is-warn {
    border-color: rgba(255, 184, 96, 0.7);
    box-shadow: inset 0 0 10px rgba(120, 60, 0, 0.45), 0 0 10px rgba(255, 170, 90, 0.18);
}

#fps-monitor.is-bad {
    border-color: rgba(255, 100, 120, 0.78);
    box-shadow: inset 0 0 12px rgba(120, 0, 30, 0.5), 0 0 12px rgba(255, 80, 110, 0.22);
}

#fps-monitor-main {
    font-family: var(--ds-font-label);
    font-size: clamp(0.55rem, 0.85vw, 0.78rem);
    letter-spacing: 0.22px;
    color: rgba(226, 238, 255, 0.96);
}

#fps-monitor.is-warn #fps-monitor-main { color: #ffd07a; }
#fps-monitor.is-bad #fps-monitor-main { color: #ff8a96; }

#fps-monitor-meta {
    margin-top: 4px;
    font-family: var(--ds-font-label);
    font-size: clamp(0.3rem, 0.42vw, 0.38rem);
    letter-spacing: 0.12px;
    color: rgba(181, 202, 243, 0.86);
}

#fps-monitor-detail {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(173, 194, 240, 0.25);
    text-align: left;
    font-family: var(--ds-font-label);
    font-size: clamp(0.28rem, 0.4vw, 0.36rem);
    color: rgba(200, 218, 248, 0.92);
    letter-spacing: 0.1px;
    min-width: 170px;
}

.fps-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 1px 0;
}

.fps-detail-row span:first-child {
    color: rgba(173, 194, 240, 0.78);
}

.fps-detail-hint {
    margin-top: 5px;
    color: rgba(150, 170, 220, 0.55);
    font-size: 0.84em;
    text-align: center;
}

#level-text {
    display: none; 
    font-size: 3em; 
    text-align: center; 
    position: absolute; 
    top: 40%; 
    left: 50%; 
    transform: translate(-50%, -50%);
}

#level-text.flash {
    animation: flash 0.5s 3;
}

/* Debug info */
#debug-info {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
    border-radius: var(--ds-radius-xs);
    font-family: monospace;
    font-size: 12px;
    z-index: 150;
    display: none;
}

/* Mobile pause button */
#mobile-pause-button {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background-color: rgba(20, 20, 40, 0.8);
    border: 2px solid #4a4a8a;
    border-radius: var(--ds-radius-md);
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 160;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
    backdrop-filter: blur(5px);
}

#mobile-pause-button:hover {
    background-color: rgba(40, 40, 60, 0.9);
    border-color: #6a6aff;
}

body.ui-on #level-progress {
    display: block;
}

body.ui-on #run-timer {
    display: block;
}

#pause-icon {
    width: 20px;
    height: 20px;
    position: relative;
}

#pause-icon::before, 
#pause-icon::after {
    content: '';
    position: absolute;
    background-color: #c58aff;
    width: 4px;
    height: 16px;
    border-radius: var(--ds-radius-xs);
}

#pause-icon::before {
    left: 4px;
}

#pause-icon::after {
    right: 4px;
}

/* Virtual joystick */
#joystick-container {
    position: absolute;
    bottom: 80px;
    left: 30px;
    width: 150px;
    height: 150px;
    z-index: 150;
    opacity: 0.5;
    display: none; /* Hidden by default */
}

#joystick-base, #joystick-handle { 
    border-radius: 50%; 
}

#joystick-base { 
    position: relative; 
    width: 100%; 
    height: 100%; 
    background: rgba(80, 80, 120, 0.4); 
    border: 2px solid rgba(150, 150, 200, 0.3); 
}

#joystick-handle { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    width: 60px; 
    height: 60px; 
    background: rgba(150, 150, 200, 0.6); 
    transform: translate(-50%, -50%); 
    border: 2px solid rgba(200, 200, 255, 0.5);
}
