/* ==================== CSS VARIABLES & RESET ==================== */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2235;
  --bg-card-hover: #1f2a40;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.3);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.3);
  --yellow: #eab308;
  --yellow-glow: rgba(234, 179, 8, 0.3);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #2a3450;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family:
    "Inter",
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ==================== BACKGROUND EFFECTS ==================== */
.bg-effects {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  animation: orbFloat 20s ease-in-out infinite;
}

.bg-orb-1 {
  width: 500px;
  height: 500px;
  background: var(--accent);
  top: -150px;
  left: -100px;
  animation-delay: 0s;
}

.bg-orb-2 {
  width: 400px;
  height: 400px;
  background: #8b5cf6;
  bottom: -100px;
  right: -80px;
  animation-delay: -7s;
}

.bg-orb-3 {
  width: 300px;
  height: 300px;
  background: #06b6d4;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes orbFloat {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(30px, -40px) scale(1.05);
  }
  50% {
    transform: translate(-20px, 20px) scale(0.95);
  }
  75% {
    transform: translate(40px, 30px) scale(1.02);
  }
}

/* ==================== MAIN CONTAINER ==================== */
.app-container {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

/* ==================== SCREENS ==================== */
.screen {
  width: 100%;
  max-width: 700px;
  display: none;
  animation: screenIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==================== MENU SCREEN ==================== */
.menu-logo {
  width: 140px;
  height: 140px;
  margin-top: 30px;
  margin-bottom: 16px;
  border-radius: 30px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  box-shadow: 0 0 60px var(--accent-glow);
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%,
  100% {
    box-shadow: 0 0 40px var(--accent-glow);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 80px var(--accent-glow);
    transform: scale(1.03);
  }
}

.menu-title {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.menu-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 40px;
  text-align: center;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 400px;
}

.menu-footer {
  margin-top: 50px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  font-family: inherit;
}

.btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.08),
    transparent
  );
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, var(--green), #16a34a);
  color: white;
  box-shadow: 0 4px 20px var(--green-glow);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--green-glow);
}

.btn-danger {
  background: linear-gradient(135deg, var(--red), #dc2626);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--red-glow);
}

.btn-back {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 10px 20px;
  font-size: 0.92rem;
}

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

.btn-sm {
  padding: 8px 16px;
  font-size: 0.88rem;
  border-radius: 8px;
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

/* ==================== CARDS / GRID ==================== */
.section-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.section-sub {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 30px;
  font-size: 0.95rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  width: 100%;
  margin-bottom: 30px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent-glow), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.card:hover::after {
  opacity: 1;
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}

.card-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

.card-info {
  color: var(--text-muted);
  font-size: 0.82rem;
  position: relative;
  z-index: 1;
}

/* Set cards specific */
.set-card .card-icon {
  font-size: 1.6rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 12px;
  margin: 0 auto 12px;
}

/* ==================== GAME SCREEN ==================== */
.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.game-set-name {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.progress-container {
  width: 100%;
  margin-bottom: 30px;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.progress-bar-wrapper {
  width: 100%;
  height: 12px;
  background: var(--bg-card);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 20px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Word display */
.word-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 30px;
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.word-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6, #06b6d4);
}

.word-prompt {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.word-foreign {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: wordAppear 0.4s ease-out;
}

@keyframes wordAppear {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.word-level {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
}

.level-1 {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}
.level-2 {
  background: rgba(234, 179, 8, 0.15);
  color: var(--yellow);
}
.level-3 {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}
.level-4 {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-light);
}
.level-5 {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.level-stars {
  letter-spacing: 2px;
}

/* Answer input */
.answer-section {
  width: 100%;
  margin-bottom: 20px;
}

.answer-input-wrapper {
  position: relative;
  width: 100%;
}

.answer-input {
  width: 100%;
  padding: 18px 24px;
  padding-right: 60px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.15rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.answer-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.answer-input.correct {
  border-color: var(--green);
  box-shadow: 0 0 0 4px var(--green-glow);
}

.answer-input.wrong {
  border-color: var(--red);
  box-shadow: 0 0 0 4px var(--red-glow);
}

.answer-input::placeholder {
  color: var(--text-muted);
}

.submit-btn-inline {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent);
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.submit-btn-inline:hover {
  background: var(--accent-light);
}

/* Feedback */
.feedback-container {
  width: 100%;
  min-height: 60px;
  margin-bottom: 20px;
}

.feedback {
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  animation: feedbackIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.feedback-correct {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--green);
}

.feedback-wrong {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.feedback-close {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: var(--yellow);
}

.game-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Skip button + hint */
.btn-skip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 20px;
  font-size: 0.9rem;
}

.btn-skip:hover {
  border-color: var(--yellow);
  color: var(--yellow);
}

.hint-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 6px;
  font-style: italic;
}

/* ==================== END SCREEN ==================== */
.end-screen-content {
  text-align: center;
  padding: 40px 0;
}

.trophy {
  font-size: 100px;
  animation: trophyBounce 1s ease-out;
  display: inline-block;
}

@keyframes trophyBounce {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.3);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.end-title {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--yellow), #f97316, var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 20px 0 10px;
}

.end-subtitle {
  color: var(--green);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.end-stats {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 40px;
}

.end-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* ==================== ADD WORDS SCREEN ==================== */
.add-form {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.form-group {
  flex: 1;
  min-width: 200px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Word list */
.word-list {
  width: 100%;
}

.word-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: var(--transition);
  animation: listItemIn 0.3s ease-out;
}

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

.word-list-item:hover {
  border-color: var(--accent);
}

.word-list-item .word-pair {
  font-weight: 600;
}

.word-list-item .word-pair span {
  color: var(--accent-light);
}

.word-list-item .delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
}

.word-list-item .delete-btn:hover {
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* ==================== LOADING ==================== */
.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 600px) {
  .menu-title {
    font-size: 1.8rem;
  }
  .word-foreign {
    font-size: 2rem;
  }
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  .form-row {
    flex-direction: column;
  }
  .game-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .word-card {
    padding: 28px 18px;
  }
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  animation:
    toastIn 0.4s ease-out,
    toastOut 0.4s ease-in 2.6s forwards;
  box-shadow: var(--shadow);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100px);
  }
}

.toast-success {
  background: rgba(34, 197, 94, 0.95);
  color: white;
}

.toast-error {
  background: rgba(239, 68, 68, 0.95);
  color: white;
}

/* ==================== STREAK COUNTER ==================== */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(234, 179, 8, 0.15);
  color: var(--yellow);
  border: 1px solid rgba(234, 179, 8, 0.3);
  animation: streakPulse 0.5s ease-out;
}

@keyframes streakPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

/* ==================== KEYBOARD HINT ==================== */
.keyboard-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 10px;
}

.kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
}
