/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Rajdhani', sans-serif;
    color: #c8e6ff;
}

/* ===== MENU CANVAS (star particles) ===== */
#menuCanvas {
    position: fixed;
    inset: 0;
    z-index: 0;
}

.hidden {
    display: none !important;
}

/* ===== MAIN MENU WRAPPER ===== */
#mainMenu {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    transition: opacity .8s ease, transform .8s ease;
}

#mainMenu.hide {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}

/* ===== TITLE ===== */
.menu-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(36px, 7vw, 80px);
    font-weight: 900;
    text-align: center;
    letter-spacing: 6px;
    line-height: 1.1;
    background: linear-gradient(135deg, #00e5ff, #7c4dff, #ff4081, #00e5ff);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradShift 4s ease infinite;
    filter: drop-shadow(0 0 30px rgba(0, 229, 255, .45));
    margin-bottom: 6px;
    flex-shrink: 0;
}

.menu-subtitle {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(12px, 2vw, 18px);
    letter-spacing: 12px;
    color: #5ef7ff;
    opacity: .7;
    text-transform: uppercase;
    margin-bottom: 36px;
    flex-shrink: 0;
}

@keyframes gradShift {

    0%,
    100% {
        background-position: 0% 50%
    }

    50% {
        background-position: 100% 50%
    }
}

/* ===== GLASS PANEL ===== */
.glass {
    background: rgba(6, 14, 30, .72);
    border: 1px solid rgba(100, 200, 255, .18);
    border-radius: 18px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
    padding: 36px 42px;
    width: min(420px, 90vw);
    flex-shrink: 0;
}

/* ===== NAME INPUT ===== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 22px;
}

.input-group label {
    font-size: 13px;
    letter-spacing: 2px;
    opacity: .6;
    text-transform: uppercase;
}

.input-group input {
    background: rgba(0, 30, 60, .6);
    border: 1px solid rgba(0, 229, 255, .3);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 18px;
    color: #00e5ff;
    font-family: 'Orbitron', sans-serif;
    outline: none;
    transition: border-color .3s, box-shadow .3s;
}

.input-group input:focus {
    border-color: #00e5ff;
    box-shadow: 0 0 20px rgba(0, 229, 255, .25);
}

.input-group input::placeholder {
    color: rgba(0, 229, 255, .3);
}

/* ===== BUTTONS ===== */
.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
    background: linear-gradient(135deg, #00b8d4, #7c4dff);
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: transform .2s, box-shadow .3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 184, 212, .5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary .shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .18), transparent);
    animation: btnShine 3s ease infinite;
}

@keyframes btnShine {
    0% {
        left: -100%
    }

    50% {
        left: 100%
    }

    100% {
        left: 100%
    }
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.btn-secondary {
    flex: 1;
    padding: 11px 0;
    border: 1px solid rgba(100, 200, 255, .25);
    border-radius: 10px;
    background: rgba(0, 30, 60, .4);
    color: #8ecfff;
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 1px;
    transition: background .3s, border-color .3s, color .3s;
}

.btn-secondary:hover {
    background: rgba(0, 80, 160, .35);
    border-color: #00e5ff;
    color: #00e5ff;
}

/* ===== STATUS BADGE ===== */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    font-size: 12px;
    opacity: .55;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ff4081;
    box-shadow: 0 0 6px #ff4081;
    animation: pulse 2s ease infinite;
}

.status-dot.online {
    background: #00e676;
    box-shadow: 0 0 6px #00e676;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: .3
    }
}

/* ===== AUTH SCREEN ===== */
#authScreen {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    transition: opacity .6s ease, transform .6s ease;
}

#authScreen.hide {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}

.auth-glass {
    width: min(440px, 92vw);
    padding: 32px 38px !important;
    flex-shrink: 0;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(0, 229, 255, 0.2);
}

.auth-tab {
    flex: 1;
    padding: 12px 0;
    border: none;
    background: rgba(0, 30, 60, 0.3);
    color: rgba(200, 230, 255, 0.5);
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 4px;
    cursor: pointer;
    transition: all 0.35s ease;
    position: relative;
}

.auth-tab.active {
    background: linear-gradient(135deg, rgba(0, 184, 212, 0.3), rgba(124, 77, 255, 0.3));
    color: #00e5ff;
    text-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}

