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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 50%, #2d1810 100%);
  color: #fff;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(255, 206, 0, 0.03) 1px,
    transparent 1px
  );
  background-size: 50px 50px;
  animation: backgroundScroll 20s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes backgroundScroll {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(50px, 50px);
  }
}

header {
  background: linear-gradient(135deg, #d00 0%, #ffce00 100%);
  padding: 40px 20px;
  text-align: center;
  border-radius: 25px;
  margin-bottom: 30px;
  box-shadow: 0 10px 40px rgba(221, 0, 0, 0.4);
  animation: slideDown 0.6s ease-out;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

header::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  animation: shine 3s infinite;
}

@keyframes shine {
  0% {
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) translateY(100%) rotate(45deg);
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

h1 {
  font-size: 2.8em;
  font-weight: bold;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 1;
}

main {
  max-width: 800px;
  margin: auto;
  position: relative;
  z-index: 1;
}

.controls,
.practice {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  padding: 35px;
  border-radius: 25px;
  margin-bottom: 20px;
  border: 2px solid rgba(255, 206, 0, 0.15);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.6s ease-out;
  transition: all 0.3s ease;
}

.controls:hover,
.practice:hover {
  border-color: rgba(255, 206, 0, 0.3);
  box-shadow: 0 15px 50px rgba(255, 206, 0, 0.15);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.control-group {
  margin-bottom: 25px;
  position: relative;
}

label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.95em;
  color: #ffce00;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

select,
input {
  width: 100%;
  padding: 18px 20px;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 206, 0, 0.3);
  border-radius: 15px;
  color: #fff;
  font-size: 1.1em;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

select:focus,
input:focus {
  outline: none;
  border-color: #ffce00;
  background: rgba(0, 0, 0, 0.7);
  box-shadow:
    0 0 25px rgba(255, 206, 0, 0.4),
    inset 0 2px 8px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

select:hover,
input:hover {
  border-color: rgba(255, 206, 0, 0.6);
  transform: translateY(-1px);
}

select {
  cursor: pointer;
}

button {
  width: 100%;
  padding: 20px;
  background: linear-gradient(135deg, #d00 0%, #a00 100%);
  border: none;
  border-radius: 15px;
  color: #fff;
  font-size: 1.3em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 6px 20px rgba(221, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition:
    width 0.6s,
    height 0.6s;
}

button:hover::before {
  width: 300px;
  height: 300px;
}

button:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 35px rgba(221, 0, 0, 0.7);
  background: linear-gradient(135deg, #ff0000 0%, #c00 100%);
}

button:active {
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(221, 0, 0, 0.5);
}

button span {
  position: relative;
  z-index: 1;
}

.practice {
  text-align: center;
}

#prompt {
  font-size: 2.8em;
  margin-bottom: 30px;
  padding: 40px;
  background: linear-gradient(
    135deg,
    rgba(221, 0, 0, 0.3) 0%,
    rgba(255, 206, 0, 0.3) 100%
  );
  border-radius: 20px;
  font-weight: bold;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 0.5s ease-out;
  border: 3px solid rgba(255, 206, 0, 0.4);
  box-shadow: 0 8px 30px rgba(255, 206, 0, 0.2);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

#prompt::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, #d00, #ffce00, #d00);
  border-radius: 20px;
  z-index: -1;
  filter: blur(10px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#prompt:hover::before {
  opacity: 0.5;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    opacity: 0;
  }
  50% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

#answer-input {
  margin-bottom: 25px;
  text-align: center;
  font-size: 1.4em;
  font-weight: 500;
}

#answer-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

#feedback {
  margin-top: 25px;
  font-size: 1.4em;
  font-weight: bold;
  min-height: 50px;
  padding: 20px;
  border-radius: 15px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#feedback.correct {
  background: linear-gradient(
    135deg,
    rgba(255, 206, 0, 0.3) 0%,
    rgba(255, 215, 0, 0.4) 100%
  );
  color: #ffce00;
  animation: correct 0.5s ease-out;
  box-shadow: 0 0 30px rgba(255, 206, 0, 0.5);
  border: 2px solid rgba(255, 206, 0, 0.6);
}

#feedback.incorrect {
  background: linear-gradient(
    135deg,
    rgba(221, 0, 0, 0.3) 0%,
    rgba(255, 0, 0, 0.4) 100%
  );
  color: #ff6b6b;
  animation: shake 0.5s ease-out;
  box-shadow: 0 0 30px rgba(221, 0, 0, 0.5);
  border: 2px solid rgba(221, 0, 0, 0.6);
}

@keyframes correct {
  0%,
  100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.05) rotate(2deg);
  }
  75% {
    transform: scale(1.05) rotate(-2deg);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-10px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(10px);
  }
}

.hidden {
  display: none;
}

.stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 25px;
  gap: 20px;
}

