/* math-teacher shared styles */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Microsoft YaHei', sans-serif; min-height: 100vh; color: #333; }
.container { max-width: 800px; margin: 0 auto; padding: 20px; }

/* Theme colors - override via CSS variable on <body> or <style> in each page */
:root {
  --theme-color: #2193b0;
  --bg-from: #2193b0;
  --bg-to: #6dd5ed;
}
body { background: linear-gradient(135deg, var(--bg-from) 0%, var(--bg-to) 100%); }

/* User dropdown (index.html top-right) */
.user-dropdown { position: fixed; top: 16px; right: 20px; z-index: 110; user-select: none; }
.user-dd-btn { padding: 8px 18px; border-radius: 22px; border: 1.5px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.85); font-size: 0.92em; font-weight: 600; cursor: pointer; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: all 0.25s; font-family: inherit; letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; }
.user-dd-btn::after { content: '▾'; font-size: 0.8em; opacity: 0.6; }
.user-dd-btn:hover { background: rgba(255,255,255,0.22); color: #fff; }
.user-dd-menu { display: none; position: absolute; top: calc(100% + 8px); right: 0; min-width: 130px; background: rgba(22,25,40,0.92); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 6px; box-shadow: 0 12px 36px rgba(0,0,0,0.4); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); overflow: hidden; }
.user-dd-menu.open { display: block; animation: ddFade 0.18s ease-out; }
@keyframes ddFade { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.user-dd-item { padding: 10px 18px; border-radius: 10px; color: rgba(255,255,255,0.55); cursor: pointer; font-size: 0.9em; font-weight: 500; transition: all 0.15s; }
.user-dd-item:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.95); }
.user-dd-item.active { background: linear-gradient(135deg, rgba(255,107,53,0.2), rgba(255,201,60,0.15)); color: #fff; font-weight: 700; }

/* Back button */
.back-btn { position: fixed; top: 16px; left: 16px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.3); border: 2px solid rgba(255,255,255,0.5); color: #fff; font-size: 1.4em; font-weight: bold; cursor: pointer; text-decoration: none; display: flex; align-items: center; justify-content: center; z-index: 10; transition: all 0.25s; backdrop-filter: blur(8px); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.back-btn:hover { background: rgba(255,255,255,0.5); transform: scale(1.08); box-shadow: 0 3px 12px rgba(0,0,0,0.2); }
.back-btn:active { transform: scale(0.95); }

/* Headings */
h1 { text-align: center; color: #fff; font-size: 2em; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); margin-bottom: 10px; }
.subtitle { text-align: center; color: rgba(255,255,255,0.8); font-size: 1.1em; margin-bottom: 20px; }

/* Score bar */
.score-bar { display: flex; justify-content: space-between; background: rgba(255,255,255,0.95); border-radius: 15px; padding: 12px 20px; margin-bottom: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.score-item { text-align: center; flex: 1; }
.score-label { font-size: 0.8em; color: #888; }
.score-value { font-size: 1.4em; font-weight: bold; color: var(--theme-color); }
.streak-fire { color: #ff6b35; }

/* Card */
.card { background: rgba(255,255,255,0.95); border-radius: 20px; padding: 25px; margin-bottom: 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }

/* Tabs */
.tabs { display: flex; gap: 10px; margin-bottom: 20px; }
.tab-btn { flex: 1; padding: 12px; border: none; border-radius: 12px; font-size: 1em; font-weight: bold; cursor: pointer; transition: all 0.3s; background: rgba(255,255,255,0.3); color: #fff; }
.tab-btn.active { background: #fff; color: var(--theme-color); box-shadow: 0 4px 15px rgba(0,0,0,0.2); transform: scale(1.05); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Choices */
.choice-btn { padding: 10px 6px; border: 3px solid #e0e0e0; border-radius: 12px; font-size: 1.15em; font-weight: bold; cursor: pointer; transition: all 0.3s; background: #fff; text-align: center; overflow: hidden; min-width: 0; display: flex; align-items: center; justify-content: center; }
.choice-btn:hover { border-color: var(--theme-color); background: rgba(33,147,176,0.05); transform: scale(1.05); }
.choice-btn.correct { border-color: #4caf50; background: linear-gradient(135deg, #e8f5e9, #c8e6c9); }
.choice-btn.wrong { border-color: #f44336; background: linear-gradient(135deg, #ffebee, #ffcdd2); }
.choice-btn:disabled { cursor: default; transform: none; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }

/* Feedback */
.feedback { display: none; text-align: center; padding: 12px; border-radius: 12px; font-size: 1.05em; font-weight: bold; margin: 15px 0; }
.feedback.show { display: block; animation: fadeIn 0.3s; }
.correct-fb { background: linear-gradient(135deg, #e8f5e9, #c8e6c9); color: #2e7d32; border: 2px solid #4caf50; }
.wrong-fb { background: linear-gradient(135deg, #fff3e0, #ffe0b2); color: #e65100; border: 2px solid #ff9800; }

/* Buttons */
.hint-btn, .next-btn { padding: 8px 20px; border: 2px solid var(--theme-color); border-radius: 20px; background: #fff; color: var(--theme-color); font-size: 0.9em; cursor: pointer; font-weight: bold; transition: all 0.3s; display: inline-block; margin: 5px; }
.hint-btn:hover, .next-btn:hover { background: var(--theme-color); color: #fff; }
.next-btn { display: block; margin: 15px auto; padding: 10px 30px; border: none; border-radius: 12px; background: linear-gradient(135deg, var(--bg-from), var(--bg-to)); color: #fff; font-size: 1.1em; }
.hint-text { display: none; text-align: center; padding: 10px; background: linear-gradient(135deg, #fffde7, #fff9c4); border-left: 4px solid #ffc107; border-radius: 8px; color: #555; margin: 10px 0; font-size: 0.9em; }

/* Progress */
.progress-bar { background: #e0e0e0; border-radius: 10px; height: 8px; margin: 15px 0; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--theme-color), var(--bg-to)); border-radius: 10px; transition: width 0.5s; }

/* Achievements */
.achievements { display: flex; gap: 8px; justify-content: center; margin-top: 15px; flex-wrap: wrap; }
.badge { padding: 4px 12px; border-radius: 20px; font-size: 0.8em; background: #e0e0e0; color: #999; transition: all 0.3s; }
.badge.earned { background: linear-gradient(135deg, #ff6b35, #ff8c42); color: #fff; box-shadow: 0 2px 8px rgba(255,107,53,0.3); }
.badge-bronze.earned { background: linear-gradient(135deg, #cd7f32, #daa520); }
.badge-silver.earned { background: linear-gradient(135deg, #c0c0c0, #a8a8a8); }
.badge-gold.earned { background: linear-gradient(135deg, #ffd700, #ffb700); }
.badge-diamond.earned { background: linear-gradient(135deg, #b9f2ff, #00bcd4); }

/* Celebration */
.celebration { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1000; }

/* Completion */
.completion { text-align: center; padding: 20px; display: none; }
.completion h2 { color: var(--theme-color); margin-bottom: 10px; }
.completion-stats { color: #666; line-height: 2; margin: 15px 0; }
.completion b { color: var(--theme-color); }
.restart-btn { padding: 10px 30px; border: none; border-radius: 12px; background: linear-gradient(135deg, var(--theme-color), var(--bg-to)); color: #fff; font-size: 1em; font-weight: bold; cursor: pointer; transition: all 0.3s; margin-top: 10px; }
.restart-btn:hover { transform: scale(1.05); box-shadow: 0 4px 15px rgba(0,0,0,0.2); }

/* Challenge area */
.challenge-area { text-align: center; }

/* Leaderboard / History */
.leaderboard { margin-top: 10px; }
.rank-card { display: flex; align-items: center; padding: 10px 15px; border-radius: 12px; margin-bottom: 8px; background: rgba(255,255,255,0.7); transition: all 0.3s; }
.rank-card:hover { background: rgba(255,255,255,0.9); transform: translateX(5px); }
.rank-num { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 0.9em; background: #e0e0e0; color: #666; flex-shrink: 0; }
.rank-info { flex: 1; margin-left: 10px; }
.rank-name { font-weight: bold; color: #333; }
.rank-detail { font-size: 0.8em; color: #888; }
.rank-score { text-align: center; flex-shrink: 0; min-width: 60px; }
.rank-score-num { font-size: 1.5em; font-weight: bold; }
.rank-score-label { font-size: 0.7em; color: #999; }
.rank-1 .rank-num { background: linear-gradient(135deg, #ffd700, #ffea00); color: #fff; }
.rank-2 .rank-num { background: linear-gradient(135deg, #c0c0c0, #e0e0e0); color: #555; }
.rank-3 .rank-num { background: linear-gradient(135deg, #cd7f32, #e8a849); color: #fff; }
.rank-1 .rank-score-num { color: #daa520; }
.rank-2 .rank-score-num { color: #808080; }
.rank-3 .rank-score-num { color: #cd7f32; }

/* Item bar (challenge道具栏) */
.item-bar { display: flex; gap: 8px; justify-content: center; margin: 8px 0; flex-wrap: wrap; }
.item-slot { display: flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 8px; border: 2px solid #ddd; background: #fff; cursor: pointer; font-size: 0.85em; transition: all 0.2s; }
.item-slot:hover { border-color: var(--theme-color); background: rgba(33,147,176,0.05); }
.item-slot.empty { opacity: 0.4; cursor: default; }
.item-slot.empty:hover { border-color: #ddd; background: #fff; }
.item-count { background: var(--theme-color); color: #fff; border-radius: 10px; padding: 1px 6px; font-size: 0.8em; font-weight: bold; }

/* Shop */
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 20px 0; }
.shop-card { background: rgba(255,255,255,0.95); border-radius: 16px; padding: 20px; text-align: center; box-shadow: 0 3px 12px rgba(0,0,0,0.1); transition: all 0.3s; }
.shop-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.15); }
.shop-icon { font-size: 2.5em; margin-bottom: 8px; }
.shop-name { font-size: 1.1em; font-weight: bold; color: #333; margin-bottom: 4px; }
.shop-desc { font-size: 0.85em; color: #888; margin-bottom: 12px; line-height: 1.4; }
.shop-bottom { display: flex; justify-content: space-between; align-items: center; }
.shop-price { font-weight: bold; color: #ff6b35; }
.shop-price span { font-size: 1.3em; }
.shop-stock { font-size: 0.85em; color: #666; }
.shop-buy { padding: 6px 16px; border: none; border-radius: 8px; background: linear-gradient(135deg, var(--theme-color), var(--bg-to)); color: #fff; font-weight: bold; cursor: pointer; transition: all 0.2s; font-size: 0.9em; }
.shop-buy:hover { transform: scale(1.05); }
.shop-buy:disabled { background: #ccc; cursor: not-allowed; transform: none; }

@media (max-width: 600px) {
  .container { padding: 15px; }
  h1 { font-size: 1.5em; }
  .card { padding: 15px; }
  .tab-btn { padding: 10px; font-size: 0.9em; }
  .choices { gap: 8px; }
  .shop-grid { grid-template-columns: 1fr; }
}
