/* ============ Tokens ============ */
:root {
  --primary: #2BB5A8;          /* focus: main buttons, progress, timer */
  --primary-strong: #229A8F;
  --primary-soft: #E3F5F3;
  --on-primary: #0E2A2C;
  --accent: #FFC94D;           /* happiness: streaks, rewards, finishes */
  --accent-2: #FF8A65;
  --accent-soft: #FFF5DC;

  --bg: #F7F9F8;
  --surface: #FFFFFF;
  --surface-2: #EEF3F2;
  --text: #2D3436;
  --muted: #66727A;
  --border: #E1E8E6;

  --good: #1F9D73; --good-soft: #E1F6EE;
  --bad: #E05A4F;  --bad-soft: #FDECEA;
  --warn: #B7791F; --warn-soft: #FFF5DC;
  --star: #FFB627;

  --shadow-sm: 0 1px 2px rgba(20, 33, 61, .05), 0 2px 8px rgba(20, 33, 61, .04);
  --shadow: 0 2px 4px rgba(20, 33, 61, .04), 0 10px 30px rgba(20, 33, 61, .07);
  --shadow-lg: 0 6px 12px rgba(20, 33, 61, .06), 0 24px 60px rgba(20, 33, 61, .12);
  --glow: 0 8px 24px rgba(43, 181, 168, .35);
  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --topbar-bg: rgba(247, 249, 248, .78);
  color-scheme: light;
}
[data-theme="dark"] {
  --primary: #2BB5A8;
  --primary-strong: #3FCBBE;
  --primary-soft: rgba(43, 181, 168, .16);
  --on-primary: #0B1A30;
  --accent-soft: rgba(255, 201, 77, .14);

  --bg: #14213D;
  --surface: #1B2A4A;
  --surface-2: #233457;
  --text: #E9EEF2;
  --muted: #9AA8BD;
  --border: #2C3E63;

  --good: #4CD3A0; --good-soft: rgba(76, 211, 160, .14);
  --bad: #FF7A6E;  --bad-soft: rgba(255, 122, 110, .14);
  --warn: #FFC94D; --warn-soft: rgba(255, 201, 77, .12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow: 0 2px 6px rgba(0, 0, 0, .18), 0 12px 32px rgba(0, 0, 0, .25);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, .25), 0 28px 64px rgba(0, 0, 0, .35);
  --glow: 0 8px 28px rgba(43, 181, 168, .3);
  --topbar-bg: rgba(20, 33, 61, .78);
  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); min-height: 100vh;
  font: 16px/1.55 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; transition: background .4s var(--ease), color .4s var(--ease);
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 .3em; line-height: 1.15; letter-spacing: -.02em; }
h1 { font-size: clamp(28px, 3.6vw, 40px); font-weight: 800; }
h2 { font-size: clamp(21px, 2.4vw, 26px); font-weight: 800; }
h3 { font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--primary-soft); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

/* Soft ambient color behind everything */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .45; animation: drift 26s ease-in-out infinite alternate; }
.b1 { width: 520px; height: 520px; background: var(--primary); top: -220px; left: -160px; opacity: .18; }
.b2 { width: 420px; height: 420px; background: var(--accent); top: 30%; right: -200px; opacity: .14; animation-duration: 32s; }
.b3 { width: 380px; height: 380px; background: var(--accent-2); bottom: -200px; left: 30%; opacity: .1; animation-duration: 38s; }
[data-theme="dark"] .b1 { opacity: .22; }
[data-theme="dark"] .b2, [data-theme="dark"] .b3 { opacity: .08; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.12); } }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 12px 28px; background: var(--topbar-bg); border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.logo {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #1F8F86); color: #fff; font-weight: 800;
  box-shadow: var(--glow); transition: transform .5s var(--spring);
}
.brand:hover .logo { transform: rotate(-8deg) scale(1.08); }
.search { flex: 1; max-width: 560px; position: relative; }
.search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 18px; }
.search input {
  width: 100%; padding: 10px 16px 10px 40px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); outline: none; transition: border-color .2s, box-shadow .2s;
}
.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.top-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.streak {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 14px;
  background: var(--accent-soft); color: #9A6B00; border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
}
[data-theme="dark"] .streak { color: var(--accent); }
.streak.bump { animation: bump .7s var(--spring); }
@keyframes bump { 40% { transform: scale(1.3) rotate(-6deg); } }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 700; font-size: 15px; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s, border-color .2s, color .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.btn:active { transform: translateY(0) scale(.97); }
.btn.primary { background: var(--primary); border-color: transparent; color: var(--on-primary); box-shadow: var(--glow); }
.btn.primary:hover { background: var(--primary-strong); box-shadow: 0 10px 30px rgba(43, 181, 168, .45); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn.small { padding: 7px 13px; font-size: 13.5px; border-radius: 10px; }
.btn.big { padding: 14px 28px; font-size: 17px; border-radius: 14px; }
.btn.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-strong); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: none; background: transparent; font-size: 17px; color: var(--muted);
  transition: background .2s, color .2s, transform .3s var(--spring);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); transform: scale(1.08); }