.stat-box {
  flex: 1;
  background: linear-gradient(
    135deg,
    rgba(255, 206, 0, 0.15) 0%,
    rgba(221, 0, 0, 0.15) 100%
  );
  padding: 20px;
  border-radius: 15px;
  text-align: center;
  border: 2px solid rgba(255, 206, 0, 0.3);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

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

.stat-box:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(255, 206, 0, 0.3);
  border-color: rgba(255, 206, 0, 0.6);
}

.stat-box:hover::before {
  left: 100%;
}

.stat-number {
  font-size: 2.5em;
  font-weight: bold;
  color: #ffce00;
  text-shadow: 0 3px 10px rgba(255, 206, 0, 0.5);
  transition: all 0.3s ease;
}

.stat-box:hover .stat-number {
  transform: scale(1.1);
}

.stat-label {
  font-size: 0.9em;
  color: #ccc;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 8px;
}

@media (max-width: 600px) {
  h1 {
    font-size: 2em;
  }

  #prompt {
    font-size: 2em;
    padding: 25px;
  }

  .controls,
  .practice {
    padding: 25px;
  }

  .stats {
    flex-direction: column;
    gap: 15px;
  }
}

/* Loading animation for categories */
@keyframes selectGlow {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(255, 206, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 206, 0, 0.6);
  }
}

select:focus {
  animation: selectGlow 2s infinite;
}

/* New Mode Styles */
.mode-section {
  transition: all 0.3s ease;
}

.mc-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-top: 25px;
}

.mc-option {
  background: linear-gradient(
    135deg,
    rgba(255, 206, 0, 0.2) 0%,
    rgba(221, 0, 0, 0.2) 100%
  );
  border: 2px solid rgba(255, 206, 0, 0.4);
  padding: 20px;
  border-radius: 15px;
  font-size: 1.2em;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mc-option:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(255, 206, 0, 0.4);
  border-color: rgba(255, 206, 0, 0.8);
}

.mc-option:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Matching Game Styles */
.matching-instructions {
  font-size: 1.3em;
  color: #ffce00;
  margin-bottom: 20px;
  text-align: center;
}

.matching-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-top: 20px;
}

.matching-card {
  background: linear-gradient(
    135deg,
    rgba(255, 206, 0, 0.15) 0%,
    rgba(221, 0, 0, 0.15) 100%
  );
  border: 2px solid rgba(255, 206, 0, 0.3);
  padding: 20px 10px;
  border-radius: 15px;
  font-size: 1.1em;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.matching-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(255, 206, 0, 0.4);
  border-color: rgba(255, 206, 0, 0.6);
}

.matching-card.selected {
  background: linear-gradient(
    135deg,
    rgba(255, 206, 0, 0.4) 0%,
    rgba(221, 0, 0, 0.4) 100%
  );
  border-color: rgba(255, 206, 0, 0.9);
  box-shadow: 0 0 30px rgba(255, 206, 0, 0.6);
  transform: scale(1.05);
}

.matching-card.matched {
  background: linear-gradient(
    135deg,
    rgba(0, 200, 0, 0.3) 0%,
    rgba(0, 150, 0, 0.4) 100%
  );
  border-color: rgba(0, 255, 0, 0.6);
  opacity: 0.7;
  cursor: default;
  animation: matchPulse 0.5s ease-out;
}

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

