/*Global Styles*/

* {
  box-sizing: border-box;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  background: linear-gradient(135deg, #eef2ff, #fdf2f8, #ecfeff);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.title {
  font-size: 44px;
  font-weight: 800;
  background: linear-gradient(90deg, #6366f1, #ec4899, #14b8a6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.5px;
  margin: 0;
}

/* Contextual help text on each screen */
.screen-help {
  font-size: 14px;
  color: #475569;
  text-align: center;
  max-width: 90%;
  line-height: 1.4;
  margin-bottom: 4px;
}

.hidden {
  display: none !important;
  transform: translateY(-4px);
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0; 
  display: flex;
  flex-direction: column;
  gap: 22px;
  justify-content: flex-start;
  align-items: center;
}
/*Screen 1*/

.screen1 {
  width: 100%;
  max-width: 620px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.score {
  font-size: 26px;
  font-weight: 600;
  color: #475569;
}
.answer {
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  color: #78350f;
  font-weight: 700;
  font-size: 16px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);        
  max-width: 100%;             
  flex-shrink: 1;               
  transition: opacity 0.2s ease, transform 0.2s ease;
  min-width: 0;
}

.input-container {
  position: relative;
  width: 100%;
}
.input-box {
  width: 100%;
  height: 170px;
  resize: none;
  padding: 18px;
  border-radius: 18px;
  border: 2px solid #e5e7eb;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  color: #334155;
  font-size: 18px;
  line-height: 1.5;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
  transition: all 0.8s ease; /* This handles the slow fade back away */
  padding-right: 60px;
}
.input-box::placeholder {
  color: #94a3b8;
}
.input-box:focus {
  outline: none;
  border-color: transparent;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(90deg, #6366f1, #ec4899, #14b8a6) border-box;
  border: 3px solid transparent;
  box-shadow:
    0 0 0 6px rgba(99, 102, 241, 0.15),
    0 14px 30px rgba(0, 0, 0, 0.1);
}

.input-box.correct {
  transition: all 0.1s ease; /* This makes the green pop in instantly */
  border-color: transparent;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(90deg, #22c55e, #10b981, #059669) border-box;
  border: 3px solid transparent;
  box-shadow:
    0 0 0 6px rgba(34, 197, 94, 0.15),
    0 14px 30px rgba(0, 0, 0, 0.1);
}

.input-box.wrong {
  transition: all 0.1s ease; /* This makes the red pop in instantly */
  border-color: transparent;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(90deg, #ef4444, #dc2626, #b91c1c) border-box;
  border: 3px solid transparent;
  box-shadow:
    0 0 0 6px rgba(239, 68, 68, 0.15),
    0 14px 30px rgba(0, 0, 0, 0.1);
}

#flag {
 position: absolute;
  top: 8px;
  right: 14px;
  background: none;
  border: none;
  font-size: 30px;
  color: #cbd5f5;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.25s ease, transform 0.2s ease;
}
#flag.yellow {
  color: #FFD700;
}
#flag:hover {
  transform: translateY(-5px);
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.buttons button {
  flex: 1 1 calc(33.333% - 16px);
  height: 68px;
  border: none;
  border-radius: 18px;
  font-size: 18px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.buttons button:hover {
  transform: translateY(-3px);
}

.buttons button:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/*Screen 2*/

.screen2 {
  width: 100%;
  max-width: 620px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;  
}

.menu-cards {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}
.menu-card {
  border: none;
  border-radius: 20px;
  padding: 22px;
  text-align: left;
  cursor: pointer;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.menu-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.12);
}
.menu-card.active {
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(90deg, #6366f1, #ec4899, #14b8a6) border-box;
  border: 3px solid transparent;
}

.card-title {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(90deg, #6366f1, #ec4899, #14b8a6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.card-sub {
  margin-top: 6px;
  font-size: 15px;
  color: #475569;
}

#begin {
  width: 100%;
  height: 68px;
  border: none;
  border-radius: 18px;
  font-size: 18px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}
.begin-btn {
  height: 72px;
  border: none;
  border-radius: 20px;
  font-size: 20px;
  font-weight: 800;
  color: white;
  cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.begin-btn:hover {
  transform: translateY(-3px);
}

.begin-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

/*Mode Screen*/

.screen-mode {
  width: 100%;
  max-width: 620px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  width: 80%;
}
.mode-card {
  border: none;
  border-radius: 20px;
  padding: 22px;
  text-align: left;
  cursor: pointer;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.mode-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.12);
}
.mode-card.active {
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(90deg, #6366f1, #ec4899, #14b8a6) border-box;
  border: 3px solid transparent;
}
.mode-title {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(90deg, #6366f1, #ec4899, #14b8a6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.mode-desc {
  margin-top: 6px;
  font-size: 15px;
  color: #475569;
}

.mode-options {
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-help {
  font-size: 15px;
  font-weight: 600;
  color: #475569;
  margin: 0;
}

#orderedStartLetter {
  width: 80px;
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  text-align: center;
  padding: 10px;
  border-radius: 14px;
  border: 2px solid #e5e7eb;
  outline: none;
}

#orderedStartLetter:focus {
  border-color: transparent;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(90deg, #6366f1, #ec4899, #14b8a6) border-box;
  border: 3px solid transparent;
}
#orderedStartLetter {
  width: 200px;          
  max-width: 100%;       
  padding: 6px 10px;   
  font-size: 16px;      
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box; 
  transition: border-color 0.2s ease;
}

#orderedStartInput:focus {
  border-color: #4a90e2; 
  outline: none;
}

.back-btn {
  width: 100%;
  height: 68px;
  border: none;
  border-radius: 18px;
  font-size: 18px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}

/*Dictionary Screen*/

.screen-dictionary,
.screen-review,
.screen-practice,
.screen-filter,
.screen-settings,
.screen-division {
  width: 100%;
  max-width: 620px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  justify-content: flex-start;
}

.dict-card {
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.1);
}
.dict-word {
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 14px;
}
.dict-section {
  margin-top: 14px;
  font-size: 16px;
  color: #334155;
}
.dict-controls {
  display: flex;
  justify-content: center;
  gap: 16px;
}
.dict-controls button {
  width: 70px;
  height: 60px;
  font-size: 24px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
}

/*Review Screen*/

.screen-review {
  min-height: 100svh;
}

.review-toggle {
  display: flex;
  gap: 12px;
}
.review-toggle button {
  flex: 1;
  height: 50px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #e5e7eb, #f3f4f6);
  color: #1e293b;
  transition: all 0.2s ease;
}
.review-toggle button.active {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;             
  overflow-y: auto;     
}
.review-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  font-weight: 600;
  font-size: 16px;
}
.review-item button {
  font-size: 20px;
  border: none;
  background: none;
  color: #9ca3af; 
  cursor: pointer;
  transition: color 0.2s ease;
}
.review-item button.removed {
  color: #ef4444; 
}
#dictPrev:disabled,
#dictNext:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.review-add-input {
  flex: 1;
  padding: 10px 12px;
  font-size: 16px;
  border-radius: 0px;
  border: 0px solid #d1d5db;
  background-color:transparent;
}

.review-add-input.invalid {
  border-color: #ef4444;
  background: #fee2e2;
}
.review-placeholder-text {
  flex: 1;
  padding: 10px 12px;
  font-size: 16px;
  color: #94a3b8;
  font-style: italic;
}
.add-btn {
  font-size: 22px;
  font-weight: 800;
  color: #22c55e;
  border: none;
  background: none;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.add-btn:hover {
  transform: scale(1.2);
}

/*Practice Screen*/


.practice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.practice-word {
  padding: 16px;
  border-radius: 14px;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  box-shadow: 0 6px 14px rgba(0,0,0,0.1);
  font-size: 15px;
}

/* Settings Screen */
.settings-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1; /* Allows content to grow and push back button to bottom */
}
.settings-group {
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  padding: 22px;
  border-radius: 20px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  text-align: left; /* Align text to the left for consistency */
}
.settings-label {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase; /* Make labels consistent with card-sub */
}
.settings-value {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
}
.danger-btn {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border: none;
  height: 68px; /* Consistent height with other buttons */
  border-radius: 18px; /* Consistent border-radius */
  font-size: 18px; /* Consistent font size */
  font-weight: 800; /* Consistent font weight */
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(239, 68, 68, 0.15); /* Consistent shadow */
  transition: transform 0.15s ease, box-shadow 0.15s ease; /* Add hover/active transitions */
}

.danger-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(239, 68, 68, 0.2);
}

