/* World Builder - PNEUOMA Create */

:root {
    --bg-space: #0a0a1f;
    --bg-deep: #050510;
    --accent-cosmic: #a78bfa;
    --accent-nebula: #f472b6;
    --accent-star: #fbbf24;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);
    --font-display: 'Cormorant Garamond', serif;
    --font-body: 'Space Grotesk', sans-serif;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
}

body {
    font-family: var(--font-body);
    background: var(--bg-space);
    color: var(--text-primary);
}

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

#stars-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    z-index: 1;
}

.screen.active {
    display: flex;
}

/* ==================== START SCREEN ==================== */

#start-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, rgba(167, 139, 250, 0.1) 0%, transparent 50%);
}

.start-content {
    text-align: center;
    padding: 2rem;
    animation: fadeInUp 1s ease;
}

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

.cosmos-preview {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 2rem;
}

.preview-planet {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at 30% 30%, 
        #6ee7b7 0%, 
        #34d399 40%, 
        #059669 100%);
    border-radius: 50%;
    box-shadow: 
        0 0 80px rgba(52, 211, 153, 0.4),
        inset -20px -20px 40px rgba(0, 0, 0, 0.3);
    animation: previewFloat 4s ease-in-out infinite;
}

@keyframes previewFloat {
    0%, 100% { transform: translate(-50%, -50%) translateY(0); }
    50% { transform: translate(-50%, -50%) translateY(-15px); }
}

.preview-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotateX(70deg);
    width: 200px;
    height: 200px;
    border: 4px solid rgba(167, 139, 250, 0.4);
    border-radius: 50%;
    animation: ringRotate 10s linear infinite;
}

@keyframes ringRotate {
    from { transform: translate(-50%, -50%) rotateX(70deg) rotateZ(0deg); }
    to { transform: translate(-50%, -50%) rotateX(70deg) rotateZ(360deg); }
}

.title {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 0%, var(--accent-cosmic) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--accent-cosmic);
    margin-bottom: 0.5rem;
}

.tagline {
    color: var(--text-muted);
    margin-bottom: 3rem;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.primary-btn {
    padding: 1rem 2.5rem;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--bg-space);
    background: linear-gradient(135deg, var(--accent-cosmic) 0%, var(--accent-nebula) 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 40px rgba(167, 139, 250, 0.4);
}

/* ==================== BUILDER SCREEN ==================== */

#builder-screen {
    flex-direction: column;
}

.planet-viewport {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: var(--safe-top);
    min-height: 50%;
}

#planet-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#planet-container {
    position: relative;
    z-index: 2;
}

#planet {
    position: relative;
    width: 150px;
    height: 150px;
    transition: width 0.5s ease, height 0.5s ease;
}

.planet-surface {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, 
        #6ee7b7 0%, 
        #34d399 40%, 
        #059669 100%);
    box-shadow: inset -20px -20px 40px rgba(0, 0, 0, 0.4);
    transition: all 0.5s ease;
}

.planet-atmosphere {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    border-radius: 50%;
    background: radial-gradient(circle, 
        rgba(59, 130, 246, 0.2) 0%, 
        rgba(59, 130, 246, 0.1) 50%,
        transparent 70%);
    pointer-events: none;
    transition: all 0.5s ease;
}

