body {
    margin: 0;
    overflow: hidden;
    background-color: #000;
    font-family: 'Courier New', Courier, monospace;
}

#blocker {
    position: absolute;
    z-index: 10;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(90deg, rgba(0,0,0,0.78), rgba(0,0,0,0.28), rgba(0,0,0,0.86)),
        url("textures/lobby_bg.png") center / cover no-repeat;
}

#instructions {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    text-align: center;
    background: rgba(0,0,0,0.28);
    padding: 24px;
    box-sizing: border-box;
}

.title {
    font-size: 46px;
    letter-spacing: 0;
    color: #ffe08a;
    text-shadow: 0 0 18px #000, 0 2px 2px #000;
}

.sub {
    font-size: 24px;
    color: #fff3bd;
    margin-top: 12px;
}

.controls {
    margin-top: 12px;
    color: #d6c891;
    font-size: 15px;
}

#playerName {
    width: min(320px, 86vw);
    min-height: 42px;
    margin-top: 18px;
    padding: 0 12px;
    border: 1px solid rgba(255, 224, 138, 0.42);
    border-radius: 6px;
    box-sizing: border-box;
    background: rgba(9, 8, 5, 0.72);
    color: #ffe08a;
    font-family: inherit;
    font-size: 16px;
    text-align: center;
    outline: none;
    pointer-events: auto;
}

#playerName:focus {
    border-color: #ffe08a;
    box-shadow: 0 0 0 2px rgba(255, 224, 138, 0.18);
}

#levelSelect {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 260px));
    gap: 12px;
    margin-top: 20px;
    pointer-events: auto;
}

.levelCard {
    min-height: 112px;
    padding: 16px;
    border: 1px solid rgba(255, 224, 138, 0.35);
    border-radius: 8px;
    background: rgba(9, 8, 5, 0.72);
    color: #f5e7b2;
    text-align: left;
    cursor: pointer;
}

.levelCard strong {
    display: block;
    color: #ffe08a;
    font-size: 17px;
    margin-bottom: 8px;
}

.levelCard span {
    display: block;
    color: #d0c295;
    font-size: 13px;
    line-height: 1.35;
}

.levelCard.active {
    border-color: #ffe08a;
    box-shadow: 0 0 0 2px rgba(255, 224, 138, 0.2), 0 0 24px rgba(255, 224, 138, 0.18);
}

#colorSelect {
    display: flex;
    gap: 12px;
    margin-top: 22px;
    pointer-events: auto;
}

.colorSwatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.55);
    background: var(--swatch);
    cursor: pointer;
}

.colorSwatch.active {
    outline: 3px solid #ffe08a;
    outline-offset: 3px;
}

#startBtn {
    margin-top: 22px;
    min-width: 180px;
    min-height: 44px;
    border: 1px solid #ffe08a;
    border-radius: 6px;
    background: #ffe08a;
    color: #141008;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    pointer-events: auto;
}

#loadingScreen {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    background: #050503;
    color: #ffe08a;
    font-family: 'Courier New', Courier, monospace;
}

#loadingScreen.active {
    display: flex;
}

.loadingBox {
    width: min(360px, calc(100vw - 44px));
    display: grid;
    gap: 12px;
    text-align: center;
}

.loadingTrack {
    height: 12px;
    border: 1px solid rgba(255, 224, 138, 0.36);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 224, 138, 0.08);
}

#loadingFill {
    width: 0%;
    height: 100%;
    background: #ffe08a;
}

#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    color: #f6df93;
    font-family: 'Courier New', Courier, monospace;
    text-shadow: 0 2px 4px #000;
}

#pickupPrompt {
    position: absolute;
    left: 50%;
    bottom: 20%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(246, 223, 147, 0.35);
    display: none;
}

#inventory {
    position: absolute;
    left: 18px;
    bottom: 16px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(246, 223, 147, 0.22);
}

#ticketHud {
    position: absolute;
    right: 18px;
    bottom: 16px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(246, 223, 147, 0.22);
}

#announcementHud {
    position: absolute;
    left: 50%;
    top: 18px;
    transform: translateX(-50%);
    width: min(560px, calc(100vw - 32px));
    padding: 9px 12px;
    background: rgba(0, 0, 0, 0.42);
    border: 1px solid rgba(246, 223, 147, 0.22);
    text-align: center;
    display: none;
}

#missionHud {
    position: absolute;
    left: 18px;
    top: 18px;
    width: min(520px, calc(100vw - 36px));
    padding: 9px 12px;
    display: none;
    background: rgba(20, 14, 6, 0.48);
    border: 1px solid rgba(255, 218, 137, 0.28);
    color: #ffe7a6;
    line-height: 1.35;
}

#mobileControls {
    position: fixed;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    display: none;
}

body:not(.gameStarted) #mobileControls {
    display: none;
}

.thumbstick {
    position: absolute;
    width: 138px;
    height: 138px;
    border: 1px solid rgba(255, 224, 138, 0.34);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.32);
    box-shadow: inset 0 0 24px rgba(255, 224, 138, 0.08);
    pointer-events: auto;
    touch-action: none;
}

.thumbstick span {
    position: absolute;
    inset: auto 0 12px;
    color: rgba(255, 224, 138, 0.55);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.stickKnob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 58px;
    height: 58px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(255, 224, 138, 0.18);
    border: 1px solid rgba(255, 224, 138, 0.38);
}

#moveStick {
    left: 20px;
    bottom: 24px;
}

#lookStick {
    right: 20px;
    bottom: 24px;
}

.mobileAction,
#backpackPanel button {
    min-height: 42px;
    border: 1px solid rgba(255, 224, 138, 0.38);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.5);
    color: #ffe08a;
    font-family: inherit;
    font-weight: 700;
    touch-action: none;
    pointer-events: auto;
}

.mobileAction {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 118px;
}

#mobileInteract {
    bottom: 98px;
}

#mobileBackpack {
    bottom: 44px;
}

#backpackPanel {
    position: absolute;
    right: 18px;
    top: 74px;
    width: min(260px, calc(100vw - 36px));
    padding: 12px;
    display: none;
    grid-template-columns: 1fr;
    gap: 9px;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(255, 224, 138, 0.34);
    border-radius: 8px;
    color: #ffe08a;
}

#backpackPanel.open {
    display: grid;
}

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

.backpackHeader strong {
    font-size: 15px;
}

#backpackClose {
    min-height: 30px;
    width: 34px;
    padding: 0;
}

#backpackPanel button:disabled {
    opacity: 0.42;
}

@media (pointer: coarse) {
    body.gameStarted #mobileControls {
        display: block;
    }

    #levelSelect {
        grid-template-columns: minmax(220px, 86vw);
    }

    .title {
        font-size: 34px;
    }
}

@media (max-width: 760px) {
    body.gameStarted #mobileControls {
        display: block;
    }

    #levelSelect {
        grid-template-columns: minmax(220px, 86vw);
    }

    #instructions {
        justify-content: flex-start;
        padding-top: 34px;
        overflow-y: auto;
    }

    .title {
        font-size: 34px;
    }

    .thumbstick {
        width: 122px;
        height: 122px;
    }

    .stickKnob {
        width: 52px;
        height: 52px;
    }

    #moveStick {
        left: 14px;
        bottom: 18px;
    }

    #lookStick {
        right: 14px;
        bottom: 18px;
    }

    .mobileAction {
        width: 104px;
        min-height: 40px;
        font-size: 12px;
    }

    #mobileInteract {
        bottom: 88px;
    }

    #mobileBackpack {
        bottom: 38px;
    }
}
