/* ===== CSS Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ===== CSS Variables ===== */
:root {
    --color-primary: #3498DB;
    --color-text: #2C3E50;
    --color-text-light: #555;
    --color-bg: #f5f7fa;
    --color-bg-card: #f8f9fa;
    --color-border: #e0e0e0;
    --color-s1: #ff6b6b;
    --color-s2: #4ecdc4;
    --color-s3: #45b7d1;
    --color-s4: #96ceb4;
    --color-s5: #f39c12;
    --color-s6: #9b59b6;
    --color-exam: #27ae60;
    --color-dark: #2c3e50;
    --font-main: -apple-system, BlinkMacSystemFont, "PingFang HK", "Microsoft YaHei", "Noto Sans TC", sans-serif;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-sm: 0 2px 5px rgba(0,0,0,0.05);
    --shadow-md: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 5px 20px rgba(0,0,0,0.15);
    --shadow-xl: 0 10px 40px rgba(0,0,0,0.2);
}

/* ===== Typography ===== */
body {
    font-family: var(--font-main);
    color: var(--color-text);
    min-height: 100vh;
}

/* ===== Container ===== */
.container { max-width: 1000px; margin: 0 auto; padding: 15px; }

/* ===== Header ===== */
header { text-align: center; padding: 15px 20px; }
header h1 { font-size: 1.8rem; margin-bottom: 5px; }
header p { opacity: 0.7; }

