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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  min-height: 100vh;
}

.page-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #a8b5f0 0%, #8b7ec8 50%, #6c5ce7 100%);
  padding: 30px 20px;
}

.page-header {
  text-align: center;
  margin-bottom: 30px;
}

.header-icon {
  font-size: 2.5em;
  margin-right: 10px;
}

.page-header h1 {
  color: white;
  font-size: 2.2em;
  font-weight: 700;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  display: inline-block;
  vertical-align: middle;
}

.main-container {
  max-width: 800px;
  margin: 0 auto;
}

.card {
  background: white;
  border-radius: 20px;
  padding: 35px 40px;
  box-shadow: 0 20px 60px rgba(108, 92, 231, 0.25);
  margin-bottom: 25px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  padding-bottom: 18px;
  border-bottom: 2px solid #f0f0f0;
}

.title-icon {
  font-size: 1.5em;
}

.card-title h2 {
  font-size: 1.5em;
  color: #333;
  font-weight: 600;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.form-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-item label {
  font-size: 0.95em;
  color: #666;
  font-weight: 500;
}

.form-item input[type="number"] {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  font-size: 1.1em;
  transition: all 0.3s;
  outline: none;
  background: #fafafa;
}

.form-item input[type="number"]:focus {
  border-color: #6c5ce7;
  background: white;
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
}

.form-section {
  margin-bottom: 25px;
}

.section-label {
  display: block;
  font-size: 0.95em;
  color: #666;
  font-weight: 500;
  margin-bottom: 15px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: #f8f8fc;
  border: 2px solid #e8e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  user-select: none;
}

.checkbox-item:hover {
  background: #f0edff;
  border-color: #c4b8f5;
}

.checkbox-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #6c5ce7;
  cursor: pointer;
}

.checkbox-item span {
  font-size: 0.95em;
  color: #555;
  font-weight: 500;
}

.checkbox-item input[type="checkbox"]:checked ~ span {
  color: #6c5ce7;
}

.tip-text {
  margin-top: 15px;
  padding: 12px 16px;
  background: #fff9e6;
  border-radius: 10px;
  border-left: 4px solid #ffc107;
  font-size: 0.9em;
  color: #886800;
  line-height: 1.6;
}

.button-row {
  display: flex;
  gap: 15px;
  margin-top: 30px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: 12px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  min-width: 140px;
}

.btn-primary {
  background: linear-gradient(135deg, #6c5ce7 0%, #a855f7 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.btn-secondary {
  background: #f5f5fa;
  color: #666;
  border: 2px solid #e0e0e8;
}

.btn-secondary:hover {
  background: #eeeef5;
  transform: translateY(-2px);
}

.progress-bar-container {
  margin-bottom: 25px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.progress-bar {
  flex: 1;
  height: 12px;
  background: #f0f0f5;
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #6c5ce7, #a855f7);
  border-radius: 6px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.9em;
  color: #666;
  font-weight: 600;
  min-width: 60px;
  text-align: right;
}

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 25px;
}

.question-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px 20px;
  background: #fafafe;
  border-radius: 12px;
  border: 2px solid #eeeef5;
  transition: all 0.3s;
}

.question-item:hover {
  border-color: #c4b8f5;
  background: #f8f7ff;
}

.question-item.correct {
  border-color: #4ade80;
  background: #f0fdf4;
}

.question-item.wrong {
  border-color: #f87171;
  background: #fef2f2;
}

.question-number {
  font-size: 1.1em;
  font-weight: 600;
  color: #6c5ce7;
  min-width: 30px;
}

.question-expression {
  font-size: 1.2em;
  color: #333;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
}

.question-expression .op {
  display: inline-block;
  color: #6c5ce7;
  font-weight: 600;
  margin: 0 4px;
}

.question-expression .frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 6px;
  line-height: 1;
  font-size: 0.85em;
}

.question-expression .frac .num {
  border-bottom: 2px solid #333;
  padding: 0 6px;
}

.question-expression .frac .den {
  padding: 0 6px;
}

.question-input {
  width: 160px;
  padding: 10px 14px;
  border: 2px solid #e8e8f0;
  border-radius: 10px;
  font-size: 1em;
  text-align: center;
  background: white;
  outline: none;
  transition: all 0.3s;
}

.question-input:focus {
  border-color: #6c5ce7;
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.question-input:disabled {
  background: #f5f5fa;
  color: #666;
}

.result-summary {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.score-circle {
  position: relative;
  width: 140px;
  height: 140px;
}

.score-circle svg {
  transform: rotate(-90deg);
}

.score-bg {
  fill: none;
  stroke: #f0f0f5;
  stroke-width: 10;
}

.score-progress {
  fill: none;
  stroke: #6c5ce7;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1s ease;
}

.score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.score-text span:first-child {
  font-size: 2.5em;
  font-weight: 700;
  color: #6c5ce7;
}

.score-unit {
  font-size: 1em;
  color: #888;
  margin-left: 3px;
}

.result-stats {
  display: flex;
  gap: 20px;
}

.stat-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  border-radius: 14px;
}

.stat-box.correct {
  background: #f0fdf4;
}

.stat-box.wrong {
  background: #fef2f2;
}

.stat-icon {
  font-size: 1.8em;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-box.correct .stat-value {
  font-size: 1.8em;
  font-weight: 700;
  color: #16a34a;
}

.stat-box.wrong .stat-value {
  font-size: 1.8em;
  font-weight: 700;
  color: #dc2626;
}

.stat-label {
  font-size: 0.85em;
  color: #666;
}

.result-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 25px;
  max-height: 400px;
  overflow-y: auto;
}

.result-detail-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fafafe;
  border-radius: 10px;
  border-left: 4px solid #ddd;
  font-size: 0.95em;
}

