:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #ffffff;
  --accent: #6366f1;
  --accent2: #8b5cf6;
  --text: #1e293b;
  --muted: #64748b;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg), var(--bg2));
  color: #e2e8f0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}
header { text-align: center; margin-bottom: 18px; }
h1 { font-size: 1.5rem; font-weight: 700; }
h1 span { color: #a5b4fc; }
.subtitle { color: #94a3b8; font-size: 0.85rem; margin-top: 4px; }

.controls {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin-bottom: 16px; max-width: 760px;
}
.chip {
  background: var(--bg2); border: 1px solid #334155; color: #cbd5e1;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 0.82rem;
  transition: all .15s; user-select: none;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.filter-section {
  flex-basis: 100%; text-align: center; color: #64748b;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 1.5px;
  font-weight: 700; margin: 8px 0 2px;
}

.stats {
  display: flex; gap: 16px; justify-content: center; margin-bottom: 14px;
  font-size: 0.82rem; color: #94a3b8;
}
.stats b { color: #e2e8f0; }

.scene { width: min(760px, 100%); perspective: 1600px; }
.card {
  position: relative; width: 100%; min-height: 380px;
  transform-style: preserve-3d; transition: transform .5s;
  cursor: pointer;
}
.card.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 18px; padding: 32px; display: flex; flex-direction: column;
  background: var(--card); color: var(--text);
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  overflow-y: auto;
}
.face.back { transform: rotateY(180deg); background: #f8fafc; }
.face-label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px;
  font-weight: 700; margin-bottom: 12px;
}
.front .face-label { color: var(--accent); }
.back .face-label { color: var(--accent2); }
.topic-tag {
  align-self: flex-start; font-size: 0.68rem; font-weight: 600;
  padding: 3px 10px; border-radius: 6px; margin-bottom: 14px;
}
.tag-os { background: #ede9fe; color: #6d28d9; }
.tag-fs { background: #dbeafe; color: #1d4ed8; }
.tag-reg { background: #dcfce7; color: #15803d; }
.tag-dec { background: #fef3c7; color: #b45309; }
.tag-cmp { background: #fee2e2; color: #b91c1c; }
.tag-arch { background: #cffafe; color: #0e7490; }
.tag-lin { background: #e0e7ff; color: #3730a3; }
.tag-ana { background: #fae8ff; color: #86198f; }
.tag-stat { background: #ccfbf1; color: #0f766e; }
.tag-graph { background: #fef9c3; color: #854d0e; }
.tag-galg { background: #ffedd5; color: #9a3412; }
.tag-tree { background: #ecfccb; color: #3f6212; }
.tag-alg { background: #e0f2fe; color: #075985; }
.tag-fun { background: #fce7f3; color: #9d174d; }
.tag-oop { background: #f3e8ff; color: #6b21a8; }
.tag-low { background: #ffe4e6; color: #9f1239; }
.tag-db { background: #d1fae5; color: #065f46; }
.tag-sql { background: #cffafe; color: #155e75; }
.tag-net { background: #fef08a; color: #713f12; }
.tag-netsec { background: #fed7aa; color: #7c2d12; }
.tag-sec { background: #fecaca; color: #7f1d1d; }
.tag-appsec { background: #ddd6fe; color: #5b21b6; }
.q-text { font-size: 1.3rem; font-weight: 650; line-height: 1.45; margin: auto 0; }
.a-text { font-size: 0.98rem; line-height: 1.6; }
.a-text ul { margin: 8px 0 8px 20px; }
.a-text li { margin-bottom: 5px; }
.a-text b { color: #4338ca; }
.a-text code {
  background: #e2e8f0; padding: 1px 6px; border-radius: 4px;
  font-size: 0.88em; font-family: "SF Mono", Consolas, monospace;
}
.hint { text-align: center; color: #64748b; font-size: 0.72rem; margin-top: 14px; }

.nav { display: flex; gap: 10px; margin-top: 20px; align-items: center; }
button.btn {
  background: var(--bg2); border: 1px solid #334155; color: #e2e8f0;
  padding: 11px 20px; border-radius: 12px; cursor: pointer; font-size: 0.9rem;
  font-weight: 600; transition: all .15s;
}
button.btn:hover { border-color: var(--accent); background: #283548; }
button.btn.primary { background: var(--accent); border-color: var(--accent); }
button.btn.primary:hover { background: #4f46e5; }
button.btn.known { color: var(--green); }
button.btn.again { color: var(--amber); }
.counter { font-size: 0.85rem; color: #94a3b8; min-width: 70px; text-align: center; }

.progress-bar {
  width: min(760px, 100%); height: 6px; background: var(--bg2);
  border-radius: 999px; margin-top: 18px; overflow: hidden;
}
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); width: 0; transition: width .3s; }
footer { margin-top: 22px; color: #475569; font-size: 0.72rem; text-align: center; }
kbd {
  background: #334155; padding: 1px 7px; border-radius: 5px; font-size: 0.72rem;
  border-bottom: 2px solid #1e293b;
}