.auth-tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #00e5ff, #7c4dff);
    transition: all 0.35s ease;
    transform: translateX(-50%);
}

.auth-tab.active::after {
    width: 80%;
}

/* Auth Form transition */
.auth-form {
    animation: authFadeIn 0.35s ease;
}

@keyframes authFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Auth Error */
.auth-error {
    color: #ff5252;
    font-size: 13px;
    min-height: 20px;
    margin-bottom: 8px;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s;
}

.auth-error.show {
    animation: authShake 0.4s ease;
}

@keyframes authShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-8px);
    }

    40% {
        transform: translateX(8px);
    }

    60% {
        transform: translateX(-5px);
    }

    80% {
        transform: translateX(5px);
    }
}

/* Auth Submit button */
.auth-submit {
    margin-top: 4px;
}

.auth-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Hint text */
.hint {
    opacity: 0.4;
    font-size: 11px;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 0;
}

/* Auth Divider */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 18px 0 14px;
    gap: 12px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(100, 200, 255, 0.2), transparent);
}

.auth-divider span {
    font-size: 12px;
    opacity: 0.4;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 2px;
}

/* Guest button */
.auth-guest {
    width: 100%;
    padding: 12px !important;
    border-style: dashed !important;
    opacity: 0.7;
    transition: all 0.3s;
}

.auth-guest:hover {
    opacity: 1;
}

/* ===== USER INFO BAR (Main Menu) ===== */
.user-info-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    background: rgba(0, 229, 255, 0.06);
    border: 1px solid rgba(0, 229, 255, 0.15);
    border-radius: 12px;
    position: relative;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00b8d4, #7c4dff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-display-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 15px;
    color: #00e5ff;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-stats {
    font-size: 11px;
    opacity: 0.5;
    margin-top: 2px;
    letter-spacing: 1px;
}

.btn-logout {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255, 82, 82, 0.3);
    background: rgba(255, 82, 82, 0.1);
    color: #ff5252;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-logout:hover {
    background: rgba(255, 82, 82, 0.3);
    border-color: #ff5252;
    box-shadow: 0 0 12px rgba(255, 82, 82, 0.3);
}

/* Loading spinner */
.auth-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: authSpin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes authSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== VERSION TAG ===== */
.version-tag {
    position: fixed;
    bottom: 16px;
    right: 20px;
    font-size: 11px;
    opacity: .25;
    z-index: 11;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 2px;
}

/* ===== Auth + MainMenu responsive (Mobile Landscape) ===== */
@media screen and (max-height: 480px) {

    /* --- Auth Screen --- */
    #authScreen {
        justify-content: flex-start;
        padding: 10px 0;
    }

    #authScreen .menu-title {
        font-size: clamp(20px, 5vh, 32px);
        margin-bottom: 0;
        filter: drop-shadow(0 0 15px rgba(0, 229, 255, .3));
    }

    #authScreen .menu-subtitle {
        font-size: 9px;
        letter-spacing: 4px;
        margin-bottom: 8px;
    }

    .auth-glass {
        padding: 14px 22px !important;
        width: min(480px, 94vw);
        border-radius: 12px;
    }

    .auth-glass .input-group {
        gap: 2px;
        margin-bottom: 6px;
    }

    .auth-glass .input-group label {
        font-size: 10px;
        letter-spacing: 1px;
    }

    .auth-glass .input-group input {
        padding: 7px 10px;
        font-size: 13px;
        border-radius: 7px;
    }

    .auth-tabs {
        margin-bottom: 10px;
        border-radius: 8px;
    }

    .auth-tab {
        padding: 7px 0;
        font-size: 11px;
        letter-spacing: 3px;
    }

    .auth-error {
        min-height: 16px;
        font-size: 11px;
        margin-bottom: 4px;
    }

    .auth-submit {
        padding: 8px !important;
        font-size: 13px !important;
        margin-top: 0;
    }

    .auth-divider {
        margin: 6px 0 5px;
    }

    .auth-divider span {
        font-size: 10px;
    }

    .auth-guest {
        padding: 7px !important;
        font-size: 11px;
    }

    .auth-glass .status-bar {
        margin-top: 6px;
    }

    .hint {
        font-size: 9px;
    }

    /* --- Main Menu --- */
    #mainMenu {
        justify-content: flex-start;
        padding: 8px 0;
    }

    .user-info-bar {
        padding: 6px 10px;
        margin-bottom: 8px;
        gap: 8px;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .user-display-name {
        font-size: 12px;
    }

    .user-stats {
        font-size: 9px;
    }

    .btn-logout {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

/* Custom scrollbar for auth/menu screens */
#authScreen::-webkit-scrollbar,
#mainMenu::-webkit-scrollbar {
    width: 4px;
}

#authScreen::-webkit-scrollbar-track,
#mainMenu::-webkit-scrollbar-track {
    background: transparent;
}

