/* =========================================
   LingoMaster - Stylesheet
   Premium Modern Glassmorphism Design
========================================= */

:root {
  --bg-gradient-1: #f0f4f8;
  --bg-gradient-2: #d9e2ec;
  --primary: #4338ca;
  --primary-hover: #3730a3;
  --secondary: #8b5cf6;
  --text-dark: #102a43;
  --text-muted: #627d98;
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(255, 255, 255, 0.6);
  --card-shadow: 0 8px 32px rgba(31, 38, 135, 0.08);
  --success: #10b981;
  --danger: #ef4444;
  --font-main: 'Outfit', 'Noto Sans TC', sans-serif;
  --radius: 20px;
}

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

body {
  font-family: var(--font-main);
  background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}

/* Background Animated Shapes */
.bg-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  z-index: -1;
  animation: float 10s infinite alternate ease-in-out;
}

.shape-1 {
  width: 400px;
  height: 400px;
  background: rgba(139, 92, 246, 0.3);
  top: -100px;
  left: -100px;
}

.shape-2 {
  width: 300px;
  height: 300px;
  background: rgba(67, 56, 202, 0.25);
  bottom: -50px;
  right: -50px;
  animation-duration: 12s;
  animation-delay: -2s;
}

.shape-3 {
  width: 250px;
  height: 250px;
  background: rgba(16, 185, 129, 0.2);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 14s;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, 30px) scale(1.1); }
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  max-height: 800px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (min-width: 481px) {
  .app-container {
    height: 90vh;
    border-radius: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    background: rgba(255,255,255,0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.5);
  }
}

/* Screens */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 30px 24px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

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

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

/* ---- Start Screen ---- */
#screen-start {
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  padding-top: 40px;
}

.logo-box {
  margin-bottom: 40px;
}

.logo-emoji {
  font-size: 80px;
  margin-bottom: 10px;
  animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.app-title {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 5px;
}

.app-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 12px;
}

.total-words-badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 700;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.diff-breakdown {
  font-size: 13px;
  color: #047857;
  margin-top: 4px;
  font-weight: 600;
}

.settings-box {
  background: var(--card-bg);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(10px);
  width: 100%;
  margin-bottom: 40px;
}

.settings-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 16px;
}

