:root {
    --primary-color: #008cce;
    --secondary-color: #666666;
    --success-color: #669933;
    --accent-color: #fbb03b;
    --error-color: #e74c3c;
    --white: #ffffff;
    --bg-color: #f4f4f4;
    --font-family: 'Open Sans', sans-serif;
    --transition-speed: 0.3s;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--secondary-color);
    margin: 0;
    padding: 0;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Prevent body scroll */
}

#app {
    width: 100%;
    height: 100%;
    max-width: 500px;
    background-color: var(--white);
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

#screen-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 15px; /* Slightly reduced padding */
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed) ease;
    box-sizing: border-box;
}

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

/* Typography */
h1 { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 1rem; }
h2 { font-size: 1.8rem; margin-bottom: 1rem; }
p { font-size: 1rem; line-height: 1.5; margin-bottom: 1.5rem; }

/* Buttons */
.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    text-align: center;
    display: inline-block;
}

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

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

/* Splash Screen */
#splash-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: var(--white);
    cursor: pointer;
}

.splash-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: auto;
}

.splash-logo {
    width: 200px;
    height: auto;
    margin-bottom: 20px;
    transition: opacity 2.5s ease;
}

.splash-text {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.2rem;
    transition: opacity 0.5s ease;
}

/* Pulse Animation */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 3s ease-in-out infinite;
}

.logo-static {
    transform: scale(1);
    transition: transform 1s ease-in-out;
}

.fade-out {
    opacity: 0;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Unified Menu Screen (Intro + Menu) */
#menu-screen {
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    background-color: var(--white);
    padding: 40px 20px 20px 20px;
}

@media (max-height: 700px) {
    #menu-screen {
        padding: 15px 15px 15px 15px;
    }
    .intro-line1 { font-size: 1.3rem; }
    .intro-line2 { font-size: 0.9rem; }
    .menu-logo { width: 90px; margin-bottom: 15px; }
    .menu-extra-content { margin-top: 10px; }
    .btn-game-time { padding: 10px 25px; font-size: 1rem; }
    .menu-instructions { margin-bottom: 15px; gap: 6px; font-size: 0.75rem; }
    .instruction-grid { font-size: 0.75rem; }
}

.menu-title-block {
    transition: transform 1s ease-in-out;
    transform: translateY(200px); /* Initial centered position */
}

.menu-screen-active .menu-title-block {
    transform: translateY(0); /* Top position after transformation */
}

.intro-line1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #000000;
    margin-bottom: 0.2rem;
}

.intro-line2 {
    font-size: 1.2rem;
    font-weight: 400;
    color: #666666;
}

.menu-extra-content {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease 0.5s, transform 1s ease 0.5s;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 30px;
}

.menu-screen-active .menu-extra-content {
    opacity: 1;
    transform: translateY(0);
}

.menu-instructions {
    font-size: 0.85rem;
    color: var(--secondary-color);
    margin-bottom: 10px;
    line-height: 1.4;
    max-width: 95%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.instruction-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    text-align: left;
    margin: 0 auto;
}

.instr-condition {
    white-space: nowrap;
    font-weight: 600;
}

.instr-action {
    color: #444;
}

.instr-header {
    font-weight: 700;
    color: #000;
    margin-bottom: 5px;
}

.menu-logo {
    width: 120px;
    height: auto;
    margin-bottom: 25px;
}

.btn-game-time {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 15px 40px;
    font-size: 1.3rem;
    box-shadow: 0 4px 15px rgba(0, 140, 206, 0.3);
}

/* Game Screen */
#game-screen {
    padding-top: 40px; /* Reduced top padding */
}

.status-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center; /* Vertical center */
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 0.85rem;
}

/* Sound Toggle */
.sound-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--secondary-color);
}

.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(16px);
}

.character-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 0px; /* Start higher up */
}

.avatar {
    width: 200px;
    height: 200px;
    margin-bottom: -15px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@media (max-height: 750px) {
    .avatar {
        width: 150px;
        height: 150px;
        margin-bottom: -10px;
    }
    .character-name {
        font-size: 1.2rem;
        margin-bottom: 5px;
    }
    .repeat-audio-btn {
        margin-bottom: 8px;
        padding: 5px 12px;
        font-size: 0.8rem;
    }
    .choice-btn {
        padding: 10px;
        font-size: 0.85rem;
    }
    .choices-grid {
        gap: 5px;
    }
}

.character-name {
    font-size: 1.8rem;
    margin-top: 0;
    margin-bottom: 10px; /* Spacing before buttons */
    font-weight: 700;
    color: #333;
    z-index: 2;
    text-align: center;
    white-space: nowrap; /* Prevent cutting */
}

.character-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.repeat-audio-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 20px;
    background-color: var(--white);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    margin-top: 0px;
    margin-bottom: 15px; /* Push answer buttons down */
}

.repeat-audio-btn:active {
    transform: scale(0.95);
    background-color: #f0f8ff;
}

.speaker-icon {
    font-size: 1.2rem;
}

.choices-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 5px;
    width: 100%;
}

.choice-btn {
    padding: 16px;
    border: none;
    border-radius: 15px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    cursor: pointer;
    transition: transform 0.2s, opacity 0.3s, background-color 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
}

/* Fixed Colors (New Order: Blue, Green, Yellow, Gray) */
.btn-color-0 { background-color: #008cce; } /* Blue */
.btn-color-1 { background-color: #669933; } /* Green */
.btn-color-2 { background-color: #fbb03b; } /* Yellow */
.btn-color-3 { background-color: #666666; } /* Gray */

.choice-btn:active {
    transform: scale(0.98);
    filter: brightness(0.9);
}

.choice-btn.correct-anim {
    animation: correctPulse 1s ease-in-out forwards;
    z-index: 10;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.choice-btn.wrong-anim {
    background-color: var(--error-color) !important;
    animation: vibrate 0.3s linear quick;
}

@keyframes vibrate {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

.choice-btn.fade-out-incorrect {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 1s ease-out;
}

.choice-btn.disabled-attempt {
    /* Keeping this for compatibility or removing if fully replaced */
    opacity: 0.4;
    pointer-events: none;
}

/* Score Screen */
#score-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: var(--white);
}

.score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-logo {
    width: 150px;
    height: auto;
    margin-bottom: 20px;
}

.score-text {
    font-size: 1rem;
    color: #000000;
    margin-top: 20px;
    max-width: 80%;
    line-height: 1.4;
}

.final-score {
    font-size: 5rem;
    font-weight: 800;
    color: var(--primary-color);
    margin: 10px 0;
}



/* Brand Info (Flowing Text Format) */
.brand-container {
    margin-top: auto; /* Spacer flexible requirement */
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0 10px 0; /* Minimized padding */
    text-align: center;
    flex-shrink: 0;
}

.brand-powered {
    color: #000000;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: -3px; /* Tight spacing */
}

.brand-details {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.brand-logo-small {
    height: 16px;
    width: auto;
}

.brand-url {
    color: #666666;
    font-size: 0.8rem;
    font-weight: 400;
}

/* Transitions */
.screen.fade-long {
    transition: opacity 1.25s ease-in-out; /* Total 2.5s split */
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease forwards;
}
