:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --success: #10B981;
    --error: #EF4444;
    --bg-color: #F3F4F6;
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --shadow-soft: 0 1vh 2.5vh -0.5vh rgba(0, 0, 0, 0.05), 0 0.8vh 1vh -0.6vh rgba(0, 0, 0, 0.01);
    --shadow-hover: 0 2vh 2.5vh -0.5vh rgba(0, 0, 0, 0.1), 0 1vh 1vh -0.5vh rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background: linear-gradient(135deg, #f0fdf4 0%, #e0e7ff 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-container {
    width: 100vw;
    max-width: 90vw;
    height: 100vh;
    padding: 2.5vh 2vw;
    display: flex;
    flex-direction: column;
}

.top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3vmin;
    padding: 2vh 0;
    margin-bottom: 2vh;
}

.timer-badge, .score-badge {
    background: white;
    padding: 1.5vh 3vw;
    border-radius: 4vmin;
    font-weight: 600;
    font-size: 2.2vmin;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 1.5vw;
}

.timer-badge i {
    color: var(--text-muted);
}

.percent-badge {
    background: #FEF3C7;
    color: #D97706;
    padding: 0.5vh 1.5vw;
    border-radius: 3vmin;
    font-size: 1.8vmin;
}

.flashcard-area {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: stretch;
    perspective: 100vw;
    padding: 2vh 0;
}

.flashcard {
    background: var(--card-bg);
    backdrop-filter: blur(1.5vmin);
    border: 0.15vmin solid rgba(255,255,255,0.8);
    width: 100%;
    min-height: 55vh;
    border-radius: 4vmin;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 5vh 5vw;
    text-align: center;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
    position: relative;
    overflow: hidden;
}

.flashcard:hover {
    transform: translateY(-0.8vh);
    box-shadow: var(--shadow-hover);
}

.card-image {
    font-size: 8vmin;
    color: var(--primary);
    margin-bottom: 3.5vh;
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0vh); }
    50% { transform: translateY(-1.5vh); }
    100% { transform: translateY(0vh); }
}

.question-text {
    font-family: 'Outfit', sans-serif;
    font-size: 4vmin;
    font-weight: 700;
    margin-bottom: 4vh;
    color: var(--text-main);
    line-height: 1.3;
    max-width: 80vw;
}

.input-wrapper {
    width: 100%;
    max-width: 50vw;
    position: relative;
}

input[type="text"] {
    width: 100%;
    padding: 2vh 3vw;
    font-size: 2.5vmin;
    font-family: 'Inter', sans-serif;
    text-align: center;
    border: 0.25vmin solid var(--border-color);
    border-radius: 2vmin;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    background: rgba(255,255,255,0.7);
    color: var(--text-main);
}

input[type="text"]:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 0.6vmin rgba(79, 70, 229, 0.15);
}

input[type="text"]::placeholder {
    color: #9CA3AF;
    font-weight: 400;
}

.hint-display {
    min-height: 3vh;
    margin-top: 2vh;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 2vmin;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hint-display.visible {
    opacity: 1;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 2vw;
    margin-top: 1.5vh;
}

.btn {
    border: none;
    padding: 2vh 4vw;
    font-size: 2.2vmin;
    font-weight: 600;
    border-radius: 2vmin;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 1.5vw;
}

.btn:active {
    transform: scale(0.96);
}

.btn-check {
    background: var(--primary);
    color: white;
    flex-grow: 1;
    max-width: 45vw;
    justify-content: center;
    box-shadow: 0 0.5vh 1.5vh 0 rgba(79, 70, 229, 0.35);
}

.btn-check:hover {
    background: var(--primary-hover);
    box-shadow: 0 1vh 2.5vh rgba(79, 70, 229, 0.25);
}

.btn-hint {
    background: white;
    color: var(--text-muted);
    box-shadow: var(--shadow-soft);
    padding: 2vh 3vw;
}

.btn-hint:hover {
    color: #F59E0B;
    box-shadow: 0 1vh 1.5vh -0.3vh rgba(0,0,0,0.1);
}

.btn-flag {
    background: white;
    color: var(--text-muted);
    box-shadow: var(--shadow-soft);
    padding: 2vh 3vw;
}

.btn-flag:hover {
    color: var(--error);
    box-shadow: 0 1vh 1.5vh -0.3vh rgba(0,0,0,0.1);
}

.btn-flag.active {
    background: var(--error);
    color: white;
    box-shadow: 0 1vh 1.5vh -0.3vh rgba(239, 68, 68, 0.3);
}

.btn-end {
    background: white;
    color: var(--error);
    box-shadow: var(--shadow-soft);
    padding: 2vh 3vw;
}

.btn-end:hover {
    background: var(--error);
    color: white;
    box-shadow: 0 1vh 1.5vh -0.3vh rgba(239, 68, 68, 0.2);
}

/* Animations for feedback */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-1vw); }
    20%, 40%, 60%, 80% { transform: translateX(1vw); }
}

.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    border-color: var(--error) !important;
    background-color: rgba(239, 68, 68, 0.05) !important;
}

