:root {
  --bg: #fff6e9;
  --bg2: #ffe3f1;
  --fg: #2b2440;
  --muted: #7a7191;
  --card: #fff;
  --border: #2b2440;
  --accent: #7c5cff;
  --accent-dark: #5a3de0;
  --good: #20b26b;
  --good-dark: #148a52;
  --bad: #ff5d6c;
  --bad-dark: #d33a49;
  --shadow: #2b2440;
  --blob1: #ffd166;
  --blob2: #9be7ff;
  --blob3: #ff9ecb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1830;
    --bg2: #261c3d;
    --fg: #f3efff;
    --muted: #a99fc7;
    --card: #2a2445;
    --border: #0d0a1a;
    --accent: #9b82ff;
    --accent-dark: #6f52e8;
    --good: #3ddc97;
    --good-dark: #22a971;
    --bad: #ff7b88;
    --bad-dark: #d9505e;
    --shadow: #0d0a1a;
    --blob1: #5b4a1f;
    --blob2: #1d4a5c;
    --blob3: #5c2447;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg), var(--bg2)) fixed;
  color: var(--fg);
  font: 17px/1.5 ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, sans-serif;
}

/* floating decoration behind everything */
body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(8px);
  animation: float 14s ease-in-out infinite alternate;
}
body::before { width: 260px; height: 260px; top: -60px; right: -60px; background: var(--blob1); }
body::after { width: 320px; height: 320px; bottom: -90px; left: -80px; background: var(--blob2); animation-delay: -6s; }
#app::before {
  content: "";
  position: fixed;
  z-index: -1;
  width: 140px; height: 140px; top: 45%; left: -50px;
  border-radius: 50%;
  background: var(--blob3);
  filter: blur(6px);
  animation: float 11s ease-in-out infinite alternate;
}
@keyframes float {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(-24px, 30px) scale(1.08); }
}

main { max-width: 640px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { margin: 0; font-size: 2em; letter-spacing: -0.5px; }
.tagline { margin: 4px 0 24px; color: var(--muted); }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: 0.9em; }
.error { color: var(--bad); font-weight: 600; }
.wiggle { display: inline-block; animation: wiggle 3s ease-in-out infinite; transform-origin: 70% 80%; }
@keyframes wiggle {
  0%, 80%, 100% { transform: rotate(0); }
  86% { transform: rotate(-14deg); }
  92% { transform: rotate(12deg); }
}

