@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
  --primary: #222222;
  --primary-hover: #333333;
  --secondary: #444444;
  --bg-dark: #0a0a0a;
  --bg-input: #171717;
  --bg-card: #1f1f1f;
  --text-white: #ffffff;
  --text-muted: #94a3b8;
  --border: #262626;
  --accent: #ffffff;
  --pointer-color: #ffffff;
  --shadow: 0 4px 30px rgba(0, 0, 0, 0.7);
  --font-family: 'Outfit', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent !important;
  outline: none !important;
}

*:focus,
*:active,
*:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #666;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-white);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding-top: 60px;
}

.bg-blob {
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
  z-index: -1;
  filter: blur(100px);
}

.blob-1 {
  top: -10%;
  left: -20%;
}

.blob-2 {
  bottom: -20%;
  right: -20%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.03) 0%, transparent 70%);
}

.tabs-container {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 1rem 1rem 0;
  background: #222222;
  border-bottom: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 50;
}

.tabs-list {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: flex-end;
  padding-bottom: 0px;
}

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

.tab-item {
  padding: 0 1.2rem;
  height: 40px;
  background: #222222;
  color: white;
  border: none;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  opacity: 0.6;
  transition: opacity 0.2s, background 0.2s;
  position: relative;
  top: 1px;
  border-bottom: 1px solid #000;
}

.tab-item.active {
  opacity: 1;
  background: var(--bg-dark);
  z-index: 10;
  border-bottom: 1px solid var(--bg-dark);
}

.tab-item:hover:not(.active) {
  opacity: 0.8;
}

.tab-item.disabled {
  opacity: 0.15 !important;
  cursor: not-allowed !important;
  filter: grayscale(1) !important;
  pointer-events: none !important;
}

#app {
  width: 100%;
  max-width: 800px;
  padding: 2rem;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  z-index: 1;
}

header {
  text-align: center;
}

header h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 0.5rem;
}

header p {
  color: var(--text-muted);
}

.deck-management {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

.deck-select {
  flex: 1;
  background: var(--bg-input);
  color: white;
  border: 1px solid var(--border);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.2rem;
  padding-right: 3rem;
}

.deck-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.icon-btn {
  background: var(--primary);
  color: var(--text-white);
  border: 1px solid var(--border);
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--primary-hover);
}

