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

/* 가로 모드 안내 오버레이 (세로 모드 감지 시) */
.orientation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.orientation-overlay-content {
    background: #fff;
    padding: 28px 24px;
    border-radius: 20px;
    text-align: center;
    max-width: 340px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.orientation-message {
    font-size: 1.15rem;
    line-height: 1.6;
    color: #333;
    margin: 0 0 24px 0;
    font-family: 'Jua', sans-serif;
}
.orientation-continue-btn {
    padding: 12px 28px;
    background: #4caf50;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-family: 'Jua', sans-serif;
    cursor: pointer;
    transition: background 0.2s;
}
.orientation-continue-btn:hover {
    background: #388e3c;
}
.orientation-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
.orientation-dismiss-btn {
    padding: 10px 20px;
    background: transparent;
    color: #666;
    border: 1px solid #ccc;
    border-radius: 12px;
    font-size: 0.9rem;
    font-family: 'Jua', sans-serif;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.orientation-dismiss-btn:hover {
    background: #f5f5f5;
    color: #333;
}

/* 카카오톡 인앱브라우저 안내 배너 */
.kakao-inapp-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fee500;
    color: #191919;
    padding: 12px 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.kakao-inapp-banner p {
    margin: 0;
    flex: 1;
}
.kakao-inapp-banner-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    background: rgba(0,0,0,0.1);
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    color: #333;
}
.kakao-inapp-banner-close:hover {
    background: rgba(0,0,0,0.2);
}

:root {
    --intro-header-height: 52px;
    --intro-footer-height: 24px;
}

body {
    font-family: 'Jua', 'Do Hyeon', 'Malgun Gothic', '맑은 고딕', sans-serif;
    background: linear-gradient(135deg, #fff9c4 0%, #c8e6c9 50%, #fff9c4 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    padding-top: var(--intro-header-height);
    padding-bottom: var(--intro-footer-height);
}

/* 헤더 (map 기준: 52px) */
.intro-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--intro-header-height);
    box-sizing: border-box;
}

.intro-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    color: #2e7d32;
    margin: 0;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    line-height: 1.2;
    font-family: 'Jua', sans-serif;
}

.intro-school-info {
    font-size: 1.2rem;
    color: #388e3c;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.2;
    margin-left: auto;
}
.intro-header-icon-btn {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
    border: 2px solid #64b5f6;
    padding: 3px 8px;
    font-size: 0.85rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-family: 'Jua', sans-serif;
}
.intro-header-icon-btn:hover {
    background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}
/* 세로 모드: index 헤더 '대전 탐험대' 왼쪽 정렬 (겹침 방지) */
@media (max-width: 768px) and (orientation: portrait) {
    .intro-title {
        position: static;
        transform: none;
        left: auto;
    }
}

/* 하단 저작권 (map 기준: 24px 높이) */
.intro-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    padding: 4px 15px;
    text-align: center;
    font-size: 0.7rem;
    color: #666;
    z-index: 1002;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
    font-family: 'Jua', sans-serif;
    height: var(--intro-footer-height);
    line-height: var(--intro-footer-height);
    box-sizing: border-box;
}

.intro-footer p {
    margin: 0;
    line-height: var(--intro-footer-height);
}

.step-container {
    width: 100%;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.intro-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 40px 30px;
    border-radius: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-width: 900px;
    width: 100%;
}

.title {
    font-size: 3rem;
    color: #2e7d32;
    margin-bottom: 30px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.question {
    font-size: 1.8rem;
    color: #388e3c;
    margin-bottom: 40px;
    font-weight: bold;
}

.step-title {
    font-size: 2.2rem;
    color: #2e7d32;
    margin-bottom: 30px;
    font-weight: bold;
}

/* 자음 그리드 */
.initial-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 15px;
    margin-top: 30px;
}