.planet-clouds {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: 
        radial-gradient(ellipse 30% 20% at 25% 30%, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(ellipse 25% 15% at 60% 20%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(ellipse 35% 25% at 70% 60%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(ellipse 20% 15% at 30% 70%, rgba(255, 255, 255, 0.25), transparent);
    animation: cloudsRotate 30s linear infinite;
    transition: opacity 0.5s ease;
}

@keyframes cloudsRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.planet-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotateX(75deg);
    width: 220%;
    height: 220%;
    border: 8px solid rgba(167, 139, 250, 0.3);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.planet-ring.visible {
    opacity: 1;
}

.planet-highlight {
    position: absolute;
    top: 15%;
    left: 20%;
    width: 25%;
    height: 25%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.5), transparent);
    border-radius: 50%;
    filter: blur(5px);
}

#orbital-objects {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ==================== MOONS ==================== */

.moon {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.moon-0 { width: 25px; height: 25px; background: radial-gradient(circle at 30% 30%, #e5e7eb, #9ca3af); animation: moonOrbit0 12s linear infinite; }
.moon-1 { width: 18px; height: 18px; background: radial-gradient(circle at 30% 30%, #fcd34d, #d97706); animation: moonOrbit1 8s linear infinite; }
.moon-2 { width: 22px; height: 22px; background: radial-gradient(circle at 30% 30%, #a5b4fc, #6366f1); animation: moonOrbit2 15s linear infinite reverse; }
.moon-3 { width: 14px; height: 14px; background: radial-gradient(circle at 30% 30%, #fca5a5, #dc2626); animation: moonOrbit3 6s linear infinite; }
.moon-4 { width: 20px; height: 20px; background: radial-gradient(circle at 30% 30%, #86efac, #16a34a); animation: moonOrbit4 18s linear infinite reverse; }
.moon-5 { width: 16px; height: 16px; background: radial-gradient(circle at 30% 30%, #f0abfc, #a855f7); animation: moonOrbit5 10s linear infinite; }
.moon-6 { width: 12px; height: 12px; background: radial-gradient(circle at 30% 30%, #fdba74, #ea580c); animation: moonOrbit6 7s linear infinite reverse; }
.moon-7 { width: 24px; height: 24px; background: radial-gradient(circle at 30% 30%, #67e8f9, #0891b2); animation: moonOrbit7 20s linear infinite; }
.moon-8 { width: 15px; height: 15px; background: radial-gradient(circle at 30% 30%, #fde68a, #ca8a04); animation: moonOrbit8 9s linear infinite reverse; }
.moon-9 { width: 19px; height: 19px; background: radial-gradient(circle at 30% 30%, #c4b5fd, #7c3aed); animation: moonOrbit9 14s linear infinite; }

@keyframes moonOrbit0 { from { transform: rotate(0deg) translateX(130px) rotate(0deg); } to { transform: rotate(360deg) translateX(130px) rotate(-360deg); } }
@keyframes moonOrbit1 { from { transform: rotate(45deg) translateX(100px) rotate(-45deg); } to { transform: rotate(405deg) translateX(100px) rotate(-405deg); } }
@keyframes moonOrbit2 { from { transform: rotate(90deg) translateX(160px) rotate(-90deg); } to { transform: rotate(450deg) translateX(160px) rotate(-450deg); } }
@keyframes moonOrbit3 { from { transform: rotate(135deg) translateX(85px) rotate(-135deg); } to { transform: rotate(495deg) translateX(85px) rotate(-495deg); } }
@keyframes moonOrbit4 { from { transform: rotate(180deg) translateX(180px) rotate(-180deg); } to { transform: rotate(540deg) translateX(180px) rotate(-540deg); } }
@keyframes moonOrbit5 { from { transform: rotate(225deg) translateX(110px) rotate(-225deg); } to { transform: rotate(585deg) translateX(110px) rotate(-585deg); } }
@keyframes moonOrbit6 { from { transform: rotate(270deg) translateX(75px) rotate(-270deg); } to { transform: rotate(630deg) translateX(75px) rotate(-630deg); } }
@keyframes moonOrbit7 { from { transform: rotate(315deg) translateX(200px) rotate(-315deg); } to { transform: rotate(675deg) translateX(200px) rotate(-675deg); } }
@keyframes moonOrbit8 { from { transform: rotate(30deg) translateX(95px) rotate(-30deg); } to { transform: rotate(390deg) translateX(95px) rotate(-390deg); } }
@keyframes moonOrbit9 { from { transform: rotate(150deg) translateX(145px) rotate(-150deg); } to { transform: rotate(510deg) translateX(145px) rotate(-510deg); } }

/* ==================== SUNS ==================== */

#suns-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.sun {
    position: absolute;
    border-radius: 50%;
}

.sun-0 {
    width: 60px;
    height: 60px;
    top: 15%;
    right: 15%;
    background: radial-gradient(circle at 40% 40%, #fff9c4 0%, #ffd54f 30%, #ff9800 70%, #f57c00 100%);
    box-shadow: 
        0 0 60px rgba(255, 193, 7, 0.8),
        0 0 120px rgba(255, 152, 0, 0.5),
        0 0 200px rgba(255, 87, 34, 0.3);
    animation: sunPulse 4s ease-in-out infinite, sunGlow 8s ease-in-out infinite;
}

.sun-1 {
    width: 45px;
    height: 45px;
    top: 25%;
    left: 12%;
    background: radial-gradient(circle at 40% 40%, #e1f5fe 0%, #81d4fa 30%, #29b6f6 70%, #0288d1 100%);
    box-shadow: 
        0 0 50px rgba(129, 212, 250, 0.8),
        0 0 100px rgba(41, 182, 246, 0.5),
        0 0 160px rgba(2, 136, 209, 0.3);
    animation: sunPulse 5s ease-in-out infinite 1s, sunGlow 10s ease-in-out infinite 2s;
}

@keyframes sunPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes sunGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

/* Sun rays */
.sun::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: rayRotate 30s linear infinite;
}

@keyframes rayRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ==================== MUSIC BUTTON ==================== */

.music-btn {
    position: absolute;
    top: calc(var(--safe-top) + 15px);
    right: 15px;
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.music-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: var(--accent-cosmic);
}

.music-btn.playing {
    border-color: var(--accent-cosmic);
    box-shadow: 0 0 20px rgba(167, 139, 250, 0.4);
}

.music-btn.playing .music-icon {
    animation: musicPulse 1s ease-in-out infinite;
}

.music-icon {
    font-size: 1.5rem;
}

@keyframes musicPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Control value display */
.control-value {
    float: right;
    color: var(--accent-cosmic);
    font-weight: 600;
}

.planet-name-display {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 30px;
    backdrop-filter: blur(10px);
}

#world-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--text-primary);
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.icon-btn:hover {
    opacity: 1;
}

/* ==================== CONTROL PANEL ==================== */

.control-panel {
    background: rgba(10, 10, 31, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px 30px 0 0;
    overflow: hidden;
    max-height: 50%;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    padding: 15px 10px;
    gap: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    overflow-x: auto;
    scrollbar-width: none;
}

.panel-header::-webkit-scrollbar {
    display: none;
}

.panel-tab {
    flex-shrink: 0;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 20px;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.panel-tab.active {
    background: linear-gradient(135deg, var(--accent-cosmic), var(--accent-nebula));
    color: white;
}

.panel-content {
    display: none;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.panel-content.active {
    display: block;
}

.control-group {
    margin-bottom: 25px;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 12px;
}

.option-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.option-btn, .life-btn, .extra-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 15px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.option-btn:hover, .life-btn:hover, .extra-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.option-btn.active {
    border-color: var(--accent-cosmic);
    background: rgba(167, 139, 250, 0.15);
}

.life-btn.added, .extra-btn.added {
    border-color: var(--accent-nebula);
    background: rgba(244, 114, 182, 0.15);
}

.option-icon {
    font-size: 1.5rem;
}

.option-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Sliders */
.slider {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--accent-cosmic), var(--accent-nebula));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(167, 139, 250, 0.4);
}

/* Color Options */
.color-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-btn {
    width: 40px;
    height: 40px;
    border: 3px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-btn.active {
    border-color: white;
    transform: scale(1.1);
}

/* Toggle */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.toggle-btn {
    width: 50px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-btn.active {
    background: var(--accent-cosmic);
}

.toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    transition: left 0.3s ease;
}

.toggle-btn.active .toggle-knob {
    left: 25px;
}

/* Life Inventory */
.life-inventory {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    min-height: 60px;
}

.inventory-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

.life-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.life-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(244, 114, 182, 0.2);
    border-radius: 20px;
    font-size: 0.85rem;
}

.life-tag button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    padding: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-cosmic);
}

.action-btn.primary {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: #0a0a1f;
    font-weight: 600;
    border: none;
    box-shadow: 0 4px 20px rgba(74, 222, 128, 0.3);
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 6px 30px rgba(74, 222, 128, 0.5);
}

/* ==================== MODALS ==================== */

.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: var(--bg-space);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 30px;
    max-width: 90%;
    width: 350px;
    text-align: center;
}

.modal-content h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.modal-content input {
    width: 100%;
    padding: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    margin-bottom: 20px;
}

.modal-content input:focus {
    outline: none;
    border-color: var(--accent-cosmic);
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn.primary {
    background: linear-gradient(135deg, var(--accent-cosmic), var(--accent-nebula));
    color: white;
}

.modal-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.save-success {
    margin-bottom: 20px;
}

.save-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
}

.save-success p {
    color: var(--text-secondary);
}

/* ==================== AURORA EFFECT ==================== */

.aurora {
    position: absolute;
    top: -50%;
    left: -25%;
    width: 150%;
    height: 100%;
    background: linear-gradient(180deg, 
        transparent 0%,
        rgba(52, 211, 153, 0.1) 30%,
        rgba(167, 139, 250, 0.1) 50%,
        rgba(244, 114, 182, 0.1) 70%,
        transparent 100%);
    transform: rotate(-15deg);
    animation: auroraWave 8s ease-in-out infinite;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.aurora.visible {
    opacity: 1;
}

@keyframes auroraWave {
    0%, 100% { transform: rotate(-15deg) translateY(0); }
    50% { transform: rotate(-15deg) translateY(20px); }
}

/* ==================== RESPONSIVE ==================== */

/* Mobile fixes - ensure save buttons are visible */
@media (max-width: 767px) {
    .control-panel {
        max-height: 55vh;
        padding-bottom: calc(var(--safe-bottom) + 20px);
    }
    
    .panel-content {
        padding-bottom: 100px;
    }
    
    .action-buttons {
        position: sticky;
        bottom: 0;
        background: rgba(10, 10, 31, 0.98);
        padding: 15px;
        margin: -20px -20px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
}

@media (min-width: 768px) {
    .control-panel {
        max-height: 40%;
    }
    
    .option-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

