/* Chinese font support */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@100;300;400;500;700;900&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --neon-primary: #00f3ff;
    --neon-secondary: #bc13fe;
    --neon-success: #0aff0a;
    --neon-danger: #ff0a0a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --dark-bg: #0f172a;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--dark-bg);
    color: #e2e8f0;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Animation */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #1e293b 0%, #0f172a 100%);
    z-index: -2;
}

body::after {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 80% 20%, rgba(188, 19, 254, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 20% 80%, rgba(0, 243, 255, 0.15) 0%, transparent 40%);
    animation: bg-pulse 15s ease-in-out infinite alternate;
    z-index: -1;
    pointer-events: none;
}

@keyframes bg-pulse {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-2%, -2%) scale(1.1); }
}

/* Typography */
.hanzi {
    font-family: 'Noto Sans SC', sans-serif;
    font-weight: 700;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Glassmorphism Card */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
}

/* 3D Flip Card Structure */
.flip-card {
    background-color: transparent;
    width: 100%;
    max-width: 500px;
    height: min(600px, 65vh); /* Responsive height */
    perspective: 1000px; /* Remove this if you don't want 3D effect */
    margin: 0 auto;
    cursor: pointer;
    user-select: none;
    touch-action: none; /* Prevent browser scrolling while interacting */
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.flip-card.dragging .flip-card-inner {
    transition: none;
}

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

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden; /* Safari */
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.flip-card-front {
    /* Front styling */
    border: 1px solid rgba(0, 243, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.1);
}

.flip-card-back {
    transform: rotateY(180deg);
    border: 1px solid rgba(188, 19, 254, 0.3);
    box-shadow: 0 0 15px rgba(188, 19, 254, 0.1);
    justify-content: flex-start; /* Align content to top for back */
    padding-top: 3rem;
}

/* Content Styling */
.hanzi-large {
    font-size: 8rem;
    background: linear-gradient(135deg, #fff 0%, #a5f3fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(0, 243, 255, 0.3));
    margin-bottom: 1rem;
}

.pinyin-large {
    font-size: 2.5rem;
    color: var(--neon-primary);
    font-weight: 300;
    margin-bottom: 0.5rem;
}

.meaning-large {
    font-size: 1.5rem;
    color: #fff;
    margin-bottom: 2rem;
    font-weight: 500;
}

.components-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.component-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.component-badge:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* Neon Buttons */
.btn-neon {
    background: transparent;
    border: 2px solid currentColor;
    border-radius: 50px;
    padding: 0.75rem 2rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-neon-primary {
    color: var(--neon-primary);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.btn-neon-primary:hover {
    background: var(--neon-primary);
    color: #000;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.6);
}

.btn-neon-success {
    color: var(--neon-success);
    border-color: var(--neon-success);
    box-shadow: 0 0 10px rgba(10, 255, 10, 0.2);
}

.btn-neon-success:hover, .btn-neon-success:active {
    background: var(--neon-success);
    color: #000;
    box-shadow: 0 0 20px rgba(10, 255, 10, 0.6);
}

.btn-neon-danger {
    color: var(--neon-danger);
    border-color: var(--neon-danger);
    box-shadow: 0 0 10px rgba(255, 10, 10, 0.2);
}

.btn-neon-danger:hover, .btn-neon-danger:active {
    background: var(--neon-danger);
    color: #000;
    box-shadow: 0 0 20px rgba(255, 10, 10, 0.6);
}

.btn-neon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
    box-shadow: none;
}

/* Keyboard Hints */
.kbd-hint {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    font-family: monospace;
    margin: 0 0.3rem;
    color: rgba(255, 255, 255, 0.7);
}

.instruction-text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 1rem;
}

/* Progress Bar Overrides */
.progress {
    background-color: rgba(255, 255, 255, 0.1);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--neon-primary), var(--neon-secondary));
    box-shadow: 0 0 10px var(--neon-primary);
}

/* Base Overrides for existing layout */
.navbar {
    background: rgba(15, 23, 42, 0.8) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
}

/* Undo Button */
.btn-undo {
    position: absolute;
    top: -20px;
    left: -20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.btn-undo:hover {
    opacity: 1;
    transform: scale(1.1) rotate(-45deg);
    border-color: var(--neon-primary);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
}

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

/* Card Transitions */
@keyframes fadeOut {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.95); }
}

@keyframes fadeIn {
    0% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

.card-exit {
    animation: fadeOut 0.4s ease-out forwards;
    pointer-events: none; /* Prevent clicks during exit */
}

.card-enter {
    animation: fadeIn 0.4s ease-out forwards;
}
