body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#error-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: black;
    z-index: 50;
}

.error-window {
    width: min(720px, calc(100vw - 40px));
    text-align: center;
}

#error-message {
    margin: 0;
    color: #ff4d4d;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 0.2px;
}

canvas {
    width: 100%;
    height: 100vh;
    display: block;
}

#fps-overlay {
    position: fixed;
    top: 24px;
    left: 26px;
    z-index: 15;
    padding: 0;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2px;
    text-shadow:
        0 1px 1px rgba(0, 0, 0, 0.85),
        0 0 1px rgba(0, 0, 0, 0.85),
        0 2px 8px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    user-select: none;
}



/* Bottom viewer controls (YouTube-like) */
#bottom-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    z-index: 16;
    pointer-events: none; /* allow scene interaction except on buttons */
}

#bottom-controls-left,
#bottom-controls-right {
    display: flex;
    align-items: center;
    gap: 16px;
    pointer-events: none;
    margin: 12px 12px;
}

#bottom-controls-left .viewer-btn,
#bottom-controls-right .viewer-btn {
    pointer-events: auto;
}

.viewer-btn {
    pointer-events: auto;
    border: none;
    background: none;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(6px);
}

.viewer-btn:hover {
    transform: scale(1.1);
    transition: transform 0.15s ease;
}

.viewer-btn:active {
    transform: translateY(1px);
}

.viewer-btn-icon {
    width: 23px;
    height: 23px;
    opacity: 0.92;
    filter:
        drop-shadow(0 1px 1px rgba(0, 0, 0, 0.85))
        drop-shadow(0 0 1px rgba(0, 0, 0, 0.85));
}


#loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(40,40,40,1.0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.loading-window {
    background: #222;
    color: #fff;
    padding: 32px 48px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 32px rgba(255,255,255,0.1);
}

#loading-bar-container {
    width: 320px;
    height: 18px;
    background: #444;
    border-radius: 9px;
    margin: 24px auto 8px auto;
    overflow: hidden;
}

#loading-bar {
    height: 100%;
    width: 0%;
    background: #3a7cff;
    border-radius: 9px;
    transition: width 0.2s;
}


#load-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(30,30,30,1.0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.load-window {
    background: #222;
    color: #fff;
    padding: 48px 64px;
    border-radius: 12px;
    text-align: center;
    user-select: none;
}

.load-window h1 {
    font-size: 2.5em;
    margin: 0 0 16px 0;
    font-weight: bold;
    color: #3a7cff;
}

.load-window p {
    font-size: 1.2em;
    margin-bottom: 32px;
    opacity: 0.8;
}

.load-window .scene-info {
    font-size: 0.9em;
    margin-bottom: 16px;
    color: #3a7cff;
    font-weight: bold;
}

.load-window button {
    padding: 12px 32px;
    font-size: 1.2em;
    border-radius: 8px;
    border: none;
    background: #3a7cff;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
}

.load-window button:hover {
    background: #255bb5;
}


#start-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(40,40,40,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.start-window {
    background: rgba(123, 123, 123, 0.8);
    color: #fff;
    padding: 48px 64px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 32px rgba(0,0,0,0.3);
    user-select: none;
}

.start-window h1 {
    font-size: 2em;
    margin: 0;
    font-weight: bold;
    letter-spacing: 2px;
}


/* Info modal (separate from pause) */
#info-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25;
}

/* Settings modal (same style as info) */
#settings-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25;
}

.info-window {
    width: min(560px, calc(100vw - 32px));
    background: rgba(25, 25, 25, 0.92);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 22px 22px 18px 22px;
    box-shadow: 0 12px 60px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    position: relative;
}

.settings-window {
    width: min(560px, calc(100vw - 32px));
    background: rgba(25, 25, 25, 0.92);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 22px 22px 18px 22px;
    box-shadow: 0 12px 60px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    position: relative;
}

.info-window h2 {
    margin: 0 0 12px 0;
    font-size: 20px;
    letter-spacing: 0.5px;
}

.settings-window h2 {
    margin: 0 0 12px 0;
    font-size: 20px;
    letter-spacing: 0.5px;
}

.info-content {
    font-size: 14px;
    line-height: 1.5;
    opacity: 0.95;
}

.settings-content {
    font-size: 14px;
    line-height: 1.5;
    opacity: 0.95;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-row:first-child {
    border-top: none;
    padding-top: 0;
}

.settings-row label {
    user-select: none;
}

.settings-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #3a7cff;
}

.settings-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: #181c22;
    color: #fff;
    border: 1px solid rgba(58, 124, 255, 0.85);
    border-radius: 8px;
    padding: 8px 36px 8px 10px;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    min-width: 160px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.25);
    background-image:
        linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.85) 50%),
        linear-gradient(135deg, rgba(255,255,255,0.85) 50%, transparent 50%),
        linear-gradient(to right, rgba(255,255,255,0.10), rgba(255,255,255,0.10));
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 12px) 50%,
        calc(100% - 32px) 50%;
    background-size: 6px 6px, 6px 6px, 1px 60%;
    background-repeat: no-repeat;
}

.settings-select:hover {
    border-color: #3a7cff;
}

.settings-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(58, 124, 255, 0.25);
}

.info-content ul {
    margin: 10px 0 0 18px;
    padding: 0;
}

.info-content li {
    margin: 6px 0;
}

.info-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.25);
    color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    font-size: 24px;
    line-height: 38px;
    text-align: center;
}

.settings-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.25);
    color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    font-size: 24px;
    line-height: 38px;
    text-align: center;
}

.info-close:hover {
    background: rgba(0, 0, 0, 0.45);
}

.settings-close:hover {
    background: rgba(0, 0, 0, 0.45);
}

.settings-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-slider {
    accent-color: #3a7cff;
    margin: 0 8px;
    vertical-align: middle;
    height: 4px;
    border-radius: 5px;
    background: linear-gradient(90deg, #3a7cff 0%, #255bb5 100%);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.settings-number {
    background: #181c22;
    color: #fff;
    border: 1px solid #3a7cff;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 1em;
    margin-left: 4px;
    text-align: left;
    width: 90px;
}

/* Mobile virtual joystick */
#mobile-controls {
    position: fixed;
    bottom: 75px;
    left: 75px;
    display: none;
    z-index: 15;
}

.virtual-joystick {
    position: relative;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    touch-action: none;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.virtual-joystick.active {
    opacity: 1;
}

.joystick-knob {
    position: absolute;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: background 0.1s;
}

/* .virtual-joystick.active .joystick-knob {
    background: rgba(58, 124, 255, 0.8);
} */