:root {
    --primary-color: #6C5CE7;
    --primary-light: #A29BFE;
    --secondary-color: #FD79A8;
    --success-color: #55EFC4;
    --warning-color: #FAB1A0;
    --text-color: #2D3436;
    --bg-color: #F9F9FF;
    --card-bg: #FFFFFF;
    --shadow: 0 10px 25px rgba(108, 92, 231, 0.15);
    --font-main: 'Quicksand', sans-serif;
    --font-heading: 'Fredoka', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, rgba(245, 247, 250, 0.9) 0%, rgba(195, 207, 226, 0.9) 100%), url('bg-pattern.png');
    background-size: cover, 400px;
    background-repeat: no-repeat, repeat;
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 500px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding-top: 20px;
}

#main-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--primary-color);
    text-shadow: 2px 2px 0px rgba(255, 255, 255, 0.8);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex-direction: column;
    width: 100%;
    animation: fadeIn 0.4s ease-out;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cards & Containers */
.welcome-card,
.result-card {
    background: var(--card-bg);
    padding: 30px 20px;
    border-radius: 30px;
    box-shadow: var(--shadow);
    text-align: center;
    border: 4px solid var(--primary-light);
}

h2 {
    font-family: var(--font-heading);
    margin-bottom: 15px;
    color: var(--primary-color);
}

p {
    color: #636e72;
    margin-bottom: 25px;
}

/* Table Selection Grid */
.table-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.btn-table {
    aspect-ratio: 1;
    border: none;
    background: white;
    border: 3px solid #dfe6e9;
    border-radius: 15px;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--primary-color);
}

.btn-table:hover,
.btn-table:active {
    transform: scale(0.95);
    background: var(--primary-light);
    color: white;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    border: none;
    padding: 15px 25px;
    border-radius: 50px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-large {
    width: 100%;
}

.btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn-icon {
    background: white;
    border: 2px solid var(--primary-light);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--primary-color);
}

.score-display {
    background: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* Flashcard */
.flashcard-container {
    perspective: 1000px;
    margin: 10px 0 20px;
    height: 250px;
    width: 100%;
}

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

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

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: white;
    border-radius: 40px;
    box-shadow: var(--shadow);
    border: 8px solid var(--primary-light);
    padding: 20px;
}

.flashcard-back {
    transform: rotateY(180deg);
    border-color: var(--success-color);
}

.flashcard.wrong .flashcard-back {
    border-color: var(--warning-color);
}

.question-container {
    background: white;
    border-radius: 30px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 4px solid var(--primary-light);
    text-align: center;
}

.big-question {
    font-family: var(--font-heading);
    font-size: 4rem;
    color: var(--text-color);
    margin-bottom: 15px;
}

.input-area {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

#answer-input {
    width: 100px;
    padding: 10px;
    border-radius: 15px;
    border: 3px solid #dfe6e9;
    font-family: var(--font-heading);
    font-size: 2rem;
    text-align: center;
    color: var(--primary-color);
    outline: none;
    transition: border-color 0.3s;
}

.card-instruction {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--primary-light);
    margin-top: 10px;
}

#answer-input:focus {
    border-color: var(--primary-color);
}

/* Hide arrows in number input */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Timer Bar */
.timer-container {
    width: 80%;
    height: 12px;
    background: #f1f2f6;
    border-radius: 10px;
    overflow: hidden;
    position: absolute;
    bottom: 30px;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #55efc4, #fdcb6e, #ff7675);
    background-size: 200% 100%;
    transition: width 1s linear;
}

/* Feedback */
.correct-answer {
    font-family: var(--font-heading);
    font-size: 6rem;
    color: #00b894;
}

.flashcard.wrong .correct-answer {
    color: #d63031;
}

#feedback-message {
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 10px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 0.9rem;
    color: #636e72;
}

.hidden {
    display: none;
}

/* Results */
.stars-earned {
    font-size: 3rem;
    margin: 20px 0;
}

.final-score {
    font-size: 1.5rem;
    margin-top: 10px;
    font-weight: bold;
}

/* Animations */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

.shake {
    animation: shake 0.3s ease-in-out 0s 2;
}

@keyframes bounce {

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

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

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

.bounce {
    animation: bounce 1s;
}