/* ── RESET & BASE ─────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    font-family: 'Nunito', sans-serif;
    background: #1a0533;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    touch-action: none;
    user-select: none;
}

/* ── CANVAS ────────────────────────────────────────────── */
canvas.webgl {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    outline: none;
    z-index: 1000;
}

/* ── SCREENS ───────────────────────────────────────────── */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}
.screen.hidden { display: none !important; }

#mainMenu {
    background: linear-gradient(135deg, #1a0533 0%, #2d0a5c 50%, #0d1f4a 100%);
    flex-direction: column;
}
#mainMenu::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 25%, rgba(255,80,180,.2) 0%, transparent 55%),
        radial-gradient(ellipse at 72% 75%, rgba(80,180,255,.18) 0%, transparent 55%);
    pointer-events: none;
}

/* ── MENU INNER ─────────────────────────────────────────── */
.menuInner {
    position: relative;
    z-index: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.gameTitle {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(3rem, 10vw, 7rem);
    background: linear-gradient(90deg, #ff6fd8, #ffcc44, #44eeff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 28px rgba(255,110,216,.5));
    letter-spacing: 4px;
    animation: titlePulse 3s ease-in-out infinite;
    margin-bottom: 6px;
}
@keyframes titlePulse {
    0%, 100% { filter: drop-shadow(0 0 28px rgba(255,110,216,.5)); }
    50%       { filter: drop-shadow(0 0 55px rgba(255,200,80,.7)); }
}

.gameSubtitle {
    color: rgba(255,255,255,.55);
    font-size: clamp(.8rem, 2.5vw, 1rem);
    letter-spacing: 5px;
    text-transform: uppercase;
    margin-bottom: 36px;
}

/* ── CARD ───────────────────────────────────────────────── */
.card {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.13);
    border-radius: 24px;
    backdrop-filter: blur(18px);
    padding: clamp(22px, 5vw, 40px);
    width: min(460px, 94vw);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.card.wide { width: min(640px, 96vw); max-height: 95vh; overflow-y: auto; }

.cardTitle {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(1.5rem, 5vw, 2rem);
    color: #fff;
    margin-bottom: 6px;
}
.cardSub {
    color: rgba(255,255,255,.45);
    font-size: .86rem;
    text-align: center;
}
.cardSub.hint { margin-bottom: 4px; }

/* ── BUTTONS ────────────────────────────────────────────── */
.menuBtn {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(.95rem, 3vw, 1.25rem);
    padding: 13px 40px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    width: 100%;
    letter-spacing: 1px;
    transition: transform .14s, box-shadow .14s, opacity .14s;
    touch-action: manipulation;
}
.menuBtn:hover  { transform: scale(1.05); }
.menuBtn:active { transform: scale(.96); }

.menuBtn.primary   { background: linear-gradient(135deg,#ff6fd8,#ff3cac); color:#fff; box-shadow:0 6px 26px rgba(255,60,172,.5); }
.menuBtn.secondary { background: linear-gradient(135deg,#44bbff,#0077ff); color:#fff; box-shadow:0 6px 26px rgba(0,119,255,.5); }
.menuBtn.success   { background: linear-gradient(135deg,#44ffaa,#00cc66); color:#0a3020; box-shadow:0 6px 26px rgba(0,204,102,.5); }
.menuBtn.danger    { background: linear-gradient(135deg,#ff6644,#cc2200); color:#fff; box-shadow:0 6px 18px rgba(204,34,0,.5); }
.menuBtn.back      { background: rgba(255,255,255,.1); color:rgba(255,255,255,.7); border:1px solid rgba(255,255,255,.2); font-size:.9rem; padding:10px 28px; }
.menuBtn.disabled  { background: rgba(255,255,255,.1); color:rgba(255,255,255,.3); cursor:not-allowed; box-shadow:none; }
.menuBtn.disabled:hover { transform: none; }

/* ── ROOM CODE ──────────────────────────────────────────── */
#roomCode {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2rem, 7vw, 3.2rem);
    letter-spacing: 10px;
    color: #ffcc44;
    background: rgba(255,200,68,.1);
    border: 2px dashed rgba(255,200,68,.4);
    border-radius: 16px;
    padding: 16px 24px;
    margin: 4px 0;
    text-align: center;
    width: 100%;
}

#waitList {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 50px;
    background: rgba(0,0,0,.18);
    border-radius: 14px;
    padding: 12px;
    width: 100%;
}
.waitChip {
    background: rgba(255,255,255,.1);
    border-radius: 100px;
    padding: 6px 14px;
    color: #fff;
    font-weight: 700;
    font-size: .84rem;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: chipIn .3s ease;
}
@keyframes chipIn { from{opacity:0;transform:scale(.7);} to{opacity:1;transform:scale(1);} }
.waitDot { width:9px; height:9px; border-radius:50%; }

/* ── FORM FIELDS ────────────────────────────────────────── */
.field {
    width: 100%;
    background: rgba(255,255,255,.08);
    border: 2px solid rgba(255,255,255,.2);
    border-radius: 12px;
    padding: 12px 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    color: #fff;
    outline: none;
    transition: border-color .2s;
}
.field::placeholder { color: rgba(255,255,255,.3); }
.field:focus        { border-color: #ff6fd8; }
.field.codeField {
    text-transform: uppercase;
    letter-spacing: 5px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    text-align: center;
}

#joinError { color: #ff6644; font-size: .88rem; text-align: center; min-height: 18px; }

/* ── CHARACTER GRID ─────────────────────────────────────── */
#charGrid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 10px 0;
}
.charCard {
    width: clamp(82px, 18vw, 106px);
    background: rgba(255,255,255,.06);
    border: 2px solid rgba(255,255,255,.15);
    border-radius: 18px;
    padding: 12px 6px 10px;
    cursor: pointer;
    text-align: center;
    transition: all .2s;
    touch-action: manipulation;
}
.charCard:hover  { border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.1); transform: translateY(-4px); }
.charCard.sel    { border-color: #ffcc44; background: rgba(255,200,68,.12); transform: translateY(-4px); box-shadow: 0 8px 26px rgba(255,200,68,.3); }
.charSwatch {
    width: 52px; height: 52px;
    border-radius: 10px;
    margin: 0 auto 8px;
    position: relative;
    transition: transform .3s;
}
.charCard:hover .charSwatch,
.charCard.sel   .charSwatch { transform: rotate(14deg) scale(1.1); }
.charSwatch::after {
    content: '';
    position: absolute;
    top: 6px; left: 6px;
    width: 14px; height: 14px;
    background: rgba(255,255,255,.35);
    border-radius: 4px;
}
.charName { font-family: 'Fredoka One', cursive; font-size: .84rem; color: rgba(255,255,255,.8); }

/* ── HUD ────────────────────────────────────────────────── */
#hud {
    position: fixed;
    top: 0; left: 0; right: 0;
    display: none;
    z-index: 1010;
    pointer-events: none;
    padding: 12px 14px;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
#hudLeft {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#hudCenter {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    pointer-events: all;
}
.hudBox {
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 8px 14px;
    border: 1px solid rgba(255,255,255,.1);
}
#hudNameWrap {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
#hudName {
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 8px 14px;
    border: 1px solid rgba(255,255,255,.1);
    font-family: 'Fredoka One', cursive;
    font-size: clamp(.9rem, 2.5vw, 1.1rem);
    color: #ffcc44;
}

#hudControls {
    font-size: clamp(.6rem, 1.5vw, .72rem);
    color: rgba(255,255,255,.42);
    line-height: 1.5;
    margin-top: 2px;
}
#hudSpeedWrap {
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 7px 14px;
    border: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: 8px;
}
#hudSpeedLabel {
    font-family: 'Fredoka One', cursive;
    font-size: .62rem;
    color: rgba(255,255,255,.42);
    letter-spacing: 2px;
}
#hudSpeedBarBg {
    width: 90px; height: 5px;
    background: rgba(255,255,255,.15);
    border-radius: 10px;
    overflow: hidden;
}
#hudSpeedBar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #44ffaa, #ffcc44, #ff3cac);
    border-radius: 10px;
    transition: width .1s;
}
#hudBrake {
    font-family: 'Fredoka One', cursive;
    font-size: .7rem;
    color: #ff6644;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    padding: 5px 12px;
    border: 1px solid rgba(255,100,70,.3);
    display: none;
}
#hudRight {
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 8px 14px;
    border: 1px solid rgba(255,255,255,.1);
    min-width: clamp(130px, 30vw, 180px);
}
#hudStandingsTitle {
    font-family: 'Fredoka One', cursive;
    color: rgba(255,255,255,.52);
    font-size: .65rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 5px;
}
.standingRow {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: clamp(.72rem, 2vw, .84rem);
    font-weight: 700;
    color: #fff;
}
.standingDot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.standingRank { font-family: 'Fredoka One', cursive; font-size: .68rem; color: rgba(255,255,255,.38); margin-left: auto; }
.standingRank.you { color: #ffcc44; }

/* ── PAUSE MENU ─────────────────────────────────────────── */
#pauseMenu { background: rgba(0,0,0,.72); backdrop-filter: blur(10px); z-index: 1030; }

/* ── FINISH OVERLAY ─────────────────────────────────────── */
#finishOverlay {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0,0,0,.82);
    backdrop-filter: blur(14px);
    z-index: 1050;
    padding: 24px;
}
#finishTitle {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2.4rem, 7vw, 4.5rem);
    color: #ffcc44;
    animation: popIn .5s cubic-bezier(.36,.07,.19,.97);
}
@keyframes popIn { 0%{transform:scale(0);opacity:0;} 80%{transform:scale(1.12);} 100%{transform:scale(1);opacity:1;} }
#finishPodium {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(420px, 94vw);
}
.podiumRow {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 14px;
    padding: 11px 18px;
    animation: slideIn .4s ease both;
}
@keyframes slideIn { from{opacity:0;transform:translateX(-28px);} to{opacity:1;transform:translateX(0);} }
.podiumRow.r1 { border-color:rgba(255,204,68,.6); background:rgba(255,204,68,.12); }
.podiumRow.r2 { border-color:rgba(200,200,220,.4); }
.podiumRow.r3 { border-color:rgba(200,140,60,.4); }
.podiumMedal { font-family:'Fredoka One',cursive; font-size:1.6rem; width:36px; text-align:center; flex-shrink:0; }
.podiumDot   { width:13px; height:13px; border-radius:50%; flex-shrink:0; }
.podiumName  { font-family:'Fredoka One',cursive; font-size:1.05rem; color:#fff; flex:1; }
.podiumYou   { font-size:.7rem; background:#ffcc44; color:#3a2000; padding:2px 8px; border-radius:20px; font-weight:800; }

#finishMenuBtn, #finishAgainBtn {
    font-family: 'Fredoka One', cursive;
    font-size: 1.15rem;
    padding: 12px 36px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform .14s;
}
#finishMenuBtn  { background:linear-gradient(135deg,#ff6fd8,#ff3cac); color:#fff; box-shadow:0 6px 24px rgba(255,60,172,.5); }
#finishAgainBtn { background:linear-gradient(135deg,#44bbff,#0077ff); color:#fff; box-shadow:0 6px 24px rgba(0,119,255,.4); }
#finishMenuBtn:hover, #finishAgainBtn:hover { transform:scale(1.06); }

/* ── MOBILE CONTROLS ────────────────────────────────────── */
#mobileControls {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 180px;
    z-index: 1020;
    pointer-events: none;
}
#joystickZone {
    position: absolute;
    left: 20px; bottom: 20px;
    width: 130px; height: 130px;
    pointer-events: all;
}
#joystickBase {
    width: 100%; height: 100%;
    background: rgba(255,255,255,.12);
    border: 2px solid rgba(255,255,255,.25);
    border-radius: 50%;
    position: relative;
}
#joystickKnob {
    width: 50px; height: 50px;
    background: rgba(255,255,255,.35);
    border-radius: 50%;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
}
#mobileButtons {
    position: absolute;
    right: 20px; bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: all;
}
#mobJump, #mobBrake {
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    padding: 14px 22px;
    border-radius: 50px;
    border: 2px solid rgba(255,255,255,.3);
    background: rgba(255,255,255,.15);
    color: #fff;
    touch-action: manipulation;
    cursor: pointer;
    transition: background .1s;
}
#mobJump:active  { background: rgba(255,255,255,.35); }
#mobBrake        { background: rgba(255,100,70,.25); border-color: rgba(255,100,70,.5); }
#mobBrake:active { background: rgba(255,100,70,.5); }

