/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(to bottom, #0f172a, #1e293b, #312e81);
    color: white;
    overflow-x: hidden;
    min-height: 100vh;
}

#app {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.icon {
    display: inline-block;
    font-size: 1em;
}

/* Star Field Background */
.starfield-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #0f172a, #1e293b);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    color: white;
    position: relative;
    z-index: 10;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 2px solid transparent;
    border-bottom: 2px solid #64ffda;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Header */
.header {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 32px 16px;
}

.title {
    font-size: 3rem;
    font-weight: 300;
    color: white;
    margin-bottom: 8px;
    animation: pulse 2s ease-in-out infinite;
}

@media (max-width: 768px) {
    .title {
        font-size: 2.5rem;
    }
}

.subtitle {
    color: #64ffda;
    font-size: 1.125rem;
    margin-bottom: 16px;
}

.header-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}

.header-btn {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.progress-btn {
    background: rgba(234, 179, 8, 0.2);
    border-color: rgba(234, 179, 8, 0.5);
    color: #fbbf24;
}

.progress-btn:hover {
    background: rgba(234, 179, 8, 0.3);
}

.settings-btn {
    background: rgba(147, 51, 234, 0.2);
    border-color: rgba(147, 51, 234, 0.5);
    color: #a78bfa;
}

.settings-btn:hover {
    background: rgba(147, 51, 234, 0.3);
}

/* Main Content */
.main-content {
    position: relative;
    flex: 1;
    margin: 0 16px 16px;
}

.canvas-container {
    position: relative;
    height: 400px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(71, 85, 105, 0.5);
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.5), rgba(49, 46, 129, 0.5));
    backdrop-filter: blur(4px);
}

@media (min-width: 768px) {
    .canvas-container {
        height: 500px;
    }
}

.canvas-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.visualizer-canvas {
    z-index: 1;
}

.line-canvas {
    z-index: 2;
}

.star-canvas {
    z-index: 3;
}

