:root {
  /* M3 mapped theme variables */
  --bg-color: var(--m3-background);
  --app-bg: var(--m3-background);
  --text-color: var(--m3-on-background);
  --text-muted: var(--m3-on-surface-variant);
  --border-color: var(--m3-secondary-container);
  --primary-color: var(--m3-secondary-container);
  --primary-hover: var(--m3-surface-variant);
  --action-color: var(--m3-primary);
  --action-hover: var(--m3-primary-container);
  --success-color: var(--m3-success);
  --success-bg: rgba(0, 200, 83, 0.1);
  --error-color: var(--m3-error);
  --error-bg: rgba(255, 90, 95, 0.1);
  --font-family: var(--font-main);

  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
}

/* Layout M3 */
.word-area-m3 {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.25rem, 2vh, 1.5rem);
  width: 100%;
  padding: 0 1rem;
}

.word-container-m3 {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

/* Arrow */
.arrow-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 24px;
}

.arrow-container img {
  height: 100%;
}

/* Ideogram + Trans + Audio */
.ideogram-group-m3 {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  width: 100%;
}

.ideogram-m3 {
  font-family: "Noto Sans SC", var(--font-main);
  font-size: clamp(2.5rem, 10vh, 4rem);
  font-weight: 400;
  letter-spacing: 6px;
  line-height: 1.1;
  color: var(--m3-on-primary-container);
}

.translation-m3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--m3-on-primary-container);
  margin-bottom: 1rem;
}

.btn-play-m3 {
  background-color: var(--m3-primary);
  color: var(--m3-on-primary);
  border: none;
  border-radius: 6.25rem;
  width: 70px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-play-m3:active {
  transform: scale(0.95);
}

.btn-play-m3 .material-symbols-rounded {
  font-size: 1.5rem;
}

/* Buttons */
.btn {
  padding: 16px 20px;
  border: 1px solid var(--border-color);
  background: var(--primary-color);
  color: var(--text-color);
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.2s, background-color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* M3 CTA Button */
.footer-m3 {
  padding-inline: 1rem;
  width: 100%;
  display: flex;
  justify-content: center;
  padding-block: clamp(0.5rem, 2vh, 1rem);
}

.btn-action-m3 {
  width: 100%;
  height: clamp(2.5rem, 7vh, 3.5rem);
  border-radius: 6.25rem;
  background-color: #82e46f;
  background-color: var(--m3-primary);
  color: var(--m3-on-primary);
  border: none;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s, opacity 0.2s;
}

.btn-action-m3 .material-symbols-rounded {
  font-size: 1.25rem;
}

.btn-action-m3:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-action-m3:disabled {
  background-color: #293042;
  color: #404659;
  cursor: not-allowed;
  transform: none;
}

.btn-action-m3:disabled .material-symbols-rounded {
  color: #404659;
}

.btn-action-m3.correct {
  background-color: #82e46f;
  color: #43533e;
}

.btn-action-m3.correct .material-symbols-rounded {
  color: #43533e;
}

/* Syllable Pill */
.syllable-box {
  background-color: var(--m3-secondary-container);
  color: var(--m3-on-secondary-container);
  border-radius: 6.25rem;
  min-width: clamp(4rem, 20vw, 6.25rem);
  height: clamp(2.5rem, 7vh, 3.5rem);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  padding: 1rem 0.75rem;
}

.syllable-box .pinyin-text {
  font-size: clamp(0.8rem, 2.5vh, 1rem);
  font-weight: 500;
  text-align: center;
}

.syllable-box.has-tone {
  background-color: var(--m3-primary-container);
  color: var(--m3-on-primary-container);
}

.syllable-box:active {
  transform: scale(0.95);
}

.syllable-box.selected {
  background-color: var(--m3-on-secondary-container);
  color: var(--m3-secondary-container);
}

/* Validation states inside syllables */
.syllable-box.correct {
  background-color: #82e46f;
  color: #43533e;
  border-color: transparent;
}

.syllable-box.correct .pinyin-text {
  color: #43533e;
}

.syllable-box.incorrect {
  background-color: #f2b8b5;
  color: #601410;
  border-color: transparent;
}

.syllable-box.incorrect .pinyin-text {
  color: #601410;
}

/* Flash Animations */
@keyframes flash-green {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-8px);
  }

  75% {
    transform: translateX(8px);
  }
}

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

.flash-incorrect {
  animation: shake 0.4s ease-in-out;
}

/* Bottom Drawer Elements */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 900;
  transition: opacity 0.3s;
}

.drawer-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.bottom-drawer-m3 {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #232428;
  border-top-left-radius: 1.75rem;
  border-top-right-radius: 1.75rem;
  box-shadow: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding-inline: 0.5rem;
}

.bottom-drawer-m3.hidden {
  transform: translateY(120%);
  pointer-events: none;
}

.drawer-header-m3 {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 16px;
}

.drawer-handle-m3 {
  width: 2rem;
  height: 0.25rem;
  background-color: #a0a1aa;
  border-radius: 6.25rem;
}

.drawer-content-m3 {
  display: flex;
  flex-direction: column;
  gap: 1.5625rem;
  align-items: center;
  width: 100%;
  padding: 0 0.2rem 1.5rem;
}

.drawer-title-m3 {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 1rem;
  color: #fcfaff;
  width: 100%;
  text-align: left;
}

