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

:root {
  --primary: #6C63FF;
  --primary-dark: #5A52D5;
  --primary-light: #E8E6FF;
  --success: #2ECC71;
  --success-light: #E8F8F0;
  --danger: #FF6B6B;
  --danger-light: #FFE8E8;
  --warning: #FFD93D;
  --bg: #FFF8F0;
  --card: #FFFFFF;
  --text: #2D3436;
  --text-light: #999;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 4px 15px rgba(108, 99, 255, 0.1);
  --shadow-lg: 0 8px 30px rgba(108, 99, 255, 0.15);
}

body {
  font-family: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 80%, rgba(108, 99, 255, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 107, 107, 0.05) 0%, transparent 50%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px;
}

#root {
  width: 100%;
  max-width: 480px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 2px solid #E8E6FF;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(0);
}

.btn-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

.btn-active:hover {
  background: var(--primary-dark);
  color: #fff;
}

.btn-cute {
  border-radius: var(--radius);
  font-weight: 600;
}

.btn-icon {
  font-size: 18px;
  font-weight: 700;
}

/* Level buttons */
.btn-level {
  flex-direction: column;
  padding: 12px 16px;
  min-width: 80px;
}

.level-emoji {
  font-size: 28px;
  line-height: 1;
}

.level-name {
  font-size: 12px;
  margin-top: 2px;
}

.level-group {
  justify-content: center;
}

.btn-start {
  display: block;
  width: 100%;
  padding: 18px;
  margin-top: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #8B83FF 100%);
  border: none;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.35);
  letter-spacing: 1px;
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(108, 99, 255, 0.45);
  color: #fff;
}

.btn-submit {
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--primary) 0%, #8B83FF 100%);
  border: none;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  border-radius: var(--radius);
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* --- Setup Screen --- */
.setup-screen {
  padding: 10px 0 30px;
}

.app-header {
  text-align: center;
  margin-bottom: 28px;
}

.app-title {
  font-size: 42px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary) 0%, #FF6B6B 50%, #FFD93D 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  font-size: 16px;
  color: var(--text-light);
  margin-top: 4px;
}

.setup-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.setup-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

.level-hint-box {
  margin-top: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #FFF8E1 0%, #FFF3E0 100%);
  border-radius: var(--radius);
  border-left: 4px solid var(--warning);
}

.level-hint {
  font-size: 14px;
  color: #8D6E63;
  line-height: 1.6;
  font-weight: 500;
}

.level-example {
  font-size: 15px;
  color: #6D4C41;
  font-weight: 700;
  margin-top: 8px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
  display: inline-block;
  letter-spacing: 1px;
}

