:root {
    --bg-cream: #FFFBEB;
    --card-bg: #FFFFFF;
    --wood-light: #FDE68A;
    --wood-border: #F59E0B;
    --wood-dark: #78350F;
    --hour-red: #EF4444;
    --hour-red-dark: #B91C1C;
    --min-blue: #2563EB;
    --min-blue-dark: #1D4ED8;
    --text-dark: #1E293B;
    --text-muted: #64748B;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body {
    font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', '맑은 고딕', sans-serif;
    background: radial-gradient(circle at top, #FEF3C7 0%, #FFFBEB 65%, #FEF9C3 100%);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    overflow-x: hidden;
}

/* 상단 헤더 및 탭 네비게이션 */
.app-header {
    width: 100%;
    max-width: 1080px;
    background: #FFFFFF;
    border: 3px solid var(--wood-light);
    border-radius: 22px;
    padding: 12px 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 8px 20px rgba(180, 83, 9, 0.08);
    margin-bottom: 14px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #FBBF24, #EA580C);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 23px;
    box-shadow: 0 4px 10px rgba(234, 88, 12, 0.25);
}

.brand-title {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--wood-dark);
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 0.78rem;
    font-weight: 700;
    color: #B45309;
    margin-top: 2px;
}

.header-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.mute-toggle-btn {
    border: 2px solid #FCD34D;
    background: #FFFBEB;
    color: #92400E;
    font-size: 0.85rem;
    font-weight: 800;
    padding: 9px 14px;
    border-radius: 13px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.mute-toggle-btn:hover {
    background: #FEF3C7;
}

.mute-toggle-btn.is-muted {
    background: #E2E8F0;
    border-color: #94A3B8;
    color: #475569;
}

.mode-tabs {
    display: flex;
    background: #FEF3C7;
    padding: 5px;
    border-radius: 15px;
    border: 2px solid var(--wood-light);
    gap: 6px;
}

.mode-tab-btn {
    border: none;
    background: transparent;
    color: #92400E;
    font-size: 0.9rem;
    font-weight: 800;
    padding: 9px 15px;
    border-radius: 11px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-tab-btn:hover {
    background: rgba(245, 158, 11, 0.15);
}

.mode-tab-btn.active {
    background: #F59E0B;
    color: #FFFFFF;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.35);
}

/* 메인 2단 레이아웃 */
.main-grid {
    width: 100%;
    max-width: 1080px;
    display: grid;
    grid-template-columns: 1.08fr 1fr;
    gap: 16px;
    align-items: start;
}

@media (max-width: 860px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    .app-header {
        justify-content: center;
        text-align: center;
    }
    .header-controls {
        width: 100%;
        justify-content: center;
    }
    .mode-tabs {
        width: 100%;
        justify-content: center;
    }
    .mode-tab-btn {
        flex: 1;
        justify-content: center;
        padding: 9px 6px;
        font-size: 0.82rem;
    }
}

.card-box {
    background: var(--card-bg);
    border: 3px solid var(--wood-light);
    border-radius: 26px;
    padding: 16px;
    box-shadow: 0 10px 26px rgba(120, 53, 15, 0.07);
}

/* 왼쪽 컬럼: 아날로그 시계 + 시간 톡톡 증감 버튼 */
.left-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* 시계 상단 오전/오후 상태 바 */
.ampm-status-bar {
    width: 100%;
    max-width: 430px;
    border-radius: 16px;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #E0F2FE;
    border: 2px solid #7DD3FC;
    transition: all 0.25s ease;
}

.ampm-status-bar.pm-active {
    background: #1E1B4B;
    border-color: #818CF8;
    color: #FFFFFF;
}

.ampm-status-left {
    display: flex;
    align-items: center;
    gap: 9px;
}

.ampm-icon {
    font-size: 1.5rem;
}

.ampm-main-label {
    font-size: 1rem;
    font-weight: 900;
    color: #0369A1;
}

.ampm-status-bar.pm-active .ampm-main-label {
    color: #E0E7FF;
}

.ampm-sub-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #0284C7;
}

.ampm-status-bar.pm-active .ampm-sub-label {
    color: #A5B4FC;
}

.ampm-toggle-group {
    display: flex;
    background: rgba(255, 255, 255, 0.92);
    padding: 3px;
    border-radius: 11px;
    gap: 4px;
}

.ampm-pill-btn {
    border: none;
    padding: 6px 11px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    background: transparent;
    color: #64748B;
    transition: all 0.15s;
}

.ampm-pill-btn.active-am {
    background: #FBBF24;
    color: #78350F;
    box-shadow: 0 2px 5px rgba(251, 191, 36, 0.4);
}

.ampm-pill-btn.active-pm {
    background: #4F46E5;
    color: #FFFFFF;
    box-shadow: 0 2px 5px rgba(79, 70, 229, 0.4);
}

/* 아날로그 시계 외곽 원형 틀 */
.clock-outer-ring {
    width: 100%;
    max-width: 370px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: linear-gradient(145deg, #FDE68A, #F59E0B);
    padding: 11px;
    box-shadow: 0 14px 30px rgba(180, 83, 9, 0.2), inset 0 2px 6px rgba(255, 255, 255, 0.75);
    position: relative;
    touch-action: none;
}

#clockSvg {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
    touch-action: none;
    cursor: grab;
}

#clockSvg:active {
    cursor: grabbing;
}

