@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border: #334155;
    --glass-bg: rgba(30, 41, 59, 0.8);
    --glass-border: rgba(148, 163, 184, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(245, 158, 11, 0.1) 0%, transparent 50%);
    z-index: -1;
}

/* Screens Base */
.start-screen, .name-screen, .difficulty-screen, .game-container, 
.end-screen, .history-screen, .emblem-album {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    width: 90%;
    max-width: 900px;
    text-align: center;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none;
}

/* Typography */
h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

/* Buttons */
button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    margin: 0.5rem;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.3);
}

button:active {
    transform: translateY(0);
}

/* Button Variants */
.start-buttons button:nth-child(2),
.name-buttons button:nth-child(2),
.difficulty-screen button:last-child,
.end-screen button:first-child,
.history-screen button,
.emblem-album button,
.game-info-bar button {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border: 1px solid var(--border);
}

.start-buttons button:nth-child(2):hover,
.name-buttons button:nth-child(2):hover,
.difficulty-screen button:last-child:hover,
.end-screen button:first-child:hover,
.history-screen button:hover,
.emblem-album button:hover,
.game-info-bar button:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* Success buttons */
#check-button,
.start-buttons button:nth-child(4) {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

#check-button:hover,
.start-buttons button:nth-child(4):hover {
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.3);
}

/* Warning buttons */
#skip-button,
.start-buttons button:nth-child(3) {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
}

#skip-button:hover,
.start-buttons button:nth-child(3):hover {
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.3);
}

/* Difficulty buttons */
.difficulty-buttons button:nth-child(1) {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.difficulty-buttons button:nth-child(2) {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
}

.difficulty-buttons button:nth-child(3) {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

.difficulty-buttons button:nth-child(4) {
    background: linear-gradient(135deg, #9d4edd 0%, #7209b7 100%);
}

/* Inputs */
#username-input,
.answer-input,
#num-questions {
    width: 100%;
    padding: 1rem 1.25rem;
    margin: 0.5rem 0;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

#username-input:focus,
.answer-input:focus,
#num-questions:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#username-input::placeholder,
.answer-input::placeholder {
    color: var(--text-muted);
}

/* Code Block */
.question-code {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    text-align: left;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #f0f6fc;
    white-space: pre-wrap;
    overflow-x: auto;
    position: relative;
}

.question-code::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 12px 12px 0 0;
}

/* Feedback */
#feedback {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin: 1rem 0;
    font-weight: 500;
    font-size: 1.1rem;
    min-height: 30px;
}

.feedback-message {
    font-weight: bold;
    margin-top: 10px;
    height: 20px;
}

/* Explanation */
#explanation {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    text-align: left;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Game Info Bar */
.game-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

#score-display {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
}

/* Number Questions Group */
.num-questions-group {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.num-questions-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Emblem Album */
#emblem-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.emblem-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.emblem-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.emblem-card.locked-emblem {
    opacity: 0.5;
    filter: grayscale(100%);
}

.emblem-card img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 50%;
}

.emblem-card h3 {
    margin: 0;
    font-size: 1.2em;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.emblem-card p {
    font-size: 0.9em;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* History */
#history-list {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px;
}

.history-item {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.history-item h3 {
    color: var(--primary);
    font-weight: 600;
    margin-top: 0;
}

.game-date {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.history-item ul {
    list-style-type: none;
    padding: 0;
}

.history-item li {
    margin-bottom: 5px;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.history-item li:last-child {
    border-bottom: none;
}

.history-details {
    font-size: 0.9em;
    color: var(--text-muted);
    margin-left: 20px;
}

.history-question.correct {
    color: var(--success);
}

.history-question.incorrect {
    color: var(--danger);
}

/* Responsive Design */
@media (max-width: 768px) {
    .start-screen, .name-screen, .difficulty-screen, .game-container, 
    .end-screen, .history-screen, .emblem-album {
        padding: 1.5rem;
        margin: 1rem;
        border-radius: 16px;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    #emblem-container {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }

    .difficulty-buttons {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .game-info-bar {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    button {
        width: 100%;
        margin: 0.25rem 0;
    }

    .start-buttons, .name-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Custom scrollbar */
#history-list::-webkit-scrollbar {
    width: 8px;
}

#history-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

#history-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

#history-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Answer inputs container */
.answer-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.answer-input-group .answer-input {
    margin: 0;
}