.modal-input-group label {
  display: block;
  text-align: left;
  margin-bottom: 0.8rem;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.modal-input-group input {
  width: 100%;
  padding: 1.2rem;
  font-size: 1.2rem;
  background: #1a1a1a !important;
  border: 1px solid #333 !important;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
}

.action-btn.secondary {
  background: var(--primary);
  color: white;
  border: 1px solid var(--border);
}

.action-btn.secondary:hover {
  background: var(--primary-hover);
}

.action-btn.delete {
  background: #ef4444 !important;
  color: white !important;
}

.action-btn.delete:hover {
  background: #dc2626 !important;
}

.progress-container {
  width: 100%;
  height: 4px;
  background: var(--bg-input);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 1.5rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.4s ease;
}

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

.flashcard-wrapper {
  perspective: 1500px;
  width: 100%;
  height: 380px;
  margin: 1rem 0;
}

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

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

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.flashcard-face.back {
  transform: rotateY(180deg);
  background: #1a1a1a;
}

.card-label {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.card-content {
  font-size: 2.2rem;
  font-weight: 600;
}

.card-subcontent {
  margin-top: 1rem;
  font-size: 1rem;
  color: var(--text-muted);
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.nav-buttons,
.quiz-buttons {
  display: flex;
  gap: 0.8rem;
}

.quiz-buttons {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.quiz-buttons.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.primary-btn {
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background-color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

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

.primary-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.15;
  cursor: not-allowed;
  transform: none !important;
  filter: grayscale(1);
  pointer-events: none;
}

.secondary-btn {
  padding: 0.7rem 1.5rem;
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.secondary-btn:hover {
  background: var(--primary-hover);
}


.btn-success {
  background: #ffffff;
  color: #000000 !important;
}

.btn-error {
  background: #ef4444 !important;
  color: white !important;
}

.btn-error:hover {
  background: #dc2626 !important;
}

.modal-primary-btn {
  background: #222222 !important;
  color: white !important;
}

.modal-primary-btn:hover {
  background: #333333 !important;
}

.mcq-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.mcq-question-box {
  background: var(--bg-card);
  padding: 3rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  text-align: center;
}

.mcq-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.mcq-option {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.mcq-option:hover {
  background: var(--primary-hover);
}

.mcq-option.correct {
  border-color: var(--accent);
}

.mcq-option.wrong {
  background: #7f1d1d !important;
  border-color: #ef4444;
  color: white;
}

.manage-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.add-card-form {
  background: var(--bg-input);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

input {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 8px;
  color: white;
  outline: none;
  font-family: inherit;
  font-size: 1rem;
}

input:focus {
  border-color: var(--primary-hover);
}

.input-error {
  border-color: #ef4444 !important;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 350px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.card-item {
  background: var(--bg-card);
  padding: 1rem 1.2rem;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
}

.card-item-text span {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.delete-btn {
  background: #7f1d1d22;
  color: #ef4444;
  border: 1px solid #7f1d1d44;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
}

.delete-btn:hover {
  background: #7f1d1d;
  color: white;
}

.summary-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 10, 0.98);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
  transition: 0.4s ease;
  z-index: 100;
}

.summary-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.score-display {
  font-size: 5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 1rem;
}

.glow-success {
  box-shadow: 0 0 40px rgba(255, 255, 255, 0.4);
  transform: rotateY(180deg) scale(1.02);
}

.glow-error {
  box-shadow: 0 0 40px rgba(127, 29, 29, 0.4);
  transform: rotateY(180deg) scale(1.02);
}

@media (max-width: 640px) {
  #app {
    padding: 1rem;
    margin-top: 80px;
  }

  .mcq-options-grid {
    grid-template-columns: 1fr;
  }

  .flashcard-wrapper {
    height: 320px;
  }

  .controls {
    flex-direction: column;
  }

  .nav-buttons,
  .quiz-buttons {
    width: 100%;
  }

  .nav-buttons button,
  .quiz-buttons button {
    flex: 1;
  }

  .tabs-container {
    height: auto;
    padding-bottom: 0.5rem;
  }

  .tab-item {
    padding: 0 0.8rem;
    font-size: 0.85rem;
  }
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(8px);
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #111111;
  padding: 2.5rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  max-width: 450px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-content h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  color: var(--text-white);
}

.modal-content p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1.1rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.modal-actions button {
  padding: 0.7rem 1rem !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  height: auto !important;
  flex: 1;
}

@media (max-width: 480px) {
  .modal-content {
    padding: 1.5rem;
    width: 95%;
  }

  .modal-actions {
    flex-direction: column-reverse;
    gap: 0.8rem;
  }

  .modal-actions button {
    width: 100%;
    margin: 0 !important;
  }
}

/* Game View Styles */
.game-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  max-height: 80vh;
}

.game-stats {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--bg-input);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-weight: 600;
}

.game-area {
  position: relative;
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 400px;
}

.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 12px;
}

.game-overlay.hidden {
  display: none;
}

.falling-asteroid {
  position: absolute;
  background: var(--bg-card);
  padding: 0.8rem 1.2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  font-weight: 600;
  cursor: default;
  transition: transform 0.1s linear;
  user-select: none;
}

.falling-asteroid.hit {
  background: var(--accent);
  color: #000000 !important;
  transform: scale(0);
  transition: all 0.3s ease-out;
}

.game-input-container {
  margin-top: 1rem;
}

.game-input-container input {
  width: 100%;
  padding: 1.2rem;
  font-size: 1.2rem;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.2s;
}

.game-input-container input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(29, 110, 0, 0.2);
}

@media (prefers-color-scheme: light) {
  :root {
    --primary: #f5f5f5;
    --primary-hover: #eeeeee;
    --secondary: #e0e0e0;
    --bg-dark: #ffffff;
    --bg-input: #f5f5f5;
    --bg-card: #f5f5f5;
    --text-white: #000000;
    --text-muted: #666666;
    --border: #dddddd;
    --pointer-color: #000000;
    --accent: #000000;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  }

  body {
    background-color: var(--bg-dark);
    color: var(--text-white);
  }

  .bg-blob {
    background: radial-gradient(circle, rgba(0, 0, 0, 0.05) 0%, transparent 70%);
  }

  .tabs-container {
    background: #e0e0e0 !important;
    border-bottom: none !important;
  }

  .tab-item {
    background: #e0e0e0 !important;
    color: #444444 !important;
    opacity: 0.8;
    border-bottom: none !important;
    border: 1px solid transparent !important;
  }

  .tab-item.active {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #dddddd !important;
    border-bottom: none !important;
    opacity: 1;
    z-index: 20 !important;
  }

  .modal {
    background: rgba(255, 255, 255, 0.8) !important;
  }

  .modal-content {
    background: #ffffff !important;
    border: 1px solid #dddddd !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1) !important;
  }

  .modal-content h2,
  .modal-content p,
  .modal-input-group label {
    color: #000000 !important;
  }

  .modal-input-group input[type="text"] {
    background: #f5f5f5 !important;
    color: #000000 !important;
    border: 1px solid #dddddd !important;
  }

  .primary-btn,
  .secondary-btn {
    background-color: #000000 !important;
    color: #ffffff !important;
  }

  .primary-btn:hover,
  .secondary-btn:hover {
    background-color: #333333 !important;
  }

  .btn-error {
    background-color: #ef4444 !important;
  }

  .btn-success {
    background-color: #ffffff !important;
    color: #000000 !important;
  }

  .primary-btn svg,
  .secondary-btn svg {
    stroke: white !important;
  }

  .mcq-option {
    background: #ffffff !important;
    border: 1px solid #dddddd !important;
    color: #000000 !important;
  }

  .mcq-option:hover {
    background: #f0f0f0 !important;
  }

  .mcq-option.correct {
    background: #000000 !important;
    border-color: #000000 !important;
    color: #ffffff !important;
  }

  .mcq-option.wrong {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #991b1b !important;
  }

  .card-item {
    background: #ffffff !important;
    border: 1px solid #dddddd !important;
  }

  .add-card-form {
    background: #ffffff !important;
    border: 1px solid #dddddd !important;
  }

  input {
    background: #f5f5f5 !important;
    color: #000000 !important;
    border: 1px solid #dddddd !important;
  }

  .flashcard-face.back {
    background: #ffffff !important;
  }

  .summary-overlay {
    background: rgba(255, 255, 255, 0.98) !important;
  }
}