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

:root {
  --bg: #ffffff;
  --bg2: #f5f5f2;
  --bg3: #eeecea;
  --text: #1a1a18;
  --text2: #6b6b67;
  --text3: #9b9b97;
  --border: rgba(0, 0, 0, 0.12);
  --border2: rgba(0, 0, 0, 0.22);
  --radius-md: 8px;
  --radius-lg: 12px;
  --green: #1D9E75;
  --green-dark: #0F6E56;
  --green-light: #E1F5EE;
  --coral: #D85A30;
  --coral-light: #FAECE7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e1c;
    --bg2: #2a2a28;
    --bg3: #333330;
    --text: #f0ede8;
    --text2: #a0a09c;
    --text3: #6b6b67;
    --border: rgba(255, 255, 255, 0.12);
    --border2: rgba(255, 255, 255, 0.22);
    --green-light: #0a3326;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg3);
  color: var(--text);
  min-height: 100vh;
  padding: 2rem 1rem;
}

.app {
  max-width: 600px;
  margin: 0 auto;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 26px;
  font-weight: 500;
  margin-bottom: 6px;
}

.header p {
  font-size: 14px;
  color: var(--text2);
}

.category-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.cat-btn {
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 20px;
  border: 0.5px solid var(--border2);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.cat-btn:hover {
  background: var(--bg2);
}

.cat-btn.active {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green-dark);
  font-weight: 500;
}

.progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg2);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--text2);
  min-width: 48px;
  text-align: right;
}

.scene {
  perspective: 1000px;
  width: 100%;
  max-width: 480px;
  height: 280px;
  margin: 0 auto 1rem;
  cursor: pointer;
}

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

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

.face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background: var(--bg);
}

.face.back {
  transform: rotateY(180deg);
  background: var(--green-light);
}

.face-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 12px;
  text-transform: uppercase;
}

.face-word {
  font-size: 34px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.2;
}

.face.back .face-word {
  color: var(--green-dark);
}

.face-hint {
  font-size: 13px;
  color: var(--text2);
}

.face.back .face-hint {
  color: var(--green);
}

.flip-hint {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 1.5rem;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
}

.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 1rem;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border2);
  background: var(--bg);
  color: var(--text);
  transition: background 0.15s, transform 0.1s;
}

button:hover {
  background: var(--bg2);
}

button:active {
  transform: scale(0.98);
}

button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

button.primary:hover {
  background: var(--green-dark);
}

button.danger {
  border-color: var(--coral);
  color: var(--coral);
}

button.danger:hover {
  background: var(--coral-light);
}

button.success {
  border-color: var(--green);
  color: var(--green);
}

button.success:hover {
  background: var(--green-light);
}

.result-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
}

.stat-n {
  font-size: 24px;
  font-weight: 500;
}

.stat-l {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}

.complete-banner {
  background: var(--green-light);
  border: 0.5px solid var(--green);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
  display: none;
}

.complete-banner h2 {
  font-size: 20px;
  font-weight: 500;
  color: var(--green-dark);
  margin-bottom: 6px;
}

.complete-banner p {
  font-size: 13px;
  color: var(--green);
}