/* 장식/타이머 레이어는 절대 포인터 이벤트를 가로채지 않도록 설정 */
.non-interactive-layer {
    pointer-events: none !important;
}

.hand-interactive {
    cursor: grab;
    touch-action: none;
}

.hand-interactive:active,
.hand-interactive.is-dragging {
    cursor: grabbing;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
}

/* 시계 하단 범례 및 눈금 토글 바 (항상 한 줄 유지) */
.clock-legend-row {
    width: 100%;
    max-width: 430px;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 0 2px;
    white-space: nowrap;
}

.clock-legend-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.legend-badges {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #334155;
    white-space: nowrap;
}

.dot-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 3px;
}

.tiny-toggle-btn {
    border: 1.5px solid #FCD34D;
    background: #FEF3C7;
    color: #92400E;
    padding: 5px 9px;
    border-radius: 9px;
    font-size: 0.74rem;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.tiny-toggle-btn:hover {
    background: #FDE68A;
}

.clock-legend-actions .tts-btn {
    padding: 5px 9px;
    font-size: 0.74rem;
    border-radius: 9px;
    white-space: nowrap;
}

/* 시계 바로 아래: 시간 톡톡 증감 버튼 박스 */
.under-clock-controls {
    width: 100%;
    max-width: 430px;
    background: #FFFDF7;
    border: 2px solid #FDE68A;
    border-radius: 20px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.under-clock-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.84rem;
    font-weight: 900;
    color: var(--wood-dark);
}

.quick-step-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.quick-hour-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.inc-btn {
    border: none;
    border-radius: 10px;
    padding: 9px 4px;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.08s ease, background 0.15s;
}

.inc-btn:active {
    transform: scale(0.94);
}

.inc-hour-minus {
    background: #FEF2F2;
    color: #DC2626;
    border: 1.5px solid #FCA5A5;
}

.inc-hour-plus {
    background: #EF4444;
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.25);
}

.inc-min-minus {
    background: #EFF6FF;
    color: #1D4ED8;
    border: 1.5px solid #93C5FD;
}

.inc-min-plus {
    background: #2563EB;
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

/* 오른쪽 컬럼: 모드별 패널 */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* 1. 일반 모드: 디지털 시계 패널 */
.digital-panel-card {
    background: #0F172A;
    border: 4px solid #334155;
    border-radius: 26px;
    padding: 18px;
    color: #FFFFFF;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.22);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.digital-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1E293B;
    padding-bottom: 10px;
}

.live-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    background: #34D399;
    border-radius: 50%;
    margin-right: 6px;
}

