/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --error-color: #ef4444;
    --background: #1a1a2e;
    --surface: #16213e;
    --surface-hover: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --border-color: #2a2a3e;
    --border-radius: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --background: #f5f5f5;
    --surface: #ffffff;
    --surface-hover: #f0f0f0;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 32px;
}

h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.tagline {
    color: var(--text-secondary);
    font-size: clamp(1rem, 2vw, 1.25rem);
}

.daily-link {
    display: inline-block;
    margin-top: 16px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 8px;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.daily-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

/* Score Board */
.score-board {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 32px;
}

.score-item {
    background: var(--surface);
    padding: 16px 32px;
    border-radius: var(--border-radius);
    text-align: center;
    min-width: 150px;
    border: 2px solid rgba(99, 102, 241, 0.2);
    transition: var(--transition);
}

.score-item:hover {
    border-color: rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
}

.score-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--surface);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.game-container {
    margin-bottom: 32px;
}

.cards-wrapper {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 24px;
    align-items: stretch;
}

.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-secondary);
    padding: 0 16px;
}

.card {
    position: relative;
    background: var(--surface);
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid transparent;
    min-height: 650px;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-8px);
    border-color: var(--primary-color);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.3);
}

.card.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.card.correct {
    border-color: var(--success-color);
    animation: pulse-correct 0.6s ease-out;
}

.card.incorrect {
    border-color: var(--error-color);
    animation: shake 0.5s ease-out;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Card Image */
.card-image {
    width: 100%;
    height: 450px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(139, 92, 246, 0.3) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.card-image.has-image {
    background-color: var(--card-bg);
}

/* Badge Copyright */
.badge-copyright {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
}

/* Card Content */
.card-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-title {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.2;
}

.card-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
}

.badge-material {
    background: rgba(139, 92, 246, 0.2);
    color: var(--secondary-color);
}

/* Card Count */
.card-count {
    text-align: center;
    padding: 10px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    margin-top: auto;
}

.count-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
}

.count-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* Card Overlay */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(99, 102, 241, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.card:hover .card-overlay {
    opacity: 1;
}

.card.disabled .card-overlay {
    display: none;
}

.overlay-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Result Message */
.result-message {
    text-align: center;
    padding: 20px;
    margin-top: 24px;
    border-radius: var(--border-radius);
    background: var(--surface);
}

.result-text {
    font-size: 1.5rem;
    font-weight: 700;
}

.result-message.correct .result-text {
    color: var(--success-color);
}

.result-message.incorrect .result-text {
    color: var(--error-color);
}

/* Footer */
footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

footer a:hover {
    color: var(--secondary-color);
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.theme-toggle:active {
    transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .cards-wrapper {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .vs-divider {
        padding: 8px 0;
    }
    
    .card {
        min-height: 550px;
    }
    
    .card-image {
        height: 350px;
    }
}

@media (max-width: 640px) {
    .score-board {
        flex-direction: column;
        gap: 12px;
    }
    
    .score-item {
        min-width: auto;
    }
    
    .card-image {
        height: 300px;
    }
    
    .card-content {
        padding: 16px;
    }
    
    .card-title {
        font-size: 1.25rem;
    }
    
    .count-value {
        font-size: 2rem;
    }
}

/* Daily Challenge Styles */
.progress-bar {
    text-align: center;
    margin-bottom: 24px;
}

.progress-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
}

.results-container {
    text-align: center;
    padding: 32px 16px;
}

.results-container h2 {
    font-size: 2rem;
    margin-bottom: 32px;
    color: var(--text-color);
}

.final-score {
    margin: 32px 0;
}

.score-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.score-circle span {
    font-size: 3rem;
    font-weight: bold;
    color: white;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    max-width: 400px;
    margin: 32px auto;
}

.result-box {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    border-radius: 8px;
    transition: transform 0.2s;
    cursor: default;
}

.result-box:hover {
    transform: scale(1.1);
}

.result-box.correct {
    background: #10b981;
    color: white;
}

.result-box.incorrect {
    background: #ef4444;
    color: white;
}

.results-actions {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.btn-primary {
    padding: 16px 32px;
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

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

.btn-secondary {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
}

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

.comeback-text {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 8px 0;
}

@media (max-width: 640px) {
    .results-grid {
        gap: 8px;
        max-width: 300px;
    }
    
    .result-box {
        font-size: 24px;
    }
    
    .score-circle {
        width: 120px;
        height: 120px;
    }
    
    .score-circle span {
        font-size: 2.5rem;
    }
}

