:root {
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    --radius: 12px;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.lang-picker {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
}

.lang-select {
    appearance: none;
    border: 1px solid rgba(17, 24, 39, 0.2);
    background: #ffffff;
    color: var(--text);
    border-radius: 999px;
    padding: 6px 12px;
    min-width: 60px;
    text-align: center;
    text-align-last: center;
    -moz-text-align-last: center;
    font-size: 1.1rem;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
}

.lang-select:focus {
    outline: 2px solid rgba(17, 24, 39, 0.35);
    outline-offset: 2px;
}

/* Center everything */
.wrap {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 24px 16px;
    box-sizing: border-box;
}

.card-container {
    perspective: 1000px;
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    margin: 10px 0; /* Reduced margin to give more space to the card */
}

.card {
    position: relative;
    width: min(90vw, 500px);
    height: 90%; /* Take as much vertical space as possible */
    max-height: 70vh;
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* Animations */
@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-100vw); opacity: 0; }
}
@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100vw); opacity: 0; }
}
@keyframes slideInRight {
    from { transform: translateX(100vw); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideInLeft {
    from { transform: translateX(-100vw); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.animate-out-left { animation: slideOutLeft 0.15s forwards ease-in; }
.animate-out-right { animation: slideOutRight 0.15s forwards ease-in; }
.animate-in-left { animation: slideInLeft 0.15s forwards ease-out; }
.animate-in-right { animation: slideInRight 0.15s forwards ease-out; }

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

/* Prevent 3D flip conflict with 2D slide animation */
.card.animate-out-left,
.card.animate-out-right,
.card.animate-in-left,
.card.animate-in-right {
    transition: none;
}

.card-face {
    backface-visibility: hidden;
    border-radius: 50px;
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 10px solid #ffd700; /* Golden border */
    box-sizing: border-box;
}

/* Front participates in layout */
.card-front {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 20px; /* Keep flag moved from edges */
    background: #fff0f5; /* Light rose background */
}

/* Back overlays front for the flip */
.card-back {
    position: absolute;
    inset: 0;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
}

/* Red dot marker */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}
.red-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: red;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.back-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 20px 10px 10px 10px;
    text-align: center;
    pointer-events: none; /* Allow interaction with map if needed, though map is non-interactive here */
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
    display: block;
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 0; /* Let it fill the card face which has overflow:hidden */
}

.state-name {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-shadow: 0 0 10px rgba(255, 255, 255, 1), 0 0 5px rgba(255, 255, 255, 0.8);
}

.state-capital {
    margin-top: 8px;
    font-size: 1.5rem;
    color: var(--text);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 255, 255, 1), 0 0 5px rgba(255, 255, 255, 0.8);
}

.nav {
    display: none;
    gap: 10px;
    justify-content: center;
    margin-top: 0;
    flex-wrap: wrap;
}

@media (min-width: 600px) {
    .nav {
        display: flex;
    }
}

.btn {
    appearance: none;
    border: 1px solid rgba(17, 24, 39, 0.15);
    background: #fff;
    color: var(--text);
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: translateY(1px);
}

.meta {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}

.heading {
    text-transform: uppercase;
    text-align: center;
    margin: 30px 0 0 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.05em;
}

.christmas-tree {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    font-size: 24px;
    animation: tree-fade-out 0.8s forwards ease-out;
}

@keyframes tree-fade-out {
    0% { transform: scale(0.5) translateY(0); opacity: 1; }
    100% { transform: scale(1.5) translateY(-50px); opacity: 0; }
}

.footer {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

/* Hint Animations */
.hint {
    position: absolute;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

@media (max-width: 599px) {
    .hint {
        display: block;
    }
}

.hint-visible {
    opacity: 1;
}

.tap-hint {
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 50px;
    animation: tap-pulse 1.5s infinite;
}

@keyframes tap-pulse {
    0% { transform: translateX(-50%) scale(1); opacity: 0.8; }
    50% { transform: translateX(-50%) scale(1.2); opacity: 1; }
    100% { transform: translateX(-50%) scale(1); opacity: 0.8; }
}

.swipe-hint {
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    width: 100%;
    text-align: center;
}

.swipe-icon {
    display: inline-block;
    animation: swipe-move 2s infinite;
}

@keyframes swipe-move {
    0% { transform: translateX(40px); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateX(-40px); opacity: 0; }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


@media (min-width: 600px) {
    .wrap {
        padding: 22px;
    }

    .state-name {
        font-size: 2.8rem;
    }

    .state-capital {
        font-size: 2rem;
    }
}
