:root {
    --bg-color: #0c0e14;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-color: #00f2ff;

    --color-1: #ff007a;
    --color-2: #00f2ff;
    --color-3: #7000ff;
    --color-4: #39ff14;
    --color-5: #ffaa00;
    --color-6: #ffff00;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: radial-gradient(circle at top right, #1a1c24, #0c0e14);
}

header {
    padding: 20px 20px 10px 20px;
    text-align: center;
}

#main-title {
    font-size: 2.2rem;
    letter-spacing: 1px;
    margin-bottom: 5px;
    display: inline-block;
    background: linear-gradient(to right,
            #BF953F,
            #FCF6BA,
            #B38728,
            #FBF5B7,
            #AA771C);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #D4AF37;
    /* Fallback */
    filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.5));
    animation: gold-shine 5s linear infinite;
}

@keyframes gold-shine {
    to {
        background-position: 200% center;
    }
}

.stats-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    opacity: 0.8;
    font-size: 0.9rem;
}

.stats-container span {
    color: var(--accent-color);
    font-weight: 600;
}

#game-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 30px;
    padding: 10px;
    min-height: 300px;
    width: 100%;
}

/* Tube - 精確計算比例 */
.tube {
    width: 72px;
    height: 250px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.01) 0%, rgba(255, 255, 255, 0.06) 100%);
    border: 2px solid var(--glass-border);
    border-top: none;
    border-radius: 0 0 36px 36px;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    padding-bottom: 15px;
    /* 瓶底墊高 */
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    position: relative;
    margin-top: 40px;
    /* 縮小頂部預留空間，讓 Level 顯示更靠近管子 */
}

.tube:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-5px);
}

.tube.selected {
    border-color: var(--accent-color);
    box-shadow: 0 10px 25px rgba(0, 242, 255, 0.15);
}

/* Ball - 精確計算比例 */
.ball {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-bottom: 5px;
    /* 球與球的垂直間距 */
    position: relative;
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    z-index: 5;
}

/* 浮起高度修正：使用 JS 動態計算的位移，確保所有球都到達相同高度 */
.ball.floating {
    transform: translateY(var(--float-offset, -120px));
    z-index: 20;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
}

/* Colors with Neon Glow */
.color-1 {
    background: radial-gradient(circle at 35% 35%, #ff4081, #96003c);
    box-shadow: 0 0 10px rgba(255, 0, 122, 0.3);
}

.color-2 {
    background: radial-gradient(circle at 35% 35%, #00f2ff, #007c82);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
}

.color-3 {
    background: radial-gradient(circle at 35% 35%, #7000ff, #3d008a);
    box-shadow: 0 0 10px rgba(112, 0, 255, 0.3);
}

.color-4 {
    background: radial-gradient(circle at 35% 35%, #39ff14, #1b7a0a);
    box-shadow: 0 0 10px rgba(57, 255, 20, 0.3);
}

.color-5 {
    background: radial-gradient(circle at 35% 35%, #ffaa00, #916100);
    box-shadow: 0 0 10px rgba(255, 170, 0, 0.3);
}

.color-6 {
    background: radial-gradient(circle at 35% 35%, #ffff00, #a1a100);
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.3);
}

/* Buttons */
.controls {
    margin-top: 15px;
    display: flex;
    gap: 15px;
}

.glass-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
    backdrop-filter: blur(10px);
}

.glass-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.glass-btn:disabled {
    opacity: 0.3;
}

.glass-btn.primary {
    background: rgba(0, 242, 255, 0.1);
    border-color: var(--accent-color);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    padding: 40px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    text-align: center;
}

.modal-content h2 {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 20px;
}