.hide-digital-btn {
    background: #1E293B;
    color: #FDE047;
    border: 1px solid #475569;
    padding: 6px 12px;
    border-radius: 9px;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.hide-digital-btn:hover {
    background: #334155;
}

.lcd-box {
    background: #020617;
    border: 2px solid #1E293B;
    border-radius: 18px;
    padding: 20px 14px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.lcd-ampm-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
}

.lcd-ampm-badge {
    padding: 4px 13px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    border: 1px solid rgba(56, 189, 248, 0.45);
    background: rgba(14, 165, 233, 0.2);
    color: #7DD3FC;
}

.lcd-ampm-badge.pm {
    border-color: rgba(129, 140, 248, 0.5);
    background: rgba(99, 102, 241, 0.25);
    color: #C7D2FE;
}

.lcd-24h-sub {
    font-size: 0.78rem;
    color: #64748B;
    font-family: monospace;
}

.lcd-digits {
    font-family: 'Courier New', Courier, monospace;
    font-size: 3.8rem;
    font-weight: 900;
    letter-spacing: 3px;
    color: #34D399;
    line-height: 1.08;
    margin: 6px 0;
    text-shadow: 0 0 18px rgba(52, 211, 153, 0.35);
}

.korean-tts-row {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.lcd-korean-text {
    margin-top: 8px;
    display: inline-block;
    background: rgba(251, 191, 36, 0.14);
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #FDE047;
    padding: 7px 18px;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 900;
}

/* TTS 읽어주기 버튼 & 음소거 비활성화 (연한 회색 + 진한 회색 X 오버레이) */
.tts-btn {
    position: relative;
    border: 1.5px solid #38BDF8;
    background: #0284C7;
    color: #FFFFFF;
    padding: 8px 13px;
    border-radius: 12px;
    font-size: 0.84rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.tts-btn:hover:not(:disabled) {
    background: #0369A1;
}

.tts-mute-cross {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    font-weight: 900;
    color: #334155; /* 진한 회색 X 표기 */
    pointer-events: none;
    line-height: 1;
}

.tts-btn:disabled,
.tts-btn.is-muted-disabled {
    background: #E2E8F0 !important; /* 연한 회색 배경 */
    border-color: #CBD5E1 !important;
    color: #94A3B8 !important;      /* 연한 회색 텍스트 */
    cursor: not-allowed !important;
    box-shadow: none !important;
}

.tts-btn:disabled .tts-btn-label,
.tts-btn.is-muted-disabled .tts-btn-label {
    opacity: 0.45;
}

.tts-btn:disabled .tts-mute-cross,
.tts-btn.is-muted-disabled .tts-mute-cross {
    display: flex;
}

.lcd-mask-cover {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.96);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.study-utility-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

@media (max-width: 520px) {
    .study-utility-grid {
        grid-template-columns: 1fr;
    }
}

.util-btn {
    border: none;
    border-radius: 12px;
    padding: 11px 8px;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    background: #1E293B;
    color: #E2E8F0;
    border: 1px solid #334155;
    transition: background 0.15s;
}

.util-btn:hover {
    background: #334155;
}

.util-btn.highlight {
    background: #F59E0B;
    color: #FFFFFF;
    border-color: #D97706;
}

/* 학습 가이드 박스 */
.guide-info-box {
    background: #FFFBEB;
    border: 2px solid #FDE68A;
    border-radius: 20px;
    padding: 14px 16px;
    color: #78350F;
    font-size: 0.83rem;
    line-height: 1.5;
}

/* 2. 퀴즈 놀이 모드 카드 (디지털 시계 완전 숨김 ❌) */
.quiz-panel-card {
    background: linear-gradient(145deg, #4338CA, #3730A3, #5B21B6);
    border: 4px solid #A5B4FC;
    border-radius: 26px;
    padding: 18px;
    color: #FFFFFF;
    display: flex;
    flex-direction: column;
    gap: 13px;
    box-shadow: 0 12px 28px rgba(67, 56, 202, 0.28);
}

.quiz-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.quiz-mode-tag {
    background: #FDE047;
    color: #1E1B4B;
    font-size: 0.78rem;
    font-weight: 900;
    padding: 4px 12px;
    border-radius: 999px;
}

.quiz-score-tag {
    background: rgba(255, 255, 255, 0.18);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
}

.quiz-diff-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: rgba(15, 23, 42, 0.35);
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
}

.quiz-diff-btn {
    border: none;
    background: transparent;
    color: #C7D2FE;
    padding: 7px 4px;
    border-radius: 9px;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.quiz-diff-btn.active {
    background: #FBBF24;
    color: #1E1B4B;
}

.quiz-countdown-wrap {
    background: rgba(15, 23, 42, 0.32);
    padding: 9px 12px;
    border-radius: 13px;
}

.quiz-countdown-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.76rem;
    font-weight: 800;
    color: #E0E7FF;
    margin-bottom: 6px;
}

.quiz-bar-bg {
    width: 100%;
    height: 9px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 999px;
    overflow: hidden;
}

.quiz-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #34D399, #FBBF24);
    transition: width 0.3s linear;
}

.quiz-mission-card {
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-radius: 18px;
    padding: 16px 12px;
    text-align: center;
}

.quiz-mission-ampm-pill {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 900;
    background: #FDE047;
    color: #1E1B4B;
    margin-bottom: 8px;
}

.quiz-tts-row {
    margin-top: 4px;
}

.quiz-mission-kor {
    font-size: 1.6rem;
    font-weight: 900;
    color: #FEF08A;
    letter-spacing: -0.01em;
}

.quiz-ampm-choice-box {
    background: rgba(15, 23, 42, 0.38);
    padding: 11px 14px;
    border-radius: 15px;
    border: 1px solid rgba(165, 180, 252, 0.3);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-ampm-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.quiz-ampm-big-btn {
    border: 2px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.1);
    color: #E2E8F0;
    padding: 10px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.15s;
}

.quiz-ampm-big-btn.selected-am {
    background: #FBBF24;
    color: #78350F;
    border-color: #FEF08A;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.35);
}

.quiz-ampm-big-btn.selected-pm {
    background: #6366F1;
    color: #FFFFFF;
    border-color: #C7D2FE;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.quiz-btn-row {
    display: flex;
    gap: 8px;
}

.quiz-submit-btn {
    flex: 1;
    border: none;
    background: #FACC15;
    color: #1E1B4B;
    font-size: 1rem;
    font-weight: 900;
    padding: 13px;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(250, 204, 21, 0.35);
}

.quiz-next-btn {
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
    font-size: 0.88rem;
    font-weight: 800;
    padding: 13px 16px;
    border-radius: 14px;
    cursor: pointer;
}

.quiz-feedback-box {
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 0.86rem;
    font-weight: 800;
    text-align: center;
    line-height: 1.45;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
}

.fb-correct {
    background: #34D399;
    color: #064E3B;
}

.fb-hint {
    background: #FDE047;
    color: #713F12;
}

.fb-wrong {
    background: #FB7185;
    color: #FFFFFF;
}

.quiz-reveal-wrap {
    margin-top: 2px;
}

.reveal-answer-btn {
    border: 2px solid #FFFFFF;
    background: #1E1B4B;
    color: #FDE047;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
    transition: transform 0.1s ease, background 0.15s;
}

.reveal-answer-btn:hover {
    background: #312E81;
}

.reveal-answer-btn:active {
    transform: scale(0.96);
}

/* 3. 시각적 타이머 모드 카드 */
.timer-panel-card {
    background: linear-gradient(145deg, #E11D48, #EA580C);
    border: 4px solid #FDA4AF;
    border-radius: 26px;
    padding: 18px;
    color: #FFFFFF;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 12px 28px rgba(225, 29, 72, 0.25);
}

.timer-lcd-box {
    background: rgba(0, 0, 0, 0.28);
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-radius: 18px;
    padding: 16px;
    text-align: center;
}

.timer-mmss {
    font-family: 'Courier New', Courier, monospace;
    font-size: 3.6rem;
    font-weight: 900;
    color: #FEF08A;
    letter-spacing: 3px;
}

.timer-preset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.timer-preset-btn {
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.16);
    color: #FFFFFF;
    padding: 10px 6px;
    border-radius: 11px;
    font-size: 0.84rem;
    font-weight: 800;
    cursor: pointer;
}

.timer-preset-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.hidden {
    display: none !important;
}

@keyframes alarmPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.ringing {
    animation: alarmPulse 0.45s infinite ease-in-out;
}
