/* ===== VocabFlash - Mobile-First Styles ===== */

:root {
  --primary: #6c5ce7;
  --primary-light: #a29bfe;
  --secondary: #00cec9;
  --accent: #fd79a8;
  --success: #00b894;
  --warning: #fdcb6e;
  --danger: #e17055;
  --dark: #2d3436;
  --gray: #636e72;
  --light-gray: #b2bec3;
  --bg: #dfe6e9;
  --white: #ffffff;
  --card-shadow: 0 4px 15px rgba(0,0,0,0.1);
  --card-shadow-lg: 0 8px 30px rgba(0,0,0,0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font);
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 50%, #74b9ff 100%);
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--dark);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: calc(100vh - 36px);
  height: calc(100dvh - 36px);
  position: relative;
  overflow: hidden;
}

/* ===== Screens ===== */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateX(30px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.screen.exit {
  opacity: 0;
  transform: translateX(-30px);
}

/* ===== Loading Screen ===== */

#screen-loading {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  justify-content: center;
  align-items: center;
}

.loading-content {
  text-align: center;
  color: var(--white);
}

.loading-icon {
  font-size: 64px;
  font-weight: 900;
  width: 100px;
  height: 100px;
  background: var(--white);
  color: var(--primary);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  animation: pulse 1.5s ease-in-out infinite;
}

.loading-content h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.loading-content p {
  opacity: 0.8;
  margin-bottom: 24px;
}

.loading-bar {
  width: 200px;
  height: 6px;
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
  margin: 0 auto;
  overflow: hidden;
}

.loading-fill {
  height: 100%;
  background: var(--white);
  border-radius: 3px;
  width: 0%;
  animation: loadProgress 1.5s ease forwards;
}

@keyframes loadProgress {
  0% { width: 0; }
  50% { width: 60%; }
  100% { width: 100%; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ===== Screen Header ===== */

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--white);
  flex-shrink: 0;
}

.screen-header h2 {
  flex: 1;
  font-size: 20px;
}

.back-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: var(--white);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

.shuffle-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: var(--white);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
}

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

/* ===== Screen Body ===== */

.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

/* ===== Home Screen ===== */

#screen-home {
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
}

.home-header {
  padding: 24px 20px 16px;
  color: var(--white);
  flex-shrink: 0;
}

.home-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.home-title h1 {
  font-size: 26px;
  font-weight: 800;
}

.icon-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: var(--white);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.sound-icon { display: block; }
.sound-slash { stroke: currentColor; stroke-width: 2.5; }

.stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.stat-icon {
  font-size: 22px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
}

.stat-label {
  font-size: 11px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.level-bar {
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.level-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.progress-track {
  height: 10px;
  background: rgba(255,255,255,0.2);
  border-radius: 5px;
  overflow: hidden;
}

.progress-track.small {
  height: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--success));
  border-radius: 5px;
  transition: width 0.5s ease;
}

.home-body {
  flex: 1;
  background: var(--white);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 12px;
}

/* ===== Pack List ===== */

.pack-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 20px 12px;
  margin: 0 -20px 20px;
  scrollbar-width: none;
}

.pack-list::-webkit-scrollbar { display: none; }

.pack-list-full {
  flex-direction: column;
  overflow-x: visible;
}

.pack-card {
  flex-shrink: 0;
  width: 150px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--white);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-align: left;
}

.pack-card:active { transform: scale(0.95); }

.pack-list-full .pack-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}

.pack-card.selected {
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.9);
  transform: scale(1.03);
}