.danger-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(239, 68, 68, 0.15);
}

/*Filter Screen*/

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.filter-options label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 600;
  color: #334155;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.filter-options label:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.filter-options input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: #6366f1;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  width: 100%;
}

.filter-buttons button {
  flex: 1 1 calc(33% - 16px);
  height: 60px;
  border: none;
  border-radius: 18px;
  font-size: 16px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 6px 14px rgba(0,0,0,0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.filter-buttons button:hover {
  transform: translateY(-3px);
}

.filter-buttons button:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

/*Media*/

@media (max-width: 480px) {
  .buttons button {
    flex: 1 1 calc(50% - 12px);
  }

  .title {
    font-size: 36px;
  }
  .top-row {
    flex-direction: row;     
    align-items: flex-start;
    gap: 6px;             
  }

  .answer {
    text-align: left; 
    max-width: 70%;            
    flex-shrink: 1;            
    white-space: nowrap;       
    overflow: hidden;
    text-overflow: ellipsis; 
  }

  #flag {
    flex-shrink: 0;             
  }
  
  .filter-buttons button {
    flex: 1 1 calc(50% - 12px);
  }

  .filter-options label {
    font-size: 16px;
  }
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 60px;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  max-width: 620px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  text-align: left;
}

/* Slider Styles */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  background: #e0e0e0;
  outline: none;
  opacity: 0.7;
  -webkit-transition: .2s;
  transition: opacity .2s;
  border-radius: 5px;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.modal-content h2 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: #1f2937;
}

.list-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.list-option-btn {
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  background: white;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.list-option-btn:hover {
  border-color: #6366f1;
  background: #f3f4f6;
}

.list-option-btn.active {
  border-color: #6366f1;
  background: #eef2ff;
  color: #6366f1;
  font-weight: 600;
}

.modal-input-container {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-input-container input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
}

.modal-input-container input:focus {
  outline: none;
  border-color: #6366f1;
}

.modal-input-container button {
  padding: 10px 16px;
  background: #6366f1;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.modal-input-container button:hover {
  background: #4f46e5;
}

.modal-close {
  width: 100%;
  padding: 12px;
  background: #f3f4f6;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.modal-close:hover {
  background: #e5e7eb;
}

/* Review List Select Dropdown */
.review-list-select {
  width: 100%;
  max-width: 300px;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  color: #334155;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  appearance: none;
  -webkit-appearance: none;
}

.review-list-select:hover {
  border-color: #6366f1;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.review-list-select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.review-list-select option {
  background: #fff;
  color: #334155;
}

.review-list-select::-ms-expand {
  display: none;
}