/* ===== Hamburger Menu ===== */
.hamburger { position: fixed; top: 15px; left: 15px; cursor: pointer; padding: 8px; z-index: 100; background: rgba(0,0,0,0.3); border-radius: 5px; }
.hamburger span { display: block; width: 25px; height: 3px; background: white; margin: 5px 0; border-radius: 2px; }
.menu-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 99; }
.menu-overlay.open { display: block; }
.side-menu { visibility: hidden; position: fixed; top: 0; right: -280px; width: 280px; height: 100%; background: white; z-index: 100; transition: right 0.3s; overflow-y: auto; box-shadow: -2px 0 10px rgba(0,0,0,0.2); }
.side-menu.open { visibility: visible; right: 0; }
.side-menu-header { padding: 20px; background: var(--color-dark); color: white; display: flex; justify-content: space-between; align-items: center; }
.side-menu-header h2 { font-size: 1.2rem; }
.close-menu { cursor: pointer; font-size: 1.5rem; }
.side-menu-content { padding: 10px; }
.menu-section { margin-bottom: 15px; }
.menu-section-title { font-size: 0.9rem; color: #666; padding: 10px; font-weight: bold; }
.menu-btn { display: block; width: 100%; padding: 12px 15px; margin: 5px 0; border: none; border-radius: var(--radius-md); background: var(--color-bg); cursor: pointer; text-align: left; font-size: 1rem; transition: all 0.2s; text-decoration: none; color: var(--color-text); }
.menu-btn:hover { background: #e0e0e0; }
.menu-btn.s1 { background: var(--color-s1); color: white; }
.menu-btn.s2 { background: var(--color-s2); color: white; }
.menu-btn.s3 { background: var(--color-s3); color: white; }
.menu-btn.s4 { background: var(--color-s4); color: white; }
.menu-btn.s5 { background: var(--color-s5); color: white; }
.menu-btn.s6 { background: var(--color-s6); color: white; }
.menu-btn.exam { background: var(--color-exam); color: white; }
.grade-chapters { display: none; padding-left: 10px; }
.grade-chapters.open { display: block; }
.grade-header { font-weight: bold; background: #f0f0f0; }

/* ===== Top Navigation ===== */
.top-nav { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; padding-top: 50px; }
.grade-btn { padding: 8px 16px; font-size: 0.95rem; font-weight: bold; border: none; border-radius: var(--radius-md); cursor: pointer; transition: all 0.2s; color: white; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.grade-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.grade-btn.active { outline: 3px solid #333; outline-offset: 1px; }
.btn-home { background: #34495e; }
.grade-s1 { background: var(--color-s1); }
.grade-s2 { background: var(--color-s2); }
.grade-s3 { background: var(--color-s3); }
.grade-s4 { background: var(--color-s4); }
.grade-s5 { background: var(--color-s5); }
.grade-s6 { background: var(--color-s6); }
.btn-exam { background: var(--color-exam); }

/* ===== Section Content ===== */
.section-content { display: none; }
.section-content.active { display: block; }
.chapters-section { display: none; }
.chapters-section.active { display: block; }

/* ===== Back Button ===== */
.back-btn { display: inline-block; padding: 10px 20px; background: #e9ecef; color: var(--color-text); text-decoration: none; border-radius: var(--radius-md); margin-bottom: 20px; cursor: pointer; }
.back-btn:hover { background: #dee2e6; }
.back-link { display: inline-block; color: white; text-decoration: none; padding: 8px 16px; background: rgba(255,255,255,0.2); border-radius: var(--radius-sm); margin-top: 10px; }
.back-link:hover { background: rgba(255,255,255,0.3); }

/* ===== Chapter Cards (index page) ===== */
.chapters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; }
.chapter-card { background: white; border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-md); transition: all 0.3s; cursor: pointer; text-decoration: none; color: inherit; display: block; }
.chapter-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.chapter-header { display: flex; align-items: center; margin-bottom: 15px; }
.chapter-num { background: #4A90E2; color: white; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; margin-right: 12px; }
.chapter-title { font-size: 1.1rem; font-weight: bold; color: var(--color-text); }

/* ===== Chapter Page Layout ===== */
.chapter-container { max-width: 900px; margin: 0 auto; background: white; border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-xl); }
.chapter-header-bar { color: white; padding: 20px; text-align: center; }
.chapter-header-bar h1 { font-size: 1.8rem; margin-bottom: 5px; }
.chapter-header-bar a { color: white; text-decoration: none; }

/* ===== Tab Navigation (Chapter Pages) ===== */
.tabs { display: flex; background: #f0f0f0; border-bottom: 2px solid #ddd; flex-wrap: wrap; }
.tab { flex: 1; padding: 15px; text-align: center; cursor: pointer; font-weight: 600; color: #666; transition: all 0.3s; border: none; background: none; font-size: 1rem; }
.tab:hover { background: #e0e0e0; }
.tab.active { background: white; border-bottom: 3px solid currentColor; }
.tab-content { display: none; padding: 25px; }
.tab-content.active { display: block; }

/* ===== Notes Section (Chapter Pages) ===== */
.note-section { margin-bottom: 25px; }
.note-title { font-size: 1.3rem; font-weight: 700; color: var(--color-text); margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid currentColor; }
.note-subtitle { font-size: 1.1rem; font-weight: 600; margin: 20px 0 10px; }
.note-desc { line-height: 1.8; color: var(--color-text-light); margin-bottom: 15px; }
.note-image { max-width: 100%; border-radius: var(--radius-md); margin: 15px 0; box-shadow: var(--shadow-md); }
.note-points { background: var(--color-bg-card); padding: 15px; border-radius: var(--radius-md); margin: 15px 0; }
.note-points li { margin: 8px 0; line-height: 1.6; }

/* ===== Practice Section (Chapter Pages) ===== */
.practice-item { background: var(--color-bg-card); padding: 15px; border-radius: 10px; margin-bottom: 15px; }
.practice-label { color: white; padding: 5px 12px; border-radius: 20px; display: inline-block; font-size: 0.85rem; margin-bottom: 10px; }
.practice-question { font-size: 1.1rem; font-weight: 600; margin-bottom: 10px; }
.practice-hint { background: #fff3cd; padding: 10px; border-radius: var(--radius-sm); margin-top: 10px; font-size: 0.9rem; color: #856404; }

/* ===== Games Grid (Chapter Pages) ===== */
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 15px; }
.game-card { background: white; border: 2px solid var(--color-border); border-radius: var(--radius-lg); padding: 15px; text-align: center; transition: all 0.3s; }
.game-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.game-card h3 { font-size: 1rem; margin-bottom: 10px; color: var(--color-text); }
.game-btn { color: white; padding: 10px 20px; border-radius: var(--radius-md); text-decoration: none; display: inline-block; margin-top: 10px; }

/* ===== Modal ===== */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 200; justify-content: center; align-items: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-content { background: white; padding: 25px; border-radius: 15px; max-width: 600px; width: 100%; position: relative; max-height: 90vh; overflow-y: auto; }
.modal-close { position: absolute; top: 15px; right: 15px; cursor: pointer; font-size: 1.5rem; color: #95a5a6; }

/* ===== Coming Soon Card ===== */
.coming-soon-card { background: white; padding: 40px; border-radius: var(--radius-lg); text-align: center; box-shadow: var(--shadow-md); }
.coming-soon-card h2 { color: #7f8c8d; margin-bottom: 10px; }
.coming-soon-card p { color: #95a5a6; }