.initial-button {
    background: linear-gradient(135deg, #fff59d 0%, #ffcc02 100%);
    color: #333;
    border: 4px solid #ffb300;
    padding: 25px 15px;
    font-size: 2.5rem;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.initial-button:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 20px rgba(255, 179, 0, 0.4);
    background: linear-gradient(135deg, #ffeb3b 0%, #ffc107 100%);
}

.initial-button:active {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 15px rgba(255, 179, 0, 0.3);
}

/* 학교 그리드 */
.school-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.school-card {
    background: linear-gradient(135deg, #a5d6a7 0%, #81c784 100%);
    color: #1b5e20;
    border: 4px solid #66bb6a;
    padding: 30px 20px;
    font-size: 1.8rem;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.school-card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4);
    background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
}

.school-card:active {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

/* 학년 선택 버튼 (좌우 병렬) */
.grade-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
    margin-top: 40px;
    align-items: stretch;
}

.grade-button {
    background: linear-gradient(135deg, #fff59d 0%, #ffcc02 100%);
    color: #333;
    border: 5px solid #ffb300;
    padding: 40px 60px;
    font-size: 2.2rem;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    min-width: 350px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.grade-button:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 12px 30px rgba(255, 179, 0, 0.5);
    background: linear-gradient(135deg, #ffeb3b 0%, #ffc107 100%);
}

.grade-button:active {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 20px rgba(255, 179, 0, 0.4);
}

.grade-emoji {
    font-size: 3.5rem;
    display: block;
}

.grade-text {
    font-size: 2.5rem;
    display: block;
}

.grade-subtitle {
    font-size: 1.5rem;
    color: #666;
    display: block;
    visibility: hidden; /* (우리 고장), (대전 전체) 숨김 - 카드 크기 유지 */
}

/* 돌아가기 버튼 */
.back-button {
    background: #81c784;
    color: white;
    border: 3px solid #66bb6a;
    padding: 12px 25px;
    font-size: 1.3rem;
    font-weight: bold;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 20px;
    align-self: flex-start;
}

.back-button:hover {
    background: #66bb6a;
    transform: translateX(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.back-button:active {
    transform: translateX(0);
}

/* 교사 정보 모달 (index, map과 동일 스타일) */
.intro-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.intro-modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    position: relative;
}
.intro-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}
.intro-modal-title {
    font-size: 1.3rem;
    margin-bottom: 16px;
    color: #2e7d32;
}
.intro-modal-body p {
    margin: 8px 0;
    line-height: 1.5;
}
.intro-modal-body a {
    color: #4a90e2;
    text-decoration: underline;
}

/* 교사 정보 모달 - 가독성 개선 */
.teacher-info-box {
    max-width: 420px;
}
.teacher-info-title,
.footer-info-dev-title {
    font-family: 'Jua', sans-serif;
    font-size: 1.42rem;
    font-weight: 700;
    color: #1b5e20;
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #e8f5e9;
    line-height: 1.35;
}
.intro-modal-title.teacher-info-title,
.map-modal-title.teacher-info-title {
    font-size: 1.42rem;
    font-weight: 700;
    color: #1b5e20;
}
.teacher-info-body {
    line-height: 1.6;
}
.teacher-info-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.teacher-info-list li {
    padding: 10px 14px;
    margin-bottom: 6px;
    background: #f8faf8;
    border-radius: 10px;
    color: #333;
    font-size: 1rem;
}
.teacher-info-list li:last-of-type {
    margin-bottom: 0;
}
.teacher-info-list a {
    color: #1976d2;
    text-decoration: none;
    font-weight: 600;
}
.teacher-info-list a:hover {
    text-decoration: underline;
}
.teacher-info-contact {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e8f5e9;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.contact-label {
    font-weight: 600;
    color: #555;
    font-size: 0.95rem;
}
.teacher-info-contact a {
    color: #1976d2;
    text-decoration: none;
}
.teacher-info-contact a:hover {
    text-decoration: underline;
}

/* 3.9 패치 노트 모달 */
.patch-notes-modal-overlay {
    z-index: 10000;
}
.patch-notes-modal-box {
    max-width: min(92vw, 420px);
    width: min(92vw, 420px);
    max-height: min(85vh, 720px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.patch-notes-modal-box.all-patch-notes-box {
    max-width: min(92vw, 480px);
    width: min(92vw, 480px);
}
.patch-notes-modal-title {
    margin-bottom: 12px;
    flex-shrink: 0;
}
.all-patch-notes-box > .intro-modal-title,
.all-patch-notes-box > .map-modal-title {
    flex-shrink: 0;
    margin-bottom: 8px;
}
.patch-notes-modal-body {
    margin-bottom: 12px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-right: 6px;
}
.patch-notes-subtitle {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: #555;
    font-style: italic;
}
.patch-notes-list {
    margin: 0;
    padding-left: 20px;
    line-height: 1.45;
    color: #333;
}
.patch-notes-list li {
    margin-bottom: 7px;
}
.patch-notes-list li:last-child {
    margin-bottom: 0;
}
.patch-notes-sublist {
    margin: 6px 0 0;
    padding-left: 18px;
    line-height: 1.45;
}
.patch-notes-sublist li {
    margin-bottom: 4px;
}
.patch-notes-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
    padding-top: 4px;
}
.patch-notes-dismiss-btn {
    padding: 10px 18px;
    background: transparent;
    color: #666;
    border: 1px solid #ccc;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: 'Jua', sans-serif;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.patch-notes-dismiss-btn:hover {
    background: #f5f5f5;
    color: #333;
}
.patch-notes-ok-btn {
    padding: 10px 24px;
    background: #4caf50;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: 'Jua', sans-serif;
    cursor: pointer;
    transition: background 0.2s;
}
.patch-notes-ok-btn:hover {
    background: #388e3c;
}
.patch-notes-past-link {
    margin: 16px 0 0 0;
}
.patch-notes-footnote {
    margin: 14px 0 0 0;
    font-size: 0.85rem;
    line-height: 1.55;
    color: #666;
}
.patch-notes-link {
    color: #1976d2;
    text-decoration: none;
    font-size: 0.9rem;
}
.patch-notes-link:hover {
    text-decoration: underline;
}
.patch-highlight { color: #2e7d32; font-weight: 600; }
.patch-highlight-alt { color: #1565c0; font-weight: 600; }
.patch-classcoin-nowrap { white-space: nowrap; }
.patch-classcoin-link { font-size: 1.04em; font-weight: 700; }
.patch-notes-inline-link { background: none; border: none; padding: 0; cursor: pointer; font: inherit; color: #1976d2; text-decoration: underline; }
.patch-notes-inline-link:hover { color: #1565c0; }
.patch-notes-toggle-btn { margin-left: 4px; }
.patch-notes-collapsible {
    margin-top: 4px;
    padding-left: 2px;
    line-height: 1.35;
    color: #444;
}
.version-link-wrap {
    cursor: pointer;
}
.version-link {
    text-decoration: underline;
    text-underline-offset: 2px;
}
.version-link-wrap:hover .version-link {
    color: #1565c0;
}
.all-patch-notes-box {
    max-height: min(85vh, 720px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
/* map.html: map-modal-box 기본 overflow-y:auto 덮어씀 */
.map-modal-box.all-patch-notes-box {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: min(85vh, 720px);
}
.all-patch-notes-body {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    padding-right: 8px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.patch-notes-version {
    margin-bottom: 28px;
    padding-bottom: 24px;
    padding-top: 4px;
    border-bottom: 2px solid #e0e0e0;
}
.patch-notes-version:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.patch-notes-version:first-child {
    padding-top: 0;
}
.patch-notes-version h3 {
    font-size: 1rem;
    color: #333;
    margin: 0 0 8px 0;
}
.version-patch-label {
    color: #666;
    font-size: 0.85rem;
}

/* 안내 사항 모달 탭 */
.footer-info-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}
.footer-info-tab {
    padding: 10px 18px;
    border: none;
    background: transparent;
    font-family: 'Jua', 'Malgun Gothic', sans-serif;
    font-size: 1rem;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}
.footer-info-tab:hover { color: #333; }
.footer-info-tab.active {
    color: #1976d2;
    font-weight: 600;
    border-bottom-color: #1976d2;
}
.footer-info-tab-content {
    display: none;
}
.footer-info-tab-content.active {
    display: block;
}
.intro-footer #teacherInfoLink,
.map-footer #teacherInfoLink {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1976d2 !important;
    letter-spacing: -0.02em;
}
.intro-footer #teacherInfoLink:hover,
.map-footer #teacherInfoLink:hover {
    color: #0d47a1 !important;
    text-decoration: underline;
}

/* QR코드 모달 - 적응형, 크게 출력 */
.qr-modal-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.qr-modal-box {
    position: relative;
    padding: 24px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
    max-width: min(96vw, 560px);
}
.qr-modal-image {
    display: block;
    width: 100%;
    max-width: 480px;
    max-height: min(85vh, 480px);
    height: auto;
    object-fit: contain;
    margin: 0 auto;
}
@media (min-width: 768px) {
    .qr-modal-box { padding: 32px; max-width: 580px; }
    .qr-modal-image { max-width: 520px; max-height: 520px; }
}

/* 안내 사항 모달 (footer info) - 공통 스타일 */
.footer-info-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.info-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.info-label {
    font-weight: 600;
    color: #555;
    min-width: 110px;
    flex-shrink: 0;
}
.info-value {
    color: #333;
}
.info-notice {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}
.info-notice p {
    margin: 0;
    line-height: 1.65;
    font-size: 0.95rem;
    color: #444;
}
.notice-highlight {
    color: #c00;
    font-weight: 600;
}
.notice-highlight-blue {
    color: #1976d2;
    font-weight: 600;
}
.tally-feedback-btn {
    margin-top: 16px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-family: 'Jua', 'Malgun Gothic', sans-serif;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.tally-feedback-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

/* 안내 모달 닫기 애니메이션 */
.footer-info-overlay {
    transition: opacity 0.25s ease;
}
.footer-info-overlay.closing {
    opacity: 0;
    pointer-events: none;
}
.footer-info-box {
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.footer-info-overlay.closing .footer-info-box {
    transform: scale(0.95);
    opacity: 0.9;
}

/* 반응형 디자인 (map 기준) */
@media (max-width: 768px) {
    :root {
        --intro-header-height: 48px;
        --intro-footer-height: 22px;
    }
    
    body {
        padding-top: var(--intro-header-height);
        padding-bottom: var(--intro-footer-height);
    }
    
    .intro-header {
        padding: 6px 15px;
    }
    
    .intro-title {
        font-size: 1.3rem;
    }
    
    .intro-school-info {
        font-size: 1rem;
    }
    
    .intro-footer,
    .map-footer {
        font-size: 0.65rem;
        padding: 3px 10px;
    }

    .intro-footer #teacherInfoLink,
    .map-footer #teacherInfoLink {
        font-size: 0.76rem;
    }
    
    .initial-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
    
    .initial-button {
        font-size: 2rem;
        padding: 20px 10px;
        min-height: 70px;
    }
    
    .school-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .school-card {
        font-size: 1.5rem;
        padding: 25px 15px;
        min-height: 90px;
    }
    
    .grade-buttons {
        flex-direction: column;
    }
    .grade-button {
        min-width: 280px;
        padding: 35px 50px;
        font-size: 1.8rem;
    }
    
    .title {
        font-size: 2.2rem;
    }
    
    .question {
        font-size: 1.5rem;
    }
}
