* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: #f4f6f8;
  color: #222;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px 15px;
}

.game-container {
  width: 100%;
  max-width: 520px;
}

header {
  text-align: center;
  margin-bottom: 25px;
}

h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.subtitle {
  margin: 0;
  color: #666;
}

.card {
  background: white;
  border-radius: 16px;
  padding: 35px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

h2 { margin: 0 0 10px; }

.setup-help, .selection-summary { color: #666; }

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 25px 0 15px;
  text-align: left;
}

.options-grid label { color: #555; font-size: 0.9rem; font-weight: bold; }

.options-grid input {
  width: 100%;
  margin-top: 7px;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 9px;
  font-size: 1rem;
}

#startButton { width: 100%; }

.export-option {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 20px;
  color: #444;
  text-align: left;
}

.export-option input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
}

.game-toolbar .progress { margin: 0; }
.danger-button { padding: 9px 12px; background: #d64545; }

.completion-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #e8f6ee;
  color: #2e9d59;
  font-size: 2rem;
  font-weight: bold;
}

.end-message {
  margin: 8px 0 25px;
  color: #666;
  line-height: 1.5;
}

.final-examples {
  margin: -12px 0 24px;
  padding: 12px;
  border-radius: 9px;
  background: #f4f6f8;
  color: #444;
  font-size: 2.5rem;
  line-height: 1.8;
  white-space: pre-line;
}

.end-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 25px;
  padding: 18px 8px;
  border-radius: 12px;
  background: #f4f6f8;
  text-align: center;
}

#homeButton { width: 100%; }

.progress {
  color: #888;
  font-size: 1.2rem;
  margin-bottom: 25px;
}

.label {
  text-transform: uppercase;
  font-size: 1.2rem;
  letter-spacing: 1.5px;
  color: #888;
  margin-bottom: 10px;
}

.character {
  font-size: 8rem;
  line-height: 1;
  margin-bottom: 35px;
}

#answerForm {
  display: flex;
  gap: 10px;
}

#answerInput {
  width: 100%;
  min-width: 0;
  padding: 14px;
  font-size: 1.8rem;
  text-align: center;
  border: 2px solid #ddd;
  border-radius: 10px;
  outline: none;
}

#answerInput:focus {
  border-color: #4a90e2;
}

#submitButton {
  flex-shrink: 0;
  white-space: nowrap;
}

button {
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  background: #4a90e2;
  color: white;
}

button:hover {
  opacity: 0.9;
}

button:disabled { cursor: not-allowed; opacity: 0.5; }

.feedback {
  margin-top: 25px;
  padding-top: 25px;
  border-top: 1px solid #eee;
}

.hidden {
  display: none;
}

#resultMessage {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 18px;
}

.correct {
  color: #2e9d59;
}

.incorrect {
  color: #d64545;
}

.answer-details {
  background: #f7f7f7;
  border-radius: 10px;
  padding: 18px;
  text-align: left;
  margin-bottom: 18px;
  line-height: 1.9;
  font-size: 2rem;
}

#examples {
  display: block;
  margin-top: 6px;
  padding-left: 12px;
  font-size: 3rem;
  line-height: 1.8;
  white-space: pre-line;
}

.detail-label {
  font-weight: bold;
}

.correct-character {
  font-size: 2.5rem;
  vertical-align: middle;
}

#nextButton {
  width: 100%;
  background: #333;
}

/* Keep all post-guess feedback at exactly twice its original scale. */
.feedback #resultMessage {
  font-size: 1.5rem;
}

.feedback .answer-details,
.feedback .detail-label,
.feedback #pinyin,
.feedback #english {
  font-size: 1.5rem;
}

.feedback .correct-character {
  font-size: 1.5rem;
}

.feedback #examples {
  display: block;
  font-size: 1.5rem;
}

.feedback .example-word {
  display: block;
}

.feedback #nextButton {
  padding: 14px 18px;
  font-size: 1.5rem;
}

.stats {
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
  background: white;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.stat-number {
  display: block;
  font-size: 1.4rem;
  font-weight: bold;
}

.stat-label {
  font-size: 1.2rem;
  color: #777;
}

.error-message {
  text-align: center;
  color: #d64545;
  margin-top: 15px;
}

@media (max-width: 500px) {
  .card {
    padding: 25px 18px;
  }

  .character {
    font-size: 6rem;
  }

  #answerForm {
    flex-direction: column;
  }

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

  .final-examples { font-size: 2rem; }
}
