/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #1e1b4b;
    --accent-color: #a78bfa;
    --background-dark: #0f0d1a;
    --background-card: #1a1625;
    --background-light: #252136;
    --text-primary: #f8fafc;
    --text-secondary: #a5b4fc;
    --text-muted: #6b7280;
    --border-color: #374151;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --health-color: #ef4444;
    --energy-color: #3b82f6;
    --gold-color: #f59e0b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.3s ease;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--background-dark) 100%);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    margin-bottom: 2rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-sm);
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding-bottom: 2rem;
}

/* Generator Panel */
.generator-panel {
    background: var(--background-card);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.generator-panel h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-size: 1.5rem;
}

/* Form Sections */
.form-section {
    background: var(--background-light);
    border-radius: var(--border-radius-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.section-icon {
    font-size: 1.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--background-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input[type="text"]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-group input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* Checkbox Group */
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    color: var(--text-primary);
}

.checkbox-group input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    margin-top: 1rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-secondary {
    background: var(--background-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

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

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

/* Game Panel */
.game-panel {
    background: var(--background-card);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.game-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.game-header h2 {
    font-size: 1.25rem;
    color: var(--accent-color);
}

.game-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Stats Panel */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    background: var(--background-light);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-bar {
    height: 8px;
    background: var(--background-dark);
    border-radius: 4px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.stat-fill.health {
    background: linear-gradient(90deg, var(--danger-color), #f87171);
}

.stat-fill.energy {
    background: linear-gradient(90deg, var(--energy-color), #60a5fa);
}

.stat-value {
    font-weight: 600;
    font-size: 0.9rem;
}

.stat-value.gold {
    color: var(--gold-color);
}

/* Inventory Panel */
.inventory-panel {
    background: var(--background-light);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.inventory-panel h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.inventory-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.inventory-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--background-dark);
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

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

/* Story Container */
.story-container {
    background: var(--background-light);
    border-radius: var(--border-radius-sm);
    padding: 1.5rem;
    margin-bottom: 1rem;
    position: relative;
}

.scene-info {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.scene-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.scene-number {
    background: var(--primary-color);
    color: white;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 600;
}

.story-text {
    line-height: 1.8;
    color: var(--text-primary);
    font-size: 1.05rem;
    padding-top: 0.5rem;
}

.story-text p {
    margin-bottom: 1rem;
}

.story-text p:last-child {
    margin-bottom: 0;
}

.story-text .highlight {
    color: var(--accent-color);
    font-weight: 500;
}

.story-text .item-found {
    color: var(--success-color);
    font-style: italic;
}

.story-text .damage-taken {
    color: var(--danger-color);
    font-weight: 500;
}

/* Choices Container */
.choices-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.choice-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--background-light);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.choice-btn:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    transform: translateX(4px);
}

.choice-btn:active {
    transform: translateX(2px);
}

.choice-number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 600;
}

.choice-text {
    flex: 1;
}

.choice-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: auto;
}

.choice-hint.danger {
    color: var(--danger-color);
}

.choice-hint.success {
    color: var(--success-color);
}

/* Game Over Screen */
.game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.game-over-content {
    background: var(--background-card);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.game-over-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.game-over-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.game-over-stats {
    background: var(--background-light);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.game-over-stats p {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.game-over-stats p:last-child {
    margin-bottom: 0;
}

.game-over-content .btn-primary {
    margin-bottom: 0.75rem;
}

.game-over-content .btn-secondary {
    width: 100%;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal-content {
    background: var(--background-card);
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

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

.saved-games-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.saved-game-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--background-light);
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.saved-game-info h4 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.saved-game-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.saved-game-actions button {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

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

/* Footer */
.footer {
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

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

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Responsive Design */
@media (min-width: 768px) {
    .header h1 {
        font-size: 2.25rem;
    }

    .tagline {
        font-size: 1.1rem;
    }

    .generator-panel,
    .game-panel {
        padding: 2.5rem;
    }

    .game-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .stats-panel {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .form-section {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .form-section h3 {
        grid-column: 1 / -1;
    }

    .form-section .checkbox-group {
        grid-column: auto;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .generator-panel,
    .game-panel {
        padding: 1.25rem;
    }

    .form-section {
        padding: 1rem;
    }

    .game-controls {
        justify-content: center;
    }

    .btn-secondary span {
        display: none;
    }

    .choice-btn {
        padding: 0.875rem 1rem;
    }
}

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

.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 1rem;
}