#authScreen::-webkit-scrollbar-thumb,
#mainMenu::-webkit-scrollbar-thumb {
    background: rgba(0, 229, 255, 0.2);
    border-radius: 4px;
}

#authScreen::-webkit-scrollbar-thumb:hover,
#mainMenu::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 229, 255, 0.4);
}

/* Extra-small mobile landscape (very short phones) */
@media screen and (max-height: 360px) {

    #authScreen .menu-title,
    #mainMenu .menu-title {
        font-size: 18px;
        letter-spacing: 3px;
    }

    #authScreen .menu-subtitle,
    #mainMenu .menu-subtitle {
        font-size: 8px;
        letter-spacing: 3px;
        margin-bottom: 4px;
    }

    .auth-glass {
        padding: 10px 16px !important;
    }

    .auth-glass .input-group input {
        padding: 5px 8px;
        font-size: 12px;
    }

    .auth-tab {
        padding: 5px 0;
        font-size: 10px;
    }

    .auth-tabs {
        margin-bottom: 6px;
    }

    .glass {
        padding: 8px 18px;
    }

    .btn-job {
        padding: 4px 0;
        font-size: 11px;
    }
}

/* ===== MODAL (Controls / Rooms) ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, .7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: rgba(6, 14, 30, .92);
    border: 1px solid rgba(100, 200, 255, .2);
    border-radius: 18px;
    padding: 32px 36px;
    width: min(480px, 90vw);
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 12px 48px rgba(0, 0, 0, .6);
}

.modal-box h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 22px;
    margin-bottom: 18px;
    background: linear-gradient(90deg, #00e5ff, #7c4dff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    color: #8ecfff;
    font-size: 22px;
    cursor: pointer;
    opacity: .6;
    transition: opacity .2s;
}

.modal-close:hover {
    opacity: 1;
}

.controls-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 18px;
    font-size: 15px;
}

.controls-grid .key {
    background: rgba(0, 229, 255, .12);
    border: 1px solid rgba(0, 229, 255, .3);
    border-radius: 6px;
    padding: 4px 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    text-align: center;
    color: #00e5ff;
}

.controls-grid .desc {
    display: flex;
    align-items: center;
    color: #8ecfff;
}

/* Room list */
.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid rgba(100, 200, 255, .12);
    border-radius: 10px;
    margin-bottom: 8px;
    transition: border-color .2s, background .2s;
}

.room-item:hover {
    border-color: #00e5ff;
    background: rgba(0, 80, 160, .15);
}

.room-join {
    background: linear-gradient(135deg, #00b8d4, #7c4dff);
    border: none;
    color: #fff;
    padding: 6px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 13px;
}

.room-empty {
    text-align: center;
    padding: 30px 0;
    opacity: .4;
    font-size: 14px;
}

/* ===== GAME CANVAS ===== */
#gameCanvas {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 0;
}

/* ===== IN‑GAME HUD (Mobile Optimized) ===== */
#ui {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 20;
    pointer-events: none;
    display: none;
    font-family: 'Orbitron', sans-serif;
    padding: 12px 18px;
    background: rgba(6, 14, 30, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#ui div {
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.8);
}

#leaderboard {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 20;
    background: rgba(0, 20, 40, .8);
    border: 1px solid rgba(0, 229, 255, .3);
    padding: 16px;
    border-radius: 12px;
    min-width: 200px;
    pointer-events: none;
    display: none;
}

#leaderboard h3 {
    margin-bottom: 10px;
    text-align: center;
    color: #ffab00;
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    letter-spacing: 2px;
}

.player-score {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    font-size: 14px;
    border: 1px solid transparent;
}

