@import url('https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@500;700&display=swap');

:root {
    --primary-color: #FF9F1C;
    --secondary-color: #2EC4B6;
    --bg-color: #CBF3F0;
    --text-color: #333;
    --card-bg: #FFFFFF;
    --base-font-scale: 1;
}

body {
    font-family: 'Zen Maru Gothic', sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    font-size: calc(16px * var(--base-font-scale));
}

#app {
    width: 100%;
    max-width: 800px;
    text-align: center;
    padding: 20px;
}

h1 {
    color: var(--text-color);
    font-size: 3rem;
    margin-bottom: 2rem;
}

.mode-btn {
    background-color: var(--primary-color);
    border: none;
    border-radius: 20px;
    padding: 20px 40px;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    margin: 10px;
    font-family: inherit;
    transition: transform 0.2s;
    box-shadow: 0 5px 0 #E08E1A;
}

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

#settings-btn {
    background: white;
    border: 2px solid #ccc;
    font-family: inherit;
    font-size: 1rem;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 4px 0 #bbb;
}

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

#settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#settings-content {
    background-color: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    text-align: left;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.settings-group {
    margin-bottom: 25px;
    border-bottom: 2px dashed #eee;
    padding-bottom: 20px;
}

.settings-group h3 {
    margin-top: 0;
    color: var(--secondary-color);
}

.settings-sub-btn {
    background-color: #eee;
    border: none;
    padding: 5px 15px;
    border-radius: 15px;
    cursor: pointer;
    font-family: inherit;
    margin-top: 10px;
}

.close-btn {
    display: block;
    width: 100%;
    padding: 15px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 1.5rem;
    font-family: inherit;
    cursor: pointer;
    font-weight: bold;
}

#row-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.row-checkbox {
    display: none;
}

.row-label {
    background-color: #fff;
    border: 2px solid var(--secondary-color);
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    color: var(--secondary-color);
    transition: all 0.2s;
}

.row-checkbox:checked+.row-label {
    background-color: var(--secondary-color);
    color: white;
}

.settings-btn {
    background-color: #eee;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    margin-top: 10px;
}

#question-display {
    /* Base styles */
    background-color: white;
    padding: 20px 40px;
    border-radius: 20px;
    box-shadow: 0 10px 0 rgba(0, 0, 0, 0.1);

    margin: 0 auto 30px auto;
    width: auto;
    /* Let it grow */
    max-width: 90%;
    /* Prevent overflow off screen */
    min-width: 300px;
    /* Force minimum width to likely include text */

    /* Flexbox Layout - Explicitly Horizontal */
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: baseline;
    gap: 15px;

    /* Text Styles */
    font-weight: bold;
    color: var(--primary-color);
}

#choices-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.choice-btn {
    background-color: var(--card-bg);
    border: 5px solid transparent;
    border-radius: 15px;
    padding: 10px;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 160px;
    height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.choice-btn img {
    width: 100%;
    height: 150px;
    object-fit: contain;
}


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

.choice-img-placeholder {
    width: 100%;
    height: 120px;
    background-color: #eee;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    border-radius: 10px;
    color: #555;
    word-break: break-all;
}

#feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#feedback-message {
    font-size: 5rem;
    font-weight: bold;
    text-align: center;
    line-height: 1.2;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

.correct-answer {
    animation: bounce 0.5s;
    background-color: #d4edda !important;
    border-color: #c3e6cb !important;
}

.wrong-answer {
    animation: shake 0.5s;
    background-color: #f8d7da !important;
    border-color: #f5c6cb !important;
}

@keyframes bounce {

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

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

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

@keyframes shake {

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

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.word-label {
    font-size: 2rem;
    margin-top: 10px;
    color: #555;
    font-weight: bold;
}

.highlight-char {
    color: #FF0000;
    /* Red for emphasis */
    font-size: 2.5rem;
    /* Slightly larger */
    transition: all 0.3s ease;
}

#result-screen {
    text-align: center;
    background-color: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#score-display {
    font-size: 3rem;
    color: var(--primary-color);
    margin: 20px 0;
    font-weight: bold;
}

#result-message {
    font-size: 2rem;
    color: var(--secondary-color);
    margin-bottom: 30px;
}

