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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #ecf0f1;
    overflow: hidden;
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Loading Screen */
#loadingScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #1a252f 0%, #2c3e50 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    color: #ecf0f1;
}

.loading-content h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #e74c3c;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.loading-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #bdc3c7;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #34495e;
    border-top: 4px solid #e74c3c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Login Screen */
#loginScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #1a252f 0%, #2c3e50 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.login-form {
    background: rgba(52, 73, 94, 0.9);
    padding: 2rem;
    border-radius: 10px;
    border: 2px solid #e74c3c;
    text-align: center;
    min-width: 300px;
}

.login-form h2 {
    color: #e74c3c;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.login-form input {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1rem;
    border: 1px solid #34495e;
    border-radius: 5px;
    background: #2c3e50;
    color: #ecf0f1;
    font-size: 1rem;
}

.login-form input:focus {
    outline: none;
    border-color: #e74c3c;
}

.login-form button {
    width: 100%;
    padding: 0.8rem;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.login-form button:hover {
    background: #c0392b;
}

/* Main Game Interface */
#gameInterface {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Game World */
#gameWorld {
    width: 100%;
    height: 100%;
    position: relative;
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 100%);
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    background: transparent;
    border: 2px solid #2c3e50;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

/* Game Overlay */
#gameOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* UI Panels */
.ui-panel {
    position: absolute;
    background: rgba(44, 62, 80, 0.6);
    border: 2px solid #e74c3c;
    border-radius: 10px;
    padding: 15px;
    color: #ecf0f1;
    pointer-events: all;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    min-width: 200px;
}

.ui-panel.left-side {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 150px;
}

.ui-panel.bottom {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    align-items: end;
    min-width: 400px;
    max-width: 600px;
}

/* Top Left - Player Info */
.ui-panel.top-left {
    top: 20px;
    left: 20px;
    min-width: 200px;
}

.player-details {
    margin-bottom: 10px;
}

.player-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 5px;
}

.player-level {
    font-size: 0.9rem;
    color: #bdc3c7;
}

.health-energy {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-icon {
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.stat-bar {
    flex: 1;
    height: 12px;
    background: #34495e;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #2c3e50;
}

.stat-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.stat-fill.health {
    background: linear-gradient(90deg, #e74c3c 0%, #c0392b 100%);
}

.stat-fill.energy {
    background: linear-gradient(90deg, #f39c12 0%, #e67e22 100%);
}

/* Top Right - Time & Weather */
.ui-panel.top-right {
    top: 20px;
    right: 20px;
    text-align: right;
}

.time-display {
    font-size: 1.1rem;
    font-weight: bold;
    color: #f39c12;
    margin-bottom: 5px;
}

.weather-display {
    font-size: 0.9rem;
    color: #bdc3c7;
}

/* Left Side - Quick Actions */
.ui-panel.left-side {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 150px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #34495e;
    border: 1px solid #2c3e50;
    border-radius: 8px;
    color: #ecf0f1;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.action-btn:hover {
    background: #e74c3c;
    transform: translateX(5px);
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-text {
    font-size: 0.85rem;
}

/* Bottom - Chat and Controls */
.ui-panel.bottom {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    align-items: end;
    min-width: 400px;
    max-width: 600px;
}

#chatContainer {
    flex: 1;
    max-width: 400px;
}

#chatWindow {
    height: 120px;
    background: rgba(52, 73, 94, 0.5);
    border: 1px solid #34495e;
    border-radius: 8px;
    padding: 10px;
    overflow-y: auto;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

#chatInput {
    display: flex;
    gap: 5px;
}

#chatMessageInput {
    flex: 1;
    padding: 8px;
    border: 1px solid #34495e;
    border-radius: 5px;
    background: #2c3e50;
    color: #ecf0f1;
    font-size: 0.9rem;
}

#chatMessageInput:focus {
    outline: none;
    border-color: #e74c3c;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

#chatSendBtn {
    padding: 8px 15px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

#chatSendBtn:hover {
    background: #c0392b;
}

#controlsInfo {
    font-size: 0.8rem;
    color: #bdc3c7;
    text-align: center;
    white-space: nowrap;
}

/* Modal Panels */
.modal-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(44, 62, 80, 0.7);
    border: 2px solid #e74c3c;
    border-radius: 15px;
    min-width: 400px;
    max-width: 600px;
    max-height: 70vh;
    overflow: hidden;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #34495e;
    background: rgba(52, 73, 94, 0.6);
}

.modal-header h3 {
    color: #e74c3c;
    font-size: 1.4rem;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: #bdc3c7;
    font-size: 1.5rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.close-btn:hover {
    background: #e74c3c;
    color: white;
}

.modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    color: #ecf0f1;
}

