/* Theme variables */
:root {
    --bg: #ffffff;
    --fg: #1a1a1a;
    --fg-secondary: #666666;
    --accent: #a78bfa;
    --real: #10b981;
    --falso: #ef4444;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --border-radius: 16px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #1a1a1a;
        --fg: #ffffff;
        --fg-secondary: #aaaaaa;
        --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    }
}

:root[data-theme="dark"] {
    --bg: #1a1a1a;
    --fg: #ffffff;
    --fg-secondary: #aaaaaa;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

:root[data-theme="light"] {
    --bg: #ffffff;
    --fg: #1a1a1a;
    --fg-secondary: #666666;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--fg);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-y: auto;
}

/* Container & Layout */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 16px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 8px 0;
}

.header-left {
    flex: 1;
}

.logo {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--real), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    gap: 16px;
    align-items: center;
}

.streak {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    padding: 8px 12px;
    background-color: rgba(167, 139, 250, 0.15);
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.streak-icon {
    font-size: 24px;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background-color: transparent;
    color: var(--fg);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.theme-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

:root[data-theme="dark"] .theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Game Area */
.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    perspective: 1000px;
    min-height: 0;
}

.card-stack {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 400px;
    max-height: 600px;
}

.card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.card.loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: var(--card-image-bg, rgba(0, 0, 0, 0.04));
    user-select: none;
}

.card-image-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.2), rgba(16, 185, 129, 0.2));
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(167, 139, 250, 0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Feedback overlay — sits directly on top of the image, like a photo caption */
.feedback-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.75) 50%, rgba(0, 0, 0, 0) 100%);
    color: #ffffff;
    padding: 70px 20px 20px;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
    z-index: 3;
    pointer-events: none;
}

.feedback-panel.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.feedback-content {
    width: 100%;
    margin-bottom: 12px;
}

.feedback-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 20px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    transform: rotate(-3deg);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.feedback-badge.correct {
    background-color: var(--real);
    color: #ffffff;
}

.feedback-badge.wrong {
    background-color: var(--falso);
    color: #ffffff;
}

.feedback-badge.info {
    background-color: var(--accent);
    color: #ffffff;
}

.feedback-text {
    font-size: 15px;
    margin-bottom: 8px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
}

.feedback-progress {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
}

.feedback-bar {
    flex: 1;
    height: 22px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 11px;
    overflow: hidden;
    display: flex;
}

.feedback-bar-real {
    background-color: var(--real);
    height: 100%;
    transition: width 0.3s ease;
}

.feedback-bar-falso {
    background-color: var(--falso);
    height: 100%;
    transition: width 0.3s ease;
}

.feedback-stat {
    font-size: 13px;
    font-weight: 600;
    min-width: 60px;
    color: rgba(255, 255, 255, 0.9);
}

.feedback-close {
    align-self: center;
    padding: 10px 28px;
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.feedback-close:hover {
    background-color: rgba(255, 255, 255, 0.28);
}

/* Correct/Wrong animations */
.emoji-burst {
    position: absolute;
    font-size: 32px;
    pointer-events: none;
    animation: burst-up 1s ease-out forwards;
}

@keyframes burst-up {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0);
    }
}

.card.shake {
    animation: shake 0.4s ease;
}

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

/* Vote buttons */
.vote-buttons {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
}

.vote-btn {
    flex: 1;
    max-width: 160px;
    padding: 14px;
    border: none;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.vote-btn:active {
    transform: scale(0.95);
}

.vote-btn-falso {
    background-color: var(--falso);
    color: white;
}

.vote-btn-real {
    background-color: var(--real);
    color: white;
}

/* Carousel of already-voted items */
.carousel-section {
    display: none;
    margin-top: 24px;
}

.carousel-section.active {
    display: block;
}

.carousel-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--fg);
}

.carousel {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 4px 4px 12px;
    -webkit-overflow-scrolling: touch;
}

.carousel-item {
    position: relative;
    flex: 0 0 220px;
    scroll-snap-align: start;
    border-radius: var(--border-radius);
    overflow: hidden;
    background-color: var(--bg);
    box-shadow: var(--card-shadow);
}

.carousel-item img {
    display: block;
    width: 100%;
    height: 260px;
    object-fit: contain;
    background-color: rgba(0, 0, 0, 0.04);
}

.carousel-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: white;
    background-color: var(--accent);
}

.carousel-badge.real {
    background-color: var(--real);
}

.carousel-badge.falso {
    background-color: var(--falso);
}

.carousel-result {
    padding: 8px 10px;
    font-size: 13px;
    color: var(--fg-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .header {
        margin-bottom: 16px;
    }

    .logo {
        font-size: 24px;
    }

    .streak {
        font-size: 18px;
        padding: 6px 10px;
    }

    .card-stack {
        max-width: 100%;
        max-height: 70vh;
    }
}
