/* ===== 基礎樣式 ===== */
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 20px;
  background-color: #f4f4f4;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  box-sizing: border-box;
}

.container {
  background-color: #ffffff;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 600px;
  text-align: center;
}

h1 {
  color: #333;
  margin-bottom: 20px;
}

/* ===== 卡片樣式 ===== */
.card {
  background-color: #e9eff5;
  border-left: 5px solid #007bff;
  padding: 15px;
  margin-bottom: 20px;
  text-align: left;
  border-radius: 4px;
}

.card p {
  margin: 5px 0;
}

/* ===== 輸入區域 ===== */
.input-section {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

#spelling-input {
  flex-grow: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  max-width: 300px;
}

/* ===== 按鈕樣式 ===== */
button {
  padding: 10px 15px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: #0056b3;
}

button:disabled {
  background-color: #cccccc !important;
  cursor: not-allowed;
}

#play-pronunciation {
  margin-top: 10px;
  width: auto;
}

#check-button {
  background-color: #4285f4;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

#check-button:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

#check-button:not(:disabled):hover {
  background-color: #3367d6;
}

/* ===== 標籤和滑桿 ===== */
label {
  display: block;
  margin-top: 10px;
  margin-bottom: 5px;
  font-weight: bold;
}

#speech-rate {
  width: 80%;
  margin-bottom: 15px;
}

/* ===== 反饋訊息 ===== */
.feedback, #feedback {
  margin-top: 15px;
  font-weight: bold;
  font-size: 1.1em;
}

.correct-word {
  color: red;
  font-weight: bold;
}

/* ===== 歷史記錄面板 ===== */
.history-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  padding: 25px;
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1000;
}

.history-panel h3 {
  margin-top: 0;
  color: #333;
  text-align: center;
  border-bottom: 2px solid #4285F4;
  padding-bottom: 10px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
}

.history-table th,
.history-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.history-table th {
  background-color: #f8f9fa;
  font-weight: bold;
  color: #333;
}

.history-table tr:hover {
  background-color: #f5f5f5;
}

.correct {
  color: #4CAF50;
  font-weight: bold;
}

.incorrect {
  color: #F44336;
  font-weight: bold;
}

.history-actions {
  text-align: center;
  margin-top: 20px;
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  margin: 0 5px;
  transition: background-color 0.3s;
}

.btn-secondary:hover {
  background-color: #545b62;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.history-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  margin: 10px 5px;
  transition: background 0.3s;
}

.history-btn:hover {
  background: #218838;
}

.history-btn i {
  margin-right: 8px;
}

/* ===== 結算畫面按鈕容器 ===== */
.summary-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ===== 年份按鈕樣式 ===== */
.year-button-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 15px 0;
}

.year-button {
  padding: 12px 24px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  transition: all 0.3s;
  min-width: 80px;
  text-align: center;
}

.year-button:hover {
  background-color: #0069d9;
}

.year-button.selected {
  background-color: #0056b3;
  box-shadow: 0 0 0 2px rgba(0,123,255,0.5);
}

/* ===== 複選框容器 ===== */
.paper-checkbox-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin: 15px 0;
}

.paper-checkbox-item {
  position: relative;
  display: flex;
  align-items: center;
}

.paper-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.paper-checkbox + label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  padding: 8px 15px 8px 35px;
  border-radius: 20px;
  background: #e9ecef;
  transition: all 0.3s ease;
  position: relative;
}

.paper-checkbox + label:before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border: 2px solid #6c757d;
  border-radius: 4px;
  background: white;
  transition: all 0.3s ease;
}

.paper-checkbox:checked + label {
  background: #28a745;
  color: white;
}

.paper-checkbox:checked + label:before {
  border-color: white;
  background: #28a745;
}

.paper-checkbox:checked + label:after {
  content: "✓";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 14px;
}

/* ===== 加載訊息 ===== */
#loading-message {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 123, 255, 0.9);
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  z-index: 1000;
}

/* ===== 結算畫面樣式 ===== */
#quiz-summary {
  max-width: 600px;
  margin: 20px auto;
  padding: 25px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.summary-header {
  text-align: center;
  margin-bottom: 20px;
}

.result-icon {
  font-size: 48px;
  color: #4CAF50;
  margin-bottom: 10px;
}

.result-icon .fa-smile-beam {
  color: #FFC107;
}

.result-icon .fa-smile {
  color: #4CAF50;
}

.summary-header h2 {
  color: #333;
  margin: 10px 0;
}

.accuracy-rate {
  display: flex;
  justify-content: center;
  margin: 15px 0;
}

.rate-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: conic-gradient(#4CAF50 var(--percentage), #f0f0f0 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.rate-circle::before {
  content: '';
  position: absolute;
  width: 60px;
  height: 60px;
  background: white;
  border-radius: 50%;
}

.rate-circle span {
  position: relative;
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.result-breakdown {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
}

.result-card {
  padding: 15px 25px;
  border-radius: 8px;
  text-align: center;
  min-width: 100px;
}

.correct-card {
  background: #E8F5E9;
  border: 1px solid #C8E6C9;
}

.incorrect-card {
  background: #FFEBEE;
  border: 1px solid #FFCDD2;
}

.result-count {
  font-size: 24px;
  font-weight: bold;
}

.correct-card .result-count {
  color: #2E7D32;
}

.incorrect-card .result-count {
  color: #C62828;
}

.result-label {
  color: #666;
  font-size: 14px;
}

.word-results {
  margin-top: 25px;
}

.word-results h3 {
  color: #444;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.word-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
  border: 1px solid #eee;
  border-radius: 8px;
}

.word-item {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid #f5f5f5;
}

.word-item:last-child {
  border-bottom: none;
}

.word-item.correct {
  background: #F1F8E9;
}

.word-item.incorrect {
  background: #FFF3E0;
}

.word-number {
  font-weight: bold;
  color: #666;
  min-width: 30px;
}

.word-text {
  flex: 1;
  font-weight: 500;
}

.word-meaning {
  flex: 2;
  color: #666;
  font-size: 14px;
  margin: 0 10px;
}

.word-status {
  color: #4CAF50;
}

.word-item.incorrect .word-status {
  color: #F44336;
}

.restart-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: #4285F4;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.3s;
}

.restart-btn:hover {
  background: #3367D6;
}

.restart-btn i {
  margin-right: 8px;
}

/* ===== 響應式設計 ===== */
@media (max-width: 600px) {
  .container {
    padding: 15px;
  }
  
  .input-section {
    flex-direction: column;
    align-items: stretch;
  }
  
  #spelling-input {
    max-width: none;
  }
  
  button {
    width: 100%;
    margin-bottom: 5px;
  }
}

  /* ========== 新增：開始按鈕置中樣式 ========== */
  #login-container {
    text-align: center;
  }

  #start-button {
    display: inline-block;
    margin: 20px auto;
    padding: 12px 30px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }

  #start-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    background: linear-gradient(135deg, #45a049, #3d8b40);
  }

  #start-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  }

  #start-button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }