/* Cosmic Pink/Purple Theme */
:root {
    --bg-dark: #1a0a2e;
    --bg-medium: #2d1b4e;
    --bg-light: #3d2a5e;
    --accent-pink: #ff69b4;
    --accent-magenta: #ff1493;
    --accent-purple: #9b59b6;
    --accent-light: #da70d6;
    --text-primary: #ffffff;
    --text-secondary: #c8a8e8;
    --bubble-color: rgba(255, 105, 180, 0.3);
    --glow-pink: 0 0 20px rgba(255, 105, 180, 0.5);
    --glow-purple: 0 0 20px rgba(155, 89, 182, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-medium) 50%, var(--bg-dark) 100%);
    color: var(--text-primary);
    user-select: none;
    touch-action: manipulation;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Floating Bubbles */
#bubbles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 105, 180, 0.4), rgba(155, 89, 182, 0.2));
    animation: float-bubble linear infinite;
    filter: blur(1px);
}

@keyframes float-bubble {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100px) scale(1);
        opacity: 0;
    }
}

/* Stars Background */
#stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: twinkle 2s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 70px);
    display: none;
    flex-direction: column;
    z-index: 1;
    padding: 20px;
    padding-top: env(safe-area-inset-top, 20px);
}

.screen.active {
    display: flex;
}

/* Home Screen */
#home-screen {
    justify-content: center;
    align-items: center;
}

.home-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    z-index: 2;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--glow-pink);
}

#logo-canvas {
    width: 100%;
    height: 100%;
}

.game-title {
    font-size: 42px;
    font-weight: bold;
    text-shadow: var(--glow-pink);
}

.title-disc {
    color: var(--accent-pink);
}

.title-fall {
    color: var(--accent-magenta);
}

/* Menu Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 280px;
}

.menu-btn {
    width: 100%;
    padding: 18px 30px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-magenta));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(255, 105, 180, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.menu-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(255, 105, 180, 0.3);
}

.btn-icon {
    font-size: 22px;
}

/* Game Screen */
#game-screen {
    padding: 10px;
    gap: 5px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    font-size: 18px;
    font-weight: 600;
    z-index: 2;
}

.level-display, .score-display {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.game-area {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
}

#game-canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
}

.tap-hint {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    color: var(--text-secondary);
    animation: pulse-hint 1.5s ease-in-out infinite;
    z-index: 10;
    pointer-events: none;
}

.tap-hint.hidden {
    display: none;
}

@keyframes pulse-hint {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Buckets */
.buckets-container {
    display: flex;
    justify-content: center;
    gap: 2px;
    padding: 0 10px;
    z-index: 2;
}

.bucket {
    flex: 1;
    max-width: 60px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--accent-magenta), var(--accent-pink));
    color: white;
    font-weight: bold;
    font-size: 14px;
    border-radius: 5px 5px 0 0;
    box-shadow: 0 -2px 10px rgba(255, 105, 180, 0.5);
}

.bucket.highlight {
    animation: bucket-glow 0.3s ease-out;
}

@keyframes bucket-glow {
    0% { box-shadow: 0 0 30px var(--accent-pink); }
    100% { box-shadow: 0 -2px 10px rgba(255, 105, 180, 0.5); }
}

/* Profile Screen */
.profile-content {
    display: flex;
    justify-content: center;
    padding-top: 20px;
    z-index: 2;
}

.profile-card {
    background: rgba(45, 27, 78, 0.8);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    max-width: 350px;
    box-shadow: var(--glow-purple);
    border: 1px solid rgba(255, 105, 180, 0.3);
}

.profile-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.avatar-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    box-shadow: var(--glow-pink);
}

.cosmic-rank {
    font-size: 14px;
    color: var(--accent-light);
    font-weight: 600;
}

.profile-name input {
    width: 100%;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--accent-pink);
    color: white;
    padding: 10px;
    margin-bottom: 20px;
}

.profile-name input:focus {
    outline: none;
    border-bottom-color: var(--accent-magenta);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--accent-pink);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.color-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.picker-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.color-options {
    display: flex;
    gap: 10px;
}

.color-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: white;
    box-shadow: 0 0 10px currentColor;
}

/* Achievements Screen */
.achievements-content {
    z-index: 2;
}

.section-title {
    text-align: center;
    font-size: 28px;
    margin-bottom: 20px;
    color: var(--accent-pink);
    text-shadow: var(--glow-pink);
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    padding-bottom: 20px;
}

.achievement-card {
    background: rgba(45, 27, 78, 0.8);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(255, 105, 180, 0.2);
    transition: transform 0.2s;
}

.achievement-card.unlocked {
    border-color: var(--accent-pink);
    box-shadow: var(--glow-pink);
}

.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(50%);
}

.achievement-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.achievement-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
}

.achievement-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Settings Screen */
.settings-content {
    z-index: 2;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(45, 27, 78, 0.8);
    border-radius: 15px;
    margin-bottom: 15px;
}

.setting-label {
    font-size: 16px;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-light);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-magenta));
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.reset-btn {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid var(--accent-pink);
    border-radius: 15px;
    background: transparent;
    color: var(--accent-pink);
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.2s, color 0.2s;
}

.reset-btn:active {
    background: var(--accent-pink);
    color: white;
}

/* Level Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, var(--bg-medium), var(--bg-dark));
    border-radius: 25px;
    padding: 40px;
    text-align: center;
    border: 2px solid var(--accent-pink);
    box-shadow: var(--glow-pink);
    animation: modal-appear 0.3s ease-out;
}

@keyframes modal-appear {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h2 {
    font-size: 28px;
    color: var(--accent-pink);
    margin-bottom: 20px;
}

.modal-score {
    font-size: 24px;
    margin-bottom: 20px;
}

.modal-stars {
    font-size: 40px;
    margin-bottom: 25px;
}

.modal-btn {
    padding: 15px 40px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-magenta));
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 105, 180, 0.4);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: rgba(26, 10, 46, 0.95);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
    border-top: 1px solid rgba(255, 105, 180, 0.2);
    z-index: 50;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 10px 20px;
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--accent-pink);
}

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* Score Popup */
.score-popup {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    color: var(--accent-pink);
    text-shadow: 0 0 10px var(--accent-pink);
    pointer-events: none;
    animation: score-float 1s ease-out forwards;
    z-index: 20;
}

@keyframes score-float {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.5);
    }
}

/* Ball Trail */
.ball-trail {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-pink), transparent);
    pointer-events: none;
    animation: trail-fade 0.3s ease-out forwards;
}

@keyframes trail-fade {
    0% {
        opacity: 0.6;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.3);
    }
}

/* Responsive adjustments */
@media (max-height: 600px) {
    .menu-buttons {
        gap: 10px;
    }
    .menu-btn {
        padding: 14px 25px;
        font-size: 16px;
    }
    .game-title {
        font-size: 32px;
    }
}

@media (min-width: 768px) {
    .screen {
        max-width: 500px;
        margin: 0 auto;
    }
    #game-canvas {
        max-width: 450px;
    }
}