.correct {
    border-color: var(--success) !important;
    background-color: rgba(16, 185, 129, 0.1) !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(1vmin);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 100;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    padding: 6vh 6vw;
    border-radius: 4vmin;
    text-align: center;
    box-shadow: 0 3vh 6vh -1.5vh rgba(0,0,0,0.3);
    transform: translateY(4vh) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 90vw;
    max-width: 60vw;
}

.modal.active .modal-content {
    transform: translateY(0vh) scale(1);
}

.modal-content h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 4.5vmin;
    margin-bottom: 3vh;
    color: var(--primary);
}

.modal-content p {
    font-size: 2.5vmin;
    margin-bottom: 1.5vh;
    color: var(--text-muted);
    font-weight: 500;
}

.modal-content span {
    color: var(--text-main);
    font-weight: 700;
}

.btn-restart {
    margin-top: 4vh;
    background: var(--success);
    color: white;
    width: 100%;
    justify-content: center;
    padding: 2vh 4vw;
    font-size: 2.5vmin;
}

.btn-restart:hover {
    background: #059669; /* Darker emerald */
}

/* Start Screen */
.hidden {
    display: none !important;
}

.start-screen {
    background: var(--card-bg);
    backdrop-filter: blur(1.5vmin);
    border: 0.15vmin solid rgba(255,255,255,0.8);
    border-radius: 4vmin;
    box-shadow: var(--shadow-soft);
    padding: 5vh 5vw;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.start-icon {
    font-size: 7vmin;
    color: var(--primary);
    margin-bottom: 3vh;
}

.start-title {
    font-family: 'Outfit', sans-serif;
    font-size: 5vmin;
    color: var(--primary);
    margin-bottom: 2vh;
}

.start-desc {
    font-size: 2.2vmin;
    color: var(--text-muted);
    margin-bottom: 4vh;
    line-height: 1.5;
    max-width: 80vw;
}

.mode-selector, .period-selector {
    margin-bottom: 4vh;
    width: 100%;
    max-width: 50vw;
    text-align: left;
}

.mode-selector label, .period-selector label {
    display: block;
    font-weight: 600;
    margin-bottom: 1.5vh;
    color: var(--text-main);
    font-size: 2vmin;
}

.mode-selector select, .period-selector select {
    width: 100%;
    padding: 2vh 3vw;
    font-size: 2vmin;
    font-family: 'Inter', sans-serif;
    border: 0.3vmin solid var(--border-color);
    border-radius: 1.5vmin;
    outline: none;
    background: white;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.mode-selector select:focus, .period-selector select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.5vmin rgba(79, 70, 229, 0.1);
}

.btn-start {
    background: var(--primary);
    color: white;
    width: 100%;
    max-width: 50vw;
    justify-content: center;
    box-shadow: 0 0.5vh 1.5vh 0 rgba(79, 70, 229, 0.35);
}

.btn-start:hover {
    background: var(--primary-hover);
    box-shadow: 0 1vh 2.5vh rgba(79, 70, 229, 0.25);
}

.btn-home {
    background: white;
    border: none;
    color: var(--text-muted);
    padding: 1.5vh;
    width: 6vh;
    height: 6vh;
    border-radius: 50%;
    font-size: 2.5vmin;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s, color 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-home:hover {
    color: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 1.5vh 2vh -0.5vh rgba(0,0,0,0.1);
}

.success-banner {
    position: absolute;
    top: 5vh;
    left: 50%;
    transform: translateX(-50%) translateY(-10vh);
    background: var(--success);
    color: white;
    padding: 2.5vh 4vw;
    border-radius: 3vmin;
    box-shadow: 0 2vh 3vh -1vh rgba(16, 185, 129, 0.4);
    font-size: 2.5vmin;
    font-weight: 700;
    z-index: 200;
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease;
    pointer-events: none;
    white-space: nowrap;
}

.success-banner.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.version-label {
    position: absolute;
    bottom: 2vh;
    right: 2vw;
    font-size: 1.5vmin;
    color: var(--text-muted);
    opacity: 0.6;
    pointer-events: none;
    font-weight: 500;
}

.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    color: var(--primary);
}

.info-tooltip i {
    font-size: 2vmin;
}

.tooltip-text {
    visibility: hidden;
    opacity: 0;
    width: 25vw;
    background-color: #E5E7EB;
    color: var(--text-main);
    text-align: left;
    border-radius: 1vmin;
    padding: 1.5vh 1.5vw;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: var(--shadow-hover);
    border: 1px solid var(--border-color);
    font-size: 1.5vmin;
    font-weight: 500;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
    line-height: 1.5;
}

.tooltip-text strong {
    color: var(--primary);
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0.8vw;
    border-style: solid;
    border-color: #E5E7EB transparent transparent transparent;
}

.info-tooltip:hover .tooltip-text,
.info-tooltip:active .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.validation-error {
    color: var(--error);
    font-size: 1.8vmin;
    font-weight: 500;
    position: absolute;
    bottom: -3.5vh;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
    white-space: nowrap;
}

.validation-error.show {
    opacity: 1;
    visibility: visible;
}