/* ── CHAT TOGGLE BUTTON (HUD center) ── */
#chatToggleBtn {
    font-family: 'Fredoka One', cursive;
    font-size: .9rem;
    padding: 8px 18px;
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,.25);
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(8px);
    color: #fff;
    cursor: pointer;
    touch-action: manipulation;
    transition: background .1s, transform .1s;
    display: none;
    pointer-events: all;
}
#chatToggleBtn:hover  { background: rgba(255,255,255,.12); }
#chatToggleBtn:active { transform: scale(.95); }
#chatToggleBtn.has-new {
    border-color: #ffcc44;
    color: #ffcc44;
    animation: chatPing .4s ease;
}
@keyframes chatPing {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* ── CHAT OVERLAY ── */
#chatOverlay {
    position: fixed;
    bottom: 200px;
    right: 14px;
    width: min(320px, 90vw);
    max-height: 340px;
    background: rgba(10,5,25,.88);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 18px;
    display: none;
    flex-direction: column;
    z-index: 1025;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
#chatHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-family: 'Fredoka One', cursive;
    color: #ffcc44;
    font-size: .95rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}
#chatClose {
    background: none;
    border: none;
    color: rgba(255,255,255,.45);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 4px;
    transition: color .15s;
}
#chatClose:hover { color: #fff; }
#chatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: .82rem;
    scroll-behavior: smooth;
}
#chatMessages::-webkit-scrollbar { width: 4px; }
#chatMessages::-webkit-scrollbar-track { background: transparent; }
#chatMessages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }
.chatMsg {
    line-height: 1.45;
    word-break: break-word;
    color: rgba(255,255,255,.88);
    padding: 3px 0;
}
.chatMsg .chatSender {
    font-weight: 800;
    margin-right: 4px;
}
.chatMsg.system {
    color: rgba(255,255,255,.38);
    font-style: italic;
    font-size: .75rem;
    text-align: center;
    padding: 4px 0;
}
.chatMsg.self .chatSender { color: #ffcc44; }
#chatInputRow {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}
#chatInput {
    flex: 1;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 10px;
    padding: 7px 10px;
    color: #fff;
    font-size: .84rem;
    font-family: 'Nunito', sans-serif;
    outline: none;
    transition: border-color .2s;
}
#chatInput::placeholder { color: rgba(255,255,255,.3); }
#chatInput:focus { border-color: #ff6fd8; }
#chatSend {
    font-family: 'Fredoka One', cursive;
    background: linear-gradient(135deg,#44bbff,#0077ff);
    border: none;
    border-radius: 10px;
    color: #fff;
    padding: 7px 14px;
    cursor: pointer;
    font-size: .84rem;
    touch-action: manipulation;
    transition: opacity .15s;
}
#chatSend:active { opacity: .75; }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 600px) {
    #hudControls { display: none; }
    #mobileControls { display: block; }
    #chatOverlay {
        bottom: 190px;
        right: 8px;
        left: 8px;
        width: auto;
    }
}
@media (pointer: coarse) {
    #mobileControls { display: block; }
    #hudControls    { display: none; }
    #chatOverlay {
        bottom: 190px;
        right: 8px;
        left: 8px;
        width: auto;
    }
}

