:root {
    --bg-color: #fcf8f2; /* 고즈택한 한지/아이보리 톤 배경 */
    --mainbox-bg: #f5ebe0; /* 따뜻한 미색 브라운 톤 */
    --text-main: #3b2f2f; /* 짙은 갈색 텍스트 */
    --title-color: #b22222; /* 전통 적색 (단청 빨강) */
    --btn-start-bg: #b22222; 
    --btn-hover-bg: #8b0000;
    
    --font-family: "맑은 고딕", "Apple SD Gothic Neo", sans-serif;
    --border-radius-lg: 20px;
    --border-radius-sm: 10px;

    --frame-line-color: #4a3b32; /* 전통 목재 브라운 테두리 */
    --frame-border-width: 3px;
}

body {
    background-color: #f7f3ed;
    background-image: 
    linear-gradient(90deg, rgba(139, 69, 19, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(139, 69, 19, 0.05) 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text-main);
    font-family: var(--font-family);
    text-align: center;
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.iphone-frame {
    position: relative;
    width: 393px;
    height: 852px;
    background-color: var(--bg-color);
    border: var(--frame-border-width) solid var(--frame-line-color);
    border-radius: 40px;
    padding: 8px;
    box-sizing: border-box;
    box-shadow: 0 15px 35px rgba(74, 59, 50, 0.2);
    zoom: 0.8;
}

.iphone-screen {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    border-radius: 32px;
    overflow-y: auto;
    padding: 50px 20px 20px 20px;
    box-sizing: border-box;
}

.iphone-screen::-webkit-scrollbar {
    display: none;
}
.iphone-screen {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.dynamic-island {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 24px;
    background-color: var(--frame-line-color);
    border-radius: 15px;
    z-index: 1000;
}

.color-red { color: #b22222; }
.font-size { font-size: 22px; }
.font-weight { font-weight: bold; }

.page {
    display: none;
}
.page.active {
    display: block;
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.app-header-icon {
    font-size: 34px;
    margin-top: 5px;
    margin-bottom: -5px;
}

.mainbox {
    background: #faf3e0; /* 부드러운 아이보리/베이지 */
    border: 2px solid #d4a373; /* 전통 한옥 창호 브라운 선 */
    padding: 20px 15px;
    border-radius: var(--border-radius-lg);
    width: 100%;
    box-sizing: border-box;
    margin: 15px auto;
    box-shadow: 0 6px 15px rgba(212, 163, 115, 0.2);
}

.main-title {
    color: var(--title-color);
    font-size: 26px;
    margin: 5px 0 10px 0;
    font-weight: 800;
}

.welcome-badge {
    display: inline-block;
    background-color: #285430; /* 단청 초록 포인트 */
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 15px;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.sub-text {
    margin: 6px 0;
    font-size: 13px;
    color: #5c4033;
}

.guide-text {
    margin: 12px 0 4px 0;
    font-size: 13.5px;
    font-weight: bold;
    color: #4a3b32;
    line-height: 1.4;
}

.rules-card {
    background: #ffffff;
    border-radius: var(--border-radius-sm);
    padding: 12px 15px;
    margin: 15px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.04);
    border: 1px solid #e6dbcc;
}

.rule-item {
    font-size: 13px;
    text-align: left;
    background: #fdfbf7;
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #f0e6d2;
}

.score-plus { color: #285430; } /* 초록 */
.score-minus { color: #b22222; } /* 빨강 */
.score-total { color: #b8860b; } /* 황금빛 옐로우 */

.btn {
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s ease;
}

.btn:active {
    transform: scale(0.96); 
    filter: brightness(0.9); 
}

.btn-start {
    background: var(--btn-start-bg);
    color: white;
    padding: 16px 30px;
    font-weight: bold;
    width: 100%;
    margin-top: 5px;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(178, 34, 34, 0.3);
    border-radius: var(--border-radius-sm);
}

.btn-start:hover {
    background: var(--btn-hover-bg);
}

.btn-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 90%;
    margin: 20px auto 0 auto;
}

/* 전통 단청 색상 조합의 액션 버튼들 */
.btn-action.check {
    background-color: #285430; /* 단청 초록 */
    color: white;
}
.btn-action.check:hover { background-color: #1b3820; }

.btn-action.hint {
    background-color: #d4a373; /* 황토 브라운/옐로우 톤 */
    color: #fff;
}
.btn-action.hint:hover { background-color: #bc6c25; }

.btn-action.pass {
    background-color: #bc6c25; /* 진한 옐로우브라운 */
    color: white;
}
.btn-action.pass:hover { background-color: #9c5419; }

.btn-action.delete {
    background-color: #e9edc9; /* 밝은 연두빛 아이보리 */
    color: #3b2f2f;
}
.btn-action.delete:hover { background-color: #ccd5ae; }

.btn-action {
    border: none;
    padding: 14px 10px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.btn-restart {
    background-color: #285430; /* 초록색 */
    color: white;
    padding: 14px 24px;
    margin: 10px auto;
    width: 90%;
}
.btn-restart:hover { background-color: #1b3820; }

.btn-home { 
    background-color: #b22222; /* 적색 */
    color: white;
    border: none;
    padding: 14px 10px;
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s ease;
    width: 90%;
    box-sizing: border-box;
    margin: 5px auto 15px auto;
}
.btn-home:hover { background-color: #8b0000; }

.question-number {
    display: inline-block;
    background: #d4a373;
    color: white;
    font-size: 13px;
    font-weight: bold;
    padding: 5px 14px;
    border-radius: 15px;
    margin-top: 15px;
    letter-spacing: 0.5px;
}

.question {
    background-color: #ffffff;
    border: 2px solid #d4a373;
    border-radius: var(--border-radius-lg);
    padding: 20px 15px;
    font-size: 17px;
    font-weight: bold;
    color: #3b2f2f;
    margin: 15px auto;
    width: 90%;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    line-height: 1.6;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.quiz-input {
    width: 90%;
    padding: 14px;
    font-size: 16px;
    border-radius: 12px;
    border: 2px dashed #d4a373;
    box-sizing: border-box;
    text-align: center;
    outline: none;
    background-color: #fdfbf7;
    color: #3b2f2f;
    transition: all 0.3s ease;
}

.quiz-input:focus {
    border-color: #285430;
    background-color: white;
    box-shadow: 0 0 8px rgba(40, 84, 48, 0.2);
}

.quiz-result {
    font-size: 18px;
    margin: 10px 0;
    font-weight: bold;
}

.quiz-hint {
    background-color: #fefae0;
    color: #bc6c25;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    width: 85%;
    margin: 8px auto;
    border: 1px dashed #dda15e;
}

.quiz-hint:empty {
    display: none;
}

.result-box {
    margin-top: 25px;
}

.divider {
    color: #d4a373;
    letter-spacing: -1px;
}

.stat-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 14px 18px;
    width: 88%;
    box-shadow: 0 4px 12px rgba(74, 59, 50, 0.08);
    border: 1px solid #e6dbcc;
    margin: 0 auto 15px auto;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    color: #4a3b32;
    padding: 8px 0;
    border-bottom: 1px dashed #f0e6d2;
}

.stat-item:last-child {
    border-bottom: none; 
}

.stat-item strong {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111;
}

.final-score {
    font-size: 1.15rem;
    font-weight: 700;
    color: #3b2f2f;
    margin-top: 5px;
}

.final-score-num {
    color: #b22222;
    font-size: 1.5rem;
    font-weight: 800;
}

.title-card {
    background: #f5ebe0;
    border: 1px solid #d4a373;
    border-radius: 16px;
    padding: 16px;
    margin: 15px auto;
    width: 88%;
    box-sizing: border-box;
    text-align: center;
}

.title-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #285430;
    background: rgba(40, 84, 48, 0.12);
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.user-title {
    font-size: 19px;
    font-weight: 700;
    margin: 4px 0 6px 0;
    color: #3b2f2f;
}

.user-title-desc {
    font-size: 13px;
    color: #5c4033;
    margin: 0;
    line-height: 1.4;
}

.btn-back {
    background: none;
    border: none;
    font-size: 12px;
    font-weight: bold;
    color: #4a3b32;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 0;
    margin-bottom: 15px;
    font-family: var(--font-family);
    transition: opacity 0.2s ease;
}

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

@media screen and (max-width: 768px) {
    body {
        background-color: var(--bg-color);
        display: block;
    }
    .iphone-frame {
        width: 100% !important;
        height: 100vh !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
    .iphone-screen {
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        padding: 20px 16px !important;
    }
    .dynamic-island {
        display: none;
    }
}