/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --accent: #e94560;
    --accent-light: #ff6b6b;
    --text-primary: #eee;
    --text-secondary: #aaa;
    --text-muted: #666;
    --success: #4ecca3;
    --warning: #ffc107;
    --message-player: #0f3460;
    --message-game: #1a1a2e;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.screen {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* === START SCREEN === */
#start-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.start-container {
    text-align: center;
    padding: 3rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 400px;
    width: 90%;
}

.start-container h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.start-container p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.start-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.start-form input {
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    text-align: center;
    transition: border-color 0.3s;
}

.start-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.start-form button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: var(--border-radius);
    background: var(--accent);
    color: white;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}

.start-form button:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
}

/* === GAME SCREEN === */
#game-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* === HEADER === */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
}

.room-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.player-name {
    color: var(--text-secondary);
}

.inventory-toggle {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.3s;
}

.inventory-toggle:hover {
    background: var(--accent);
}

/* === INVENTORY SIDEBAR === */
.inventory-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--bg-tertiary);
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.3);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--bg-tertiary);
}

.inventory-header h3 {
    color: var(--accent);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--accent);
}

.inventory-list {
    list-style: none;
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.inventory-list li {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inventory-list li::before {
    content: "📦";
}

.empty-inventory {
    color: var(--text-muted);
    font-style: italic;
}

.empty-inventory::before {
    content: "" !important;
}

/* === CHAT CONTAINER === */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* === MESSAGES === */
.message {
    max-width: 85%;
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    animation: fadeIn 0.3s ease;
}

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

.message-game {
    align-self: flex-start;
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent);
}

.message-player {
    align-self: flex-end;
    background: var(--bg-tertiary);
    border-right: 4px solid var(--success);
}

.message-system {
    align-self: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--warning);
    text-align: center;
    font-style: italic;
    color: var(--text-secondary);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Exits & Items in messages */
.message-meta {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--bg-tertiary);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.message-meta strong {
    color: var(--text-primary);
}

/* === TYPING INDICATOR === */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: bounce 1.4s infinite both;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* === QUICK ACTIONS === */
.quick-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
    overflow-x: auto;
}

.quick-actions button {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--bg-primary);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.quick-actions button:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* === INPUT AREA === */
.input-area {
    padding: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
}

.input-container {
    display: flex;
    gap: 0.75rem;
    max-width: 800px;
    margin: 0 auto;
}

#command-input {
    flex: 1;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    border: 2px solid var(--bg-tertiary);
    border-radius: 25px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.3s;
}

#command-input:focus {
    outline: none;
    border-color: var(--accent);
}

#command-input::placeholder {
    color: var(--text-muted);
}

#send-button {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}

#send-button:hover {
    background: var(--accent-light);
    transform: scale(1.05);
}

#send-button:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* === RESPONSIVE === */
@media (max-width: 600px) {
    .game-header {
        padding: 0.75rem 1rem;
    }

    .room-name {
        font-size: 1rem;
    }

    .player-name {
        display: none;
    }

    .message {
        max-width: 95%;
    }

    .quick-actions {
        justify-content: flex-start;
    }

    .inventory-sidebar {
        width: 100%;
    }
}

/* === MODAL === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--bg-tertiary);
}

.modal-header h3 {
    color: var(--accent);
    margin: 0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Save Form */
#save-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

#save-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--bg-tertiary);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
}

#save-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-primary {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: var(--accent-light);
}

.btn-secondary {
    padding: 1rem 2rem;
    font-size: 1rem;
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Save List */
.save-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.save-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    transition: background 0.2s;
}

.save-item:hover {
    background: var(--bg-primary);
}

.save-info {
    flex: 1;
}

.save-name {
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.save-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.save-details span {
    margin-right: 1rem;
}

.save-actions {
    display: flex;
    gap: 0.5rem;
}

.save-actions button {
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-load {
    background: var(--success);
    color: white;
}

.btn-load:hover {
    background: #3db88a;
}

.btn-delete {
    background: var(--accent);
    color: white;
}

.btn-delete:hover {
    background: var(--accent-light);
}

.loading-saves, .no-saves {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.no-saves {
    font-style: italic;
}

.gold-display {
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: #1a1a2e;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
}