/* Context Example Styles */
.context-example {
  background: rgba(255, 206, 0, 0.1);
  border-left: 4px solid rgba(255, 206, 0, 0.6);
  padding: 15px 20px;
  margin: 20px 0;
  border-radius: 10px;
  font-size: 1em;
  color: #ccc;
  font-style: italic;
}

/* Online Status Indicator */
.online-status {
  margin-top: 15px;
  padding: 12px 20px;
  background: rgba(255, 206, 0, 0.1);
  border-radius: 10px;
  border: 1px solid rgba(255, 206, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95em;
  color: #ffce00;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffce00;
  animation: pulse 1.5s infinite;
}

.status-indicator.loading {
  animation: spin 1s linear infinite;
  background: transparent;
  border: 2px solid #ffce00;
  border-top-color: transparent;
}

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

/* SRS Info Box */
.srs-info {
  margin-top: 20px;
  padding: 15px 20px;
  background: rgba(0, 150, 255, 0.1);
  border-left: 4px solid rgba(0, 150, 255, 0.6);
  border-radius: 10px;
  font-size: 0.95em;
  color: #aaa;
}

.srs-info p {
  margin: 0;
}

/* Progress Section */
.progress-section {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  padding: 35px;
  border-radius: 25px;
  margin-top: 20px;
  border: 2px solid rgba(255, 206, 0, 0.15);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.progress-section h2 {
  color: #ffce00;
  margin-bottom: 25px;
  font-size: 1.8em;
  text-align: center;
}

#progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.progress-stat {
  background: linear-gradient(
    135deg,
    rgba(255, 206, 0, 0.1) 0%,
    rgba(221, 0, 0, 0.1) 100%
  );
  padding: 20px;
  border-radius: 15px;
  text-align: center;
  border: 2px solid rgba(255, 206, 0, 0.2);
}

.progress-stat .stat-label {
  display: block;
  font-size: 0.9em;
  color: #ccc;
  margin-bottom: 10px;
}

.progress-stat .stat-value {
  display: block;
  font-size: 2em;
  font-weight: bold;
  color: #ffce00;
}

#reset-progress-btn {
  background: linear-gradient(
    135deg,
    rgba(221, 0, 0, 0.5) 0%,
    rgba(150, 0, 0, 0.5) 100%
  );
  max-width: 300px;
  margin: 0 auto;
  display: block;
}

.secondary-btn {
  background: linear-gradient(
    135deg,
    rgba(100, 100, 100, 0.5) 0%,
    rgba(80, 80, 80, 0.5) 100%
  );
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 14px 28px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.3s ease;
  margin-top: 10px;
}

.secondary-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
}

/* SRS Info Box */
.srs-info {
  background: linear-gradient(
    135deg,
    rgba(255, 206, 0, 0.15) 0%,
    rgba(221, 0, 0, 0.15) 100%
  );
  border: 2px solid rgba(255, 206, 0, 0.3);
  border-radius: 15px;
  padding: 15px 20px;
  margin-bottom: 20px;
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.srs-info p {
  color: #ffce00;
  font-size: 0.95em;
  margin: 0;
}

.srs-info.hidden {
  display: none;
}

/* Context Example Display */
.context-example {
  background: rgba(255, 255, 255, 0.05);
  border-left: 4px solid rgba(255, 206, 0, 0.5);
  border-radius: 8px;
  padding: 12px 15px;
  margin: 15px 0;
  font-style: italic;
  color: #ddd;
  font-size: 0.9em;
  animation: fadeIn 0.4s ease;
}

.context-example.hidden {
  display: none;
}

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

/* Responsive adjustments for new features */
@media (max-width: 768px) {
  .mc-options {
    grid-template-columns: 1fr;
  }

  .matching-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .matching-card {
    min-height: 60px;
    font-size: 1em;
  }
}

@media (max-width: 480px) {
  .matching-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .matching-card {
    padding: 15px 8px;
    font-size: 0.9em;
    min-height: 50px;
  }
}

/* Topic input hint (online vocabulary mode) */
.topic-hint {
  margin-top: 10px;
  font-size: 0.85em;
  color: #aaa;
  font-style: italic;
}

/* Keep the idle online indicator hidden despite its flex layout. */
.online-status.hidden {
  display: none;
}
