:root {
    --primary-color: #4A90E2;
    --secondary-color: #F8B400;
    --success-color: #4CAF50;
    --retry-color: #FF6B6B;
    --bg-color: #F0F9FF;
    --text-color: #2C3E50;
    --card-bg: #FFFFFF;
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 800px;
    background: var(--card-bg);
    border-radius: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    padding: 40px;
    text-align: center;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    border: 8px solid #E1F5FE;
}

.screen {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none !important;
}

h1 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    text-shadow: 2px 2px 0px rgba(74, 144, 226, 0.1);
}

/* Logo CSS Fallback */
.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.project-logo {
    width: 280px;
    height: auto;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1));
    animation: floating 3s ease-in-out infinite;
    margin-bottom: 10px;
}

@keyframes floating {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-10px) rotate(2deg);
    }

    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #5D6D7E;
}

.selection-container {
    margin: 30px 0;
}

.grid-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stats-container {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: bold;
    background: #E3F2FD;
    padding: 5px 15px;
    border-radius: 20px;
    border: 2px solid #BBDEFB;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: white;
    color: var(--primary-color);
    border: 2px solid #BBDEFB;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.icon-btn:hover {
    transform: scale(1.1);
}

.reset-btn {
    background: var(--retry-color);
    color: white;
    border: none;
    font-size: 0.8rem;
}

.settings-group {
    margin-top: 20px;
    padding: 15px;
    background: #FFF9C4;
    border-radius: 15px;
    border: 2px solid #FFF176;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    color: #5D4037;
}

.setting-item input {
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

.flex-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    padding: 15px 25px;
    border: none;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-speed);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-family: inherit;
}

.btn:active {
    transform: scale(0.95);
}

.category-btn {
    background-color: #E3F2FD;
    color: var(--primary-color);
    border: 3px solid transparent;
}

.category-btn.active {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-5px);
}

.difficulty-btn {
    background-color: #FDFEFE;
    color: #7F8C8D;
    border: 2px solid #D5DBDB;
}

.difficulty-btn.active {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.primary-btn {
    background-color: var(--success-color);
    color: white;
}

.primary-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 12px rgba(76, 175, 80, 0.3);
}

.secondary-btn {
    background-color: #95A5A6;
    color: white;
}

.main-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    margin-top: 20px;
}

.large-btn {
    font-size: 1.5rem;
    padding: 20px 50px;
    width: 100%;
    max-width: 400px;
}

#home-icon-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 10px 15px;
    font-size: 1rem;
    z-index: 10;
}

.instruction {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.progress-text {
    font-size: 1rem;
    color: #7F8C8D;
    font-weight: bold;
    margin-bottom: 20px;
}

.big-word {
    font-size: clamp(2rem, 12vw, 5rem);
    font-weight: 900;
    letter-spacing: 5px;
    margin: 30px 0;
    color: var(--text-color);
    word-break: break-word;
    line-height: 1.2;
}

.big-word.highlight {
    color: var(--primary-color);
    animation: bounce 0.5s infinite alternate;
}

@keyframes bounce {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.05);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

@keyframes confettiFall {
    0% {
        transform: translateY(-10px) rotate(0deg) scale(1);
        opacity: 0;
    }

    50% {
        transform: translateY(5px) rotate(180deg) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translateY(0px) rotate(360deg) scale(1);
        opacity: 1;
    }
}

#timer-bar-container {
    width: 100%;
    height: 15px;
    background-color: #E8F6F3;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 20px;
}

#timer-bar {
    width: 100%;
    height: 100%;
    background-color: var(--secondary-color);
    transition: width linear;
}

.prompt-text {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.character-illustration {
    font-size: 5rem;
    margin: 10px 0;
}

.hint-text {
    margin-bottom: 10px;
    color: #E67E22;
    font-weight: bold;
}

.hint-btn {
    margin-top: 10px;
    background: #FFD54F;
    color: #5D4037;
    border: none;
}

.hint-btn:hover {
    background: #FFCA28;
}

.feedback-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

.success-btn {
    background-color: var(--success-color);
    color: white;
}

.retry-btn {
    background-color: var(--retry-color);
    color: white;
}

.practice-report {
    margin: 10px 0;
    color: #E67E22;
    font-weight: bold;
}

.summary-box {
    margin: 20px 0;
    font-size: 1.2rem;
    line-height: 1.6;
}

/* Footer Style */
footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px dashed #D5DBDB;
    font-size: 0.9rem;
    color: #7F8C8D;
    font-weight: 500;
}

/* Tablet & Mobile tweaks */
@media (max-width: 600px) {
    #app {
        padding: 20px;
        border-width: 4px;
    }

    .big-word {
        font-size: 3rem;
    }

    h1 {
        font-size: 2rem;
    }

    .grid-buttons {
        grid-template-columns: 1fr 1fr;
    }
}

/* Reset Button & Confetti */
#reset-stats-btn:hover {
    background: #E74C3C !important;
    transform: rotate(180deg);
    transition: all 0.3s ease;
}

#reset-stats-btn:active {
    transform: scale(0.9) rotate(180deg);
}

#confetti {
    animation: confettiFall 2s ease-in-out infinite;
    display: inline-block;
}

/* Toast Notification Styles */
.toast-notification {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #FF6B6B;
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    font-weight: 700;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    transition: bottom 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
}

.toast-notification.show {
    bottom: 30px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 25px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 5px solid var(--primary-color);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.modal-content p {
    margin-bottom: 25px;
    line-height: 1.5;
    color: #5D6D7E;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-actions .btn {
    padding: 10px 20px;
    font-size: 1rem;
}

.info-btn {
    background-color: var(--primary-color);
    color: white;
}

.info-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 12px rgba(74, 144, 226, 0.3);
}

/* Reading Screen Styles */
#reading-back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 10px 15px;
    font-size: 1rem;
    z-index: 10;
}

.worksheet-paper {
    background: white;
    border: 2px solid #D5DBDB;
    border-radius: 15px;
    padding: 40px;
    margin: 20px 0;
    text-align: left;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    min-height: 400px;
    position: relative;
    max-width: 100%;
}

.reading-title {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 30px;
    font-size: 2rem;
    text-decoration: underline;
}

.reading-text {
    font-size: 1.5rem;
    line-height: 1.8;
    margin-bottom: 40px;
    color: #34495E;
}

.reading-question-box {
    border-top: 2px dashed #BDC3C7;
    padding-top: 20px;
    margin-top: 20px;
}

.question-label {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.question-text {
    font-size: 1.3rem;
    font-style: italic;
    margin-bottom: 20px;
}

.answer-line {
    border-bottom: 1px solid #7F8C8D;
    height: 40px;
    width: 100%;
}

.viewer-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

/* Print Styles */
@media print {
    body {
        background: white;
        padding: 0;
    }

    #app {
        box-shadow: none !important;
        border: none !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .screen:not(#reading-screen) {
        display: none !important;
    }

    #reading-selection,
    #reading-back-btn,
    .viewer-actions,
    footer,
    .stats-container,
    .logo-container,
    h1,
    p {
        display: none !important;
    }

    /* Override hidden state for print */
    #reading-screen {
        display: block !important;
        padding: 0 !important;
    }

    #reading-screen h1 {
        display: none !important;
    }

    #reading-viewer {
        display: block !important;
    }

    .worksheet-paper {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .reading-title {
        color: black !important;
        margin-top: 0 !important;
    }

    .reading-text {
        color: black !important;
        font-size: 1.4rem !important;
    }

    .answer-line {
        border-bottom: 1px solid black !important;
    }
}