:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --accent-color: #38bdf8;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    /* Tube Colors */
    --color-1: #ef4444; /* Red */
    --color-2: #22c55e; /* Green */
    --color-3: #3b82f6; /* Blue */
    --color-4: #eab308; /* Yellow */
    --color-5: #a855f7; /* Purple */
    --color-6: #ec4899; /* Pink */
    --color-7: #06b6d4; /* Cyan */
    --color-8: #f97316; /* Orange */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.15) 0px, transparent 50%);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
header {
    padding: 1rem 1.5rem;
    text-align: center;
    background: var(--bg-color);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #38bdf8, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn-icon {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:active {
    transform: scale(0.9);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Screens */
.screen {
    flex: 1;
    display: none;
    padding: 1rem;
    animation: fadeIn 0.3s ease-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Level Selection Grid */
.level-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.level-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    aspect-ratio: 1;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--glass-shadow);
}

.level-card:hover { border-color: var(--accent-color); }
.level-card:active { transform: scale(0.95); }

.level-card .num { font-size: 1.2rem; font-weight: 700; }
.level-card .status { font-size: 0.6rem; color: var(--text-secondary); margin-top: 4px; }

/* Game Board */
#game-board {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    padding: 2rem 1rem 4rem 1rem;
    min-height: min-content;
}

.tube {
    width: 50px;
    height: 180px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top: none;
    border-radius: 0 0 25px 25px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    transition: transform 0.2s;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
}

.tube.selected {
    transform: translateY(-20px);
    border-color: var(--accent-color);
    box-shadow: 0 10px 20px rgba(56, 189, 248, 0.3);
}

.liquid {
    position: absolute;
    width: 100%;
    bottom: 0;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-icon:disabled { opacity: 0.2; cursor: not-allowed; transform: none; }

/* Win Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 2.5rem;
    border-radius: 32px;
    text-align: center;
    max-width: 90%;
    width: 320px;
    box-shadow: var(--glass-shadow);
}

.modal h2 { margin-bottom: 1rem; font-size: 2rem; }
.modal p { color: var(--text-secondary); margin-bottom: 2rem; }

.btn-primary {
    background: linear-gradient(135deg, #38bdf8, #a855f7);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 16px;
    font-weight: 700;
    width: 100%;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary:active { transform: scale(0.98); }

/* Responsive adjustments */
@media (max-width: 400px) {
    .tube { width: 45px; height: 160px; }
    #game-board { gap: 1rem; }
}
