:root {
  --main-font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --button-padding: 12px 24px;
  --button-margin: 10px;
  --button-radius: 5px;
  --controls-gap: 15px;
  --actions-gap: 15px;
}
* {
  box-sizing: border-box;
  font-family: var(--main-font);
}
body {
  background-color: #f8f9fa;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  padding: 20px;
  color: #333;
}

#welcome {
  text-align: center;
  background: white;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  max-width: 500px;
  border: 1px solid #e9ecef;
}

#welcome h1 {
  color: #495057;
  margin-bottom: 20px;
  font-size: 2.5rem;
  font-weight: 600;
}

.deck-form { margin-top: 10px; }
.welcome-instructions { margin-top: 20px; font-size: 0.9rem; color: #666; }

#card-container {
  display: none; /* hidden on welcome screen */
  width: 90vw;
  max-width: 600px;
  height: 350px;
  perspective: 1000px;
  margin: 20px 0;
  position: relative;
}

/* Navigation arrows */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border: 2px solid #dee2e6;
  border-radius: 50%;
  background: #ffffff;
  color: #495057;
  font-size: 1.8rem;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: all 0.2s ease;
  z-index: 20;
}

.nav-arrow:hover {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: translateY(-50%) scale(1.05);
}

.nav-arrow:active {
  transform: translateY(-50%) scale(0.95);
}

.nav-arrow.left {
  left: -30px;
}

.nav-arrow.right {
  right: -30px;
}

@media (max-width: 768px) {
  .nav-arrow.left {
    left: 10px;
  }
  .nav-arrow.right {
    right: 10px;
  }
}

.card {
  width: 100%;
  height: 100%;
  position: absolute;
  border-radius: 10px;
  cursor: pointer;
  display: none;
  transform-style: preserve-3d;
}

.card.active {
  display: block;
  animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-inner {
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.8s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
  position: relative;
}

.card.flipped .card-inner { transform: rotateY(-180deg); }

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  backface-visibility: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  font-size: 1.4rem;
  line-height: 1.6;
  overflow-y: auto;
  border: 1px solid #dee2e6;
}

.card-front { background-color: #ffffff; color: #333; }
.card-back { background-color: #f8f9fa; color: #333; transform: rotateY(180deg); }

.card-front .term { font-weight: bold; font-size: 1.6rem; color: #495057; }
.card-back .definition { font-size: 1.3rem; color: #6c757d; }

.progress {
  position: absolute;
  top: 15px;
  right: 15px;
  background: #e9ecef;
  padding: 8px 15px;
  border-radius: 5px;
  font-size: 0.9rem;
  color: #495057;
  font-weight: 600;
  z-index: 10;
  border: 1px solid #dee2e6;
}

/* Actions */
.actions {
  display: flex;
  justify-content: space-between;
  gap: var(--actions-gap);
  margin-top: 20px;
  max-width: 400px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}
.actions.show { opacity: 1; visibility: visible; }

/* Controls */
.controls {
  display: none; /* hidden on welcome screen */
  flex-direction: column;
  align-items: center;
  gap: var(--controls-gap);
  margin-top: 20px;
}

button {
  padding: var(--button-padding);
  border: 1px solid #dee2e6;
  border-radius: var(--button-radius);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  margin: var(--button-margin) 0;
  transition: all 0.2s ease;
  background-color: white;
  color: #495057;
  width: 220px;
  box-sizing: border-box;
}
button:hover { background-color: #f8f9fa; border-color: #adb5bd; }
button:active { background-color: #e9ecef; }

#start-btn, #restart-btn { background-color: #007bff; color: white; border-color: #007bff; }
#start-btn:hover, #restart-btn:hover { background-color: #0056b3; border-color: #0056b3; }

.nav-btn { background-color: #6c757d; color: white; border-color: #6c757d; }
.nav-btn:hover { background-color: #545b62; border-color: #545b62; }

.score-btn { 
  background-color: #28a745; 
  color: white; 
  border-color: #28a745; 
  position: relative;
}
.score-btn:hover { background-color: #218838; border-color: #218838; }

.miss-btn { 
  background-color: #dc3545; 
  color: white; 
  border-color: #dc3545;
  position: relative;
}
.miss-btn:hover { background-color: #c82333; border-color: #c82333; }

.score-counter, .miss-counter {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ffffff;
  color: #333;
  border: 2px solid currentColor;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
}

#result {
  text-align: center;
  background: white;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  max-width: 500px;
  display: none;
  border: 1px solid #e9ecef;
}

#result h2 { color: #495057; margin-bottom: 20px; font-size: 2rem; }

#score { font-size: 1.2rem; margin-bottom: 20px; line-height: 1.6; }

.keyboard-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 10px 20px;
  border-radius: 5px;
  font-size: 0.9rem;
  color: #495057;
  display: none;
  border: 1px solid #dee2e6;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.keyboard-hint.show { display: block; animation: fadeIn 0.5s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tip-text { font-size: 0.85rem; color: #6c757d; max-width: 600px; text-align: center; }

@media (max-width: 768px) {
  #card-container { width: 95vw; height: 300px; }
  .card-front .term { font-size: 1.3rem; }
  .card-back .definition { font-size: 1.1rem; }
  .controls { flex-direction: column; align-items: center; gap: var(--controls-gap); }
  button { width: 200px; }
}