.icon-btn:active { transform: scale(.92); }
.icon-btn:disabled { opacity: .35; cursor: default; transform: none; }
.icon-btn.star.on { color: var(--star); }
.icon-btn.star.pop { animation: starPop .5s var(--spring); }
@keyframes starPop { 50% { transform: scale(1.4) rotate(15deg); } }
#themeBtn:hover { transform: rotate(180deg); }
.link { border: none; background: none; color: var(--primary-strong); font-weight: 700; padding: 4px 0; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ============ Layout ============ */
.page { max-width: 1100px; margin: 0 auto; padding: 34px 28px 90px; }
.page.narrow, .page.study { max-width: 880px; }
#app.enter > .page { animation: pageIn .5s var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(14px); } }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; margin-top: 18px; }
.center { text-align: center; justify-content: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.back { display: inline-flex; gap: 6px; color: var(--muted); font-weight: 700; font-size: 14px; margin-bottom: 16px; transition: color .2s, transform .2s var(--ease); }
.back:hover { color: var(--primary-strong); transform: translateX(-3px); }
.good-t { color: var(--good); } .bad-t { color: var(--bad); } .warn-t { color: var(--warn); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); margin: 16px 0; }
.empty { text-align: center; padding: 70px 20px; }
.big-emoji { font-size: 56px; line-height: 1; margin-bottom: 12px; display: inline-block; animation: float 3.5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }

/* Staggered entrance for lists of cards */
.rise { animation: rise .55s var(--ease) both; animation-delay: calc(min(var(--i, 0), 14) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }

/* ============ Home ============ */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 34px 36px; margin-bottom: 26px;
  background: linear-gradient(135deg, #2BB5A8 0%, #1F8F86 55%, #14213D 140%); color: #fff; box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ""; position: absolute; width: 340px; height: 340px; right: -80px; top: -120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 201, 77, .55), transparent 65%); animation: drift 14s ease-in-out infinite alternate;
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { color: #fff; margin-bottom: 6px; }
.hero p { margin: 0; opacity: .9; font-size: 16px; max-width: 520px; }
.hero-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.hero-stat { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .2); border-radius: 14px; padding: 10px 16px; backdrop-filter: blur(6px); }
.hero-stat b { display: block; font-size: 22px; font-weight: 800; line-height: 1.2; }
.hero-stat span { font-size: 13px; opacity: .85; }
.hero-stat.fire b { color: var(--accent); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.hero .btn { background: rgba(255, 255, 255, .95); color: #14213D; border-color: transparent; }
.hero .btn.glass { background: rgba(255, 255, 255, .12); color: #fff; border: 1px solid rgba(255, 255, 255, .3); box-shadow: none; }
.hero .btn.glass:hover { background: rgba(255, 255, 255, .22); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-top: 16px; }
.set-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 20px; min-height: 168px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s;
}
.set-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--primary), var(--accent));
  transform: scaleX(0); transform-origin: left; transition: transform .45s var(--ease);
}
.set-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.set-card:hover::before { transform: scaleX(1); }
.set-card h3 { font-size: 18px; margin: 0; }
.set-card p { margin: 0; font-size: 14px; flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.set-card .meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); font-weight: 600; }
.pill { align-self: flex-start; font-size: 12.5px; font-weight: 700; padding: 3px 11px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-strong); }
[data-theme="dark"] .pill { color: var(--primary); }
.mastery { height: 7px; border-radius: 7px; background: var(--surface-2); overflow: hidden; }
.mastery > div { height: 100%; border-radius: 7px; background: linear-gradient(90deg, var(--primary), #5FD3C7); transition: width 1s var(--ease); }

/* ============ Editor ============ */
.field {
  width: 100%; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); outline: none; margin-bottom: 12px; resize: vertical; transition: border-color .2s, box-shadow .2s;
}
.field:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.field.big { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.field.tiny { width: 90px; padding: 5px 9px; margin: 0; }
.field.mono { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.toolbar { margin: 4px 0 8px; flex-wrap: wrap; }
.import-opts { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 12px; }
.import-opts fieldset { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.import-opts legend { font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.import-opts label { display: flex; align-items: center; gap: 6px; }
.import-opts input[type=radio] { accent-color: var(--primary); }
.rows { list-style: none; padding: 0; margin: 18px 0; display: flex; flex-direction: column; gap: 14px; }
.row-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); animation: rise .4s var(--ease) both; transition: border-color .2s, box-shadow .2s; }
.row-card:focus-within { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); box-shadow: var(--shadow); }
.row-top { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px 6px 20px; border-bottom: 1px solid var(--border); }
.num { font-weight: 800; color: var(--muted); font-size: 14px; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; padding: 16px 20px 18px; }
.row-fields label { display: flex; flex-direction: column; }
.row-fields textarea {
  border: none; border-bottom: 2px solid var(--border); background: transparent; resize: none;
  padding: 6px 0; outline: none; overflow: hidden; min-height: 36px; transition: border-color .25s;
}
.row-fields textarea:focus { border-bottom-color: var(--primary); }
.row-fields span { font-size: 11.5px; font-weight: 800; letter-spacing: .08em; color: var(--muted); margin-top: 7px; }
.add-row {
  width: 100%; padding: 24px; border-radius: var(--radius); border: 2px dashed var(--border);
  background: transparent; font-weight: 800; color: var(--muted); transition: all .25s var(--ease);
}
.add-row:hover { border-color: var(--primary); color: var(--primary-strong); background: var(--primary-soft); transform: translateY(-2px); }

/* ============ Set page ============ */
.modes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin: 14px 0 22px; }
.mode-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 18px; font-weight: 800;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s;
}
.mode-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.mode-icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; font-size: 22px;
  background: var(--primary-soft); transition: transform .4s var(--spring);
}
.mode-tile:hover .mode-icon { transform: scale(1.12) rotate(-6deg); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.stats { display: flex; gap: 28px; flex-wrap: wrap; align-items: center; }
.stats b { font-size: 26px; display: block; font-weight: 800; letter-spacing: -.02em; }
.switch { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; cursor: pointer; font-size: 14px; }
.switch input {
  appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border);
  position: relative; cursor: pointer; transition: background .25s; flex: none; margin: 0;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .3s var(--spring);
}
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:disabled { opacity: .45; cursor: default; }
.term-group h3 { margin: 30px 0 12px; font-size: 18px; }
.term-group h3 small { color: var(--muted); font-weight: 500; }
.term-row {
  display: grid; grid-template-columns: 1fr 2fr auto; gap: 18px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 15px 10px 15px 20px; margin-bottom: 9px;
  transition: transform .25s var(--ease), box-shadow .25s, border-color .25s;
}
.term-row:hover { transform: translateX(3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.term-row .t { font-weight: 700; border-right: 1px solid var(--border); padding-right: 18px; }
.term-row .t, .term-row .d { white-space: pre-wrap; word-break: break-word; }
.term-row .tools { display: flex; }

/* ============ Study chrome ============ */
.study-head { margin-bottom: 20px; }
.mode-switch { display: inline-flex; gap: 4px; flex-wrap: wrap; padding: 5px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.mode-switch a { padding: 8px 15px; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--muted); transition: background .25s, color .25s; }
.mode-switch a:hover { color: var(--text); background: var(--surface-2); }
.mode-switch a.active { background: var(--primary); color: var(--on-primary); box-shadow: var(--glow); }
.opts-bar { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.opts-bar select, .fc-options select, .setup-grid select, .setup-grid input[type=number] {
  padding: 7px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-weight: 600;
}

.progress { position: relative; height: 10px; border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.progress > div {
  position: relative; height: 100%; width: 0; border-radius: 10px; overflow: hidden;
  background: linear-gradient(90deg, var(--primary), #5FD3C7); transition: width .7s var(--ease);
}
.progress > div::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: translateX(-100%); animation: shimmer 2.2s ease-in-out infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.progress.thin { height: 5px; margin-top: 16px; }
.progress-label { font-size: 13px; color: var(--muted); margin: 8px 0 18px; font-weight: 600; }

/* ============ Flashcards ============ */
.flashcard { position: relative; height: min(52vh, 420px); perspective: 1800px; cursor: pointer; outline: none; user-select: none; }
.flashcard .face {
  position: absolute; inset: 0; display: flex; flex-direction: column; padding: 16px 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 26px; box-shadow: var(--shadow-lg);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .7s var(--spring);
}
.flashcard .back { transform: rotateX(180deg); background: linear-gradient(160deg, var(--surface), color-mix(in srgb, var(--primary) 7%, var(--surface))); }
.flashcard.flipped .front { transform: rotateX(-180deg); }
.flashcard.flipped .back { transform: rotateX(0deg); }
.flashcard:hover .face { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.flashcard:focus-visible .face { border-color: var(--primary); }
.flashcard.in-next { animation: slideNext .45s var(--ease); }
.flashcard.in-prev { animation: slidePrev .45s var(--ease); }
@keyframes slideNext { from { opacity: 0; transform: translateX(60px) rotate(2deg); } }
@keyframes slidePrev { from { opacity: 0; transform: translateX(-60px) rotate(-2deg); } }
.face-tools { display: flex; justify-content: space-between; align-items: center; }
.label { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.face-text {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: clamp(22px, 3.6vw, 36px); font-weight: 600; letter-spacing: -.01em; overflow: auto; padding: 10px; word-break: break-word;
}
.hint { text-align: center; font-size: 13px; color: var(--muted); }
.fc-controls { display: flex; justify-content: center; align-items: center; gap: 30px; margin-top: 22px; }
.round {
  width: 58px; height: 58px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface);
  font-size: 22px; font-weight: 800; display: grid; place-items: center; box-shadow: var(--shadow-sm);
  transition: transform .3s var(--spring), border-color .2s, color .2s, box-shadow .2s;
}
.round:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-strong); transform: scale(1.1); box-shadow: var(--shadow); }
.round:active:not(:disabled) { transform: scale(.92); }
.round:disabled { opacity: .4; cursor: default; }
.round.good { color: var(--good); border-color: var(--good); }
.round.good:hover { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.round.bad { color: var(--bad); border-color: var(--bad); }
.round.bad:hover { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.count { font-weight: 800; min-width: 74px; text-align: center; font-variant-numeric: tabular-nums; }
.fc-options { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; align-items: center; margin: 24px 0 10px; font-size: 14px; font-weight: 600; }
.track-counts { display: flex; justify-content: space-between; font-weight: 800; margin-bottom: 12px; font-size: 14px; }
.track-counts span { padding: 4px 13px; border-radius: 999px; }
.track-counts .bad { color: var(--bad); background: var(--bad-soft); }
.track-counts .good { color: var(--good); background: var(--good-soft); }

/* ============ Questions (Learn / Write) ============ */
.qcard { background: var(--surface); border: 1px solid var(--border); border-radius: 26px; box-shadow: var(--shadow-lg); padding: 28px 32px; animation: qIn .45s var(--ease) both; }
@keyframes qIn { from { opacity: 0; transform: translateY(16px) scale(.985); } }
.qcard.center { text-align: center; }
.qcard.center .row { justify-content: center; }
.qcard.celebrate { background: linear-gradient(160deg, var(--surface), var(--accent-soft)); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.qlabel { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.qprompt { font-size: clamp(22px, 3.2vw, 30px); font-weight: 700; letter-spacing: -.015em; margin: 8px 0 28px; word-break: break-word; }
.qprompt.sm { font-size: 18px; font-weight: 600; margin: 4px 0 0; }
.qsub { display: block; font-weight: 700; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 15px 17px; min-height: 62px;
  border-radius: 14px; border: 2px solid var(--border); background: var(--surface); word-break: break-word; font-weight: 600;
  animation: rise .4s var(--ease) both; transition: border-color .2s, transform .25s var(--ease), box-shadow .25s, background .2s;
}
.choice:nth-child(2) { animation-delay: 50ms; } .choice:nth-child(3) { animation-delay: 100ms; } .choice:nth-child(4) { animation-delay: 150ms; }
.choice:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.choice:disabled { cursor: default; }
.choice .key { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--surface-2); font-size: 13px; font-weight: 800; color: var(--muted); }
.choice.correct { border-color: var(--good); background: var(--good-soft); animation: pop .5s var(--spring); }
.choice.correct .key { background: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake .4s; }
.choice:disabled:not(.correct):not(.wrong) { opacity: .5; }
@keyframes pop { 40% { transform: scale(1.04); } }
.qfoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; min-height: 44px; }
.fb { font-weight: 800; animation: rise .35s var(--ease) both; }
.wform .field { font-size: 18px; }
.fb-card { border-radius: 14px; padding: 15px 17px; margin-top: 14px; border: 2px solid; animation: rise .35s var(--ease) both; }
.fb-card.good { border-color: var(--good); background: var(--good-soft); animation: pop .5s var(--spring); }
.fb-card.bad { border-color: var(--bad); background: var(--bad-soft); }
.fb-card.warn { border-color: var(--accent); background: var(--accent-soft); }
.fb-card > b { display: block; margin-bottom: 8px; }
.kv { margin-top: 8px; }
.kv span { display: block; font-size: 11.5px; font-weight: 800; text-transform: uppercase; color: var(--muted); letter-spacing: .08em; }
.strike { text-decoration: line-through; }
.round-list { list-style: none; padding: 0; margin: 20px auto; max-width: 580px; text-align: left; }
.round-list li { display: grid; grid-template-columns: 18px 1fr 1.4fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); animation: rise .4s var(--ease) both; }

/* ============ Test ============ */
.test-score { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; animation: qIn .5s var(--ease) both; }
.score-ring {
  width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 800;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-2) 0); position: relative;
  animation: pop .8s var(--spring);
}
.score-ring span { position: relative; z-index: 1; }
.score-ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.section-title { margin: 32px 0 12px; font-size: 18px; }
.tq { position: relative; background: var(--surface); border: 2px solid var(--border); border-radius: 18px; padding: 20px 24px; margin-bottom: 12px; transition: border-color .3s, box-shadow .3s; }
.tq:focus-within { box-shadow: var(--shadow); }
.tq.right { border-color: var(--good); }
.tq.wrongq { border-color: var(--bad); }
.tq-num { position: absolute; top: 16px; right: 20px; font-size: 13px; color: var(--muted); font-weight: 800; }
.tf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 14px; }
.opts { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.opts.inline { flex-direction: row; gap: 10px; }
.opt { display: flex; align-items: center; gap: 10px; padding: 11px 15px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font-weight: 600; transition: border-color .2s, background .2s; }
.opt:hover { border-color: var(--primary); }
.opt input { accent-color: var(--primary); }
.opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.reveal { font-weight: 600; margin-top: 10px; animation: rise .35s var(--ease) both; }
.reveal:empty { display: none; }
.match-q { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.match-q .mrow { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border); }
.match-q .mrow.right select { border-color: var(--good); }
.match-q .mrow.wrongq select { border-color: var(--bad); }
.match-q select { padding: 6px; border-radius: 9px; border: 2px solid var(--border); background: var(--surface); min-width: 64px; font-weight: 700; }
.match-q .mrow .reveal { margin: 4px 0 0; font-size: 14px; }
.match-q ol { margin: 0; padding-left: 0; list-style: none; }
.match-q .ans li { padding: 9px 0; border-bottom: 1px solid var(--border); }
.match-q .letter { font-weight: 800; color: var(--primary-strong); margin-right: 8px; }
details.panel summary { cursor: pointer; font-weight: 800; }
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 16px 0; }
.setup-grid label.f, label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; }

/* ============ Match ============ */
.match-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.timer {
  font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--primary-strong);
  padding: 4px 16px; border-radius: 14px; background: var(--primary-soft);
}
[data-theme="dark"] .timer { color: var(--primary); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; perspective: 1000px; }
.tile {
  min-height: 132px; padding: 12px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow-sm); font-size: 16px; font-weight: 600; word-break: break-word;
  transition: opacity .35s var(--ease), transform .35s var(--ease), border-color .15s, box-shadow .2s, background .2s;
}
.tiles.intro .tile { animation: tileIn .5s var(--spring) both; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes tileIn { from { opacity: 0; transform: rotateX(-50deg) translateY(16px) scale(.9); } }
.tile:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow); }
.tile.sel { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.03); box-shadow: var(--glow); }
.tile.bad { border-color: var(--bad); background: var(--bad-soft); animation: shake .4s; }
.tile.gone { opacity: 0; transform: scale(.6) rotate(6deg); pointer-events: none; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

/* ============ AI generation ============ */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; cursor: pointer;
  padding: 40px 20px; margin: 20px 0 4px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface);
  transition: border-color .25s, background .25s, transform .3s var(--ease), box-shadow .3s;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-2px); box-shadow: var(--shadow); }