.player-score.me {
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: #ffab00 !important;
}

.rank-num {
    color: rgba(255, 255, 255, 0.5);
    margin-right: 10px;
    font-weight: bold;
    font-size: 12px;
}

#connectionStatus {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    padding: 8px 20px;
    background: rgba(0, 0, 0, .7);
    border: 1px solid #0ff;
    border-radius: 20px;
    font-size: 12px;
    display: none;
}

#controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 20;
    background: rgba(0, 0, 0, .6);
    padding: 14px;
    border-radius: 10px;
    border: 1px solid rgba(0, 229, 255, .2);
    font-size: 12px;
    line-height: 1.6;
    display: none;
}

#controls.hidden {
    display: none !important;
}

.connected {
    color: #0f0;
    border-color: #0f0;
}

.disconnected {
    color: #f00;
    border-color: #f00;
}

.hidden {
    display: none !important;
}

/* Kill notification animation */
@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }

    20% {
        opacity: 1;
        transform: translateX(-50%) scale(1.1);
    }

    80% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) scale(0.9);
    }
}

.kill-notification {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #ffab00;
    color: #ffab00;
    padding: 15px 30px;
    border-radius: 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    z-index: 100;
    animation: fadeInOut 2s ease forwards;
    pointer-events: none;
}

/* Room code display in game */
.room-badge {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: rgba(0, 20, 40, .9);
    border: 1px solid #ffab00;
    padding: 8px 20px;
    border-radius: 20px;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: #ffab00;
    display: none;
}

/* ===== ORIENTATION OVERLAY ===== */
#orientation-overlay {
    position: fixed;
    inset: 0;
    background: #060e1e;
    z-index: 9999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #0ff;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    pointer-events: auto;
}

.phone-icon {
    width: 40px;
    height: 70px;
    border: 3px solid #0ff;
    border-radius: 8px;
    margin-bottom: 20px;
    position: relative;
    animation: rotatePhone 2s ease-in-out infinite;
}

.phone-icon::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0ff;
}

@keyframes rotatePhone {

    0%,
    100% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotate(-90deg);
    }
}

/* 修正：更精確的移動端橫向偵測 (放寬寬度限制以支援平板) */
@media screen and (max-aspect-ratio: 1/1) and (max-width: 1366px) {
    #orientation-overlay {
        display: flex !important;
    }
}

/* ✅ 手機橫向模式下縮小主選單 UI */
@media screen and (max-height: 480px) {
    .menu-title {
        font-size: clamp(20px, 5vh, 34px);
        margin-bottom: 0;
        filter: drop-shadow(0 0 15px rgba(0, 229, 255, .3));
    }

    .menu-subtitle {
        font-size: 9px;
        letter-spacing: 4px;
        margin-bottom: 6px;
    }

    .glass {
        padding: 12px 24px;
        width: min(520px, 95vw);
        border-radius: 12px;
    }

    .input-group {
        gap: 2px;
        margin-bottom: 6px;
    }

    .input-group label {
        font-size: 10px;
    }

    .input-group input {
        padding: 7px 10px;
        font-size: 13px;
    }

    #jobDesc {
        font-size: 9px;
        height: auto;
        margin-top: 3px;
        margin-bottom: 0;
    }

    .btn-primary {
        padding: 8px;
        font-size: 13px;
    }

    .btn-row {
        margin-top: 6px;
        gap: 5px;
    }

    .btn-secondary {
        padding: 6px 0;
        font-size: 11px;
    }

    .status-bar {
        margin-top: 6px;
        font-size: 10px;
    }

    .btn-job {
        padding: 6px 0;
        font-size: 12px;
    }
}

/* Job Button Styles */
.btn-job {
    flex: 1;
    padding: 10px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    cursor: pointer;
    font-family: 'Rajdhani';
    transition: 0.3s;
}

.btn-job.active {
    background: linear-gradient(135deg, #00b8d4, #7c4dff);
    border-color: #0ff;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
}

/* Mobile Controls Styles - Futuristic HUD Redesign */
#mobileControls {
    position: fixed;
    inset: 0;
    z-index: 30;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: clamp(20px, 5vw, 40px) clamp(25px, 6vw, 50px);
}

