/* ===== OVERRIDES DO DESIGN SYSTEM PARA SCROLL MOBILE ===== */
body {
  overflow-y: auto !important;
  height: auto !important;
}

#app {
  height: auto !important;
  min-height: 100dvh;
}

.screen {
  flex: none !important;
  min-height: 100dvh;
}

/* Screens com scroll interno precisam de altura fixa */
#start-screen,
#game-screen,
#result-screen {
  height: 100dvh !important;
  overflow: hidden !important;
}

.footer-m3 {
  position: sticky;
  bottom: 0;
  background-color: var(--m3-background);
  z-index: 10;
}

/* ===== SELECTION SCREEN ===== */

.selection-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* ===== GAME SCREEN ===== */

#game-screen .app-bar {
  margin-bottom: 0.5rem;
}

#game-screen .game-status {
  margin-bottom: 0.5rem;
}

.support-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  flex-shrink: 0;
  height: 2.5rem;
}

.support-category {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--m3-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-icon-tonal {
  background-color: var(--m3-primary);
  color: var(--m3-on-primary);
  border: none;
  border-radius: 6.25rem;
  width: 2.5rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
  touch-action: manipulation;
}

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

.btn-icon-tonal:active {
  transform: scale(0.92);
}

.btn-icon-tonal.muted {
  background-color: var(--m3-secondary-container);
  color: var(--m3-on-secondary-container);
}

.game-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  overflow: hidden;
}

/* ===== CARD GRID ===== */

.game-grid {
  display: grid;
  gap: 8px;
  width: 100%;
}

.game-grid.easy,
.game-grid.normal,
.game-grid.hard {
  grid-template-columns: repeat(4, 1fr);
}

/* ===== CARDS ===== */

.card {
  width: 100%;
  aspect-ratio: 3 / 4;
  perspective: 800px;
  cursor: pointer;
  min-width: 0;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.card.flipped .card-inner,
.card.matched .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 1.25rem;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Face down */
.card-front {
  background-color: var(--m3-secondary-container);
}

/* Face up */
.card-back {
  background-color: var(--m3-primary-container);
  transform: rotateY(180deg);
}

/* Matched */
.card.matched .card-back {
  background-color: #82e46f;
}

.card-back-content {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--m3-on-secondary-container);
}

.card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.375rem;
  gap: 2px;
  width: 100%;
  height: 100%;
}

.pinyin {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1rem;
  color: #719dff;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character {
  font-family: "Noto Sans SC", var(--font-main);
  font-size: clamp(1.25rem, 6.5vw, 2rem);
  font-weight: 400;
  line-height: 1.1;
  color: var(--m3-on-primary-container);
  overflow: hidden;
  max-width: 100%;
}

.meaning {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1rem;
  color: var(--m3-on-primary-container);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-content--hard .character {
  font-size: clamp(2rem, 10vw, 3rem);
}

/* Matched text overrides */
.card.matched .pinyin    { color: #318d14; }
.card.matched .character { color: #43533e; }
.card.matched .meaning   { color: #43533e; }

@keyframes success-pulse {
  0%   { transform: rotateY(180deg) scale(1); }
  40%  { transform: rotateY(180deg) scale(1.07); }
  100% { transform: rotateY(180deg) scale(1); }
}

.card.matched .card-inner {
  animation: success-pulse 0.35s ease-out;
}

/* ===== SAFARI FIXES ===== */

@supports (-webkit-appearance: none) {
  .card-inner {
    -webkit-transform-style: preserve-3d;
  }
  .card-front,
  .card-back {
    -webkit-backface-visibility: hidden;
  }
}

/* ===== RESULT SCREEN ===== */

.result-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-block: 2rem;
}

.end-content-header {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0 1rem;
}

.stats-card {
  background-color: #d9dff6;
  border-radius: 1.75rem;
  padding: 1.0625rem 2.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.stats-card-title {
  font-size: 1.5rem;
  font-weight: 500;
  color: #151b2c;
  text-align: center;
  line-height: 2rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  color: #151b2c;
}

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

.stat-row-value {
  font-size: 1.5rem;
}

.stats-divider {
  width: 100%;
  height: 1px;
  background-color: rgba(21, 27, 44, 0.2);
  margin: 0.25rem 0;
}



/* Review list */

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

#review-words {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.review-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--m3-on-surface-variant);
  text-align: center;
}

.word-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--m3-secondary-container);
  border-radius: 1.75rem;
  padding: 1rem;
}

.word-card-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.word-character {
  font-family: "Noto Sans SC", var(--font-main);
  font-size: 2.25rem;
  font-weight: 400;
  color: var(--m3-on-secondary-container);
  width: 3rem;
  text-align: center;
  flex-shrink: 0;
  line-height: 2.875rem;
}

.word-pronunciation {
  font-size: 1rem;
  font-weight: 500;
  color: var(--m3-on-secondary-container);
  flex-shrink: 0;
}

.word-divider {
  width: 1px;
  height: 1.75rem;
  background-color: var(--m3-on-surface-variant);
  opacity: 0.3;
  flex-shrink: 0;
}

.word-meaning {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--m3-on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.word-audio-btn {
  background-color: var(--m3-on-surface-variant);
  border: none;
  border-radius: 100px;
  width: 1.75rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--m3-background);
  transition: opacity 0.15s;
}

.word-audio-btn.disabled {
  background-color: rgba(226, 226, 233, 0.1);
  opacity: 0.38;
  cursor: not-allowed;
}

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

/* Final actions */

.result-footer {
  padding: clamp(0.5rem, 2vh, 1rem) 1rem;
  padding-bottom: calc(clamp(0.5rem, 2vh, 1rem) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

/* ===== POINTS FLOAT ANIMATION ===== */

.points-animation {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--m3-primary);
  font-size: 1.5rem;
  font-weight: 700;
  pointer-events: none;
  animation: points-fade 1.4s ease-out forwards;
  z-index: 200;
}

@keyframes points-fade {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  80%  { opacity: 1; transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(0.9); }
}

