* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  display: flex;
  min-height: 100vh;
  margin: 0;
  background-color: #f0f0f0;
  transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
  background-color: #1a1a1a;
  color: #fff;
}

.container {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: center;
  width: 100%;
}

.number-list-left, .number-list-right {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  position: fixed;
  top: 100px;
  padding: 10px;
  border-radius: 10px;
  z-index: 5;
  background-color: rgba(240,240,240,0.85);
}
body.dark-mode .number-list-left,
body.dark-mode .number-list-right {
  background-color: rgba(40,40,40,0.85);
}

@media (max-width: 767px) {
  .number-list-left, .number-list-right { display: none; }
  .flashcard-container { width: 95vw; margin-bottom: 15px; }
  .flashcard { width: 100%; height: 375px; }
  .front, .back { max-height: 375px; }
  .search-container {
    width: 95vw;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }
  .header {
    width: 95vw;
    margin: 15px auto;
  }
  .controls {
    width: 95vw;
    margin: 10px auto;
  }
  .choice { font-size: 13px; padding: 8px 10px; }
  .controls button { padding: 8px 16px; font-size: 14px; }
}

@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1366px) 
  and (-webkit-min-device-pixel-ratio: 1) {
  .number-list-left, .number-list-right { display: none; }
  .flashcard-container { width: 90vw; }
  .flashcard { width: 100%; height: 500px; }
  .front, .back { max-height: 500px; }
  .search-container { width: 90vw; }
  .header { width: 90vw; }
  .controls { width: 90vw; }
  .choice { font-size: 16px; padding: 12px 16px; }
  .controls button { padding: 12px 24px; font-size: 16px; }
}

.number-list-left { left: 10px; }
.number-list-right { right: 10px; }

.number-list-left button,
.number-list-right button {
  width: 30px;
  height: 30px;
  font-size: 12px;
  cursor: pointer;
  border: none;
  border-radius: 5px;
  background-color: #007bff;
  color: #fff;
  transition: background-color 0.2s;
}
.number-list-left button:hover,
.number-list-right button:hover {
  background-color: #0056b3;
}
.number-list-left button.active,
.number-list-right button.active {
  background-color: #dc3545;
  outline: 2px solid #fff;
}
.number-list-left button.mastered,
.number-list-right button.mastered {
  background-color: #28a745;
}
.number-list-left button.mastered:hover,
.number-list-right button.mastered:hover {
  background-color: #218838;
}

.header {
  width: 450px;
  max-width: 90vw;
  text-align: center;
  margin: 20px auto;
  font-size: 24px;
  font-weight: bold;
}

.search-container {
  width: 450px;
  max-width: 90vw;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}
#search-bar {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
}

.flashcard-container {
  width: 450px;
  max-width: 90vw;
  perspective: 1000px;
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.flashcard {
  width: 100%;
  height: 400px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

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

.front, .back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-height: 400px;
  backface-visibility: hidden;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  background: #fff;
  padding: 14px;
}

.back {
  transform: rotateY(180deg);
  display: block;
  font-size: 16px;
  font-weight: normal;
  text-align: left;
  line-height: 1.4;
}

body.dark-mode .front, body.dark-mode .back {
  background: #2c2c2c;
  color: #fff;
}

body.dark-mode .front .choice {
  background: #4a4a4a;
  color: #fff;
  border-color: #666;
}

body.dark-mode .front .choice:hover {
  background: #555;
  border-color: #0056b3;
}

body.dark-mode .front .choice.correct {
  background: #218838;
  border-color: #218838;
  color: #fff;
}

body.dark-mode .front .choice.wrong {
  background: #c82333;
  border-color: #c82333;
  color: #fff;
}

body.dark-mode .back .choice {
  background: #4a4a4a;
  color: #fff;
  border-color: #666;
}

body.dark-mode .back .choice.correct {
  background: #218838;
  border-color: #218838;
  color: #fff;
}

body.dark-mode .back .choice.wrong {
  background: #c82333;
  border-color: #c82333;
  color: #fff;
}

.front .number {
  font-size: 24px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 8px;
}

.front .question-text {
  font-size: 16px;
  font-weight: normal;
  text-align: left;
  line-height: 1.4;
  margin-bottom: 12px;
}

.choice {
  padding: 10px 14px;
  margin: 6px 0;
  border: 2px solid #007bff;
  border-radius: 8px;
  cursor: pointer;
  background-color: #fff;
  font-size: 14px;
  transition: all 0.3s ease;
  user-select: none;
}
.choice:hover {
  background-color: #e6f0ff;
  border-color: #0056b3;
}
.choice.correct {
  background-color: #28a745;
  color: #fff;
  border-color: #28a745;
}
.choice.wrong {
  background-color: #dc3545;
  color: #fff;
  border-color: #dc3545;
  animation: pulseWrong 0.5s ease-in-out 2;
}
@keyframes pulseWrong {
  0%, 100% { background-color: #dc3545; }
  50% { background-color: #ff4d4d; }
}

.controls {
  width: 450px;
  max-width: 90vw;
  margin: 10px auto;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.controls button {
  padding: 10px 20px;
  font-size: 16px;
  border: none;
  border-radius: 5px;
  background: #007bff;
  color: #fff;
  cursor: pointer;
}
.controls button:hover { background: #0056b3; }

.question-select {
  width: 450px;
  max-width: 90vw;
  display: flex;
  justify-content: center;
  margin: 10px auto;
}
.question-select select {
  width: 100%;
  max-width: 300px;
  padding: 10px;
  font-size: 16px;
  border-radius: 5px;
}

.donate-form {
  width: 450px;
  max-width: 90vw;
  display: flex;
  justify-content: center;
  margin: 10px auto;
}
.donate-form form {
  display: inline-block;
}

.footer {
  width: 450px;
  max-width: 90vw;
  text-align: center;
  margin: 10px auto;
}

#hover-preview {
  position: fixed;
  z-index: 9999;
  padding: 12px 18px;
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  white-space: pre-wrap;
  line-height: 1.3;
  font-size: 14px;
  color: #111;
  pointer-events: none;
  max-width: 400px;
}
body.dark-mode #hover-preview {
  background: rgba(35,35,35,0.98);
  color: #fff;
  border-color: rgba(255,255,255,0.15);
}

@media only screen and (max-device-width: 480px) {
  .flashcard-container { width: 95vw; }
  .flashcard { width: 100%; height: 350px; }
  .front, .back { max-height: 350px; }
  .search-container { width: 95vw; }
  .header { width: 95vw; }
  .controls { width: 95vw; }
  .choice { font-size: 12px; padding: 6px 8px; }
  .controls button { padding: 6px 12px; font-size: 12px; }
}