/* --- Practice Screen --- */
.practice-screen {
  padding: 8px 0;
  transition: background 0.3s;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.flash-correct {
  animation: flashGreen 0.4s ease;
}

.flash-wrong {
  animation: flashRed 0.4s ease;
}

@keyframes flashGreen {
  0%, 100% { background: transparent; }
  50% { background: rgba(46, 204, 113, 0.15); }
}

@keyframes flashRed {
  0%, 100% { background: transparent; }
  50% { background: rgba(255, 107, 107, 0.15); }
}

.practice-header {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
}

.practice-info {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.badge-op { background: var(--primary-light); color: var(--primary); }
.badge-level { background: #FFF3E0; color: #E65100; }
.badge-mode { background: #E8F5E9; color: #2E7D32; }

.practice-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timer {
  font-size: 36px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.counter {
  font-size: 16px;
  color: var(--text-light);
  font-weight: 600;
}

.progress-bar {
  height: 8px;
  background: #F0EEFF;
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8B83FF);
  border-radius: 4px;
  transition: width 0.3s linear;
}

/* --- Question --- */
.question-area {
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.question-display {
  font-size: 44px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: 3px;
  color: var(--text);
}

.correct-feedback {
  color: var(--success);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
  animation: popIn 0.3s ease;
}

.wrong-answer-hint {
  color: var(--danger);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  animation: shake 0.4s ease;
}

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* Answer display (replaces input) */
.answer-display-row {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.answer-display {
  min-width: 120px;
  padding: 10px 20px;
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  border-bottom: 4px solid var(--primary);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-height: 52px;
}

/* Practice bottom area */
.practice-bottom {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
}

.score-bar {
  display: inline-flex;
  gap: 16px;
  background: var(--card);
  padding: 6px 20px;
  border-radius: 30px;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
}

/* Custom Numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.numpad-key {
  padding: 14px 0;
  font-size: 24px;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.numpad-key:active {
  transform: scale(0.95);
  background: #F0EEFF;
}

.numpad-go {
  background: var(--primary);
  color: #fff;
  font-size: 20px;
}

.numpad-go:active {
  background: var(--primary-dark);
}

.numpad-del {
  font-size: 20px;
  color: var(--text-light);
}

.btn-quit {
  padding: 6px 18px;
  border: 2px solid #E0E0E0;
  border-radius: 30px;
  background: transparent;
  color: var(--text-light);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}

.btn-quit:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-light);
}

/* --- Star Burst --- */
.star-burst {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.star {
  display: inline-block;
  font-size: 24px;
  animation: starFly 0.6s ease forwards;
  opacity: 0;
}

@keyframes starFly {
  0% { transform: translate(0, 0) scale(0); opacity: 1; }
  50% { opacity: 1; }
  100% { transform: translate(var(--tx, 0), var(--ty, -40px)) scale(1.2); opacity: 0; }
}

.star:nth-child(1) { --tx: -30px; --ty: -45px; }
.star:nth-child(2) { --tx: 25px;  --ty: -50px; }
.star:nth-child(3) { --tx: -10px; --ty: -55px; }
.star:nth-child(4) { --tx: 35px;  --ty: -40px; }
.star:nth-child(5) { --tx: 0px;   --ty: -60px; }

/* --- Confetti Canvas --- */
.confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
}

/* --- Result Screen --- */
.result-screen {
  padding: 16px 0;
  text-align: center;
  position: relative;
}

.new-record-banner {
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #fff;
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  animation: bannerPulse 1s ease infinite alternate;
  box-shadow: 0 6px 20px rgba(255, 165, 0, 0.4);
}

.trophy {
  font-size: 28px;
  animation: trophyBounce 0.6s ease infinite alternate;
}

@keyframes bannerPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.02); }
}

@keyframes trophyBounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-5px); }
}

.result-hero {
  margin-bottom: 24px;
}

.result-hero-emoji {
  font-size: 64px;
  display: block;
  margin-bottom: 8px;
  animation: heroFloat 2s ease-in-out infinite alternate;
}

@keyframes heroFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-10px); }
}

.result-hero h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 12px;
}

.star-rating {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.rating-star {
  font-size: 36px;
  transition: transform 0.3s ease;
}

.rating-star.filled {
  animation: starPop 0.4s ease forwards;
}

.rating-star:nth-child(2).filled { animation-delay: 0.15s; }
.rating-star:nth-child(3).filled { animation-delay: 0.3s; }

@keyframes starPop {
  0% { transform: scale(0) rotate(-30deg); }
  70% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.result-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.result-icon {
  font-size: 22px;
  line-height: 1;
}

.result-label {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
}

.result-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}

.result-accuracy {
  color: var(--primary);
}

.comparison {
  padding: 14px 20px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 16px;
}

.comparison.improved {
  background: var(--success-light);
  color: var(--success);
  border: 2px solid var(--success);
  animation: popIn 0.5s ease;
}

.comparison.declined {
  background: #FFF8E1;
  color: #F57F17;
  border: 2px solid #FFD93D;
}

.incomplete-banner {
  background: #FFF3E0;
  color: #E65100;
  border: 2px solid #FFB74D;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 16px;
}

.result-actions {
  margin-top: 8px;
}

/* --- Profile Screen --- */
.profile-screen {
  padding: 10px 0 30px;
}

.profile-empty {
  text-align: center;
  color: var(--text-light);
  padding: 20px 0;
  font-size: 15px;
}

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.profile-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-select-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--card);
  border: 2px solid #E8E6FF;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.profile-select-btn:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.profile-avatar {
  font-size: 36px;
  line-height: 1;
}