#progress-container {
    margin-bottom: 20px;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    /* For absolute positioning of home btn if needed, or flex */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

#home-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    padding: 5px 10px;
    transition: transform 0.2s;
}

#home-btn:hover {
    transform: scale(1.1);
}

#progress-text {
    text-align: right;
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 5px;
    flex-grow: 1;
}

#progress-bar {
    width: 100%;
    height: 15px;
    background-color: #eee;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 5px;
}

#progress-fill {
    height: 100%;
    background-color: var(--highlight-color);
    width: 0%;
    transition: width 0.3s ease;
}

.confetti {
    position: fixed;
    top: -10px;
    width: 10px;
    height: 10px;
    background-color: red;
    animation: fall linear forwards;
    z-index: 1000;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
    }
}

#hanamaru-feedback {
    width: 300px;
    height: 300px;
    object-fit: contain;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Gallery Mode */
#gallery-screen {
    width: 100%;
    height: 100vh;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    overflow: hidden;
    /* Header fixed, content scrolls */
}

.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    flex-shrink: 0;
}

#gallery-home-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    background-color: white;
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#gallery-container {
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 50px;
}

.gallery-row {
    background-color: white;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Set explicitly in JS but good to have fallback */
    display: flex;
    align-items: center;
}

.gallery-char-header {
    font-size: 3rem;
    color: var(--primary-color);
    font-weight: bold;
    width: 60px;
    text-align: center;
    flex-shrink: 0;
    margin-right: 10px;
}

.gallery-items {
    display: flex;
    flex-wrap: wrap;
    /* Allow wrap if screen is very small, but prefer single line if possible */
    gap: 10px;
    justify-content: flex-start;
    flex-grow: 1;
}

.gallery-row-header {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    font-weight: bold;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
}

.gallery-card {
    width: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px;
    border: 1px solid #eee;
    border-radius: 8px;
    background-color: #fafafa;
}

.gallery-card img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 3px;
}

.gallery-card .word {
    font-size: 0.9rem;
    font-weight: bold;
    color: #333;
}

.correct-hint { box-shadow: 0 0 10px 4px #4CAF50, 0 0 0 4px #fff inset !important; border-color: #4CAF50 !important; animation: pulse 1s infinite; }

.word-label { font-size: clamp(1rem, 5vw, 1.8rem); margin-top: 10px; color: #555; font-weight: bold; white-space: nowrap; overflow: visible; text-align: center; width: 100%; }


/* Shiritori Unified Card Style */
.choice-btn { justify-content: flex-start !important; padding-top: 15px !important; overflow: hidden; }
.choice-btn img { height: 140px !important; margin-bottom: 10px !important; }

/* Shiritori Previous Item Display */
.shiritori-prev-card { width: 120px; height: 160px; padding: 10px; background: white; border-radius: 15px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); display: flex; flex-direction: column; align-items: center; justify-content: center; margin-right: 20px; text-align: center; }
.shiritori-prev-card img { width: 80px; height: 80px; object-fit: contain; margin-bottom: 5px; }
.shiritori-prev-text { font-size: 1.5rem; font-weight: bold; color: #555; }


/* Standardized Nav Buttons */
.nav-btn { background-color: white !important; border: none !important; border-radius: 50px !important; padding: 8px 20px !important; font-size: 1.2rem !important; font-weight: bold; cursor: pointer; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important; display: flex; align-items: center; gap: 8px; transition: transform 0.2s, background-color 0.2s; color: #333 !important; font-family: inherit; z-index: 10; }
.nav-btn:hover { transform: scale(1.05); background-color: #f9f9f9 !important; }
.gallery-header { display: flex !important; align-items: center !important; justify-content: flex-start !important; gap: 20px !important; }
