:root {
    --bg-color: #0c0e14;
    --card-bg: rgba(30, 41, 59, 0.4);
    --accent-cyan: #22d3ee;
    --accent-amber: #fbbf24;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --card-width: 800px;
    --transition-speed: 0.6s;
}

html, body {
    overflow-x: hidden;
    position: relative;
    width: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(251, 191, 36, 0.05) 0%, transparent 40%);
    color: var(--text-primary);
    min-height: 100vh;
}

.flashcard-container {
    perspective: 2000px;
    width: var(--card-width);
    aspect-ratio: 1.6 / 1;
    cursor: pointer;
    outline: none !important;
    max-width: 95vw;
    transition: transform 0.3s ease;
    min-height: 450px;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent !important;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flashcard-container:focus .flashcard-inner {
    box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.2);
    border-radius: 32px;
}

.flashcard-container.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3.5rem;
    box-sizing: border-box;
    border-radius: 32px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.6);
}

.flashcard-back {
    transform: rotateY(180deg);
}

/* Component Styling */
.card-tag {
    position: absolute;
    top: 2rem;
    left: 2rem;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    padding: 0.4rem 1.25rem;
    border-radius: 100px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.c1-tag {
    background: rgba(34, 211, 238, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(34, 211, 238, 0.2);
}

.question-text {
    font-size: 2.8rem;
    line-height: 1.3;
    width: 100%;
    text-align: center;
    font-weight: 600;
    margin-top: 1.2rem; /* Keep high for terminals below */
    margin-bottom: 0.5rem;
    padding-bottom: 2.5rem;
    max-height: 440px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.question-text::-webkit-scrollbar, 
.answer-text::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
}

.answer-text {
    margin: auto 0; /* Float in the middle of card face */
    font-size: 2.4rem;
    line-height: 1.4;
    color: var(--text-primary);
    max-width: 90%;
    width: 100%;
    text-align: center;
    font-weight: 600;
    max-height: 440px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.answer-text strong, .question-text strong {
    color: var(--accent-cyan);
    font-weight: 800;
}

.instruction-hint {
    position: absolute;
    bottom: 1.5rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
    opacity: 0.6;
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
}

.revision-links {
    margin-top: auto; /* Push to bottom of flex container */
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.9rem;
    width: 100%;
}

.revision-link {
    color: var(--accent-cyan);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none !important;
}

.revision-link:hover {
    background: rgba(34, 211, 238, 0.1);
    border-color: rgba(34, 211, 238, 0.3);
    text-decoration: none;
    transform: translateY(-2px);
}

.revision-link.amber {
    color: var(--accent-amber);
}

.revision-link.amber:hover {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
}

/* Decorative Glow (Desktop Only) */
@media (min-width: 851px) {
    .flashcard-inner::before {
        content: '';
        position: absolute;
        top: -2px; left: -2px; right: -2px; bottom: -2px;
        background: linear-gradient(45deg, var(--accent-cyan), transparent, var(--accent-amber));
        z-index: -1;
        border-radius: 32px;
        opacity: 0.2;
        transition: opacity 0.3s ease;
    }
    .flashcard-container:hover .flashcard-inner::before {
        opacity: 0.4;
    }
}

/* Developer Terminal UI */
.code-window {
    background: #0c0e14;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    width: 100%; /* Fill the card face */
    min-width: 100%; /* Prevent any width discrepancy between faces */
    margin-top: 0.5rem; /* Docked just under the question */
    margin-bottom: 1.5rem; /* Critical: preserves bottom symmetry */
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    text-align: left;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    font-family: 'Courier New', Courier, monospace;
}

.code-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dot { display: none; } /* Kill Mac dots */

.header-icon {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.header-icon.python { color: var(--accent-amber); }
.header-icon.console { color: var(--accent-cyan); }

.code-action {
    margin-left: auto;
    font-size: 0.8rem;
    opacity: 0.6;
    color: var(--text-secondary);
}

.code-title {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 500;
}

.code-content {
    padding: 1.2rem 1.5rem; /* Symmetrically balanced gaps */
    line-height: 1.4; /* Tighter logic alignment */
    font-size: 1.4rem;
    color: var(--accent-cyan);
    position: relative;
}

.code-window.console-mode .line-num {
    display: none;
}

.code-window.console-mode .code-line {
    padding-left: 0.5rem;
}

.code-line {
    display: flex;
    gap: 1.25rem;
}

.code-text {
    white-space: pre-wrap;
    word-break: normal; /* No more mid-word breaking */
}

/* MOBILE OPTIMIZATION (SCORCHED EARTH RESET) */
@media (max-width: 850px) {
    * {
        -webkit-tap-highlight-color: transparent !important;
        outline: 0px solid transparent !important;
    }

    :root {
        --card-width: 90vw;
    }

    .flashcard-container {
        aspect-ratio: auto;
        height: 540px; /* Fixed height to prevent jumping */
        min-height: 540px;
        outline: none !important;
    }

    .flashcard-front, .flashcard-back {
        padding: 1.5rem;
        padding-top: 5rem;
        padding-bottom: 2rem;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        height: 100%;
        box-sizing: border-box;
        border: none !important; 
        box-shadow: 0 15px 40px rgba(0,0,0,0.6) !important;
        -webkit-font-smoothing: antialiased;
    }

    .card-tag {
        font-size: 0.8rem;
        top: 1.5rem;
        left: 50%;
        transform: translateX(-50%);
        white-space: nowrap;
        border: none !important;
        background: rgba(34, 211, 238, 0.2);
        color: var(--accent-cyan);
    }

    .question-text, .answer-text {
        font-size: 1.5rem !important;
        margin: auto 0;
        width: 100%;
        line-height: 1.4;
        text-align: center;
        border: none !important;
        outline: none !important;
    }

    .code-window {
        width: 100%;
        border: none !important;
        background: #080a0f !important;
        box-shadow: none !important;
    }

    .revision-links {
        margin-top: 1.5rem;
        margin-bottom: 0.5rem;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
        align-items: center;
        border: none !important;
        outline: none !important;
    }

    .revision-link {
        font-size: 0.85rem;
        padding: 0.7rem 1.2rem;
        width: 100%;
        max-width: 250px;
        border: none !important;
        outline: none !important;
        background: rgba(34, 211, 238, 0.1) !important;
        color: var(--accent-cyan) !important;
        backdrop-filter: none !important;
    }

    .revision-link.amber {
        color: var(--accent-amber) !important;
        background: rgba(251, 191, 36, 0.1) !important;
    }

    .instruction-hint {
        position: relative !important;
        bottom: 0 !important;
        margin-top: auto !important; /* Pushes to extreme bottom */
        padding-bottom: 1rem !important;
        font-size: 0.85rem !important;
        color: var(--text-secondary) !important;
        opacity: 0.8 !important;
        border: none !important;
        outline: none !important;
    }
}


/* --- Clean CSS/SVG Shape Styling --- */
.shape-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 80px; /* Snapped tight to question above */
    margin: 0.2rem 0; 
}

.shape-terminal {
    width: 140px;
    height: 60px;
    border: 2.5px solid var(--accent-cyan);
    border-radius: 30px;
    background: rgba(34, 211, 238, 0.05);
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.1);
}

.shape-process {
    width: 150px;
    height: 70px;
    border: 2.5px solid var(--accent-cyan);
    background: rgba(34, 211, 238, 0.05);
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.1);
}

.shape-decision-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 80px;
}