.dropzone.over { transform: scale(1.01); }
.dropzone.has-file { border-style: solid; border-color: var(--primary); }
.dropzone .big-emoji { font-size: 44px; margin-bottom: 6px; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .88em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Celebration ============ */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i {
  position: absolute; top: -16px; width: 9px; height: 14px; border-radius: 2px; opacity: 0;
  animation: fall var(--d, 2.4s) cubic-bezier(.25, .6, .4, 1) var(--delay, 0s) forwards;
}
@keyframes fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--x, 0), 105vh) rotate(var(--r, 720deg)); }
}

/* ============ Toast ============ */
#toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 40px) scale(.95); opacity: 0; pointer-events: none;
  background: #14213D; color: #F7F9F8; padding: 12px 20px; border-radius: 14px; font-weight: 700; box-shadow: var(--shadow-lg);
  transition: opacity .3s var(--ease), transform .4s var(--spring); z-index: 70; max-width: calc(100% - 32px);
}
[data-theme="dark"] #toast { background: #F7F9F8; color: #14213D; }
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#toast.reward { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #3A2400; }

/* ============ Polish layer ============ */
:root { --primary-ink: #17786F; }
[data-theme="dark"] { --primary-ink: #5FD3C7; }
.pill, .link, .match-q .letter, .btn.on { color: var(--primary-ink); }
.back:hover { color: var(--primary-ink); }

/* Icons */
.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.icon-btn .ic { width: 19px; height: 19px; }
.icon-btn.star.on .ic { fill: currentColor; }
.round .ic { width: 22px; height: 22px; stroke-width: 2.4; }
.h-icon { display: inline-grid; place-items: center; width: 1.3em; height: 1.3em; border-radius: .35em; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; vertical-align: -.18em; margin-right: .2em; box-shadow: 0 8px 20px rgba(255, 138, 101, .35); }
.h-icon .ic { width: .75em; height: .75em; }
.drop-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--primary-soft); color: var(--primary-ink); margin-bottom: 8px; transition: transform .4s var(--spring); }
.drop-icon .ic { width: 30px; height: 30px; }
.dropzone:hover .drop-icon, .dropzone.over .drop-icon { transform: translateY(-4px) scale(1.06); }