/* chunky buttons that press down */
button, .button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  box-shadow: 0 4px 0 var(--shadow);
  transition: transform 0.08s, box-shadow 0.08s;
}
button:hover, .button:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--shadow); }
button:active, .button:active { transform: translateY(4px); box-shadow: 0 0 0 var(--shadow); }
button.primary { background: var(--accent); color: #fff; }
button.good { background: var(--good); color: #fff; }
button.bad { background: var(--bad); color: #fff; }
button.link, label.link {
  border: 0; background: none; padding: 0; color: var(--accent); box-shadow: none;
  cursor: pointer; font-size: inherit; font-weight: 600;
}
button.link:hover, button.link:active { transform: none; box-shadow: none; text-decoration: underline; }
kbd { opacity: 0.7; font: 0.75em monospace; margin-left: 6px; }

/* deck list */
.decks { list-style: none; padding: 0; margin: 0 0 24px; }
.decks li { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.deck {
  --hue: 260;
  flex: 1; display: flex; align-items: center; gap: 16px;
  padding: 14px 16px; border-radius: 20px; text-decoration: none;
  background: var(--card); border: 2px solid var(--border); color: var(--fg);
  box-shadow: 0 5px 0 var(--shadow);
  transition: transform 0.12s, box-shadow 0.12s;
}
.deck:hover { transform: translateY(-3px) rotate(-0.4deg); box-shadow: 0 8px 0 var(--shadow); }
.deck:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--shadow); }
.deck .badge {
  flex: none; width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center; font-size: 30px;
  background: hsl(var(--hue) 90% 85%);
  border: 2px solid var(--border);
}
.deck .info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.deck .title { font-weight: 800; font-size: 1.1em; }
.counts { display: flex; gap: 12px; font-size: 0.85em; margin-top: 2px; }
.counts b { color: var(--muted); font-weight: 600; }
.counts b.on { color: var(--accent); font-weight: 800; }
.mastery { display: block; height: 8px; margin-top: 6px; border-radius: 99px; background: hsl(var(--hue) 40% 50% / 0.18); overflow: hidden; }
.mastery span { display: block; height: 100%; border-radius: 99px; background: hsl(var(--hue) 80% 55%); transition: width 0.4s; }
footer { margin-top: 32px; }

/* study */
.bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.bar a { font-weight: 700; text-decoration: none; }
.progress {
  height: 14px; border-radius: 99px; margin-bottom: 20px; overflow: hidden;
  background: var(--card); border: 2px solid var(--border);
}
.progress div {
  height: 100%; border-radius: 99px; transition: width 0.4s cubic-bezier(.3, 1.4, .5, 1);
  background: repeating-linear-gradient(45deg, var(--accent) 0 10px, var(--accent-dark) 10px 20px);
}
.streak {
  margin: -8px 0 12px; text-align: center; font-weight: 800; color: #ff8a1f;
  animation: pop 0.35s cubic-bezier(.3, 1.6, .5, 1);
}
.card {
  background: var(--card); border: 2px solid var(--border); border-radius: 24px;
  box-shadow: 0 8px 0 var(--shadow);
  padding: 24px; min-height: 180px;
  animation: slide-in 0.3s cubic-bezier(.3, 1.3, .5, 1);
  transition: background 0.2s;
}
.card.right { background: color-mix(in srgb, var(--good) 22%, var(--card)); animation: pop 0.35s; }
.card.wrong { background: color-mix(in srgb, var(--bad) 22%, var(--card)); animation: shake 0.4s; }
.card .q { font-size: 1.15em; font-weight: 600; }
.card .a { margin-top: 16px; padding-top: 16px; border-top: 3px dotted var(--muted); animation: fade-in 0.3s; }
.card p:first-child { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
.card img, .card svg { max-width: 100%; height: auto; }
.card code { background: hsl(260 60% 60% / 0.15); padding: 1px 6px; border-radius: 6px; }
.hint { color: var(--muted); font-size: 0.9em; }
.actions {
  display: flex; gap: 12px; margin-top: 20px; padding: 12px 0 14px;
  position: sticky; bottom: 0;
}
.actions button { flex: 1; padding: 14px; }
.done { text-align: center; padding: 32px 0; }
.big-emoji { font-size: 72px; line-height: 1; animation: pop 0.5s cubic-bezier(.3, 1.8, .5, 1); }
.done h2 { margin: 12px 0; }

@keyframes slide-in { from { opacity: 0; transform: translateX(28px) rotate(1.5deg); } }
@keyframes fade-in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* emoji rain on session end */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confetti span { position: absolute; top: -10vh; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(115vh) rotate(540deg); } }

/* tablets (iPad portrait 768-834px, landscape 1024-1194px) */
@media (min-width: 700px) {
  body { font-size: 20px; }
  main { max-width: 780px; padding: 40px 32px 80px; }
  .card { padding: 36px; min-height: 280px; }
  .card .q { font-size: 1.3em; }
  .bar { margin-bottom: 16px; }
  .deck { padding: 18px 22px; }
  .deck .badge { width: 64px; height: 64px; font-size: 34px; }
  button, .button { padding: 14px 24px; }
  .actions button { padding: 18px; font-size: 1.05em; }
}

/* touch devices have no keyboard: hide the shortcut hints */
@media (hover: none) {
  kbd { display: none; }
}

/* small text links need a finger-sized hit area on touch screens */
@media (pointer: coarse) {
  button.link, label.link { padding: 12px 8px; display: inline-block; }
  .bar a { padding: 10px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
