:root {
    --bg: #290000;
    --text: #eaeaea;
    --muted: #ccc;
    --accent: #ff4d4d;
    --accent-2: #ff1a1a;
    --surface: rgba(255, 255, 255, 0.062);
    --ring: rgba(255, 0, 0, 0.25);
    --shadow: 0 0 15px rgba(0, 0, 0, 0.25);
    --radius: 14px;

    /* spacing scale */
    --space-1: 8px;
    --space-2: 12px;
    --space-3: 16px;
    --space-4: 20px;
    --space-5: 28px;
    --space-6: 40px;

    /* flip animation settings */
    --flip-speed: 0.8s;
    --flip-ease: ease-in-out;
}

/* =========================
   CARD GRID (inside container)
========================= */

.card-section {
    display: grid;
    grid-template-columns: 1fr;
    /* single column on mobile */
    gap: 20px;
    width: 80%;
    margin: 40px 0;
    justify-items: stretch;
    /* cards fill column width */
}

/* Tablet breakpoint: 2 columns */
@media (min-width: 640px) {
    .card-section {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        display: grid;
        gap: 20px;
        width: 100%;
        margin: 40px 0;
        justify-items: stretch;
    }
}

/* Desktop: keep 2 columns */
@media (min-width: 1024px) {
    .card-section {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* =========================
   CARD CONTENT
========================= */

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 10px;
    line-height: 1;
}

.card-text {
    text-align: start;
    width: 90%;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
    color: #ddd;
}

/* =========================
   FLIP CARD
========================= */

.card-container {
    perspective: 1000px;
    /* enable 3D perspective */
    display: flex;
    justify-content: center;
    align-items: center;
    contain: paint;
    /* isolate paint area */
}

.card {
    width: 100%;
    margin-bottom: 30px;
    aspect-ratio: 300 / 250;
    position: relative;

    transform-style: preserve-3d;
    /* keep 3D for children */
    transform: translateZ(0);
    will-change: transform;

    transition: transform var(--flip-speed) var(--flip-ease);
}

/* Both faces of the card */
.card .card-side {
    position: absolute;
    inset: 0;
    height: 230px;
    padding: 20px;
    border-radius: 16px;

    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;

    background: rgba(255, 255, 255, 0.062);
    border: 1px solid rgba(255, 255, 255, 0.08);

    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;

    transform: translateZ(0);
    will-change: transform;

    backdrop-filter: blur(6px);
}

/* Front face */
.front {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: clamp(48px, 8vw, 72px);
    color: var(--accent);
    text-shadow: 0 0 14px rgba(255, 0, 0, 0.35);
    opacity: 1;
    z-index: 2;
    isolation: isolate;
    /* avoid blending issues */
}

/* Back face */
.card .back {
    transform: rotateY(180deg) translateZ(0);
}

/* Flipped state */
.card.flipped {
    transform: rotateY(180deg) translateZ(0);
}

/* =========================
   PERFORMANCE TWEAKS
========================= */

/* Disable expensive blur on very small screens */
@media (max-width: 480px) {
    .card .card-side {
        backdrop-filter: none;
        background: rgba(255, 255, 255, 0.08);
    }
}

/* Accessibility: instant flip if user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    .card {
        transition: none;
    }

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