/* Mode Indicators */
.mode-indicators {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-indicator {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.edit-mode {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.journey-mode {
    background: rgba(147, 51, 234, 0.2);
    color: #c4b5fd;
}

/* Musical Info */
.musical-info {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(4px);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Floating Toolbar */
.floating-toolbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

.toolbar-content {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid rgba(71, 85, 105, 0.3);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    justify-content: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group .icon {
    color: #64ffda;
    font-size: 20px;
}

.select-input {
    background: #374151;
    color: white;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #4b5563;
    outline: none;
    transition: border-color 0.2s ease;
}

.select-input:focus {
    border-color: #64ffda;
}

.control-buttons {
    display: flex;
    gap: 8px;
}

.control-btn {
    background: #4b5563;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.control-btn:hover:not(:disabled) {
    background: #6b7280;
    transform: translateY(-1px);
}

.control-btn:disabled {
    background: #374151;
    cursor: not-allowed;
    opacity: 0.5;
}

.control-btn.active {
    background: #3b82f6;
}

.control-btn.active:hover {
    background: #2563eb;
}

.save-btn {
    background: #10b981;
}

.save-btn:hover:not(:disabled) {
    background: #059669;
}

.load-btn {
    background: #3b82f6;
}

.load-btn:hover:not(:disabled) {
    background: #2563eb;
}

.share-btn {
    background: #8b5cf6;
}

.share-btn:hover:not(:disabled) {
    background: #7c3aed;
}

.play-btn {
    background: #64ffda;
    color: #0f172a;
}

.play-btn:hover:not(:disabled) {
    background: #4ecdc4;
}

.stop-btn {
    background: #ef4444;
}

.stop-btn:hover:not(:disabled) {
    background: #dc2626;
}

.delete-btn {
    background: #ef4444;
}

.delete-btn:hover:not(:disabled) {
    background: #dc2626;
}

.clear-btn {
    background: #4b5563;
}

.clear-btn:hover:not(:disabled) {
    background: #6b7280;
}

/* Footer */
.footer {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 0 16px 24px;
}

.footer p {
    color: #94a3b8;
    font-size: 14px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 16px;
}

.modal-content {
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    border: 1px solid rgba(71, 85, 105, 0.3);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 18px;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: white;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.text-input {
    width: 100%;
    background: #374151;
    color: white;
    border-radius: 8px;
    padding: 12px 16px;
    border: 1px solid #4b5563;
    outline: none;
    transition: border-color 0.2s ease;
}

.text-input:focus {
    border-color: #64ffda;
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: #64ffda;
    color: #0f172a;
}

.btn-primary:hover:not(:disabled) {
    background: #4ecdc4;
}

.btn-primary:disabled {
    background: #4b5563;
    color: #9ca3af;
    cursor: not-allowed;
}

.btn-secondary {
    background: #4b5563;
    color: white;
}

.btn-secondary:hover {
    background: #6b7280;
}

/* Achievements */
.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.achievement {
    padding: 16px;
    border-radius: 8px;
    border: 1px solid;
    transition: all 0.3s ease;
}

.achievement.unlocked {
    background: linear-gradient(135deg, rgba(100, 255, 218, 0.2), rgba(147, 51, 234, 0.2));
    border-color: rgba(100, 255, 218, 0.5);
}

.achievement.locked {
    background: rgba(71, 85, 105, 0.5);
    border-color: rgba(71, 85, 105, 0.3);
}

.achievement-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.achievement-icon {
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.achievement.unlocked .achievement-icon {
    background: rgba(100, 255, 218, 0.2);
}

.achievement.locked .achievement-icon {
    background: rgba(75, 85, 99, 0.5);
}

.achievement-info {
    flex: 1;
}

.achievement-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.achievement.unlocked .achievement-name {
    color: white;
}

.achievement.locked .achievement-name {
    color: #94a3b8;
}

.achievement-description {
    font-size: 14px;
    color: #94a3b8;
}

.achievement-check {
    color: #64ffda;
    font-size: 14px;
    font-weight: 500;
}

.achievement-progress {
    width: 100%;
    background: rgba(75, 85, 99, 0.5);
    border-radius: 9999px;
    height: 8px;
    margin-top: 8px;
}

.achievement-progress-bar {
    height: 8px;
    border-radius: 9999px;
    transition: all 0.5s ease;
}

.achievement.unlocked .achievement-progress-bar {
    background: linear-gradient(90deg, #64ffda, #a78bfa);
}

.achievement.locked .achievement-progress-bar {
    background: #6b7280;
}

.achievement-progress-text {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

/* Saved Constellations */
.saved-constellations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.no-constellations {
    color: #94a3b8;
    text-align: center;
    padding: 32px 0;
}

.constellation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: rgba(71, 85, 105, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(71, 85, 105, 0.3);
    transition: border-color 0.2s ease;
}

.constellation-item:hover {
    border-color: rgba(100, 255, 218, 0.5);
}

.constellation-info {
    flex: 1;
}

.constellation-name {
    color: white;
    font-weight: 500;
    margin-bottom: 4px;
}

.constellation-details {
    color: #94a3b8;
    font-size: 14px;
}

.constellation-actions {
    display: flex;
    gap: 8px;
}

.constellation-load-btn {
    background: #64ffda;
    color: #0f172a;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.constellation-load-btn:hover {
    background: #4ecdc4;
}

.constellation-delete-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.constellation-delete-btn:hover {
    background: #dc2626;
}

/* Share Modal */
.share-description {
    color: #cbd5e1;
    font-size: 14px;
    margin-bottom: 16px;
}

.share-url-container {
    background: rgba(71, 85, 105, 0.5);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(71, 85, 105, 0.3);
    margin-bottom: 16px;
}

.share-url {
    color: #64ffda;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

.share-note {
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
    margin-top: 8px;
}

/* Settings Modal */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    color: white;
    font-weight: 500;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-item {
    margin-bottom: 12px;
}

.setting-item label {
    display: block;
    color: #cbd5e1;
    font-size: 14px;
    margin-bottom: 4px;
}

.setting-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #4b5563;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #64ffda;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #64ffda;
    cursor: pointer;
    border: none;
}

.setting-value {
    color: #64ffda;
    font-size: 14px;
    margin-top: 4px;
}

/* Tooltip */
.tooltip {
    position: absolute;
    z-index: 1000;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.tooltip-content {
    background: #0f172a;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    border: 1px solid #4b5563;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
}

.tooltip-arrow {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #0f172a;
    border: 1px solid #4b5563;
    transform: rotate(45deg);
}

.tooltip.top .tooltip-arrow {
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    border-top: none;
    border-left: none;
}

.tooltip.bottom .tooltip-arrow {
    top: -5px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    border-bottom: none;
    border-right: none;
}

.tooltip.left .tooltip-arrow {
    right: -5px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    border-left: none;
    border-bottom: none;
}

.tooltip.right .tooltip-arrow {
    left: -5px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    border-right: none;
    border-top: none;
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

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

.modal {
    animation: fadeIn 0.2s ease;
}

/* Responsive Design */
@media (max-width: 768px) {
    .toolbar-content {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }
    
    .control-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .modal-content {
        margin: 16px;
        max-width: none;
    }
    
    .setting-row {
        grid-template-columns: 1fr;
    }
    
    .musical-info {
        flex-direction: column;
        gap: 4px;
        font-size: 12px;
    }
}