.result-detail-item.correct {
  border-left-color: #4ade80;
  background: #f0fdf4;
}

.result-detail-item.wrong {
  border-left-color: #f87171;
  background: #fef2f2;
}

.result-detail-expr {
  font-weight: 600;
  color: #333;
  min-width: 120px;
}

.result-detail-answers {
  display: flex;
  gap: 15px;
  flex: 1;
  font-size: 0.9em;
}

.result-detail-answers .your {
  color: #dc2626;
}

.result-detail-answers .correct-ans {
  color: #16a34a;
  font-weight: 600;
}

.result-detail-status {
  font-size: 1.2em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  text-align: center;
  padding: 25px 20px;
  background: linear-gradient(135deg, #f8f7ff 0%, #f0edff 100%);
  border-radius: 16px;
  border: 2px solid #e8e8f5;
}

.stat-card-icon {
  font-size: 2em;
  margin-bottom: 10px;
}

.stat-card-value {
  font-size: 2em;
  font-weight: 700;
  color: #6c5ce7;
  margin-bottom: 5px;
}

.stat-card-label {
  font-size: 0.9em;
  color: #888;
}

.history-section {
  margin-bottom: 25px;
}

.history-title {
  font-size: 1.1em;
  color: #333;
  margin-bottom: 15px;
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: #fafafe;
  border-radius: 10px;
  border: 1px solid #eee;
}

.history-info {
  display: flex;
  gap: 20px;
  align-items: center;
}

.history-time {
  color: #888;
  font-size: 0.9em;
}

.history-count {
  font-weight: 600;
  color: #555;
}

.history-score {
  font-size: 1.2em;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 16px;
}

.history-score.high {
  background: #dcfce7;
  color: #16a34a;
}

.history-score.medium {
  background: #fef9c3;
  color: #ca8a04;
}

.history-score.low {
  background: #fee2e2;
  color: #dc2626;
}

.empty-history {
  text-align: center;
  padding: 30px;
  color: #aaa;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 20px;
  padding: 40px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-icon {
  font-size: 3em;
  margin-bottom: 15px;
}

.modal-content h3 {
  font-size: 1.3em;
  color: #333;
  margin-bottom: 10px;
}

.modal-content p {
  color: #666;
  line-height: 1.6;
  margin-bottom: 25px;
}

.modal-content .btn {
  min-width: 120px;
}

@media (max-width: 600px) {
  .page-bg {
    padding: 15px 10px;
  }

  .card {
    padding: 25px 20px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .button-row {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .result-summary {
    flex-direction: column;
    gap: 20px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .checkbox-group {
    flex-direction: column;
  }

  .checkbox-item {
    width: 100%;
  }
}

/* 打印样式 */
@media print {
  .page-bg {
    background: white;
    padding: 0;
  }

  .page-header {
    margin-bottom: 20px;
  }

  .page-header h1 {
    color: #333;
    font-size: 1.6em;
    text-shadow: none;
  }

  .header-icon {
    font-size: 1.8em;
  }

  .main-container {
    max-width: 100%;
  }

  .card {
    box-shadow: none;
    border: none;
    padding: 0;
    margin-bottom: 0;
  }

  .card-title {
    border-bottom: 2px solid #333;
  }

  .card-title h2 {
    font-size: 1.2em;
  }

  /* 隐藏设置卡片、结果卡片、统计卡片 */
  #settingsCard,
  #resultCard,
  #statsCard,
  .modal {
    display: none !important;
  }

  /* 只显示答题卡片 */
  #quizCard {
    display: block !important;
  }

  /* 隐藏按钮和进度条 */
  .button-row,
  .progress-bar-container {
    display: none !important;
  }

  /* 题目样式调整 */
  .questions-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 30px;
  }

  .question-item {
    border: none;
    background: none;
    padding: 8px 0;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .question-number {
    color: #333;
  }

  .question-expression {
    font-size: 1.1em;
    color: #000;
  }

  .question-expression .op {
    color: #333;
  }

  .question-expression .frac .num {
    border-bottom-color: #000;
  }

  /* 输入框变为下划线 */
  .question-input {
    border: none;
    border-bottom: 1px solid #999;
    border-radius: 0;
    background: transparent;
    width: 100px;
    text-align: left;
    padding: 2px 0;
  }

  .question-input::placeholder {
    color: transparent;
  }
}
