* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    direction: rtl;
}

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 0.5s;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    text-align: center;
    color: white;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

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

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

#ui-overlay > * {
    pointer-events: auto;
}

/* Main HUD */
#main-hud {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    min-width: 280px;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.hud-section h2 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #fff;
}

.age-display {
    font-size: 32px;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 20px;
}

.stats-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-bar {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-bar label {
    font-size: 14px;
    color: #ccc;
}

.bar-container {
    width: 100%;
    height: 25px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 12px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.stat-bar span {
    font-size: 12px;
    color: #fff;
    font-weight: bold;
}

/* Events Panel */
#events-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#events-panel h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: #fff;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

#events-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.event-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 8px;
    border-right: 3px solid #4CAF50;
    animation: slideIn 0.3s ease;
    font-size: 14px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Actions Panel */
#actions-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 90%;
}

.action-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 15px 25px;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-weight: bold;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Life Stage Indicator */
#life-stage-indicator {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 15px 25px;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.stage {
    padding: 8px 15px;
    border-radius: 15px;
    font-size: 14px;
    color: #ccc;
    transition: all 0.3s ease;
}

.stage.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    transform: scale(1.1);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    color: white;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h1 {
    font-size: 36px;
    margin-bottom: 20px;
}

.modal-content p {
    font-size: 18px;
    margin-bottom: 30px;
    opacity: 0.9;
}

#character-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#character-form input,
#character-form select {
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

.btn-primary {
    background: white;
    color: #667eea;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

#life-summary {
    text-align: right;
    margin: 20px 0;
    font-size: 16px;
    line-height: 1.8;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #main-hud {
        top: 10px;
        right: 10px;
        padding: 15px;
        min-width: 200px;
        font-size: 14px;
    }
    
    .hud-section h2 {
        font-size: 18px;
    }
    
    .age-display {
        font-size: 24px;
    }
    
    #events-panel {
        top: 10px;
        left: 10px;
        width: calc(100% - 20px);
        max-height: 200px;
        font-size: 12px;
    }
    
    #actions-panel {
        bottom: 10px;
        gap: 8px;
    }
    
    .action-btn {
        padding: 12px 18px;
        font-size: 14px;
    }
    
    #life-stage-indicator {
        bottom: 80px;
        padding: 10px 15px;
        gap: 5px;
    }
    
    .stage {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
    
    .modal-content h1 {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    #actions-panel {
        flex-direction: column;
        width: 90%;
    }
    
    .action-btn {
        width: 100%;
    }
    
    #life-stage-indicator {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Scrollbar Styling */
#events-panel::-webkit-scrollbar {
    width: 8px;
}

#events-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#events-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

#events-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}
