@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
  --primary-color: #6366f1;
  --secondary-color: #a855f7;
  --accent-color: #ec4899;
  --background-dark: #0f172a;
  --surface-dark: #1e293b;
  --text-light: #f8fafc;
  --text-dim: #94a3b8;
  --success: #22c55e;
  --error: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--background-dark);
  color: var(--text-light);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at top left, #1e1b4b, #0f172a);
  flex-direction: column;
}

.app-container {
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 3rem;
  width: 90%;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
  height: 620px;
}

.app-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.content-wrapper {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

header {
  margin-bottom: 2rem;
}

h1 {
  font-weight: 800;
  font-size: 1.5rem;
  background: linear-gradient(to right, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}

.score-board {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-weight: 600;
}

#score-value {
  color: var(--text-light);
}

.card-container {
  perspective: 1000px;
  margin-bottom: 2rem;
  height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.kana-display {
  font-size: 8rem;
  font-weight: 300;
  line-height: 1;
  text-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.kana-display.animate-pop {
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.input-group {
  position: relative;
  margin-bottom: 1.5rem;
}

input[type="text"] {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1rem;
  font-size: 1.25rem;
  color: var(--text-light);
  text-align: center;
  font-family: 'Outfit', sans-serif;
  transition: all 0.3s ease;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

input[type="text"]::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

.feedback-message {
  height: 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.feedback-message.visible {
  opacity: 1;
}

.feedback-message.correct {
  color: var(--success);
}

.feedback-message.incorrect {
  color: var(--error);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.mode-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-light);
}

.mode-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* Shake animation for incorrect answer */
.shake {
  animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}

/* Layout Updates */
.main-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
  max-width: 1000px;
}

/* Sidebar Styling */
.sidebar {
  width: auto;
  height: 420px;
  backdrop-filter: blur(10px);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  margin-top: 20px;
}

.stats-container {
  display: flex;
  gap: 1rem;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.stats-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.stats-panel h3 {
  margin: 0.5rem 0;
  text-align: center;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.5rem;
  font-size: 1.1rem;
}

.stats-list {
  overflow-y: auto;
  padding-right: 0.5rem;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  writing-mode: vertical-rl;
  align-content: start;
}

/* Custom Scrollbar for Sidebar */
.stats-list::-webkit-scrollbar {
  width: 6px;
}

.stats-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.stats-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.stats-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item:last-child {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-char {
  font-weight: bold;
  font-size: 1.2rem;
  width: auto;
  margin-bottom: 0.2rem;
  margin-right: 15px;
}

.stat-counts {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
  writing-mode: horizontal-tb;
  flex-direction: column;
}

.count-correct {
  color: #4ade80;
}

.count-incorrect {
  color: #f87171;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column-reverse;
    align-items: center;
  }

  .sidebar {
    width: 100%;
    max-width: 400px;
    max-height: 300px;
  }
}

/* Mode Toggle Button */
.mode-toggle-container {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    width: 350px;
    gap: 1rem;
}

.reverse-toggle-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  width: 100%;
}

.reverse-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-light);
}

/* Hint Display */
.hint-display {
  font-size: 1.5rem;
  color: var(--text-dim);
  margin-top: -1rem;
  margin-bottom: 1rem;
  height: 2rem;
  font-weight: 600;
  transition: opacity 0.3s ease;
}

.hidden {
  display: none;
}