:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #10B981;
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --radius-lg: 16px;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.app-background {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200vw;
    height: 200vh;
    background: radial-gradient(circle at 50% 50%, rgba(79, 70, 229, 0.15) 0%, rgba(15, 23, 42, 1) 40%);
    z-index: -1;
    animation: pulseBg 15s ease infinite alternate;
}

@keyframes pulseBg {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.1);
    }
}

.container {
    width: 100%;
    max-width: 1200px;
    /* Widened for grid view */
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    font-weight: 300;
}

/* Glassmorphism Card base */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

/* Forms and Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

select,
textarea {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    color: white;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
    transition: all 0.3s ease;
}

select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

/* Mode Selection Cards */
.game-mode-selection {
    margin-bottom: 1.5rem;
}

.game-mode-selection>label {
    display: block;
    margin-bottom: 0.75rem;
}

.mode-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.mode-card {
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.mode-card:hover {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

.mode-card.selected {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
    box-shadow: 0 4px 20px -5px rgba(79, 70, 229, 0.3);
}

.mode-card input[type="radio"] {
    display: none;
}

.mode-card i {
    color: var(--primary);
}

.mode-card h3 {
    font-size: 1.1rem;
    margin: 0;
}

.mode-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

@media (max-width: 640px) {
    .mode-cards {
        grid-template-columns: 1fr;
    }
}

/* File Upload & Buttons */
.file-upload-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.file-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

input[type="file"] {
    display: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem;
    width: 100%;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Messages */
.warning-msg {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.warning-msg.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.error-msg {
    color: #ef4444;
    font-size: 0.9rem;
    margin-top: 1rem;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Flashcard Interface */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: white;
}

.progress-indicator {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

/* 3D Flashcard Grid */
.flashcard-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    width: 100%;
    margin-bottom: 2rem;
}

.flashcard {
    width: 100%;
    height: 300px;
    /* Fixed height for each grid card */
    cursor: pointer;
    perspective: 1000px;
    /* Perspective applied per card now */
}

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

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

.flashcard.matched {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8) !important;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.flashcard-front {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
}

.flashcard-back {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(30, 41, 59, 0.9));
    transform: rotateY(180deg);
}

/* Audio Button in Flashcard */
.btn-audio {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.btn-audio:hover {
    background: var(--primary);
    transform: scale(1.1);
}

/* Card Typography */
.target-word,
.native-word {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.target-word {
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.native-word {
    color: #f8fafc;
}

.click-hint {
    position: absolute;
    bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 300;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-5px);
    }

    60% {
        transform: translateY(-3px);
    }
}

.context-sentence {
    font-size: 1rem;
    color: #cbd5e1;
    font-style: italic;
    font-weight: 300;
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
    width: 100%;
}

/* Audio Status */
.audio-status {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-size: 0.9rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    backdrop-filter: blur(4px);
}