:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --bg-color: #e2e8f0; /* Darker slate to make white cards pop */
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #475569;
    --border-color: #cbd5e1;
    --success: #10b981;
    --danger: #ef4444;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.18);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: 'Noto Sans KR', sans-serif; 
    background-color: var(--bg-color); 
    color: var(--text-main); 
    height: 100vh; /* Fallback for older browsers */
    height: 100dvh; 
    display: flex; 
    justify-content: center; 
    overflow: hidden; 
}

.mobile-app { 
    width: 100%; 
    max-width: 480px; /* Slightly wider for easier reading */
    height: 100%; 
    background-color: var(--bg-color); 
    display: flex; 
    flex-direction: column; 
    position: relative;
    box-shadow: var(--shadow-lg);
}

/* Header */
.app-header {
    background: var(--primary-gradient);
    color: white;
    padding: 12px 16px; /* 스마트폰 여백 축소 */
    padding-top: max(12px, env(safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    z-index: 10;
    gap: 12px;
}
.app-header h1 { 
    font-size: 1.25rem; 
    font-weight: 800; 
    letter-spacing: -0.5px; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    flex: 1; 
}
.app-header > div {
    flex-shrink: 0; /* 우측 아이콘 버튼 영역이 절대 찌그러지지 않도록 고정 */
}
.icon-btn { 
    background: rgba(255,255,255,0.2); 
    border: none; color: white; 
    width: 44px; height: 44px; 
    border-radius: 12px; font-size: 1.2rem; 
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    padding-bottom: 100px;
    background: var(--bg-color);
}

/* View Sections */
.view-section { display: none; flex-direction: column; animation: fadeIn 0.3s ease; }
.view-section.active { display: flex; }

.view-title { text-align: center; margin-bottom: 8px; }
.view-title h2 { font-size: 1.3rem; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.view-title p { font-size: 0.95rem; color: var(--text-muted); font-weight: 600; }

/* 1단계: 라디오 모드 */
.radio-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 20px 15px; /* 상하 패딩 축소 */
    box-shadow: var(--shadow-md);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start; /* Changed to left */
    min-height: 250px; /* Reduced min-height */
    margin-bottom: 16px;
    text-align: left; /* Changed to left */
}
.theme-badge-btn {
    background: var(--primary); color: white;
    padding: 8px 20px; border-radius: 20px;
    font-size: 1rem; font-weight: 700;
    margin-bottom: 24px; display: inline-flex; align-items: center; justify-content: center;
    border: none; cursor: pointer;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3); transition: all 0.2s;
    font-family: inherit;
    align-self: center; /* 가운데 정렬 */
}
.theme-badge-btn:active {
    transform: scale(0.95);
    background: var(--primary-dark);
}
.kor-text { font-size: 1.3rem; font-weight: 800; color: var(--text-main); margin-bottom: 20px; word-break: keep-all; }
.eng-text { font-size: 1.4rem; font-weight: 800; color: #334155; margin-bottom: 12px; word-break: keep-all; }
.pron-text { font-size: 1.1rem; font-weight: 700; color: #db2777; background: #fce7f3; padding: 6px 12px; border-radius: 12px; display: inline-block; word-break: keep-all; }

.player-controls {
    display: flex; justify-content: center; align-items: center; gap: 20px;
    margin-bottom: 20px; /* Raise above nav bar */
}
.control-btn {
    width: 42px; height: 42px; border-radius: 50%;
    background: #e2e8f0; color: var(--text-muted);
    border: none; font-size: 1.1rem; cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.play-btn {
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--primary-gradient); color: white;
    border: none; font-size: 1.4rem; cursor: pointer;
    box-shadow: var(--shadow-lg); display: flex; justify-content: center; align-items: center;
}

/* 2단계: 슬롯머신(플래시카드) 모드 */
.flashcard-container {
    width: 100%; height: 250px; flex-shrink: 0; perspective: 1000px; margin-bottom: 30px; cursor: pointer;
}
.flashcard-inner {
    width: 100%; height: 100%;
    position: relative; transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}
.flashcard-container.flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-front, .flashcard-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden; border-radius: 24px;
    padding: 30px 15px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
    box-shadow: var(--shadow-md); text-align: left;
}
.flashcard-front { background: var(--card-bg); border: 4px solid #e0e7ff; }
.flashcard-back { background: #f8fafc; border: 4px solid var(--primary); transform: rotateY(180deg); }

.kor-text.big { font-size: 1.4rem; }
.eng-text.big { font-size: 1.5rem; margin-top: 20px; word-break: keep-all; }
.pron-text.big { font-size: 1.1rem; margin-top: 16px; word-break: keep-all; }
.touch-hint { position: absolute; bottom: 20px; left: 0; width: 100%; font-size: 1.1rem; color: var(--text-muted); font-weight: 600; animation: bounce 2s infinite; text-align: center; }

.slot-controls button { width: auto; padding: 10px 20px; border-radius: 12px; font-weight: 700; font-size: 1.1rem; height: 50px; background: #e2e8f0; color: var(--text-muted); border: none; cursor: pointer; box-shadow: var(--shadow-sm); display: flex; justify-content: center; align-items: center; gap: 8px; }
.slot-controls #slot-auto-play { background: var(--primary-gradient); color: white; flex: 1; box-shadow: var(--shadow-md); }



/* Bottom Navigation */
.bottom-nav {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 65px;
    background: white; border-top: 1px solid var(--border-color);
    display: flex; justify-content: space-around; align-items: center;
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 6px;
}
.nav-item i { font-size: 1.4rem; transition: transform 0.2s; }
.nav-item span { font-size: 0.85rem; font-weight: 700; }
.nav-item.active { color: var(--primary); }
.nav-item.active i { transform: translateY(-4px) scale(1.1); }

/* Utilities */
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes pulse { 0% { transform: scale(0.98); } 100% { transform: scale(1.02); } }
@keyframes glowPulse { 0% { opacity: 0.6; filter: blur(15px); } 100% { opacity: 0.9; filter: blur(25px); } }



/* 뼈대 시각화 진짜 형광펜 효과 */
.skeleton {
    background: linear-gradient(transparent 40%, #fde047 40%);
    color: #0f172a;
    font-weight: 900;
    padding: 0 4px;
}

/* Bottom Sheet (Category Selection) */
.bottom-sheet-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5); z-index: 40;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.bottom-sheet-overlay.open { opacity: 1; pointer-events: auto; }

.bottom-sheet {
    position: absolute; bottom: -100%; left: 0; right: 0;
    background: var(--card-bg); border-radius: 24px 24px 0 0;
    z-index: 50; padding: 20px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex; flex-direction: column; max-height: 85%;
}
.bottom-sheet.open { bottom: 0; }

.bottom-sheet-header {
    text-align: center; position: relative; margin-bottom: 15px; flex-shrink: 0;
}
.bottom-sheet-handle {
    width: 40px; height: 5px; background: #cbd5e1; border-radius: 10px;
    margin: 0 auto 15px auto;
}

.bottom-sheet-content {
    overflow-y: auto; flex: 1; padding-bottom: 30px;
}
.category-item {
    margin-bottom: 10px; background: #f8fafc; border-radius: 16px; border: 1px solid var(--border-color);
    overflow: hidden;
}
.category-header {
    padding: 16px 20px; font-size: 1.1rem; font-weight: 700; color: var(--text-main);
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; background: white; transition: background 0.2s;
}
.category-header:active { background: #f1f5f9; }
.category-header.active { color: var(--primary); }
.category-header.active .fa-chevron-down { transform: rotate(180deg); }
.category-header .fa-chevron-down { transition: transform 0.3s; color: #94a3b8; }

.category-body {
    max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out;
}
.category-body.open {
    max-height: 400px; /* enough for 5 items */
}
.sentence-list {
    list-style: none; padding: 10px 15px; margin: 0; display: flex; flex-direction: column; gap: 8px;
}
.sentence-item {
    padding: 12px 16px; background: #e2e8f0; border-radius: 12px; font-size: 0.95rem; font-weight: 600;
    color: var(--text-main); cursor: pointer; transition: background 0.2s; display: flex; align-items: center;
}
.sentence-item:active { background: #cbd5e1; transform: scale(0.98); }
.sentence-item-num {
    background: var(--primary); color: white; width: 24px; height: 24px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center; font-size: 0.8rem; margin-right: 12px; font-weight: 800; flex-shrink: 0;
}
.sentence-item-text {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