/* Logo: two stacked cards */
.logo { position: relative; width: 34px; height: 34px; background: none; box-shadow: none; border-radius: 0; }
.logo i { position: absolute; width: 24px; height: 24px; border-radius: 7px; transition: transform .5s var(--spring); }
.logo i:first-child { left: 0; bottom: 0; background: #14213D; }
[data-theme="dark"] .logo i:first-child { background: #F7F9F8; opacity: .9; }
.logo i:last-child { right: 0; top: 0; background: linear-gradient(135deg, #3CCABD, var(--primary)); box-shadow: var(--glow); }
.brand:hover .logo { transform: none; }
.brand:hover .logo i:first-child { transform: translate(-2px, 2px) rotate(-8deg); }
.brand:hover .logo i:last-child { transform: translate(2px, -2px) rotate(8deg); }

/* Topbar extras */
.kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 600 12px/1 "Plus Jakarta Sans", sans-serif; color: var(--muted); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 3px 7px; background: var(--surface-2); }
.search input:focus ~ .kbd { opacity: 0; }
.search-icon { width: 17px; height: 17px; transform: translateY(-50%); }
.theme-sun { display: none; }
[data-theme="dark"] .theme-sun { display: block; }
[data-theme="dark"] .theme-moon { display: none; }
.streak .ic { width: 15px; height: 15px; fill: var(--accent); stroke: #E39A00; stroke-width: 1.5; }

/* ---------- Animated background ---------- */
.blob { filter: blur(90px); }
.b1 { animation: orbit1 28s ease-in-out infinite alternate; }
.b2 { animation: orbit2 34s ease-in-out infinite alternate; }
.b3 { animation: orbit3 40s ease-in-out infinite alternate; }
@keyframes orbit1 { 50% { transform: translate(18vw, 10vh) scale(1.15); } 100% { transform: translate(6vw, 30vh) scale(.95); } }
@keyframes orbit2 { 50% { transform: translate(-16vw, 12vh) scale(1.2); } 100% { transform: translate(-6vw, -14vh) scale(1); } }
@keyframes orbit3 { 50% { transform: translate(-14vw, -18vh) scale(1.1); } 100% { transform: translate(12vw, -6vh) scale(1.25); } }
.dots {
  position: absolute; inset: -40px;
  background-image: radial-gradient(color-mix(in srgb, var(--text) 16%, transparent) 1px, transparent 1.2px);
  background-size: 26px 26px; animation: pan 60s linear infinite;
  -webkit-mask-image: radial-gradient(ellipse 70% 55% at 50% 30%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 55% at 50% 30%, #000 20%, transparent 75%);
  opacity: .55;
}
[data-theme="dark"] .dots { opacity: .35; }
[data-theme="dark"] .floaters { opacity: .55; }
@keyframes pan { to { transform: translate(26px, 26px); } }
.floaters span {
  position: absolute; bottom: -120px; width: 74px; height: 50px; border-radius: 10px;
  border: 1.5px solid color-mix(in srgb, var(--primary) 30%, transparent);
  background: color-mix(in srgb, var(--surface) 35%, transparent);
  backdrop-filter: blur(2px); opacity: 0; animation: floatUp 30s linear infinite;
}
.floaters span:nth-child(1) { left: 6%;  animation-delay: 0s;  animation-duration: 34s; }
.floaters span:nth-child(2) { left: 20%; animation-delay: -12s; animation-duration: 40s; width: 56px; height: 38px; border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.floaters span:nth-child(3) { left: 38%; animation-delay: -24s; animation-duration: 46s; }
.floaters span:nth-child(4) { left: 57%; animation-delay: -6s;  animation-duration: 38s; width: 62px; height: 42px; border-color: color-mix(in srgb, var(--accent-2) 40%, transparent); }
.floaters span:nth-child(5) { left: 74%; animation-delay: -18s; animation-duration: 44s; }
.floaters span:nth-child(6) { left: 88%; animation-delay: -30s; animation-duration: 36s; width: 50px; height: 34px; border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.floaters span:nth-child(7) { left: 48%; animation-delay: -36s; animation-duration: 52s; width: 84px; height: 56px; }
@keyframes floatUp {
  0% { transform: translateY(0) rotate(-8deg); opacity: 0; }
  10% { opacity: .55; }
  90% { opacity: .4; }
  100% { transform: translateY(-120vh) rotate(14deg); opacity: 0; }
}
/* Fine grain so gradients feel printed, not flat */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="dark"] body::after { mix-blend-mode: screen; opacity: .04; }

/* ---------- Hero ---------- */
.hero { background: linear-gradient(125deg, #2BB5A8 0%, #1E8E88 45%, #17506A 80%, #14213D 115%); }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 0; opacity: .5;
  background-image: radial-gradient(rgba(255, 255, 255, .22) 1px, transparent 1.3px); background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(110deg, transparent 30%, #000 75%); mask-image: linear-gradient(110deg, transparent 30%, #000 75%);
  animation: pan 30s linear infinite;
}
.hero-stat { transition: transform .3s var(--ease), background .3s; }
.hero-stat:hover { transform: translateY(-3px); background: rgba(255, 255, 255, .2); }
.hero-stat b { display: flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.hero-stat b span { font-size: inherit; opacity: 1; }
.hero-stat.fire .ic { fill: var(--accent); stroke: #FFE29A; stroke-width: 1.4; animation: flicker 2.4s ease-in-out infinite; }
@keyframes flicker { 50% { transform: scale(1.12) rotate(-4deg); } }

/* ---------- Cursor glow on cards ---------- */
.spot { position: relative; }
.spot::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--primary) 16%, transparent), transparent 60%);
}
.spot:hover::after { opacity: 1; }

/* ---------- Set cards with covers ---------- */
.set-card { padding: 0 20px 20px; gap: 9px; min-height: 0; }
.set-card::before { display: none; }
.cover {
  position: relative; margin: 0 -20px 6px; height: 92px; overflow: hidden;
  background: linear-gradient(135deg, var(--c1), var(--c2));
}
.cover::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .28) 1px, transparent 1.3px); background-size: 16px 16px;
  -webkit-mask-image: linear-gradient(120deg, transparent 20%, #000 90%); mask-image: linear-gradient(120deg, transparent 20%, #000 90%);
}
.cover::after {
  content: ""; position: absolute; width: 120px; height: 80px; right: -18px; bottom: -34px; border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, .35); transform: rotate(-12deg); transition: transform .6s var(--spring);
}
.cover span {
  position: absolute; left: 18px; bottom: -16px; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px;
  background: var(--surface); color: var(--text); font-weight: 800; font-size: 22px; box-shadow: var(--shadow); transition: transform .5s var(--spring);
}
.set-card .pill { margin: 22px 0 0 auto; position: absolute; right: 16px; top: 104px; }
.set-card h3 { margin-top: 26px; }
.set-card:hover .cover::after { transform: rotate(4deg) translate(-12px, -6px); }
.set-card:hover .cover span { transform: translateY(-4px) rotate(-4deg); }

/* ---------- Mode tiles ---------- */
.mode-tile { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
.mode-tile b { display: block; font-size: 15.5px; }
.mode-tile small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.mode-icon { color: var(--primary-ink); background: var(--primary-soft); }
.mode-icon .ic { width: 22px; height: 22px; }
.mode-tile:hover .mode-icon { background: var(--primary); color: #fff; }
.modes { grid-template-columns: repeat(5, 1fr); }
.mode-switch a { display: inline-flex; align-items: center; gap: 7px; }
.mode-switch .ic { width: 16px; height: 16px; }

/* ---------- Misc polish ---------- */
.btn .ic { width: 17px; height: 17px; }
.btn.small .ic { width: 15px; height: 15px; }
.back .ic { width: 15px; height: 15px; transition: transform .25s var(--ease); }
.back:hover .ic { transform: translateX(-3px); }
.back:hover { transform: none; }
details.panel summary { display: flex; align-items: center; gap: 8px; list-style: none; }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .3s var(--ease); }
details.panel[open] summary::after { transform: rotate(225deg); }
.add-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.face-tools .icon-btn .ic { width: 18px; height: 18px; }
.flashcard .face::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 80% at 0% 0%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 55%);
}
.qcard { position: relative; }
.toolbar .btn, .actions .btn { backdrop-filter: blur(6px); }
.hide-sm { display: inline; }

/* ============ Feature styles ============ */
.modes { grid-template-columns: repeat(4, 1fr); }
.mode-switch { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.mode-switch::-webkit-scrollbar { display: none; }
.mode-switch a { white-space: nowrap; }

/* Segmented control */
.seg { display: inline-flex; padding: 4px; border-radius: 14px; background: var(--surface-2); gap: 4px; margin-bottom: 4px; }
.seg.center { display: flex; width: fit-content; margin: 14px auto; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--muted); transition: background .25s, color .25s, box-shadow .25s; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); }

/* Card images */
.card-img { display: block; max-width: 100%; max-height: 170px; margin: 0 auto 12px; border-radius: 12px; object-fit: contain; box-shadow: var(--shadow-sm); }
.face-text { flex-direction: column; }
.face-text .card-img { max-height: 55%; }
.thumb { display: block; width: 64px; height: 48px; object-fit: cover; border-radius: 8px; margin-bottom: 6px; }
.tile-img { display: block; max-width: 100%; max-height: 60px; margin: 0 auto 6px; border-radius: 8px; }
.field-wrap { display: flex; gap: 10px; align-items: flex-start; }
.field-wrap label { flex: 1; min-width: 0; }
.img-slot {
  flex: none; display: grid; place-items: center; width: 52px; height: 44px; border-radius: 10px; margin-top: 2px;
  border: 1.5px dashed var(--border); background: transparent; color: var(--muted); transition: all .2s var(--ease);
}
.img-slot:hover { border-color: var(--primary); color: var(--primary-ink); background: var(--primary-soft); }
.img-slot.has { position: relative; border: none; padding: 0; }
.img-slot.has img { width: 52px; height: 44px; object-fit: cover; border-radius: 10px; }
.img-x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: none; display: grid; place-items: center; background: var(--text); color: var(--bg); padding: 0; }
.img-x .ic { width: 11px; height: 11px; stroke-width: 3; }

