body {
    margin: 0;
    font-family: -apple-system, sans-serif;

    /* 🔥 เพิ่ม depth + glow */
    background:
        radial-gradient(circle at top, rgba(255, 122, 0, 0.15), transparent 40%),
        linear-gradient(rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.95)),
        url('https://i.postimg.cc/WbCfDbw7/bg-pack.jpg');

    background-size: cover;
    background-position: center;
    background-attachment: fixed;

    color: white;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    min-height: 100dvh;
    padding-bottom: 100px;
    /* 🔥 กันเมนูทับ */
}

html,
body {
    height: 100%;
    overflow-x: hidden;
}

/* 🔥 logo */
.logo {
    margin-bottom: 25px;
    text-align: center;
}

.logo img {
    width: 200px;
    filter: drop-shadow(0 5px 15px rgba(255, 122, 0, 0.3));
}

/* container */
.container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    margin-bottom: 10px;

    /* 🔥 glass effect */
    backdrop-filter: none;

    display: flex;
    flex-direction: column;
    align-items: center;
    /* 🔥 center ทุกอย่าง */
}

/* title */
.title {
    font-size: 20px;
    margin-bottom: 20px;
    text-align: center;
}

/* input + button */
.input,
.btn {
    width: 75%;
    height: 55px;
    border-radius: 14px;
    border: none;
    font-size: 18px;

    display: block;
    /* 🔥 สำคัญ */
    margin: 0 auto;
    /* 🔥 ทำให้ center */
    margin-bottom: 15px;

    position: relative;
    overflow: hidden;
}

/* ✨ light sweep */
.btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -80%;

    width: 50%;
    height: 100%;

    background: linear-gradient(120deg,
            transparent,
            rgba(255, 255, 255, 0.5),
            transparent);

    transform: skewX(-20deg);

    animation: sweepLoop 3.0s infinite;
}

/* 🔥 input upgrade */
.input {
    text-align: center;
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.input:focus {
    outline: none;
    border: 1px solid #ff7a00;
    box-shadow: 0 0 10px rgba(255, 122, 0, 0.6);
}

/* 🔥 button upgrade */
.btn {
    background: linear-gradient(135deg, #ff7a00, #ff9a2f);
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 122, 0, 0.4);
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 122, 0, 0.6);
}

.btn:active {
    transform: scale(0.97);
}

/* result */
.result {
    margin-top: 20px;
    text-align: center;
    font-size: 16px;
}

.success {
    color: #00ffae;
}

.error {
    color: #ff4d4f;
}

/* popup */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.hidden {
    display: none !important;
}

/* 🔥 popup glow */
.popup-card {
    background: linear-gradient(145deg, #111, #000);
    border-radius: 20px;
    padding: 25px;
    width: 85%;
    text-align: center;
    animation: pop 0.3s ease;
    box-shadow: 0 0 30px rgba(255, 122, 0, 0.3);
}

@keyframes pop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.popup-title {
    font-size: 20px;
    margin-bottom: 15px;
}

.popup-points {
    font-size: 30px;
    color: #00ffae;
    margin-bottom: 10px;
}

.popup-reward {
    margin-bottom: 20px;
}

.popup-btn {
    width: 100%;
    height: 50px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #ff7a00, #ff9a2f);
    color: white;
    font-size: 16px;
}

/* menu */
.menu {
    position: fixed;
    left: 0;
    right: 0;

    bottom: 0;
    width: 100%;

    height: 85px;

    background: #111;
    display: flex;
    align-items: center;

    border-top: 1px solid #222;

    z-index: 9999;

    /* 🔥 สำคัญมาก */
    padding-bottom: env(safe-area-inset-bottom);

    backdrop-filter: blur(10px);
    background: rgba(17, 17, 17, 0.9);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.6);
}

/* 🔥 เส้น indicator */
#tab-indicator {
    position: absolute;
    top: 0;
    width: 60px;
    /* สั้นลง */
    height: 0;
    /* 🔥 สำคัญ */
    border-top: 2px solid #ff7a00;
    /* 🔥 ใช้เส้นแทน block */
    transition: all 0.25s ease;
    z-index: 10;
}