.pack-icon { font-size: 28px; margin-bottom: 8px; display: block; }
.pack-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.pack-count { font-size: 12px; opacity: 0.8; }
.pack-progress-mini {
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.pack-progress-mini .fill {
  height: 100%;
  background: var(--white);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ===== Mode Grid ===== */

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.mode-card {
  background: var(--white);
  border: 2px solid #f0f0f0;
  border-radius: var(--radius);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.mode-card:active {
  transform: scale(0.93);
  border-color: var(--primary);
  background: #f8f7ff;
}

.mode-icon { font-size: 28px; }
.mode-name { font-size: 13px; font-weight: 700; color: var(--dark); }
.mode-desc { font-size: 11px; color: var(--gray); }

.btn-stats {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-stats:active { transform: scale(0.97); }

/* ===== Flashcard Mode ===== */

#screen-flashcard {
  background: linear-gradient(135deg, #00b894, #55efc4);
}

.flashcard-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.flashcard-progress {
  text-align: center;
  color: var(--white);
  width: 100%;
}

.flashcard-progress span {
  font-size: 14px;
  display: block;
  margin-bottom: 6px;
}

.flashcard-container {
  perspective: 1000px;
  width: 100%;
  max-width: 340px;
  height: 280px;
}

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

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--card-shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.flashcard-back {
  transform: rotateY(180deg);
  text-align: center;
}

.fc-word {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}

.fc-pos {
  font-size: 14px;
  color: var(--gray);
  font-style: italic;
}

.fc-tap-hint {
  font-size: 12px;
  color: var(--light-gray);
  position: absolute;
  bottom: 20px;
}

.fc-definition {
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 16px;
  line-height: 1.4;
}

.fc-example {
  font-size: 14px;
  color: var(--gray);
  font-style: italic;
  margin-bottom: 12px;
  line-height: 1.5;
}

.fc-synonyms {
  font-size: 13px;
  color: var(--primary);
}

.flashcard-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}

.fc-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  color: var(--white);
}

.fc-btn:active { transform: scale(0.95); }
.fc-btn.learning { background: var(--warning); color: var(--dark); }
.fc-btn.got-it { background: var(--success); }

/* ===== Quiz Mode ===== */

#screen-quiz {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
}

.quiz-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.quiz-progress {
  text-align: center;
  color: var(--white);
}

.quiz-progress span {
  font-size: 13px;
  display: block;
  margin-top: 6px;
}

.quiz-score {
  font-size: 16px;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  padding: 6px 12px;
  border-radius: 20px;
}

.quiz-question {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--card-shadow);
}

.quiz-prompt {
  font-size: 14px;
  color: var(--gray);
  margin-bottom: 8px;
}

.quiz-definition {
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.4;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  background: var(--white);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 500;
  color: var(--dark);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.quiz-option:active { transform: scale(0.97); }

.quiz-option.correct {
  background: #d4edda;
  border-color: var(--success);
  color: var(--success);
}

.quiz-option.wrong {
  background: #f8d7da;
  border-color: var(--danger);
  color: var(--danger);
  animation: shake 0.5s ease;
}

.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.7;
}

.quiz-option.show-correct {
  border-color: var(--success);
  background: #d4edda;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ===== Fill-in-the-Blank ===== */

#screen-fill {
  background: linear-gradient(135deg, #e17055, #fab1a0);
}

.fill-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fill-sentence {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--dark);
  box-shadow: var(--card-shadow);
  text-align: center;
}

.fill-blank {
  display: inline-block;
  min-width: 80px;
  border-bottom: 3px solid var(--primary);
  margin: 0 4px;
  font-weight: 700;
  color: var(--primary);
}

.fill-input-area {
  display: flex;
  gap: 10px;
}

.fill-input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 600;
  background: var(--white);
  color: var(--dark);
  outline: none;
  transition: var(--transition);
}

.fill-input:focus {
  border-color: var(--white);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

.fill-input.correct {
  border-color: var(--success);
  background: #d4edda;
}

.fill-input.wrong {
  border-color: var(--danger);
  background: #f8d7da;
  animation: shake 0.5s ease;
}

.btn-hint {
  padding: 14px 16px;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

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

.fill-feedback {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.fill-feedback .correct-word {
  font-size: 20px;
  font-weight: 700;
  color: var(--success);
}

.fill-feedback .word-def {
  font-size: 14px;
  color: var(--gray);
  margin-top: 4px;
}

/* ===== Word Match ===== */

#screen-match {
  background: linear-gradient(135deg, #0984e3, #74b9ff);
}

.match-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.match-info {
  display: flex;
  justify-content: space-between;
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
}

.match-timer {
  font-size: 16px;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  padding: 6px 12px;
  border-radius: 20px;
}

.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.match-tile {
  background: var(--white);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  font-size: 12px;
  color: var(--dark);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.4;
  word-break: break-word;
}

.match-tile:active { transform: scale(0.95); }

.match-tile.selected {
  border-color: var(--primary);
  background: #f8f7ff;
  box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.3);
}

.match-tile.matched {
  background: #d4edda;
  border-color: var(--success);
  opacity: 0.6;
  pointer-events: none;
  animation: matchPop 0.4s ease;
}

.match-tile.wrong-match {
  background: #f8d7da;
  border-color: var(--danger);
  animation: shake 0.4s ease;
}

.match-tile.word-tile {
  font-weight: 700;
  color: var(--primary);
}

@keyframes matchPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ===== Spelling Bee ===== */

#screen-spelling {
  background: linear-gradient(135deg, #fdcb6e, #f39c12);
}

.spelling-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.spell-definition-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--card-shadow);
  position: relative;
}