/* AI helper */
.fc-ai { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.ai-help-box:empty { display: none; }
.ai-help {
  position: relative; margin-top: 14px; padding: 14px 16px 14px 18px; border-radius: 14px; text-align: left;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--surface)), color-mix(in srgb, var(--primary) 10%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); animation: rise .4s var(--ease) both;
}
.ai-help-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--warn); }
.ai-help p { margin: 6px 0 0; line-height: 1.6; }
.ai-help.error { color: var(--bad); background: var(--bad-soft); border-color: var(--bad); }
.ai-help.loading { display: grid; gap: 8px; }
.shimmer-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), color-mix(in srgb, var(--primary) 18%, var(--surface-2)), var(--surface-2)); background-size: 200% 100%; animation: shimmerBg 1.2s linear infinite; }
.shimmer-line.short { width: 60%; }
@keyframes shimmerBg { to { background-position: -200% 0; } }
.qfoot .row { flex-wrap: wrap; justify-content: flex-end; }

/* Steps (Quizlet import) */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; }
.steps li { counter-increment: s; position: relative; padding: 14px 16px 14px 56px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 12px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-weight: 800; font-size: 14px; }
.preview { margin-top: 12px; }
.preview .term-row { padding: 10px 12px; }

/* Review (spaced repetition) */
.badge { margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; background: var(--accent-soft); color: var(--warn); letter-spacing: .06em; }
.qlabel .icon-btn { margin-left: auto; }
.rv-answer { border-top: 1px dashed var(--border); padding-top: 16px; animation: rise .35s var(--ease) both; }
kbd { font: 700 11px/1 "Plus Jakarta Sans", sans-serif; padding: 3px 6px; border-radius: 6px; border: 1px solid currentColor; opacity: .55; margin-left: 6px; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rate-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border-radius: 14px; border: 2px solid var(--border);
  background: var(--surface); transition: transform .2s var(--spring), border-color .2s, background .2s; animation: rise .35s var(--ease) both;
}
.rate-btn:nth-child(2) { animation-delay: 40ms; } .rate-btn:nth-child(3) { animation-delay: 80ms; } .rate-btn:nth-child(4) { animation-delay: 120ms; }
.rate-btn:hover { transform: translateY(-3px); }
.rate-btn small { color: var(--muted); font-weight: 600; }
.rate-btn kbd { margin: 4px 0 0; }
.rate-btn.bad:hover { border-color: var(--bad); background: var(--bad-soft); }
.rate-btn.warn:hover { border-color: var(--accent); background: var(--accent-soft); }
.rate-btn.good:hover { border-color: var(--good); background: var(--good-soft); }
.rate-btn.easy:hover { border-color: var(--primary); background: var(--primary-soft); }