/* Inventory Grid */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
    max-width: 500px;
}

.inventory-slot {
    aspect-ratio: 1;
    background: #34495e;
    border: 2px solid #2c3e50;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.inventory-slot:hover {
    border-color: #e74c3c;
    background: #3a5269;
}

.inventory-slot.filled {
    background: #4a5f7a;
}

.item-icon {
    font-size: 1.2rem;
}

.item-quantity {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.7rem;
    color: #f39c12;
    font-weight: bold;
}

/* Skills List */
.skills-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.skill-item {
    background: #34495e;
    border: 1px solid #2c3e50;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s;
}

.skill-item:hover {
    border-color: #e74c3c;
}

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

.skill-name {
    font-weight: bold;
    color: #e74c3c;
}

.skill-level {
    color: #f39c12;
    font-size: 0.9rem;
}

.skill-progress {
    width: 100%;
    height: 10px;
    background: #2c3e50;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 5px;
}

.skill-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60 0%, #2ecc71 100%);
    transition: width 0.3s ease;
}

.skill-description {
    font-size: 0.85rem;
    color: #bdc3c7;
}

/* Crafting Recipes */
.crafting-recipes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.recipe-item {
    background: #34495e;
    border: 1px solid #2c3e50;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s;
    cursor: pointer;
}

.recipe-item:hover {
    border-color: #e74c3c;
    background: #3a5269;
}

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

.recipe-name {
    font-weight: bold;
    color: #e74c3c;
}

.recipe-level {
    color: #f39c12;
    font-size: 0.9rem;
}

.recipe-materials {
    margin-bottom: 10px;
}

.recipe-materials h4 {
    color: #bdc3c7;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.material-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #95a5a6;
    margin-bottom: 2px;
}

.craft-btn {
    width: 100%;
    padding: 8px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.craft-btn:hover {
    background: #2ecc71;
}

.craft-btn:disabled {
    background: #7f8c8d;
    cursor: not-allowed;
}

/* Chat Styles */
.chat-message {
    margin-bottom: 5px;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 0.85rem;
    line-height: 1.4;
    word-wrap: break-word;
    opacity: 0;
    animation: fadeIn 0.3s ease-in-out forwards;
}

.chat-message.system {
    background: rgba(52, 152, 219, 0.2);
    border-left: 3px solid #3498db;
    color: #3498db;
    font-style: italic;
}

.chat-message.own {
    background: rgba(231, 76, 60, 0.2);
    border-left: 3px solid #e74c3c;
    color: #ecf0f1;
}

.chat-message.other {
    background: rgba(149, 165, 166, 0.2);
    border-left: 3px solid #95a5a6;
    color: #ecf0f1;
}

.chat-message.emote {
    background: rgba(155, 89, 182, 0.2);
    border-left: 3px solid #9b59b6;
    color: #9b59b6;
    font-style: italic;
}

.chat-message.whisper {
    background: rgba(241, 196, 15, 0.2);
    border-left: 3px solid #f1c40f;
    color: #f1c40f;
}

.chat-message .player-name {
    font-weight: bold;
    margin-right: 5px;
}

.chat-message .timestamp {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-left: 5px;
}

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

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: 5px;
    right: 10px;
    background: #e74c3c;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    cursor: pointer;
    animation: pulse 2s infinite;
}

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

/* Draggable elements */
.draggable {
    cursor: move;
}

.draggable.dragging {
    z-index: 1000;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

.drag-handle {
    background: rgba(231, 76, 60, 0.6);
    margin: -15px -15px 10px -15px;
    padding: 8px 15px;
    border-radius: 8px 8px 0 0;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: move;
    user-select: none;
    text-align: center;
}

.drag-handle:hover {
    background: rgba(231, 76, 60, 0.8);
}

/* Visual Key */
#visualKey {
    max-width: 250px;
}

.key-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.key-section {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.key-title {
    font-weight: bold;
    color: #f39c12;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.key-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.key-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #2c3e50;
}

.player-icon {
    background: #3498db;
}

.key-text {
    font-size: 0.85rem;
    color: #bdc3c7;
}

/* Actions content */
.actions-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Responsive Design */
@media (max-width: 1600px) {
    .ui-panel.left-side {
        width: 100px;
    }
    
    .btn-text {
        display: none;
    }
    
    .ui-panel.bottom {
        min-width: 500px;
    }
}

@media (max-width: 1200px) {
    #gameCanvas {
        width: 90vw;
        height: 60vh;
    }
    
    .ui-panel.top-left,
    .ui-panel.top-right {
        position: fixed;
        z-index: 200;
    }
    
    .ui-panel.left-side {
        left: 10px;
        width: 80px;
    }
    
    .ui-panel.bottom {
        min-width: 400px;
    }
}