/* 按鈕組需要自己開啟觸控事件 */
.mobile-action-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    pointer-events: auto;
    /* ← 修復：讓觸控事件可以到達子元素 */
}

#mobileSkill,
#mobileChatBtn {
    pointer-events: auto;
    touch-action: manipulation;
    /* 防止雙擊縮放延遲 */
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Base Joystick Styling with HUD Elements */
#joystickZone,
#joystickZoneRight {
    width: clamp(120px, 18vh, 160px);
    height: clamp(120px, 18vh, 160px);
    background: radial-gradient(circle, rgba(0, 229, 255, 0.03) 0%, rgba(0, 229, 255, 0.12) 100%);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 229, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    pointer-events: auto;
    touch-action: none;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 229, 255, 0.1);
}

/* Right Joystick (Shooter) - Red/Pink Theme */
#joystickZoneRight {
    background: radial-gradient(circle, rgba(255, 64, 129, 0.03) 0%, rgba(255, 64, 129, 0.12) 100%);
    border-color: rgba(255, 64, 129, 0.25);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(255, 64, 129, 0.1);
}

/* Scanning Rotating Ring for Joystick */
#joystickZone::before,
#joystickZoneRight::before {
    content: '';
    position: absolute;
    inset: -8px;
    border: 2px solid transparent;
    border-top: 2px solid rgba(0, 229, 255, 0.4);
    border-right: 2px solid rgba(0, 229, 255, 0.1);
    border-radius: 50%;
    animation: hudRotate 4s linear infinite;
    pointer-events: none;
}

#joystickZoneRight::before {
    border-top-color: rgba(255, 64, 129, 0.4);
    border-right-color: rgba(255, 64, 129, 0.1);
}

