:root {
    --bg-gradient: linear-gradient(135deg, #1e272e 0%, #2f3542 100%);
    --primary-color: #4facfe;
    --primary-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --secondary-gradient: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    --text-main: #f5f6fa;
    --text-light: #b2bec3;
    --card-bg: rgba(47, 53, 66, 0.9);
    --border-radius: 24px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    
    --correct-color: #00b894;
    --incorrect-color: #ff7675;
}

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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    animation: fadeInDown 0.5s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo .icon {
    font-size: 2rem;
}

.logo h1 {
    font-family: 'Outfit', 'Noto Sans JP', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.score-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 100px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    font-weight: bold;
    color: var(--primary-color);
}

/* Screens */
.screen {
    flex: 1;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.4s ease-out;
}

.screen.active {
    display: flex;
}

/* Hero / Start Screen */
.hero {
    text-align: center;
    background: var(--card-bg);
    padding: 60px 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    line-height: 1.3;
}

.hero p {
    color: var(--text-light);
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.mode-selection {
    margin-bottom: 30px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 16px;
}

.mode-title {
    color: var(--text-main);
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 1rem !important;
}

.mode-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mode-btn {
    background: #3d4554;
    border: 2px solid #57606f;
    color: var(--text-light);
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(79, 172, 254, 0.4);
}

/* Buttons */
.btn {
    padding: 16px 32px;
    border: none;
    border-radius: 100px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.primary-btn {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 8px 20px rgba(79, 172, 254, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(79, 172, 254, 0.5);
}

.secondary-btn {
    background: var(--secondary-gradient);
    color: white;
    box-shadow: 0 8px 20px rgba(253, 160, 133, 0.4);
}

.secondary-btn:hover {
    transform: translateY(-2px);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    padding: 10px;
    transition: opacity 0.2s;
}

.btn-text:hover {
    opacity: 0.7;
}

/* Quiz Screen */
.quiz-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 500px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.image-container {
    width: 200px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    background: #dfe4ea;
    border-radius: 20px;
    box-shadow: inset 0 4px 10px rgba(0,0,0,0.2);
    padding: 20px;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.hint-container {
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
    min-height: 60px;
}

.hint-text {
    background: #3d4554;
    padding: 12px;
    border-radius: 12px;
    color: var(--text-light);
    font-size: 0.95rem;
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}

.choices-container {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.choices-container.col-3 {
    grid-template-columns: repeat(3, 1fr);
}

.choice-btn {
    background: #3d4554;
    border: 2px solid #57606f;
    padding: 12px 10px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 54px;
}

.choice-btn ruby {
    ruby-align: center;
}
.choice-btn rt {
    color: var(--text-light);
    font-size: 0.65em;
    font-weight: normal;
    line-height: 1;
}
.choice-btn.correct rt, .choice-btn.wrong rt {
    color: rgba(255, 255, 255, 0.9);
}

.choice-btn:hover {
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.choice-btn.correct {
    background: var(--correct-color);
    border-color: var(--correct-color);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 8px 15px rgba(0, 184, 148, 0.3);
}

.choice-btn.wrong {
    background: var(--incorrect-color);
    border-color: var(--incorrect-color);
    color: white;
    animation: shake 0.4s ease;
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 52, 54, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

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

.result-box {
    background: #2f3542;
    padding: 40px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    min-width: 300px;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mark {
    font-size: 8rem;
    font-weight: bold;
    margin-bottom: 20px;
    line-height: 1;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-box.correct-bg .mark {
    color: var(--correct-color);
}

.result-box.wrong-bg .mark {
    color: var(--incorrect-color);
}

.result-box.correct-bg .result-correct-answer {
    display: none; /* Hide answer if correct */
}

.result-correct-answer {
    margin-bottom: 30px;
}

.result-correct-answer .reading {
    font-size: 0.9rem;
    color: var(--text-light);
}

.result-correct-answer .answer {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-main);
}

/* Kusudama Celebration */
.kusudama-container {
    text-align: center;
    color: white;
    animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.kusudama {
    font-size: 6rem;
    margin-bottom: 20px;
    animation: slideDown 1s ease-out, swing 2s infinite ease-in-out;
    transform-origin: top center;
}

.kusudama-container h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.kusudama-container p {
    font-size: 1.2rem;
    margin-bottom: 30px;
}

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

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    50% { transform: translateX(10px); }
    75% { transform: translateX(-10px); }
}

@keyframes slideDown {
    from { transform: translateY(-100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes swing {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(5deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(-5deg); }
    100% { transform: rotate(0deg); }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(79, 172, 254, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(79, 172, 254, 0); }
    100% { box-shadow: 0 0 0 0 rgba(79, 172, 254, 0); }
}

/* Responsive */
@media (max-width: 600px) {
    .hero h2 {
        font-size: 2rem;
    }
    
    .choices-container {
        /* On small screens, fallback to 2 columns mostly, except 12 mode maybe. 2 cols is fine */
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .quiz-card {
        padding: 30px 15px;
    }
    
    .choice-btn {
        font-size: 0.9rem;
        padding: 10px 5px;
        min-height: 50px;
    }
}