.profile-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.profile-delete-btn {
  width: 42px;
  height: 42px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
  flex-shrink: 0;
}

.profile-delete-btn:hover {
  background: var(--danger-light);
}

.profile-confirm-delete {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.confirm-text {
  font-size: 12px;
  color: var(--danger);
  font-weight: 600;
  white-space: nowrap;
}

.btn-confirm-yes {
  padding: 4px 10px;
  border: none;
  background: var(--danger);
  color: #fff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-confirm-no {
  padding: 4px 10px;
  border: 1px solid #ddd;
  background: var(--card);
  color: var(--text-light);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

.btn-add-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 2px dashed #D0CDE1;
  border-radius: var(--radius);
  background: transparent;
  color: var(--primary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add-profile:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Add profile form */
.profile-add-form {
  padding: 16px;
  background: #F8F7FF;
  border-radius: var(--radius);
  border: 2px solid var(--primary-light);
}

.profile-add-form h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.avatar-option {
  width: 44px;
  height: 44px;
  font-size: 26px;
  border: 2px solid #E8E6FF;
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-option:hover {
  border-color: var(--primary);
  transform: scale(1.1);
}

.avatar-selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2);
  transform: scale(1.1);
}

.profile-name-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 18px;
  border: 2px solid #E8E6FF;
  border-radius: var(--radius);
  outline: none;
  margin-bottom: 12px;
  font-weight: 600;
  background: var(--card);
}

.profile-name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

.profile-add-actions {
  display: flex;
  gap: 10px;
}

.profile-add-actions .btn {
  flex: 1;
  justify-content: center;
}

/* Current profile bar */
.current-profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.current-profile-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
}

.current-profile-avatar {
  font-size: 28px;
  line-height: 1;
}

.btn-switch-profile {
  padding: 6px 14px;
  border: 2px solid #E8E6FF;
  border-radius: 20px;
  background: transparent;
  color: var(--text-light);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-switch-profile:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.admin-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  color: var(--text-light);
  text-decoration: none;
  font-size: 14px;
}

.admin-link:hover {
  color: var(--primary);
}

/* --- Leaderboard --- */
.leaderboard-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  text-align: left;
}

.leaderboard-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: background 0.15s;
}

.lb-row-me {
  background: var(--primary-light);
  font-weight: 700;
}

.lb-rank {
  font-size: 20px;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.lb-avatar {
  font-size: 24px;
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  flex-shrink: 0;
}

.lb-acc {
  font-size: 12px;
  color: var(--text-light);
  flex-shrink: 0;
  min-width: 38px;
  text-align: right;
}

/* Rankings button */
.btn-rankings {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 10px;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  border: none;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 15px rgba(255, 165, 0, 0.3);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-rankings:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 165, 0, 0.4);
  color: #fff;
}

/* --- Rankings Screen --- */
.rankings-screen {
  padding: 10px 0 30px;
}

.rank-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.rank-tab {
  flex: 1;
  padding: 12px;
  border: 2px solid #E8E6FF;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text-light);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.rank-tab-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

.rank-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.rank-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid #F5F3FF;
}

.rank-card-op {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.rank-card-level {
  font-size: 14px;
  font-weight: 600;
  color: #E65100;
  background: #FFF3E0;
  padding: 2px 10px;
  border-radius: 12px;
}

.rank-card-mode {
  font-size: 13px;
  color: var(--text-light);
  margin-left: auto;
  font-weight: 500;
}

.rank-entries {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.rank-entry-me {
  background: #F5F3FF;
  border-radius: var(--radius);
  padding: 6px 10px;
  margin: 0 -10px;
}

.rank-entry-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 100px;
  flex-shrink: 0;
}

.rank-medal {
  font-size: 18px;
  width: 26px;
  text-align: center;
}

.rank-avatar {
  font-size: 20px;
}

.rank-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-bar-wrap {
  flex: 1;
  background: #F0EEFF;
  border-radius: 8px;
  height: 28px;
  overflow: hidden;
  position: relative;
}

.rank-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8B83FF);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  transition: width 0.6s ease;
  min-width: 40px;
}