/* Gravity */
.gv-bar { display: flex; align-items: center; gap: 18px; margin-bottom: 12px; font-weight: 700; }
.gv-stat b { font-size: 20px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.gv-stat .ic { color: var(--accent-2); }
.gv-lives { margin-left: auto; display: flex; gap: 4px; }
.gv-lives span { color: var(--border); }
.gv-lives span.on { color: #FF6B6B; animation: pop .4s var(--spring); }
.gv-lives span.on .ic { fill: currentColor; }
.gv-field {
  position: relative; height: min(58vh, 480px); border-radius: 22px; overflow: hidden; border: 1px solid var(--border);
  background: radial-gradient(120% 90% at 50% 0%, #1B2A4A, #0B1326 70%); box-shadow: var(--shadow-lg);
}
.gv-field::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(1.5px 1.5px at 20% 30%, #fff8, transparent), radial-gradient(1px 1px at 70% 20%, #fff6, transparent), radial-gradient(1.5px 1.5px at 40% 70%, #fff5, transparent), radial-gradient(1px 1px at 85% 60%, #fff7, transparent), radial-gradient(1px 1px at 10% 85%, #fff5, transparent);
  background-size: 300px 300px; animation: pan 40s linear infinite;
}
.gv-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; background: linear-gradient(90deg, var(--primary), var(--accent), var(--accent-2)); opacity: .85; }
.gv-field.shake { animation: shake .45s; }
.meteor {
  position: absolute; top: 0; max-width: 34%; padding: 12px 16px; border-radius: 16px; color: #fff; font-weight: 700; text-align: center;
  background: linear-gradient(135deg, #2BB5A8, #1F6F8B); box-shadow: 0 0 0 1px #ffffff22, 0 10px 30px rgba(43, 181, 168, .45);
  will-change: transform;
}
.meteor::before { content: ""; position: absolute; left: 50%; bottom: 100%; width: 3px; height: 60px; transform: translateX(-50%); background: linear-gradient(transparent, #5FD3C7aa); border-radius: 3px; }
.meteor.danger { background: linear-gradient(135deg, #FF8A65, #E8577A); box-shadow: 0 0 0 1px #ffffff22, 0 10px 30px rgba(255, 138, 101, .55); }
.meteor.boom { animation: boom .45s var(--ease) forwards; }
.meteor.crash { background: #E05A4F; }
@keyframes boom { to { transform: scale(1.8); opacity: 0; filter: blur(4px); } }
.gv-form { margin-top: 14px; }
.gv-form .field { font-size: 19px; text-align: center; margin: 0; }
.field.nope { animation: shake .4s; border-color: var(--bad); }

/* Live game */
.live-hero { max-width: 560px; margin: 0 auto; }
.live-lobby { display: grid; gap: 18px; }
.live-code-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 30px; border-radius: 26px; color: #fff; text-align: center;
  background: linear-gradient(125deg, #2BB5A8, #17506A 70%, #14213D); box-shadow: var(--shadow-lg);
}
.live-code-card .muted { color: #ffffffcc; }
.live-code { font-size: clamp(54px, 10vw, 96px); font-weight: 800; letter-spacing: .08em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.btn.glass-dark { background: #ffffff1f; color: #fff; border-color: #ffffff40; box-shadow: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { padding: 7px 14px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; }
.pop-in { animation: pop .5s var(--spring); }
.live-q { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
label.f { min-width: 0; max-width: 100%; }
label.f select, label.f input { max-width: 100%; }
.live-top { display: flex; justify-content: space-between; font-weight: 700; }
.answered { color: var(--primary-ink); }
.live-prompt { text-align: center; margin: 10px 0; font-size: clamp(26px, 4vw, 44px); }
.live-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.live-choice {
  display: flex; align-items: center; gap: 14px; padding: 22px 20px; min-height: 86px; border-radius: 16px; border: none; color: #fff;
  font-size: 19px; font-weight: 700; text-align: left; box-shadow: var(--shadow); transition: transform .2s var(--spring), opacity .3s, filter .3s;
}
.live-choice span { font-size: 22px; opacity: .9; }
.live-choice.c0 { background: #E05A4F; } .live-choice.c1 { background: #2F7FD8; } .live-choice.c2 { background: #E8A320; } .live-choice.c3 { background: #1F9D73; }
button.live-choice:hover:not(:disabled) { transform: scale(1.03); }
.live-choice.dim { opacity: .35; filter: grayscale(.5); }
.live-choice.right { outline: 4px solid #fff; box-shadow: 0 0 0 7px var(--good), var(--shadow-lg); animation: pop .6s var(--spring); }
.live-choices.player .live-choice { min-height: 120px; }
.timebar { height: 10px; border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.timebar > div { height: 100%; width: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--primary)); }
.lb { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.lb li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: var(--surface-2); }
.lb-rank { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-weight: 800; font-size: 13px; }
.lb li:nth-child(1) .lb-rank { background: var(--accent); color: #3A2400; }
.lb-name { flex: 1; font-weight: 700; }
.lb-plus { color: var(--good); font-weight: 800; font-size: 13px; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 26px 0 18px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 120px; animation: rise .6s var(--spring) both; }
.pod.p1 { animation-delay: .5s; } .pod.p2 { animation-delay: .25s; }
.pod-name { font-weight: 800; }
.pod-score { color: var(--muted); font-weight: 700; font-size: 14px; }
.pod-block { width: 100%; display: grid; place-items: center; color: #fff; font-size: 30px; font-weight: 800; border-radius: 14px 14px 4px 4px; }
.p1 .pod-block { height: 130px; background: linear-gradient(180deg, var(--accent), #E8A320); }
.p2 .pod-block { height: 96px; background: linear-gradient(180deg, #A8B4C4, #7B8A9E); }
.p3 .pod-block { height: 72px; background: linear-gradient(180deg, var(--accent-2), #D96A45); }
.player-top { display: flex; justify-content: space-between; padding: 10px 16px; margin-bottom: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-weight: 700; }
.player-top b { color: var(--primary-ink); }
.join-form { display: grid; gap: 10px; max-width: 340px; margin: 18px auto 0; }
.join-form .field { margin: 0; text-align: center; }
.code-input { font-size: 30px; font-weight: 800; letter-spacing: .15em; }
.dots-loader { display: flex; justify-content: center; gap: 6px; margin-top: 14px; }
.dots-loader i { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); animation: bounce 1.2s ease-in-out infinite; }
.dots-loader i:nth-child(2) { animation-delay: .15s; } .dots-loader i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 40% { transform: translateY(-8px); opacity: .6; } }

/* Account */
#accountBtn { position: relative; }
#accountBtn .avatar { width: 30px; height: 30px; font-size: 14px; }
#accountBtn[data-sync]::after { content: ""; position: absolute; right: 2px; bottom: 2px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--bg); }
#accountBtn[data-sync="ok"]::after, #accountBtn[data-sync="idle"]::after { background: var(--good); }
#accountBtn[data-sync="syncing"]::after { background: var(--accent); animation: bounce 1s infinite; }
#accountBtn[data-sync="error"]::after { background: var(--bad); }
#accountBtn[data-sync="off"]::after { display: none; }
.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--primary), #1F6F8B); }
.avatar.big { width: 64px; height: 64px; font-size: 28px; box-shadow: var(--glow); }
.account-card { max-width: 480px; margin: 0 auto; }
.acct-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.acct-head h2 { margin: 0; }
.acct-head p { margin: 2px 0 0; display: flex; align-items: center; gap: 6px; }
.auth-form { display: grid; gap: 12px; }
.auth-form .field { margin: 6px 0 0; }

/* Print */
.sheet { background: #fff; color: #222; margin: 0 auto 24px; box-shadow: var(--shadow); width: 100%; max-width: 820px; aspect-ratio: 8.5 / 11; padding: 4%; display: grid; }
.sheet.fold { grid-template-rows: repeat(var(--rows), 1fr); }
.fold-row { display: grid; grid-template-columns: 1fr 1fr; }
.sheet.grid2 { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(var(--rows), 1fr); }
.pcard { position: relative; border: 1px dashed #bbb; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10px 14px; font-size: 15px; overflow: hidden; }
.pcard.empty { border-color: #eee; }
.plabel { position: absolute; top: 6px; left: 8px; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: #999; }
.pimg { max-height: 55%; max-width: 90%; margin-bottom: 6px; }
@media print {
  @page { margin: 0.4in; }
  body { background: #fff; }
  body::after, .backdrop, .topbar, .no-print, #toast { display: none !important; }
  #app.enter > .page { animation: none; }
  .page { padding: 0; max-width: none; }
  .sheet { box-shadow: none; margin: 0; max-width: none; width: 100%; height: 100vh; aspect-ratio: auto; padding: 0; page-break-after: always; break-after: page; }
}

/* ============ Blocks ============ */
.bk-logo { display: grid; grid-template-columns: repeat(2, 26px); gap: 4px; justify-content: center; margin-bottom: 12px; }
.bk-logo i, .bk-cell.filled, .bk-piece i, .bk-float i {
  background: linear-gradient(145deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c) 55%, color-mix(in srgb, var(--c) 80%, #000));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), inset 0 -3px 0 rgba(0, 0, 0, .18), 0 2px 4px rgba(0, 0, 0, .15);
}
.bk-logo i { width: 26px; height: 26px; border-radius: 6px; animation: pop .6s var(--spring) both; }
.bk-logo i:nth-child(2) { animation-delay: .1s; } .bk-logo i:nth-child(3) { animation-delay: .2s; } .bk-logo i:nth-child(4) { animation-delay: .3s; }
.bk-top { display: flex; align-items: flex-end; justify-content: space-between; max-width: 440px; margin: 0 auto 12px; }
.bk-top > div { display: flex; flex-direction: column; }
.bk-top .right { align-items: flex-end; }
.bk-top b { font-size: 20px; font-variant-numeric: tabular-nums; }
.bk-score { font-size: 36px !important; line-height: 1; color: var(--primary-ink); }
.bk-score.bump { animation: bump .5s var(--spring); }
.bk-combo { padding: 6px 12px; border-radius: 999px; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #3A2400; }
.bk-combo.bump { animation: bump .6s var(--spring); }
.bk-wrap { position: relative; max-width: 440px; margin: 0 auto; }
.bk-board {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; padding: 8px; aspect-ratio: 1; border-radius: 18px;
  background: #1B2A4A; box-shadow: inset 0 2px 10px rgba(0, 0, 0, .35), var(--shadow-lg); touch-action: none;
}
[data-theme="dark"] .bk-board { background: #0F1A33; }
.bk-board.over { filter: grayscale(.6) brightness(.85); transition: filter .6s; }
.bk-cell { border: none; padding: 0; border-radius: 5px; background: rgba(255, 255, 255, .07); aspect-ratio: 1; transition: background .12s; }
.bk-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.bk-cell.ghost { background: color-mix(in srgb, var(--g) 55%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--g) 90%, #fff); }
.bk-cell.bad { background: rgba(224, 90, 79, .35); }
.bk-cell.will-clear { filter: brightness(1.35); box-shadow: 0 0 10px 1px color-mix(in srgb, var(--accent) 80%, transparent); }
.bk-cell.drop { animation: drop .28s var(--spring); }
.bk-cell.clearing { animation: clearOut .38s ease-in forwards; }
@keyframes drop { from { transform: scale(.6); } }
@keyframes clearOut { 30% { transform: scale(1.15); filter: brightness(2); } 100% { transform: scale(0); opacity: 0; } }
.bk-pop {
  position: absolute; z-index: 5; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap;
  font-size: 26px; font-weight: 800; color: #fff; text-shadow: 0 2px 0 #E8A320, 0 4px 14px rgba(0, 0, 0, .35);
  animation: popUp 1.1s var(--ease) forwards;
}
@keyframes popUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
.bk-tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 440px; margin: 16px auto 0; min-height: 120px; }
.bk-slot { display: grid; place-items: center; min-height: 120px; border-radius: 16px; background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--border); }
.bk-piece {
  display: grid; grid-template-rows: repeat(var(--rows), 20px); grid-template-columns: repeat(var(--cols), 20px); gap: 2px;
  padding: 6px; border: none; background: none; cursor: grab; touch-action: none; border-radius: 10px;
  transition: transform .25s var(--spring), opacity .2s; animation: pop .45s var(--spring) both;
}
.bk-slot:nth-child(2) .bk-piece { animation-delay: .06s; } .bk-slot:nth-child(3) .bk-piece { animation-delay: .12s; }
.bk-piece i { border-radius: 4px; }
.bk-piece:hover { transform: scale(1.08); }
.bk-piece.sel { transform: scale(1.12); box-shadow: 0 0 0 2px var(--primary); background: var(--primary-soft); }
.bk-piece.lifted { opacity: .25; }
.bk-piece.dead { opacity: .35; filter: grayscale(.8); }
.bk-piece.nope { animation: shake .35s; }
.bk-float {
  position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none; display: grid; gap: 3px;
  grid-template-rows: repeat(var(--rows), calc(var(--s) - 3px)); grid-template-columns: repeat(var(--cols), calc(var(--s) - 3px));
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .3));
}
.bk-float i { border-radius: 5px; }
.bk-hint { margin-top: 10px; }
.bk-ask { max-width: 640px; margin: 18px auto 0; animation: rise .4s var(--ease) both; }
.bk-ask-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.bk-ask-head b { display: inline-flex; align-items: center; gap: 6px; }
.bk-ask-head .ic { color: var(--warn); }
.bk-over { max-width: 440px; margin: 16px auto 0; }

/* ============ Deleting sets ============ */
.card-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.card-link:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 60%, transparent); outline-offset: 2px; }
.card-del {
  position: absolute; top: 10px; right: 10px; z-index: 2; display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 10px; border: none; color: #fff; background: rgba(20, 33, 61, .45); backdrop-filter: blur(6px);
  opacity: 0; transform: scale(.85); transition: opacity .2s, transform .25s var(--spring), background .2s;
}
.set-card:hover .card-del, .card-del:focus-visible { opacity: 1; transform: scale(1); }
.card-del:hover { background: var(--bad); }
.card-del .ic { width: 17px; height: 17px; }
@media (hover: none) { .card-del { opacity: 1; transform: none; } }
.set-card.removing { animation: removeCard .28s var(--ease) forwards; pointer-events: none; }
@keyframes removeCard { to { opacity: 0; transform: scale(.9) translateY(8px); } }
#toast.has-action { display: flex; align-items: center; gap: 14px; pointer-events: none; }
#toast.show.has-action { pointer-events: auto; }
.toast-btn { border: none; background: none; color: var(--accent); font-weight: 800; padding: 2px 4px; text-transform: uppercase; letter-spacing: .04em; font-size: 14px; }
[data-theme="dark"] .toast-btn { color: var(--primary-strong); }
.toast-btn:hover { text-decoration: underline; }

/* ============ Gates ============ */
.modes { grid-template-columns: repeat(5, 1fr); }
.gt-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.gt-intro h2 { margin: 0; }
.gt-intro p { margin: 4px 0 0; max-width: 460px; }
.gt-intro .opts-bar { margin: 0; }
.seg input:disabled + span { opacity: .4; cursor: not-allowed; }
.gt-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 12px; margin-bottom: 12px; }
.gt-level {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px 10px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .25s var(--spring), box-shadow .25s, border-color .25s;
}
.gt-level:hover:not(:disabled) { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.gt-level.done { background: linear-gradient(160deg, var(--surface), var(--primary-soft)); }
.gt-level.locked { opacity: .5; cursor: not-allowed; }
.gt-num { font-size: 24px; font-weight: 800; line-height: 1; }
.gt-num .ic { width: 18px; height: 18px; color: var(--muted); }
.gt-stars { display: flex; gap: 2px; }
.gt-stars i .ic { width: 14px; height: 14px; color: var(--border); }
.gt-stars i.on .ic { color: var(--star); fill: currentColor; }

.gt-hud { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.gt-hud .gv-lives { margin-left: auto; }
.gt-dots { display: flex; gap: 5px; }
.gt-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); transition: background .3s, transform .3s var(--spring); }
.gt-dots i.on { background: var(--primary); border-color: var(--primary); transform: scale(1.15); }
.gt-prompt { text-align: center; font-size: clamp(18px, 2.6vw, 24px); font-weight: 700; margin: 6px 0 12px; min-height: 2.6em; }
.gt-prompt .qlabel { justify-content: center; margin-bottom: 2px; }

.gt-track {
  position: relative; height: min(60vh, 520px); border-radius: 24px; overflow: hidden; touch-action: pan-y; cursor: pointer;
  background: linear-gradient(180deg, #0B1326, #1B2A4A 70%, #23395F); box-shadow: var(--shadow-lg); user-select: none;
}
.gt-road {
  position: absolute; inset: 0; opacity: .5;
  background:
    linear-gradient(90deg, transparent 0 2%, rgba(255, 255, 255, .05) 2% 98%, transparent 98%),
    repeating-linear-gradient(180deg, rgba(95, 211, 199, .12) 0 2px, transparent 2px 48px);
  animation: roadMove 0.9s linear infinite;
}
@keyframes roadMove { to { background-position: 0 0, 0 48px; } }
.gt-divider { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed rgba(255, 255, 255, .14); }
.gt-row { position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: repeat(var(--lanes), 1fr); gap: 10px; padding: 0 10px; will-change: transform; }
.gt-row.pass { transition: transform .5s var(--ease), opacity .5s; opacity: 0; }
.gt-gate {
  display: grid; place-items: center; min-height: 86px; padding: 18px 10px 12px; text-align: center; color: #fff; font-weight: 700; font-size: 15px;
  border-radius: 60px 60px 10px 10px; border: 3px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .08);
  backdrop-filter: blur(4px); transition: border-color .2s, background .2s, box-shadow .2s;
}
.gt-gate span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; hyphens: auto; }
.gt-row.close .gt-gate { border-color: rgba(255, 201, 77, .7); box-shadow: 0 0 18px rgba(255, 201, 77, .25); }
.gt-gate.right { border-color: var(--good) !important; background: rgba(76, 211, 160, .3); box-shadow: 0 0 28px rgba(76, 211, 160, .6) !important; }
.gt-gate.wrong { border-color: var(--bad) !important; background: rgba(255, 122, 110, .3); animation: shake .4s; }
.gt-player {
  position: absolute; bottom: 22px; left: 50%; width: clamp(66px, calc(100% / var(--lanes) - 16px), 180px); transform: translateX(-50%);
  padding: 12px 10px; border-radius: 14px; text-align: center; font-weight: 800; font-size: 14px; color: #14213D;
  background: linear-gradient(160deg, #fff, #E3F5F3); border: 3px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(43, 181, 168, .25), 0 14px 30px rgba(0, 0, 0, .4); transition: left .22s var(--spring);
}
.gt-player span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; hyphens: auto; }
.gt-player::after { content: ""; position: absolute; left: 50%; top: 100%; width: 60%; height: 20px; transform: translateX(-50%); background: radial-gradient(ellipse at top, rgba(95, 211, 199, .55), transparent 70%); filter: blur(2px); }
.gt-player.boost { animation: boost .45s var(--spring); }
.gt-player.crash { animation: shake .45s; border-color: var(--bad); }
@keyframes boost { 40% { transform: translateX(-50%) translateY(-14px) scale(1.06); } }
.gt-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s; }
.gt-flash.good { opacity: 1; background: radial-gradient(circle at 50% 80%, rgba(76, 211, 160, .35), transparent 60%); }
.gt-flash.bad { opacity: 1; background: radial-gradient(circle at 50% 80%, rgba(255, 122, 110, .4), transparent 60%); }
.gt-result-stars { display: flex; justify-content: center; gap: 10px; margin-bottom: 8px; }
.gt-result-stars .ic { width: 52px; height: 52px; color: var(--border); }
.gt-result-stars i.on .ic { color: var(--star); fill: currentColor; animation: starIn .6s var(--spring) both; animation-delay: var(--d); }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }

/* ============ Gate Run (Math Runners style) ============ */
.gt-dots i.miss { background: var(--bad); border-color: var(--bad); }
.gr-goal { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; padding: 5px 12px; border-radius: 999px; background: var(--accent-soft); font-size: 13.5px; font-weight: 700; }
.gr-goal .ic { color: var(--accent-2); }
.gr-stage {
  position: relative; height: min(64vh, 580px); border-radius: 26px; overflow: hidden; touch-action: none; cursor: grab; user-select: none;
  background: linear-gradient(180deg, #9BE3C2, #5CC79A 60%, #3FAE84); box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .gr-stage { background: linear-gradient(180deg, #1F5A55, #17463F 60%, #10352F); }
.gr-stage:active { cursor: grabbing; }
.gr-stage.shake { animation: shake .45s; }
.gr-sky { position: absolute; left: 0; right: 0; top: 0; height: 20.4%; overflow: hidden; background: linear-gradient(180deg, #7FD0F2, #CFF1F6); }
[data-theme="dark"] .gr-sky { background: linear-gradient(180deg, #14213D, #2E3F6E); }
.gr-sky .sun { position: absolute; right: 14%; top: 18%; width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle, #FFE7A0, var(--accent) 60%, transparent 62%); box-shadow: 0 0 40px 10px rgba(255, 201, 77, .45); animation: float 6s ease-in-out infinite; }
[data-theme="dark"] .gr-sky .sun { background: radial-gradient(circle, #fff, #DDE6F5 60%, transparent 62%); box-shadow: 0 0 30px 6px rgba(221, 230, 245, .3); }
.gr-sky .hill { position: absolute; bottom: -40px; border-radius: 50%; background: #6FD0A7; }
.gr-sky .h1 { left: -10%; width: 60%; height: 90px; }
.gr-sky .h2 { right: -15%; width: 70%; height: 110px; background: #4FBF92; }
[data-theme="dark"] .gr-sky .h1 { background: #1F5A55; } [data-theme="dark"] .gr-sky .h2 { background: #17463F; }
.gr-road { position: absolute; inset: 0; background: linear-gradient(180deg, #DCE5E3, #F7F9F8 70%, #FFFFFF); }
[data-theme="dark"] .gr-road { background: linear-gradient(180deg, #2C3E63, #3A5080 70%, #445B8E); }
#grLines i { position: absolute; left: 0; top: 0; width: 4px; margin-left: -2px; border-radius: 3px; transform-origin: 50% 0; background: rgba(43, 181, 168, .55); will-change: transform; }
#grLines i.edge { background: var(--accent-2); }
.gr-row {
  position: absolute; left: 0; top: 0; height: 168px; display: grid; grid-template-columns: repeat(var(--lanes), 1fr); gap: 3%; padding: 0 1.5%;
  transform-origin: 50% 100%; will-change: transform, opacity; pointer-events: none;
}
.gr-gate {
  --gc: #2BB5A8; position: relative; display: grid; place-items: center; padding: 18px 10px 10px; text-align: center;
  color: #fff; font-size: var(--gfs, 26px); font-weight: 800; line-height: 1.15; text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  border: 8px solid var(--gc); border-bottom: none; border-radius: 22px 22px 0 0;
  background: color-mix(in srgb, var(--gc) 42%, transparent); backdrop-filter: blur(2px);
  box-shadow: inset 0 0 30px rgba(255, 255, 255, .25), 0 10px 30px rgba(0, 0, 0, .15);
}
.gr-gate span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; hyphens: auto; }
.gr-gate.g1 { --gc: #5B8DEF; } .gr-gate.g2 { --gc: #FF8A65; } .gr-gate.g3 { --gc: #A77BF3; }
.gr-gate::before { content: ""; position: absolute; left: 50%; top: -24px; transform: translateX(-50%); width: 34px; height: 34px; border-radius: 50%; background: var(--gc); box-shadow: 0 0 0 5px rgba(255, 255, 255, .5); }
.gr-gate.right { --gc: #1FBF7A; background: rgba(31, 191, 122, .55); box-shadow: 0 0 50px rgba(31, 191, 122, .8); }
.gr-gate.right::after { content: "✓"; position: absolute; top: -24px; left: 50%; transform: translateX(-50%); width: 34px; line-height: 34px; color: #fff; font-size: 22px; }
.gr-gate.wrong { --gc: #E05A4F; background: rgba(224, 90, 79, .55); }
.gr-row.finish { grid-template-columns: 1fr; }
.gr-boss {
  display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 16px 16px 0 0; color: #fff;
  background:
    linear-gradient(rgba(20, 33, 61, .78), rgba(20, 33, 61, .78)),
    repeating-conic-gradient(#fff 0 25%, #14213D 0 50%) 0 0 / 40px 40px;
  box-shadow: 0 0 0 6px var(--accent), 0 14px 40px rgba(0, 0, 0, .3);
}
.gr-boss-num { font-size: 72px; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; text-shadow: 0 4px 0 rgba(0, 0, 0, .3); }
.gr-boss-label { font-weight: 800; letter-spacing: .1em; text-transform: uppercase; font-size: 18px; }
.gr-crowd { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; will-change: transform; }
.gr-crowd.fight { animation: fightJitter .15s linear infinite; }
@keyframes fightJitter { 50% { margin-left: 3px; } }
.gr-people { position: absolute; left: 0; top: 0; }
.gr-people i {
  position: absolute; left: -7px; top: -22px; width: 14px; height: 20px; border-radius: 7px 7px 4px 4px;
  background: linear-gradient(180deg, #3CCABD, #1F8F86); box-shadow: 0 3px 4px rgba(0, 0, 0, .2); animation: runBob .35s ease-in-out infinite alternate, pop .35s var(--spring);
}
.gr-people i::before { content: ""; position: absolute; left: 2px; top: -9px; width: 10px; height: 10px; border-radius: 50%; background: #FFD7B5; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08); }
.gr-people i:nth-child(3n) { animation-delay: .1s, 0s; } .gr-people i:nth-child(3n+1) { animation-delay: .2s, 0s; }
@keyframes runBob { to { margin-top: -3px; } }
.gr-num {
  position: absolute; left: 0; bottom: 34px; transform: translateX(-50%); min-width: 54px; padding: 5px 14px; border-radius: 999px; text-align: center;
  background: #fff; color: #14213D; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
  border: 3px solid var(--primary);
}
.gr-num.up { animation: numUp .5s var(--spring); border-color: var(--good); }
.gr-num.down { animation: numShake .45s; border-color: var(--bad); }
@keyframes numShake { 25% { transform: translateX(calc(-50% - 7px)); } 75% { transform: translateX(calc(-50% + 7px)); } }
@keyframes numUp { 40% { transform: translateX(-50%) scale(1.35); } }
.gr-pop { position: absolute; z-index: 4; transform: translateX(-50%); font-size: 30px; font-weight: 800; pointer-events: none; animation: popUp 1s var(--ease) forwards; }
.gr-pop.good { color: #fff; text-shadow: 0 2px 0 #1F9D73, 0 4px 14px rgba(0, 0, 0, .3); }
.gr-pop.bad { color: #fff; text-shadow: 0 2px 0 #C2413A, 0 4px 14px rgba(0, 0, 0, .3); }

/* Gate Run: checkered line where the road ends */
.gr-finishline { position: absolute; z-index: 1; background: repeating-conic-gradient(#fff 0 25%, #14213D 0 50%) 0 0 / 16px 16px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); pointer-events: none; }
/* Gate Run: rival crowd clash at the finish */
.gr-row.finish { display: block; z-index: 2; }
.gr-enemy { position: absolute; left: 50%; bottom: 26px; }
.gr-enemy .gr-num { bottom: 34px; }
.gr-num.enemy { border-color: #E05A4F; color: #C2413A; }
.gr-people.enemy i { background: linear-gradient(180deg, #FF8A65, #E05A4F); }
.gr-people.enemy i::before { background: #FFD0B5; }
.gr-enemy.fight, .gr-crowd.fight { animation: fightJitter .12s linear infinite; }
.gr-people i.sink { animation: sinkDown .5s ease-in forwards !important; }
.gr-people i.sink::after {
  content: ""; position: absolute; left: 50%; bottom: -6px; width: 26px; height: 8px; margin-left: -13px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .7); animation: splash .5s ease-out forwards;
}
@keyframes sinkDown { 60% { opacity: 1; } to { height: 0; margin-top: 20px; opacity: 0; } }
@keyframes splash { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.gr-num.gone { animation: numGone .5s ease-in forwards; }
@keyframes numGone { to { transform: translateX(-50%) scale(0); opacity: 0; } }
.gr-people.cheer i { animation: cheer .35s ease-in-out infinite alternate; }
@keyframes cheer { to { margin-top: -9px; } }

/* ============ Responsive & motion ============ */
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .brand-name { display: none; }
  .hide-sm { display: none; }
  .kbd { display: none; }
  .floaters span:nth-child(n+5) { display: none; }
  .set-card .pill { top: 104px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .page { padding: 22px 16px 70px; }
  .hero { padding: 26px 22px; border-radius: 22px; }
  .hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .hero-stat { padding: 8px 10px; }
  .hero-stat b { font-size: 18px; }
  .hero-stat span { font-size: 11px; }
  .hero-stat b, .hero-stat span { white-space: nowrap; }
  .modes { grid-template-columns: repeat(2, 1fr); }
  .live-choices, .rate { grid-template-columns: 1fr 1fr; }
  .live-choice { min-height: 70px; padding: 14px; font-size: 16px; }
  .meteor { max-width: 60%; font-size: 14px; }
  .gv-bar { gap: 10px; font-size: 14px; }
  .row-fields, .tf-grid, .match-q, .choices { grid-template-columns: 1fr; gap: 12px; }
  .term-row { grid-template-columns: 1fr auto; }
  .term-row .t { border-right: none; padding-right: 0; grid-column: 1; }
  .term-row .d { grid-column: 1; }
  .term-row .tools { grid-column: 2; grid-row: 1 / span 2; flex-direction: column; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tile { min-height: 98px; font-size: 14px; padding: 8px; }
  .qcard { padding: 20px; }
  .flashcard { height: 56vh; }
}
@media (max-width: 420px) {
  .gr-row { height: 140px; }
  .gr-gate { border-width: 6px; padding: 16px 6px 8px; }
  .gr-goal { margin-left: 0; }
  .gt-gate { font-size: 12.5px; padding: 14px 4px 8px; min-height: 72px; }
  .gt-row { gap: 5px; padding: 0 5px; }
  .gt-player { font-size: 12px; padding: 9px 6px; }
  .bk-piece { grid-template-rows: repeat(var(--rows), 15px); grid-template-columns: repeat(var(--cols), 15px); }
  .bk-slot { min-height: 96px; }
  .bk-board { padding: 6px; gap: 2px; }
  .live-choices, .rate { grid-template-columns: 1fr; }
  .live-choice, .live-choices.player .live-choice { min-height: 60px; }
  .live-choice { min-width: 0; overflow-wrap: anywhere; }
}
@media (max-width: 360px) {
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .confetti, .floaters { display: none; }
}
