/* ============================================================
   Card Flip & Match — Custom Stylesheet
   ============================================================ */

/* ---------- Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Screen Transitions ---------- */
.screen {
    /* Tailwind's generated `.flex` utility is injected after this stylesheet.
       Force inactive screens out of the document flow so they cannot leave a
       full viewport of blank space above the active game. */
    display: none !important;
    opacity: 0;
    transition: opacity 0.5s ease;
}
.screen.active-screen {
    display: flex !important;
    opacity: 1;
}

/* ---------- Floating decorative cards (Start Screen) ---------- */
.floating-cards-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}
.floating-card {
    position: absolute;
    font-size: 2.5rem;
    opacity: 0.07;
    animation: floatCard 18s ease-in-out infinite;
}
.fc-1 { top: 10%; left: 8%;  animation-delay: 0s; }
.fc-2 { top: 25%; right: 12%; animation-delay: -3s; font-size: 3rem; }
.fc-3 { bottom: 20%; left: 15%; animation-delay: -7s; }
.fc-4 { top: 60%; right: 20%; animation-delay: -11s; font-size: 2rem; }
.fc-5 { bottom: 10%; right: 8%; animation-delay: -14s; font-size: 3.5rem; }

@keyframes floatCard {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25%      { transform: translateY(-30px) rotate(5deg); }
    50%      { transform: translateY(-15px) rotate(-3deg); }
    75%      { transform: translateY(-40px) rotate(4deg); }
}

/* ---------- Bounce slow for emoji ---------- */
.animate-bounce-slow {
    animation: bounceSlow 3s ease-in-out infinite;
}
@keyframes bounceSlow {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-12px); }
}

/* ---------- Mechanic cards hover ---------- */
.mechanic-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.mechanic-card:hover {
    transform: translateY(-4px);
}

/* ============================================================
   CARD ARENA — The felt table
   ============================================================ */