.menu div {
    flex: 1;
    text-align: center;
    font-size: 14px;
    padding: 10px 0;
    line-height: 1.5;
    color: #888;
}

.menu div::first-line {
    font-size: 24px;
}

/* 🔥 active glow */
.menu .active {
    color: #ff7a00;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 122, 0, 0.8);
}

/* Leaderboard */
.my-score-card {
    background: linear-gradient(135deg, #222 0%, #111 100%);
    padding: 20px;
    border-radius: 18px;
    margin: 0 auto 20px auto;
    border: 1px solid #ff7a00;
    text-align: center;
    width: 85%;
    max-width: 320px;
    box-shadow: 0 5px 20px rgba(255, 122, 0, 0.2);
}

.rank-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #111;
    border-radius: 12px;
    margin-bottom: 10px;
    border-left: 4px solid #ff7a00;
    width: 85%;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    transition: all 0.2s ease;
}

.rank-item:hover {
    transform: scale(1.03);
    box-shadow: 0 5px 20px rgba(255, 122, 0, 0.3);
}

/* 🔥 top 1 highlight */
.rank-item:first-child {
    border-left: 4px solid gold;
    background: rgba(255, 215, 0, 0.08);
}

.rank-item span:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
    flex-grow: 1;
}

.rank-item span:last-child {
    white-space: nowrap;
    flex-shrink: 0;
}

.highlight-me {
    background: rgba(255, 122, 0, 0.2) !important;
    border: 1px solid #ff7a00 !important;
    transform: scale(1.02);
    z-index: 1;
}

.menu div {
    transition: all 0.2s ease;
}

.menu .active {
    transform: translateY(-2px);
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-5px);
    }

    40% {
        transform: translateX(5px);
    }

    60% {
        transform: translateX(-5px);
    }

    80% {
        transform: translateX(5px);
    }

    100% {
        transform: translateX(0);
    }
}

.shake {
    animation: shake 0.3s;
}

.input-error {
    border: 1px solid #ff4d4f !important;
    box-shadow: 0 0 8px rgba(255, 77, 79, 0.6);
}

@keyframes sweepLoop {
    0% {
        left: -80%;
    }

    50% {
        left: 120%;
    }

    100% {
        left: 120%;
    }
}

.processing {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    display: flex;
    justify-content: center;
    align-items: center;

    background: radial-gradient(circle, rgba(255, 122, 0, 0.15), #000);
    backdrop-filter: blur(0px);

    opacity: 0;
    visibility: hidden;

    transition:
        opacity 0.4s ease,
        backdrop-filter 0.4s ease;

    z-index: 99999;
}

.processing.active {
    opacity: 1;
    visibility: visible;
    backdrop-filter: blur(8px);
}

/* กล่องกลาง */
.processing-box {
    text-align: center;
    color: white;

    transform: translateY(20px) scale(0.95);
    opacity: 0;

    transition: all 0.4s ease;
}

.processing.active .processing-box {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* 🔥 spinner แบบเกม */
.spinner {
    width: 70px;
    height: 70px;

    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #ff7a00;

    border-radius: 50%;

    animation: spin 1s linear infinite, glowPulse 2s infinite;

    margin: 0 auto 20px;
    box-shadow: 0 0 20px rgba(255, 122, 0, 0.6);
}

@keyframes glowPulse {
    0% {
        box-shadow: 0 0 10px rgba(255, 122, 0, 0.4);
    }

    50% {
        box-shadow: 0 0 25px rgba(255, 122, 0, 0.8);
    }

    100% {
        box-shadow: 0 0 10px rgba(255, 122, 0, 0.4);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 🔥 text */
.processing-text {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
    color: #ff7a00;

    animation: pulseText 1.5s infinite;
}

@keyframes pulseText {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.4;
    }
}

.processing-sub {
    font-size: 12px;
    color: #aaa;
    margin-top: 8px;
}

#music-toggle {
    position: fixed;
    top: 10px;
    right: 10px;

    width: 30px;
    height: 30px;

    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);

    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 20px;
    cursor: pointer;

    z-index: 99999;
    pointer-events: auto;
}

.start-audio {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);

    background: #ff7a00;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;

    font-weight: bold;
    z-index: 99999;
}

button:active {
    transform: scale(0.95);
}