.difficulty-options {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.btn-diff {
  padding: 10px 20px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: #fff;
  color: var(--text-dark);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.btn-diff:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.btn-diff.active {
  border-color: var(--primary);
  background: rgba(67, 56, 202, 0.1);
  color: var(--primary);
}

.word-count-options {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.btn-count {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: #fff;
  color: var(--text-dark);
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.btn-count:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.btn-count.active {
  border-color: var(--primary);
  background: rgba(67, 56, 202, 0.1);
  color: var(--primary);
}

/* Button Primary */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
  border-radius: 100px;
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-main);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(67, 56, 202, 0.3);
  transition: all 0.3s ease;
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 25px rgba(67, 56, 202, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary.hidden {
  display: none;
}

/* Button Icon */
.btn-icon {
  background: rgba(67, 56, 202, 0.1);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--primary);
  margin-left: 10px;
}

.btn-icon:hover {
  background: rgba(67, 56, 202, 0.2);
  transform: scale(1.1);
}

/* Button Text */
.btn-text {
  background: none;
  border: none;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease;
}

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

/* Utility */
.hidden {
  display: none !important;
}

/* ---- Top Bar (Progress) ---- */
.top-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
}

.progress-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  width: 0%;
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.quiz-theme {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

/* ---- Learning Screen ---- */
.flashcard-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 30px;
  perspective: 1000px;
}

.flashcard {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: 24px;
  padding: 40px 24px;
  backdrop-filter: blur(15px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: cardIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes cardIn {
  0% { transform: scale(0.8) rotateY(-20deg); opacity: 0; }
  100% { transform: scale(1) rotateY(0); opacity: 1; }
}

.fc-word-group {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fc-word {
  font-size: 42px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}

.fc-pos {
  font-size: 16px;
  color: #fff;
  background: var(--secondary);
  padding: 2px 10px;
  border-radius: 12px;
  display: inline-block;
  margin-top: 8px;
  font-weight: 600;
}

.fc-verb-forms {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 8px;
}

.fc-trans {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 24px;
}

.fc-divider {
  width: 40px;
  height: 4px;
  background: rgba(0,0,0,0.1);
  border-radius: 2px;
  margin-bottom: 24px;
}

.fc-example-group {
  text-align: left;
  width: 100%;
  background: rgba(255,255,255,0.5);
  padding: 16px;
  border-radius: 16px;
}

.fc-example-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.fc-example {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-dark);
  line-height: 1.4;
  flex: 1;
}

.fc-example-trans {
  font-size: 15px;
  color: var(--text-muted);
}

.highlight {
  color: var(--primary);
  font-weight: 700;
}

/* ---- Ready Quiz Screen ---- */
#screen-ready-quiz {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.ready-box {
  background: var(--card-bg);
  padding: 40px 24px;
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(15px);
}

.ready-emoji { font-size: 64px; margin-bottom: 20px; }
.ready-title { font-size: 28px; font-weight: 800; color: var(--text-dark); margin-bottom: 10px; }
.ready-desc { font-size: 16px; color: var(--text-muted); margin-bottom: 30px; }

/* ---- Quiz Screen ---- */
.quiz-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.quiz-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: 24px;
  padding: 24px;
  backdrop-filter: blur(15px);
  margin-bottom: 20px;
}

.quiz-instruction {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 600;
}

.quiz-q-group {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.quiz-question {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.5;
  flex: 1;
}

.quiz-helpers {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.quiz-hint, .quiz-trans {
  font-size: 14px;
  color: var(--secondary);
  background: rgba(139, 92, 246, 0.1);
  padding: 8px 12px;
  border-radius: 8px;
  display: inline-block;
  margin-bottom: 12px;
  font-weight: 500;
}

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

.btn-option {
  width: 100%;
  padding: 16px;
  background: #fff;
  border: 2px solid transparent;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
  display: flex;
  align-items: center;
}

.btn-option:hover {
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.05);
}

.btn-option.correct {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success);
  color: #065f46;
}

.btn-option.wrong {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
  color: #7f1d1d;
}

.btn-option:disabled {
  pointer-events: none;
}

.quiz-feedback {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  min-height: 28px;
  transition: all 0.3s;
}

.feedback-correct { color: var(--success); animation: pop 0.4s; }
.feedback-wrong { color: var(--danger); animation: shake 0.4s; }

@keyframes pop {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

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

/* ---- Result Screen ---- */
#screen-result {
  justify-content: center;
  align-items: center;
}

.result-box {
  background: var(--card-bg);
  padding: 40px 30px;
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(15px);
  text-align: center;
  width: 100%;
}

.result-emoji {
  font-size: 70px;
  margin-bottom: 10px;
}

.result-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 24px;
}

.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) var(--progress, 0%), rgba(0,0,0,0.05) 0);
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.score-circle::before {
  content: '';
  position: absolute;
  width: 120px;
  height: 120px;
  background: #fff;
  border-radius: 50%;
}

.score-text {
  position: relative;
  z-index: 1;
}

#score-correct { font-size: 48px; font-weight: 900; color: var(--text-dark); }
.score-slash { font-size: 24px; color: var(--text-muted); margin: 0 4px; }
#score-total { font-size: 24px; font-weight: 600; color: var(--text-muted); }

.result-msg {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 30px;
  font-weight: 500;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Wordle Styles */
.wordle-board {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  margin: 20px 0;
}
.wordle-row {
  display: flex;
  gap: 5px;
}
.wordle-tile {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(139, 92, 246, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  font-weight: bold;
  text-transform: uppercase;
  color: var(--text-dark);
  background: rgba(255, 255, 255, 0.5);
  border-radius: 8px;
}
.wordle-tile.correct {
  background-color: #10b981;
  border-color: #10b981;
  color: white;
}
.wordle-tile.present {
  background-color: #f59e0b;
  border-color: #f59e0b;
  color: white;
}
.wordle-tile.absent {
  background-color: #9ca3af;
  border-color: #9ca3af;
  color: white;
}
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}
.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}
.key {
  flex: 1;
  background: rgba(139, 92, 246, 0.1);
  color: var(--text-dark);
  border: none;
  border-radius: 6px;
  padding: 12px 0;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s;
}
.key:hover {
  background: rgba(139, 92, 246, 0.2);
}
.key.key-large {
  flex: 1.5;
  font-size: 12px;
}
.key.correct { background-color: #10b981; color: white; }
.key.present { background-color: #f59e0b; color: white; }
.key.absent { background-color: #9ca3af; color: white; }
