:root {
    --primary: #FF7E67;
    --primary-light: #FF9A8B;
    --secondary: #2ECC71;
    /* Logo match green */
    --secondary-dark: #27AE60;
    --accent: #FFD93D;
    --success: #6BCB77;
    --bg-main: #F8FAFC;
    --card-bg: rgba(255, 255, 255, 0.98);
    --text-main: #1E293B;
    --text-muted: #64748B;
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    --shadow-strong: 0 20px 35px -5px rgba(0, 0, 0, 0.1);
    --radius-lg: 32px;
    --radius-md: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Nanum Gothic', sans-serif;
    background: radial-gradient(circle at top left, #FFF5F5 0%, #F5FFF9 100%);
    min-height: 100vh;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 800px;
    /* Wider for matching game */
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Auth Screen Styling */
#auth-screen {
    max-width: 450px;
    margin: auto;
    text-align: center;
    padding: 30px;
}

.auth-box {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.selection-group {
    text-align: left;
}

.selection-group label {
    display: block;
    font-weight: 800;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-group {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.btn-group::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

.choice-btn {
    flex: 0 0 auto;
    padding: 10px 15px;
    border-radius: 12px;
    border: 2px solid #E2E8F0;
    background: white;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.choice-btn:hover {
    border-color: var(--secondary);
}

.choice-btn.active {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.auth-logo {
    width: 120px;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0;
}

.form-input {
    width: 100%;
    padding: 14px 20px;
    border-radius: 12px;
    border: 2px solid #E2E8F0;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--secondary);
}

/* Header Styling */
header {
    text-align: center;
    padding: 10px 0 20px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 15px;
}

.header-logo {
    width: 50px;
    height: 50px;
}

.title {
    font-family: 'Gaegu', cursive;
    font-size: 1.6rem;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 10px;
}

#display-user {
    font-weight: 800;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.score-container {
    background: white;
    padding: 6px 16px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-soft);
    border: 1px solid #eee;
}

#score {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.2rem;
}

.month-badge {
    background: var(--secondary);
    color: white;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-block;
}

/* Card Container */
.card-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-strong);
    animation: fadeIn 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

.hero-image {
    width: calc(100% + 60px);
    margin-left: -30px;
    margin-top: -30px;
    margin-bottom: 25px;
    height: 280px;
    /* 크롭된 이미지에 맞게 높이 최적화 */
    overflow: hidden;
    position: relative;
    background: #fdfbf7;
}

.main-illustration {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    /* 직접 크롭하신 이미지이므로 중앙 정렬이 가장 좋습니다 */
}

.hero-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to top, white 10%, transparent);
}

/* Menu Grid */
.menu-grid {
    display: grid;
    gap: 14px;
    margin-bottom: 20px;
}

.menu-card {
    background: white;
    border: 1px solid #f1f1f1;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.menu-card:hover {
    transform: translateX(5px);
    border-color: var(--secondary);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.card-icon {
    font-size: 1.8rem;
    background: #f8f8f8;
    width: 55px;
    height: 55px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-title {
    display: block;
    font-weight: 800;
    font-size: 1.1rem;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.menu-footer {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-secondary-sm {
    background: #f1f5f9;
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Game Styles */
.verse-display {
    font-size: 1.4rem;
    line-height: 1.7;
    margin-bottom: 20px;
    padding: 25px;
    background: #f8fafc;
    border-radius: var(--radius-md);
    font-weight: 700;
    word-break: keep-all;
    position: relative;
    text-align: center;
}

.verse-ref-box {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
    font-size: 1.1rem;
    color: #94a3b8;
    font-style: italic;
    display: block;
}

.blank {
    display: inline-block;
    padding: 0 10px;
    border-bottom: 4px solid var(--primary);
    margin: 0 4px;
    color: var(--primary);
    background: #fff5f5;
    min-width: 60px;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.option-btn {
    background: white;
    border: 2px solid #f1f5f9;
    padding: 18px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    border-color: var(--primary);
    background: #fffaf9;
}

.option-btn.correct {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.option-btn.wrong {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    animation: shake 0.4s;
}

/* Scramble Game Styles */
.scramble-slots {
    min-height: 80px;
    border: 2px dashed #CBD5E1;
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 20px;
    background: #fff;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.scramble-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    padding: 15px;
}

.word-chip {
    background: white;
    border: 2px solid #E2E8F0;
    padding: 10px 18px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    user-select: none;
}

.word-chip:hover {
    border-color: var(--secondary);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.word-chip:active {
    transform: translateY(0);
}

.scramble-slots .word-chip {
    background: #F0FDF4;
    border-color: var(--secondary);
    color: var(--secondary-dark);
}

/* Matching Drawing */
.matching-container {
    display: flex;
    justify-content: space-between;
    gap: 40px;
    position: relative;
    z-index: 10;
}

.matching-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.match-item {
    background: white;
    border: 2px solid #f1f5f9;
    padding: 12px;
    border-radius: 15px;
    font-weight: 700;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: keep-all;
}

.match-item.selected {
    border-color: var(--secondary);
    background: #f0fff4;
}

.match-item.matched {
    opacity: 0.5;
    border-color: var(--success);
    background: #f0fdf4;
    cursor: default;
}

#match-canvas {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 5;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    padding: 35px;
    border-radius: var(--radius-lg);
    max-width: 450px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.title-container {
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-title-img {
    width: 100%;
    max-width: 400px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.auth-logo {
    width: 60px;
    height: 60px;
    margin-bottom: 15px;
}

.modal-content h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    word-break: keep-all;
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: 16px 30px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 1.1rem;
    border: none;
    cursor: pointer;
    width: 100%;
}

.btn-secondary {
    background: #f1f5f9;
    color: #64748b;
    padding: 14px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    font-weight: 700;
}

/* Ranking Table */
.ranking-list {
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
    align-items: center;
}

.ranking-rank {
    font-weight: 800;
    color: var(--primary);
    width: 40px;
    font-size: 1.1rem;
}

.ranking-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    gap: 2px;
}

.rank-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
}

.rank-student {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
}

.ranking-score {
    font-weight: 800;
    color: var(--secondary);
    font-size: 1.1rem;
}

/* Audio Button */
.btn-audio {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Mobile */
@media (max-width: 600px) {
    #app {
        padding: 15px;
    }

    .title {
        font-size: 1.4rem;
    }

    .verse-display {
        font-size: 1.2rem;
        padding: 15px;
    }

    .matching-container {
        gap: 15px;
    }

    .match-item {
        font-size: 0.85rem;
        padding: 10px;
    }
}