.spell-prompt {
  font-size: 14px;
  color: var(--gray);
  margin-bottom: 8px;
}

.spell-definition {
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.4;
}

.btn-speak {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--primary-light);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: var(--white);
  transition: var(--transition);
}

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

.spell-hint-area {
  text-align: center;
  font-size: 20px;
  letter-spacing: 6px;
  font-weight: 700;
  color: var(--white);
  min-height: 32px;
}

.spell-input-area {
  display: flex;
  gap: 10px;
}

/* ===== Quiz Results ===== */

#screen-quiz-results {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
}

.results-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.results-stars {
  font-size: 48px;
  animation: bounceIn 0.6s ease;
}

.results-score {
  font-size: 36px;
  font-weight: 800;
  color: var(--white);
}

.results-xp {
  font-size: 18px;
  color: rgba(255,255,255,0.8);
}

.results-breakdown {
  width: 100%;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
}

.results-breakdown .result-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  color: var(--white);
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.results-breakdown .result-item:last-child { border: none; }

.results-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* ===== Stats Screen ===== */

#screen-stats {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
}

.stats-body {
  color: var(--white);
}

.stats-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-big {
  font-size: 28px;
  font-weight: 800;
}

.stat-card .stat-label {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 4px;
}

.stats-body .section-title {
  color: var(--white);
  margin-top: 8px;
}

.stats-pack-item {
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 8px;
}

.stats-pack-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.word-tag {
  background: rgba(255,255,255,0.15);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
}

.word-tag.mastered {
  background: rgba(0, 184, 148, 0.3);
}

.word-tag.weak {
  background: rgba(225, 112, 85, 0.3);
}

.reset-area {
  margin-top: 24px;
  text-align: center;
  padding-bottom: 40px;
}

/* ===== Buttons ===== */

.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--white);
  color: var(--primary);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

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