/* ── TAKEN CHARACTER CARDS ── */
.charCard.taken {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: rgba(255,255,255,.08);
}
.charCard.taken:hover {
    transform: none;
    border-color: rgba(255,255,255,.08);
    background: rgba(255,255,255,.06);
}

/* ── DISCONNECTED PLAYER ROW ── */
.disconnected-row { opacity: 0.5; }

/* ── MUTE MUSIC BUTTON ── */
#muteMusic {
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.3);
    background: rgba(0,0,0,.5);
    color: #fff;
    touch-action: manipulation;
    cursor: pointer;
    pointer-events: auto;
    backdrop-filter: blur(8px);
    transition: background .1s, transform .1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
}
#muteMusic:active {
    background: rgba(255,255,255,.25);
    transform: scale(0.93);
}

/* ── MOBILE PAUSE BUTTON ── */
#mobPause {
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.3);
    background: rgba(0,0,0,.5);
    color: #fff;
    touch-action: manipulation;
    cursor: pointer;
    pointer-events: auto;
    backdrop-filter: blur(8px);
    transition: background .1s, transform .1s;
    display: none;
    align-items: center;
    justify-content: center;
}
#mobPause:active {
    background: rgba(255,255,255,.25);
    transform: scale(0.93);
}
@media(max-width:768px) {
    #mobPause { display: inline-flex; }
}
@media (pointer: fine) {
    #mobPause { display: none !important; }
}

/*# sourceMappingURL=main.css.map*/