.card-arena {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 560px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    border-radius: 1.5rem;
    position: relative;
    /* Felt table background */
    background:
        radial-gradient(ellipse at center, rgba(8,111,178,0.06) 0%, transparent 70%),
        linear-gradient(135deg, #f0f4f0 25%, transparent 25%) -10px 0,
        linear-gradient(225deg, #f0f4f0 25%, transparent 25%) -10px 0,
        #e8ece8;
    background-size: 100% 100%, 20px 20px, 20px 20px;
    border: 2px solid rgba(8,111,178,0.1);
    box-shadow:
        0 0 0 4px rgba(8,111,178,0.04),
        0 8px 32px rgba(0,0,0,0.08),
        inset 0 2px 12px rgba(0,0,0,0.03);
}

/* Responsive: single column on very small screens */
@media (max-width: 420px) {
    .card-arena {
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
        padding: 1rem;
    }
}

/* ============================================================
   FLIP CARDS — 3D CSS Transform
   ============================================================ */
.flip-card {
    perspective: 1000px;
    height: 180px;
    cursor: pointer;
    outline: none;
}
@media (max-width: 480px) {
    .flip-card {
        height: 160px;
    }
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ---------- Card Back (face-down) ---------- */
.flip-card-back {
    /* Geometric brand pattern */
    background:
        linear-gradient(135deg, #086FB2 0%, #0a7ec7 40%, #00ACED 100%);
    box-shadow:
        0 4px 16px rgba(8,111,178,0.25),
        inset 0 1px 0 rgba(255,255,255,0.15),
        inset 0 -1px 0 rgba(0,0,0,0.1);
    border: 2px solid rgba(255,255,255,0.12);
}

/* Decorative pattern overlay on the back */
.flip-card-back::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 0.6rem;
}
.flip-card-back::after {
    content: '';
    position: absolute;
    inset: 16px;
    border-radius: 0.4rem;
    background:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 8px,
            rgba(255,255,255,0.04) 8px,
            rgba(255,255,255,0.04) 16px
        );
}

.card-back-icon {
    position: relative;
    z-index: 2;
    font-size: 2rem;
    color: rgba(255,255,255,0.6);
    text-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* ---------- Card Front (face-up) ---------- */
.flip-card-front {
    transform: rotateY(180deg);
    background: #ffffff;
    border: 2px solid #e5e7eb;
    box-shadow:
        0 4px 16px rgba(0,0,0,0.08),
        inset 0 1px 0 rgba(255,255,255,1);
    flex-direction: column;
    padding: 1rem 0.75rem;
    gap: 0.5rem;
}

.card-letter {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    background: linear-gradient(135deg, #086FB2, #00ACED);
    color: white;
    box-shadow: 0 2px 6px rgba(8,111,178,0.3);
    flex-shrink: 0;
}

.card-option-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
    text-align: center;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

@media (max-width: 480px) {
    .card-option-text {
        font-size: 0.7rem;
    }
    .card-letter {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }
}

/* ---------- Card States ---------- */
/* Selected card */
.flip-card.selected .flip-card-front {
    border-color: #086FB2;
    box-shadow:
        0 0 0 3px rgba(8,111,178,0.25),
        0 0 20px rgba(8,111,178,0.15),
        0 4px 16px rgba(8,111,178,0.2);
}
.flip-card.selected .card-letter {
    animation: pulseGlow 1.5s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 2px 6px rgba(8,111,178,0.3); }
    50%      { box-shadow: 0 2px 16px rgba(8,111,178,0.6); }
}

/* Faded cards (after selection, non-selected) */
.flip-card.faded {
    opacity: 0.55;
    pointer-events: none;
    transform: scale(0.97);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Disabled state (after selection) */
.flip-card.disabled {
    pointer-events: none;
    cursor: default;
}

/* Peek animation — card briefly shows face then hides */
.flip-card.peeking .flip-card-inner {
    animation: peekFlip 2.8s ease-in-out;
}

@keyframes peekFlip {
    0%   { transform: rotateY(0deg); }
    15%  { transform: rotateY(180deg); }
    75%  { transform: rotateY(180deg); }
    100% { transform: rotateY(0deg); }
}

/* ---------- Timer warning ---------- */
.timer-warning #timer-text {
    color: #ef4444;
    animation: timerPulse 0.5s ease-in-out infinite alternate;
}
@keyframes timerPulse {
    from { opacity: 1; }
    to   { opacity: 0.5; }
}

/* ---------- Progress dots ---------- */
.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e5e7eb;
    transition: background 0.3s, transform 0.3s;
}
.progress-dot.active {
    background: linear-gradient(135deg, #086FB2, #00ACED);
    transform: scale(1.3);
    box-shadow: 0 0 8px rgba(8,111,178,0.4);
}
.progress-dot.done {
    background: #086FB2;
}

/* ---------- Review Modal ---------- */
#review-modal.show {
    display: block;
    animation: fadeInModal 0.3s ease;
}
@keyframes fadeInModal {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.review-question-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    padding: 1.25rem;
}

.review-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.4;
}
.review-option.correct-answer {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}
.review-option.user-wrong {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}
.review-option.user-correct {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}
.review-option.neutral {
    background: #f9fafb;
    border: 1px solid #f3f4f6;
    color: #6b7280;
}

/* ---------- Results screen confetti particles ---------- */
.confetti-particle {
    position: fixed;
    top: -10px;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    animation: confettiFall 3s ease-out forwards;
    z-index: 100;
    pointer-events: none;
}
@keyframes confettiFall {
    0%   { opacity: 1; transform: translateY(0) rotate(0deg); }
    100% { opacity: 0; transform: translateY(100vh) rotate(720deg); }
}

/* ---------- Screen fade-in ---------- */
.screen-enter {
    animation: screenFadeIn 0.5s ease forwards;
}
@keyframes screenFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Scrollbar styling ---------- */
#review-body::-webkit-scrollbar {
    width: 6px;
}
#review-body::-webkit-scrollbar-track {
    background: transparent;
}
#review-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
#review-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Tabular numbers for timer */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* ---------- Option cards (legend below the question) ---------- */
.option-card {
    transition: all 0.2s ease;
    word-break: break-word;
}
.option-card:hover {
    border-color: #086FB2;
}