.shape-decision {
    width: 70px;
    height: 70px;
    border: 2.5px solid var(--accent-cyan);
    transform: rotate(45deg);
    background: rgba(34, 211, 238, 0.05);
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.1);
}

.shape-io {
    width: 150px;
    height: 70px;
    border: 2.5px solid var(--accent-cyan);
    transform: skewX(-20deg);
    background: rgba(34, 211, 238, 0.05);
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.1);
}

.gate-svg {
    height: 80px;
    stroke: var(--accent-amber);
    stroke-width: 2.5;
    fill: rgba(251, 191, 36, 0.05);
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.2));
}
/* --- Kinetic Swipe Animations --- */
.slide-out-left {
    animation: slideOutLeft 0.25s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-out-right {
    animation: slideOutRight 0.25s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-in-right {
    animation: slideInRight 0.25s forwards cubic-bezier(0, 0, 0.2, 1);
}

.slide-in-left {
    animation: slideInLeft 0.25s forwards cubic-bezier(0, 0, 0.2, 1);
}

@keyframes slideOutLeft {
    to {
        transform: translateX(-120%) rotate(-10deg);
        opacity: 0;
    }
}

@keyframes slideOutRight {
    to {
        transform: translateX(120%) rotate(10deg);
        opacity: 0;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