.drawer-tones-grid-m3 {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.btn-tone-m3 {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 6.25rem;
  align-items: center;
  justify-content: center;
  background: #36373b;
  border: none;
  border-radius: 1.75rem;
  color: #fcfaff;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.btn-tone-m3.selected {
  background-color: #c2c9e0;
  color: #36373b;
  border: none;
}

.btn-tone-m3:active {
  transform: scale(0.96);
}

.tone-mark-display-m3 {
  font-family: "Noto Sans SC", var(--font-main);
  font-size: 1.375rem;
  /* 22px */
  font-weight: 500;
}

.tone-label-m3 {
  font-family: var(--font-main);
  font-size: 1rem;
  /* 16px */
  font-weight: 500;
}

.btn-clear-m3 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background: transparent;
  border: 1px solid #fcfaff;
  border-radius: 6.25rem;
  color: #fcfaff;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  height: clamp(3rem, 7vh, 3.5rem);
}

.btn-clear-m3:active {
  background-color: rgba(255, 255, 255, 0.08);
}

/* Results Screen Elements */
h1 {
  font-size: 24px;
  font-weight: 600;
}

.score {
  font-size: 20px;
  text-align: center;
  margin-bottom: var(--spacing-lg);
  font-weight: 500;
}

#end-screen {
    overflow: hidden;
}

#result-screen {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
}

.end-content-header {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0 1.5rem;
  width: 100%;
  margin-bottom: 2rem;
}

.stats-card {
  background-color: #D9DFF6;
  border-radius: 1.75rem;
  padding: 1.0625rem 1.125rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: #1d192b;
  width: 100%;
}

.stats-card h2 {
  font-size: 1.5rem;
  font-weight: 500;
  text-align: center;
  line-height: 2rem;
  margin: 0;
}

.stats-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  flex-wrap: wrap;
  text-align: center;
}

.stats-card .stat {
  display: grid;
  align-items: center;
}

.stats-card .stat span {
  font-size: 1rem;
  font-weight: 500;
}

.stats-card .stat strong {
  font-size: 1.5rem;
  font-weight: 500;
}

.stat-divider {
  width: 80%;
  height: 1px;
  background-color: rgba(29, 25, 43, 0.2);
  margin-block: 0.3rem;
}



.review-section {
  flex: 1;
  padding: 0 1.5rem;
  margin-bottom: 1.5rem;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stats-footer {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--m3-on-surface-variant, #4a4459);
  margin-bottom: 0.5rem;
  text-align: center;
}

.review-item {
  background-color: #633b48;
  border-radius: 1.75rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: none;
}

.review-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.75rem;
}

.review-hanzi {
  font-family: "Noto Sans SC", var(--font-main);
  font-size: 2.25rem;
  font-weight: 400;
  color: #ffd8e4;
  text-align: center;
  line-height: 1;
}

.review-meaning-text {
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 500;
  color: #ffd8e4;
}

.review-meaning-text::first-letter {
  text-transform: uppercase;
}

.review-actions-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.review-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 1.5rem;
  border-radius: 1.875rem;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 500;
  transition: transform 0.2s, opacity 0.2s;
  background: transparent;
}

.review-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.review-btn-left {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.wrong-choice-btn {
  background-color: #ffd8e4;
  color: #633b48;
  cursor: default;
}

.correct-choice-btn {
  border-color: #ffd8e4;
  color: #ffd8e4;
}

.review-btn .material-symbols-rounded {
  font-size: 1.25rem;
}

.capitalize {
  text-transform: capitalize;
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 8px;
  width: auto;
  background: var(--primary-color);
  border: 1px solid var(--border-color);
}

.final-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0 1.5rem;
}

.btn-primary-large {
    width: 100%;
    height: 3.5rem;
    border-radius: 6.25rem;
    background-color: var(--m3-primary);
    color: var(--m3-on-primary, #ffffff);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.btn-primary-large:active {
    transform: scale(0.98);
}

.btn-text-sair {
    background: transparent;
    border: none;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 500;
    color: var(--m3-on-surface-variant, #c5c6d0);
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.2s, opacity 0.2s;
}

.btn-text-sair:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Error Bottom Drawer */
.bottom-drawer-error {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #f2b8b5;
  border-top-left-radius: 1.75rem;
  border-top-right-radius: 1.75rem;
  box-shadow: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-inline: 0.5rem;
}

.bottom-drawer-error.hidden {
  transform: translateY(120%);
  pointer-events: none;
}

.drawer-header-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.drawer-handle-error {
  width: 2rem;
  height: 0.25rem;
  background-color: #601410;
  border-radius: 6.25rem;
  margin-block: 0.8rem;
}

.error-drawer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 380px;
  padding: 0 0.2rem 1.5rem;
  gap: 1rem;
}

.error-title-row {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  color: #601410;
}

.error-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-main);
  font-size: 1.3rem;
  font-weight: 600;
}

.error-answer-section {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 0.25rem;
  color: #601410;
}

.error-answer-label {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
}

.error-answer-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-main);
  font-size: 1.375rem;
  font-weight: 500;
}

.btn-play-error {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 2.5rem;
  border-radius: 6.25rem;
  background-color: #f9dedc;
  color: #601410;
  border: none;
  cursor: pointer;
}

.btn-action-error {
  width: 100%;
  height: 3.5rem;
  border-radius: 6.25rem;
  background-color: #601410;
  color: #f9dedc;
  border: none;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-action-error:active {
  transform: scale(0.98);
}


/* Helper class to test 32px icons */
.icon-32 {
  font-size: 2rem !important;
}