@keyframes hudRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* HUD Corner Brackets for Joysticks */
#joystickZone::after,
#joystickZoneRight::after {
    content: '';
    position: absolute;
    inset: -12px;
    border-radius: 12px;
    background:
        linear-gradient(to right, #0ff 6px, transparent 6px) 0 0,
        linear-gradient(to bottom, #0ff 6px, transparent 6px) 0 0,
        linear-gradient(to left, #0ff 6px, transparent 6px) 100% 0,
        linear-gradient(to bottom, #0ff 6px, transparent 6px) 100% 0,
        linear-gradient(to right, #0ff 6px, transparent 6px) 0 100%,
        linear-gradient(to top, #0ff 6px, transparent 6px) 0 100%,
        linear-gradient(to left, #0ff 6px, transparent 6px) 100% 100%,
        linear-gradient(to top, #0ff 6px, transparent 6px) 100% 100%;
    background-repeat: no-repeat;
    background-size: 15px 15px;
    opacity: 0.3;
    animation: hudPulse 2s ease-in-out infinite alternate;
}

#joystickZoneRight::after {
    background:
        linear-gradient(to right, #ff4081 6px, transparent 6px) 0 0,
        linear-gradient(to bottom, #ff4081 6px, transparent 6px) 0 0,
        linear-gradient(to left, #ff4081 6px, transparent 6px) 100% 0,
        linear-gradient(to bottom, #ff4081 6px, transparent 6px) 100% 0,
        linear-gradient(to right, #ff4081 6px, transparent 6px) 0 100%,
        linear-gradient(to top, #ff4081 6px, transparent 6px) 0 100%,
        linear-gradient(to left, #ff4081 6px, transparent 6px) 100% 100%,
        linear-gradient(to top, #ff4081 6px, transparent 6px) 100% 100%;
    background-repeat: no-repeat;
    background-size: 15px 15px;
}

@keyframes hudPulse {
    from {
        opacity: 0.15;
        transform: scale(0.98);
    }

    to {
        opacity: 0.4;
        transform: scale(1.02);
    }
}

/* Joystick Stick UI */
#joystickStick,
#joystickStickRight {
    width: clamp(50px, 8vh, 70px);
    height: clamp(50px, 8vh, 70px);
    background: radial-gradient(circle, #fff 0%, rgba(0, 229, 255, 0.8) 40%, rgba(0, 184, 212, 0.6) 100%);
    border-radius: 50%;
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

#joystickStickRight {
    background: radial-gradient(circle, #fff 0%, rgba(255, 64, 129, 0.8) 40%, rgba(194, 24, 91, 0.6) 100%);
    box-shadow: 0 0 30px rgba(255, 64, 129, 0.6);
}

/* Center Crosshair on Stick */
#joystickStick::before,
#joystickStickRight::before {
    content: '';
    width: 20px;
    height: 2px;
    background: rgba(255, 255, 255, 0.8);
    position: absolute;
}

#joystickStick::after,
#joystickStickRight::after {
    content: '';
    height: 20px;
    width: 2px;
    background: rgba(255, 255, 255, 0.8);
    position: absolute;
}

#mobileSkill {
    width: 75px;
    height: 75px;
    background: rgba(124, 77, 255, 0.2);
    border: 2px solid rgba(124, 77, 255, 0.6);
    /* Hexagon Shape */
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
    touch-action: none;
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    text-shadow: 0 0 10px #7c4dff;
}

#mobileSkill:active {
    transform: scale(0.85);
    background: rgba(124, 77, 255, 0.6);
    box-shadow: 0 0 40px rgba(124, 77, 255, 0.8);
}

.fire-icon {
    position: absolute;
    font-size: 32px;
    opacity: 0.6;
    pointer-events: none;
    z-index: 1;
    filter: drop-shadow(0 0 10px rgba(255, 64, 129, 0.8));
    animation: hudRotate 8s linear infinite reverse;
}

#mobilePauseBtn {
    position: fixed;
    top: 25px;
    left: 25px;
    z-index: 2005;
    background: rgba(6, 14, 30, 0.4) !important;
    border: 1px solid rgba(0, 229, 255, 0.4) !important;
    backdrop-filter: blur(8px);
    border-radius: 8px;
    width: 48px;
    height: 48px;
    font-size: 20px;
    color: #0ff;
    transition: all 0.2s;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#mobilePauseBtn:active {
    transform: scale(0.9);
    background: rgba(0, 229, 255, 0.2) !important;
}

/* Cancel Zone - Tactical Warning Style */
#cancelZone {
    position: fixed;
    top: 25px;
    right: 25px;
    width: 100px;
    height: 100px;
    background: rgba(255, 0, 0, 0.05);
    border: 2px dashed rgba(255, 82, 82, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #ff5252;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    font-weight: 900;
    pointer-events: none;
    z-index: 2000;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#cancelZone.active {
    opacity: 1;
    transform: scale(1);
    animation: cancelStrobe 1s ease-in-out infinite;
}

@keyframes cancelStrobe {

    0%,
    100% {
        background: rgba(255, 0, 0, 0.05);
        border-color: rgba(255, 82, 82, 0.4);
    }

    50% {
        background: rgba(255, 0, 0, 0.2);
        border-color: rgba(255, 82, 82, 0.8);
    }
}

#cancelZone.hover {
    background: rgba(255, 0, 0, 0.7) !important;
    color: #fff;
    transform: scale(1.2);
    border-style: solid;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.6);
}

.cancel-icon {
    font-size: 32px;
    margin-bottom: 2px;
}

@media screen and (max-height: 480px) {
    #mobileControls {
        padding: 15px 30px;
    }

    #joystickZone,
    #joystickZoneRight {
        width: 110px;
        height: 110px;
    }

    #mobileSkill,
    #mobileChatBtn {
        width: 50px;
        height: 50px;
        font-size: 10px;
    }

    .fire-icon {
        font-size: 22px;
    }
}

/* ===== CHAT SYSTEM (Desktop Base) ===== */
#chatBox {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 260px;
    height: 180px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    background: rgba(6, 14, 30, 0.7);
    border: 1px solid rgba(0, 229, 255, 0.25);
    border-radius: 14px;
    backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* 📱 針對平板與觸控裝置調整聊天室位置 (避免擋住搖桿) */
body.touch-device #chatBox {
    left: 50%;
    transform: translateX(-50%);
    bottom: clamp(12px, 5vh, 40px); /* 根據高度動態調整距離 */
    width: min(450px, 80vw);
    height: clamp(90px, 20vh, 160px);
    background: rgba(6, 14, 30, 0.85); 
}

body.touch-device #chatBox.hidden {
    transform: translateX(-50%) translateY(20px) scale(0.95);
}

body.touch-device #chatInputArea {
    padding: 10px 15px;
    gap: 10px;
}

body.touch-device #chatInput {
    height: 40px;
    font-size: 16px; /* 防止 iOS 自動放大 */
}

body.touch-device #btnSendChat {
    padding: 8px 15px;
    font-size: 14px;
}