.btn-secondary {
  flex: 1;
  padding: 16px;
  background: rgba(255,255,255,0.2);
  color: var(--white);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:active { transform: scale(0.97); }

.btn-danger {
  padding: 12px 24px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:active { background: rgba(225, 112, 85, 0.3); }

.hidden { display: none !important; }

/* ===== Confetti ===== */

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

/* ===== Toast ===== */

#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--dark);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--card-shadow-lg);
  animation: toastIn 0.4s ease, toastOut 0.4s ease 2.5s forwards;
  white-space: nowrap;
}

.toast.xp { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.toast.success { background: linear-gradient(135deg, #00b894, #55efc4); color: var(--dark); }
.toast.warning { background: linear-gradient(135deg, #fdcb6e, #f39c12); color: var(--dark); }
.toast.level-up { background: linear-gradient(135deg, #fd79a8, #e84393); }

@keyframes toastIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ===== Pack select colors ===== */
.pack-card:nth-child(1) { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.pack-card:nth-child(2) { background: linear-gradient(135deg, #00b894, #55efc4); }
.pack-card:nth-child(3) { background: linear-gradient(135deg, #e17055, #fab1a0); }
.pack-card:nth-child(4) { background: linear-gradient(135deg, #0984e3, #74b9ff); }
.pack-card:nth-child(5) { background: linear-gradient(135deg, #fdcb6e, #f39c12); }
.pack-card:nth-child(6) { background: linear-gradient(135deg, #fd79a8, #e84393); }
.pack-card:nth-child(7) { background: linear-gradient(135deg, #636e72, #b2bec3); }

/* ===== Synonym Paraphrasing ===== */

#screen-synonym {
  background: linear-gradient(135deg, #e84393, #fd79a8);
}

.synonym-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.syn-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--card-shadow);
  text-align: center;
}

.syn-instruction {
  font-size: 14px;
  color: var(--gray);
  margin-bottom: 12px;
}

.syn-sentence-text {
  font-size: 17px;
  line-height: 1.6;
  color: var(--dark);
}

.syn-target-word {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  margin: 8px 0;
}

.syn-category {
  font-size: 12px;
  color: var(--light-gray);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.syn-highlight {
  background: linear-gradient(135deg, #fd79a8, #e84393);
  color: var(--white);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
}

.syn-feedback-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.syn-all-synonyms {
  font-size: 15px;
  color: var(--dark);
  margin-bottom: 6px;
}

.syn-synonyms-list {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.6;
}

.syn-definition {
  font-size: 14px;
  color: var(--gray);
}

/* ===== Pack Word Browser ===== */

#screen-pack-browse {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
}

.pack-browse-count {
  font-size: 13px;
  background: rgba(255,255,255,0.2);
  padding: 4px 10px;
  border-radius: 12px;
}

.browse-word-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.browse-word-chip {
  border: none;
  color: var(--white);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.3;
  background: rgba(255,255,255,0.18);
}

.browse-word-chip:active {
  transform: scale(0.9);
  opacity: 0.8;
}

.browse-category-label {
  width: 100%;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 12px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.browse-category-label:first-child {
  margin-top: 0;
}

/* ===== Single Word View ===== */

#screen-word-view {
  background: linear-gradient(135deg, #00b894, #55efc4);
}

.word-view-body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.word-view-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--card-shadow-lg);
  text-align: center;
  width: 100%;
  max-width: 360px;
}

.wv-word {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
}

.wv-pos {
  font-size: 14px;
  color: var(--gray);
  font-style: italic;
  margin-bottom: 20px;
}

.wv-definition {
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 16px;
  line-height: 1.5;
}

.wv-example {
  font-size: 14px;
  color: var(--gray);
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 16px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: var(--radius-sm);
}

.wv-synonyms {
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
}

/* ===== Credit Footer (on background, below app) ===== */

.credit-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 10px;
  z-index: 0;
}

.credit-footer p {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  font-weight: 600;
  letter-spacing: 0.8px;
}

/* ===== Responsive: Small phones (320px - 360px, e.g. iPhone SE) ===== */

@media (max-width: 360px) {
  .home-header { padding: 16px 14px 12px; }
  .home-title h1 { font-size: 22px; }
  .stats-bar { gap: 6px; }
  .stat-item { padding: 8px 6px; gap: 4px; }
  .stat-icon { font-size: 16px; }
  .stat-value { font-size: 15px; }
  .stat-label { font-size: 10px; }
  .level-info { font-size: 11px; }
  .home-body { padding: 18px 14px; }
  .section-title { font-size: 14px; }
  .pack-card { width: 130px; padding: 12px; }
  .pack-icon { font-size: 22px; margin-bottom: 4px; }
  .pack-name { font-size: 12px; }
  .pack-count { font-size: 11px; }
  .mode-grid { gap: 8px; }
  .mode-card { padding: 10px 4px; gap: 4px; }
  .mode-icon { font-size: 22px; }
  .mode-name { font-size: 11px; }
  .mode-desc { font-size: 10px; }
  .fc-word { font-size: 24px; }
  .flashcard-container { height: 230px; }
  .flashcard-front, .flashcard-back { padding: 16px; }
  .fc-definition { font-size: 15px; margin-bottom: 10px; }
  .fc-example { font-size: 12px; }
  .fc-btn { padding: 12px; font-size: 13px; }
  .screen-body { padding: 16px 14px; }
  .screen-header { padding: 12px 14px; }
  .screen-header h2 { font-size: 17px; }
  .quiz-question { padding: 16px; }
  .quiz-definition { font-size: 15px; }
  .quiz-option { padding: 12px 14px; font-size: 14px; }
  .fill-sentence { padding: 16px; font-size: 15px; }
  .fill-input { padding: 12px 14px; font-size: 16px; }
  .btn-hint { padding: 12px; font-size: 12px; }
  .btn-primary { padding: 14px; font-size: 15px; }
  .match-tile { padding: 10px; font-size: 12px; min-height: 44px; }
  .syn-card { padding: 16px; }
  .syn-sentence-text { font-size: 14px; }
  .spell-definition-box { padding: 16px; }
  .spell-definition { font-size: 15px; }
  .results-score { font-size: 28px; }
  .results-stars { font-size: 36px; }
  .stat-big { font-size: 22px; }
}

/* ===== Responsive: Regular phones (361px - 428px) ===== */

@media (min-width: 361px) and (max-width: 428px) {
  .flashcard-container { height: 260px; max-width: 320px; }
  .flashcard-actions { max-width: 320px; }
}

/* ===== Responsive: Large phones (429px - 480px) ===== */

@media (min-width: 429px) and (max-width: 480px) {
  .flashcard-container { height: 280px; }
}

/* ===== Responsive: Tablets portrait (481px - 820px, iPad Mini / iPad) ===== */

@media (min-width: 481px) {
  #app {
    max-width: 500px;
    border-radius: 24px;
    overflow: hidden;
    margin-top: 20px;
    height: calc(100vh - 76px);
    height: calc(100dvh - 76px);
    box-shadow: var(--card-shadow-lg);
  }
}

@media (min-width: 481px) and (max-width: 820px) {
  .home-header { padding: 28px 24px 20px; }
  .home-title h1 { font-size: 28px; }
  .stats-bar { gap: 14px; }
  .stat-item { padding: 12px 14px; }
  .stat-value { font-size: 20px; }
  .home-body { padding: 28px 24px; }
  .section-title { font-size: 18px; }
  .pack-card { width: 160px; padding: 18px; }
  .mode-card { padding: 18px 10px; }
  .mode-icon { font-size: 32px; }
  .mode-name { font-size: 14px; }
  .mode-desc { font-size: 12px; }
  .screen-body { padding: 24px; }
  .flashcard-container { height: 320px; max-width: 380px; }
  .flashcard-actions { max-width: 380px; }
  .fc-word { font-size: 36px; }
  .fc-definition { font-size: 20px; }
  .fc-example { font-size: 15px; }
  .quiz-option { padding: 18px 22px; }
  .match-tile { padding: 14px; font-size: 15px; min-height: 60px; }
  .btn-primary { padding: 18px; font-size: 17px; }
}

/* ===== Responsive: Tablets landscape & large iPads (821px+) ===== */

@media (min-width: 821px) {
  #app {
    max-width: 520px;
    margin-top: 40px;
    height: calc(100vh - 80px);
    height: calc(100dvh - 80px);
  }

  .home-header { padding: 32px 28px 24px; }
  .home-title h1 { font-size: 30px; }
  .stat-value { font-size: 22px; }
  .home-body { padding: 32px 28px; }
  .pack-card { width: 170px; }
  .flashcard-container { height: 340px; max-width: 400px; }
  .flashcard-actions { max-width: 400px; }
  .fc-word { font-size: 38px; }
  .screen-body { padding: 28px; }
}

/* ===== Safe area insets for notched phones ===== */

@supports (padding-top: env(safe-area-inset-top)) {
  .screen-header {
    padding-top: calc(16px + env(safe-area-inset-top));
  }
  .home-header {
    padding-top: calc(24px + env(safe-area-inset-top));
  }
  #screen-loading {
    padding-top: env(safe-area-inset-top);
  }
}

/* ===== Landscape orientation ===== */

@media (orientation: landscape) and (max-height: 500px) {
  #app { max-width: 100%; }
  .home-header { padding: 8px 20px; }
  .stats-bar { margin-bottom: 8px; }
  .level-bar { display: none; }
  .home-body { border-radius: 0; padding: 12px 20px; }
  .section-title { margin-bottom: 8px; }
  .mode-grid { margin-bottom: 12px; gap: 8px; }
  .mode-card { padding: 8px 4px; }
  .mode-icon { font-size: 20px; }
  .mode-name { font-size: 11px; }
  .mode-desc { display: none; }
  .flashcard-container { height: 180px; }
  .flashcard-body { gap: 8px; }
  .fc-btn { padding: 10px; font-size: 13px; }
  .screen-body { padding: 12px 16px; }
  .screen-header { padding: 8px 16px; }
}
