:root {
  /* Brand colors - Modern Chinese palette */
  --color-primary: #d62828;
  --color-primary-hover: #c1121f;
  --color-primary-shadow: rgba(214, 40, 40, 0.25);

  /* Background colors - Warm, paper-like */
  --color-bg-primary: #faf9f6;
  --color-bg-secondary: #f8f7f4;
  --color-bg-tertiary: #f0efe9;
  --color-bg-card: #ffffff;

  /* Text colors - Ink-inspired */
  --color-text-primary: #2b2d42;
  --color-text-secondary: #5a5c6e;
  --color-text-tertiary: #8d99ae;
  --color-text-muted: #6b6d7f;

  /* Button colors - Ink wash gradient (深墨 to 淡墨) */
  --color-btn-again: #2b2d42;
  --color-btn-again-hover: #1f2132;
  --color-btn-hard: #4a4e5f;
  --color-btn-hard-hover: #3d4150;
  --color-btn-good: #7a8191;
  --color-btn-good-hover: #6b7280;
  --color-btn-easy: #b8bcc7;
  --color-btn-easy-hover: #a8adb9;
  --color-btn-success: #06a77d;
  --color-btn-danger: #c1121f;

  /* Border colors - Subtle, refined */
  --color-border: #d5d4cf;
  --color-border-light: #e5e5e5;

  /* Progress gradient - Ink wash inspired */
  --gradient-progress: linear-gradient(90deg, #d62828 0%, #c1121f 100%);

  /* Stability colors for heatmap - Chinese palette */
  --color-stability-mastered: #06a77d;
  --color-stability-strong: #2a9d8f;
  --color-stability-learning: #e9c46a;
  --color-stability-weak: #f77f00;
  --color-stability-new: #e5e5e5;

  /* Tooltip colors */
  --color-tooltip-bg: rgba(43, 45, 66, 0.95);
  --color-tooltip-text: #faf9f6;

  /* Keyboard hint colors */
  --color-kbd-bg: #f0efe9;
  --color-kbd-text: #d62828;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Brand colors - Chinese palette for dark mode */
    --color-primary: #e63946;
    --color-primary-hover: #f14350;
    --color-primary-shadow: rgba(230, 57, 70, 0.3);

    /* Background colors - Dark ink tones */
    --color-bg-primary: #1a1a1d;
    --color-bg-secondary: #25252a;
    --color-bg-tertiary: #303035;
    --color-bg-card: #202024;

    /* Text colors - Soft, readable */
    --color-text-primary: #edf2f4;
    --color-text-secondary: #b8bcc2;
    --color-text-tertiary: #8d99ae;
    --color-text-muted: #a0a8b8;

    /* Button colors - Ink wash gradient for dark mode */
    --color-btn-again: #1f2132;
    --color-btn-again-hover: #2b2d42;
    --color-btn-hard: #3d4150;
    --color-btn-hard-hover: #4a4e5f;
    --color-btn-good: #6b7280;
    --color-btn-good-hover: #7a8191;
    --color-btn-easy: #a8adb9;
    --color-btn-easy-hover: #b8bcc7;
    --color-btn-success: #0dbf8f;
    --color-btn-danger: #e63946;

    /* Border colors */
    --color-border: #3a3a40;
    --color-border-light: #303035;

    /* Progress gradient - Red gradient for dark mode */
    --gradient-progress: linear-gradient(90deg, #e63946 0%, #d62828 100%);

    /* Stability colors for heatmap - Chinese palette for dark */
    --color-stability-mastered: #0dbf8f;
    --color-stability-strong: #2eb3a1;
    --color-stability-learning: #f0cf7a;
    --color-stability-weak: #ff9500;
    --color-stability-new: #3a3a40;

    /* Tooltip colors */
    --color-tooltip-bg: rgba(32, 32, 36, 0.98);
    --color-tooltip-text: #edf2f4;

    /* Keyboard hint colors */
    --color-kbd-bg: #303035;
    --color-kbd-text: #e63946;
  }
}

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

body {
  font-family:
    "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "SimHei", -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  min-height: 100vh;
}

.container {
  background: var(--color-bg-primary);
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
  position: relative;
}

h1 {
  color: var(--color-primary);
  text-align: center;
  margin-bottom: 16px;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.app-title {
  color: inherit;
  text-decoration: none;
}

.subtitle {
  text-align: center;
  color: var(--color-text-secondary);
  margin-bottom: 30px;
  font-size: 14px;
}

.stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 24px;
  padding: 24px 20px;
  background: var(--color-bg-secondary);
  border-radius: 2px;
}

.stat-item {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  order: 1;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  color: var(--color-primary);
  order: 2;
}

.card-container {
  background: var(--color-bg-secondary);
  border-radius: 0px;
  padding: 40px 32px;
  margin-bottom: 16px;
  height: 300px;
  display: grid;
  grid-template-rows: 1fr;
  text-align: center;
  transition: grid-template-rows 0.3s ease;
}

.card-container.flipped {
  grid-template-rows: auto 1fr;
}

.card-container.transitioning {
  opacity: 0;
  transition: opacity 0.1s ease;
}

.char-zone {
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
}

.answer-zone {
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
}

.answer-zone.visible {
  display: flex;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.bopomofo-char {
  font-size: 110px;
  font-weight: bold;
  color: var(--color-primary);
  margin-bottom: 0;
  font-family:
    "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Microsoft JhengHei",
    "SimHei", sans-serif;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: font-size 0.3s ease;
}

.card-container.flipped .bopomofo-char {
  font-size: 88px;
}

.sound-btn {
  background: none;
  color: var(--color-primary);
  border: none;
  width: 48px;
  height: 48px;
  font-size: 36px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sound-btn:hover {
  transform: scale(1.2);
}

.sound-btn:active {
  transform: scale(0.9);
}

.romanization {
  font-size: 30px;
  color: var(--color-text-primary);
  margin-bottom: 0;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.type {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.example {
  font-size: 16px;
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: 12px;
}

.buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 24px;
}

.button-group {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-bottom: 12px;
}

/* Hidden state for various elements */
.buttons.hidden,
.button-group.hidden,
.keyboard-hint.hidden,
.sound-btn.hidden {
  display: none;
}

button {
  padding: 16px 32px;
  border: none;
  border-radius: 2px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
  min-width: 120px;
}

.show-btn {
  background: var(--color-primary);
  color: white;
  width: 100%;
}

.show-btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px var(--color-primary-shadow);
}

.difficulty-btn {
  font-size: 14px;
  padding: 12px 16px;
  min-width: 0;
  flex: 1 1 0;
}

.again-btn {
  background: var(--color-btn-again);
  color: white;
}

.again-btn:hover {
  background: var(--color-btn-again-hover);
  transform: translateY(-2px);
}

.hard-btn {
  background: var(--color-btn-hard);
  color: white;
}

.hard-btn:hover {
  background: var(--color-btn-hard-hover);
  transform: translateY(-2px);
}

.good-btn {
  background: var(--color-btn-good);
  color: white;
}

.good-btn:hover {
  background: var(--color-btn-good-hover);
  transform: translateY(-2px);
}

.easy-btn {
  background: var(--color-btn-easy);
  color: var(--color-text-primary);
}

.easy-btn:hover {
  background: var(--color-btn-easy-hover);
  transform: translateY(-2px);
}

.interval-info {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 3px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-border-light);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 24px;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-progress);
  transition: width 0.3s ease;
}

.complete-message {
  text-align: center;
  padding: 40px;
}

.complete-message h2 {
  color: var(--color-primary);
  margin-bottom: 15px;
}

.complete-message p {
  color: var(--color-text-secondary);
  margin-bottom: 25px;
}

.reset-btn {
  background: var(--color-primary);
  color: white;
}

.reset-btn:hover {
  background: var(--color-primary-hover);
}

.settings-section {
  background: var(--color-bg-secondary);
  border-radius: 2px;
}

.settings-section summary {
  padding: 18px 24px;
  color: var(--color-text-primary);
  user-select: none;
  cursor: pointer;
  font-weight: bold;
}

.settings-section summary:hover {
  background: var(--color-bg-tertiary);
  border-radius: 2px;
}

.settings-content {
  padding: 20px 24px 24px 24px;
}

.setting-group {
  margin-bottom: 24px;
}

.setting-group h3 {
  font-size: 14px;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.setting-group h3.with-top-margin {
  margin-top: 0;
}

.profile-list-container {
  max-height: 200px;
  overflow-y: auto;
}

.create-profile-btn {
  margin-top: 10px;
  padding: 8px 16px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  width: 100%;
}

.import-file-input {
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  width: 100%;
  background: var(--color-bg-card);
  color: var(--color-text-primary);
}

.deck-options-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deck-option-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.retention-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.retention-slider {
  flex: 1;
}

.retention-value {
  min-width: 40px;
  font-weight: bold;
}

.retention-description {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 5px;
}

.randomize-option-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.randomize-description {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 5px;
}

.settings-section-spaced {
  margin-top: 16px;
}

.app-footer {
  padding-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.app-footer a {
  color: var(--color-primary);
  text-decoration: none;
}

.reset-btn-spaced {
  margin-top: 10px;
}

.visible-block {
  display: block;
}

.hidden-element {
  display: none;
}

.profile-item {
  display: flex;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  margin-bottom: 8px;
  background: var(--color-bg-card);
}

.profile-item input[type="radio"] {
  margin-right: 10px;
}

.profile-info {
  flex: 1;
}

.profile-name {
  font-weight: bold;
  margin-bottom: 3px;
  color: var(--color-text-primary);
}

.profile-stats {
  font-size: 12px;
  color: var(--color-text-secondary);
}

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

.profile-actions button {
  padding: 5px 10px;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
}

.download-btn {
  background: var(--color-btn-success);
  color: white;
}

.delete-btn {
  background: var(--color-btn-danger);
  color: white;
}

.delete-btn:disabled {
  background: var(--color-text-tertiary);
  cursor: not-allowed;
}

.button-area {
  min-height: 106px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.heatmap-group {
  margin-bottom: 20px;
}

.heatmap-group-label {
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.heatmap-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.heatmap-cell {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  font-size: 24px;
  font-family:
    "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Microsoft JhengHei",
    "SimHei", sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.heatmap-cell:hover,
.heatmap-cell.active {
  transform: scale(1.1);
  z-index: 10;
}

.heatmap-cell-mastered {
  background-color: var(--color-stability-mastered);
}

.heatmap-cell-strong {
  background-color: var(--color-stability-strong);
}

.heatmap-cell-learning {
  background-color: var(--color-stability-learning);
}

.heatmap-cell-weak {
  background-color: var(--color-stability-weak);
}

.heatmap-cell-new {
  background-color: var(--color-stability-new);
}

.heatmap-tooltip {
  position: absolute;
  background: var(--color-tooltip-bg);
  color: var(--color-tooltip-text);
  padding: 8px 12px;
  border-radius: 2px;
  font-size: 12px;
  font-family:
    "PingFang SC", "Noto Sans SC", "Microsoft YaHei", -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1000;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.heatmap-cell:hover .heatmap-tooltip,
.heatmap-cell.active .heatmap-tooltip {
  opacity: 1;
}

.heatmap-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--color-tooltip-bg);
}

.keyboard-hint {
  text-align: center;
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-bottom: 15px;
}

.keyboard-hint kbd {
  background: var(--color-kbd-bg);
  padding: 2px 6px;
  border-radius: 2px;
  font-family: monospace;
  font-weight: bold;
  color: var(--color-kbd-text);
}

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

  .bopomofo-char {
    font-size: 90px;
  }

  .romanization {
    font-size: 26px;
  }

  .keyboard-hint,
  .keyboard-hint.hidden {
    display: none;
  }

  .stats {
    padding: 10px;
    gap: 8px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-label {
    font-size: 10px;
  }

  .profile-item {
    flex-wrap: wrap;
    padding: 8px;
  }

  .profile-actions {
    width: 100%;
    margin-top: 8px;
    justify-content: flex-end;
  }

  .profile-actions button {
    flex: 0 0 auto;
  }

  .setting-group h3 {
    font-size: 13px;
  }

  .heatmap-cell {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .heatmap-row {
    gap: 4px;
  }
}