.rank-entry-me .rank-bar {
  background: linear-gradient(90deg, #FFD700, #FFA500);
}

.rank-bar-label {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.rank-acc {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* 3-column tabs */
.rank-tabs-3 { gap: 6px; }
.rank-tabs-3 .rank-tab { font-size: 13px; padding: 10px 6px; }
.sub-tabs { margin-bottom: 12px; }
.sub-tabs .rank-tab { font-size: 13px; padding: 8px; border-width: 1px; }

/* --- Bests Grid --- */
.bests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.best-card {
  background: #F8F7FF;
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  border: 2px solid #E8E6FF;
}

.best-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.best-level { font-size: 13px; font-weight: 600; }
.best-mode { font-size: 11px; color: var(--text-light); }

.best-main-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.best-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* --- History Filters --- */
.history-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  padding: 6px 14px;
  border: 2px solid #E8E6FF;
  border-radius: 20px;
  background: var(--card);
  color: var(--text-light);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-chip:hover { border-color: var(--primary); color: var(--primary); }

.filter-chip-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.filter-dates {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-input {
  flex: 1;
  padding: 8px 10px;
  border: 2px solid #E8E6FF;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  background: var(--card);
  color: var(--text);
  outline: none;
}

.date-input:focus { border-color: var(--primary); }

.date-sep {
  color: var(--text-light);
  font-weight: 600;
}

.history-select {
  padding: 8px 12px;
  border: 2px solid #E8E6FF;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  background: var(--card);
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.history-select:focus { border-color: var(--primary); }

/* --- History Chart --- */
.history-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  padding: 8px 0;
  overflow-x: auto;
}

.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 32px;
}

.chart-val {
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.chart-bar-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  width: 100%;
}

.chart-bar {
  width: 100%;
  background: #E8E6FF;
  border-radius: 6px 6px 0 0;
  position: relative;
  overflow: hidden;
  min-height: 8px;
}

.chart-bar-correct {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  border-radius: 6px 6px 0 0;
}

.chart-label {
  font-size: 9px;
  color: var(--text-light);
  margin-top: 4px;
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-light);
}

.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-box { width: 12px; height: 12px; border-radius: 3px; }
.legend-total { background: #E8E6FF; }
.legend-correct { background: var(--primary); }

/* --- Practice Time Chart --- */
.pt-chart-wrap {
  display: flex;
  gap: 4px;
  height: 160px;
  margin-bottom: 8px;
}

.pt-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 4px 18px 0;
  flex-shrink: 0;
  min-width: 32px;
}

.pt-y-label {
  font-size: 10px;
  color: var(--text-light);
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pt-chart-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.pt-grid-lines {
  position: absolute;
  inset: 0 0 18px 0;
  pointer-events: none;
}

.pt-grid-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #F0EEFF;
}

.pt-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: calc(100% - 18px);
  position: relative;
  z-index: 1;
}

.pt-day-col {
  flex: 1;
  min-width: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.pt-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 100%;
}

.pt-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 0;
  transition: height 0.4s ease;
  opacity: 0.7;
}

.pt-bar-me {
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

.pt-today-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #F0EEFF;
}

.pt-summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #FAFAFE;
}

.pt-summary-me {
  background: var(--primary-light);
  font-weight: 600;
}

.pt-summary-time {
  color: var(--primary);
  font-weight: 700;
}

/* --- History List --- */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.history-row {
  padding: 10px 12px;
  background: #FAFAFE;
  border-radius: var(--radius);
  border: 1px solid #F0EEFF;
}

.history-row-top {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.history-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  background: #F0EEFF;
  border-radius: 10px;
  color: var(--primary);
}

.history-date {
  font-size: 11px;
  color: var(--text-light);
  margin-left: auto;
}

.history-row-stats {
  display: flex;
  gap: 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