#chatBox::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    z-index: 5;
    opacity: 0.3;
}

#chatBox::after {
    content: "TACTICAL-COMM";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 18px;
    background: rgba(0, 229, 255, 0.1);
    color: rgba(0, 229, 255, 0.5);
    font-family: 'Orbitron';
    font-size: 8px;
    display: flex;
    align-items: center;
    padding-left: 10px;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(0, 229, 255, 0.2);
    z-index: 6;
}

#chatBox.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    display: flex !important;
}

#chatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 12px 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 229, 255, 0.2) transparent;
}

#chatMessages::-webkit-scrollbar {
    width: 4px;
}

#chatMessages::-webkit-scrollbar-thumb {
    background: rgba(0, 229, 255, 0.2);
    border-radius: 4px;
}

.chat-msg {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-all;
    animation: chatMsgFade 0.3s ease-out;
}

@keyframes chatMsgFade {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.chat-msg .name {
    color: #0ff;
    font-weight: 700;
    margin-right: 6px;
}

.chat-msg .time {
    font-size: 10px;
    opacity: 0.4;
    margin-right: 6px;
    font-family: 'Orbitron';
}

#chatInputArea {
    display: flex;
    padding: 8px 10px;
    border-top: 1px solid rgba(0, 229, 255, 0.1);
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    z-index: 10;
}

#chatInput {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    padding: 6px 10px;
    font-size: 14px;
    outline: none;
}

#btnSendChat {
    background: rgba(0, 229, 255, 0.2);
    border: 1px solid rgba(0, 229, 255, 0.4);
    color: #0ff;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Orbitron';
    font-size: 12px;
}

#btnSendChat:hover {
    background: rgba(0, 229, 255, 0.4);
}

#mobileChatBtn {
    width: 75px;
    height: 75px;
    background: rgba(0, 229, 255, 0.15);
    border: 2px solid rgba(0, 229, 255, 0.4);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    color: #fff;
    font-family: 'Orbitron';
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    animation: chatBtnPulse 3s infinite;
}

@keyframes chatBtnPulse {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
    }

    50% {
        box-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
        border-color: rgba(0, 229, 255, 0.8);
    }
}

#mobileChatBtn:active {
    transform: scale(0.9);
    background: rgba(0, 229, 255, 0.3);
}

/* ============================================================ */
/* ===== FINAL RESPONSIVE OVERRIDES (MOBILE LANDSCAPE) ===== */
/* ============================================================ */
@media screen and (max-height: 480px) {

    /* --- HUD / UI --- */
    #leaderboard {
        top: 20px;
        right: auto;
        left: 85px;
        /* Beside pause button */
        bottom: auto;
        min-width: 150px;
        padding: 8px;
    }

    #leaderboard h3 {
        font-size: 11px;
        margin-bottom: 5px;
    }

    .player-score {
        font-size: 11px;
        padding: 4px 8px;
        margin: 4px 0;
    }

    #ui {
        top: auto;
        bottom: 15px;
        left: 170px !important;
        /* Move to bottom near joystick */
        padding: 5px 12px !important;
    }

    #ui div {
        font-size: 12px !important;
    }

    /* --- Chat Box Mobile --- */
    #chatBox {
        width: 220px;
        height: 90px;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(6, 14, 30, 0.9);
    }

    #chatBox.hidden {
        transform: translateX(-50%) translateY(15px) scale(0.9);
    }

    #chatBox::after {
        height: 14px;
        font-size: 7px;
    }

    #chatMessages {
        padding: 18px 8px 5px 8px;
        gap: 3px;
    }

    .chat-msg {
        font-size: 11px;
    }

    #chatInputArea {
        padding: 5px 8px;
        gap: 5px;
    }

    #chatInput {
        padding: 4px 8px;
        font-size: 12px;
        height: 26px;
    }

    #btnSendChat {
        padding: 3px 8px;
        font-size: 10px;
    }

    .cancel-icon {
        font-size: 24px;
    }

    #cancelZone {
        width: 80px;
        height: 80px;
        top: 15px;
        right: 15px;
    }
}