:root {
  --ink: #24314d;
  --muted: #6f7690;
  --paper: #fffdf8;
  --surface: #ffffff;
  --line: #e8e5ef;
  --purple: #7657d5;
  --purple-dark: #5639b5;
  --purple-soft: #eee9ff;
  --mint: #d9f4e9;
  --green: #238765;
  --yellow: #ffd867;
  --coral: #ee6e61;
  --coral-soft: #ffebe7;
  --shadow: 0 14px 40px rgba(53, 43, 90, 0.09);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 6%, rgba(255, 216, 103, 0.14), transparent 24rem),
    radial-gradient(circle at 92% 26%, rgba(118, 87, 213, 0.09), transparent 28rem),
    var(--paper);
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

button,
.button {
  touch-action: manipulation;
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}

.main-content {
  padding-block: 56px 80px;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid rgba(232, 229, 239, 0.85);
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(18px);
}

.header-inner {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px 12px 12px 4px;
  color: white;
  background: var(--purple);
  box-shadow: 0 6px 14px rgba(118, 87, 213, 0.28);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
}

.site-nav a,
.link-button {
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
}

.site-nav form,
.set-actions form,
.heading-actions form,
.practice-finish-actions form,
.bottom-actions form {
  margin: 0;
}

.site-nav a:hover,
.link-button:hover,
.text-link:hover {
  color: var(--purple);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(2.35rem, 5vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.eyebrow {
  margin-bottom: 12px;
  color: var(--purple);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.subhead {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.muted {
  color: var(--muted);
}

.page-heading {
  margin-bottom: 40px;
}

.heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.heading-actions,
.form-actions,
.practice-finish-actions,
.bottom-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0 20px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button.primary {
  color: white;
  background: var(--purple);
  box-shadow: 0 8px 18px rgba(118, 87, 213, 0.22);
}

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

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
}

.button.quiet {
  color: var(--muted);
  background: transparent;
}

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

.text-link {
  color: var(--purple-dark);
  font-weight: 800;
  text-decoration: none;
}

.muted-link {
  color: var(--muted);
}

.card-grid,
.set-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.reader-card,
.set-card,
.panel,
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.reader-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 25px;
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease;
}

.reader-card:hover {
  transform: translateY(-3px);
  border-color: #cfc4f2;
}

.reader-card h2,
.reader-card p {
  margin: 0;
}

.reader-card p {
  margin-top: 5px;
  color: var(--muted);
}

.reader-avatar {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 18px 18px 18px 6px;
  color: var(--purple-dark);
  background: var(--purple-soft);
  font-size: 1.5rem;
  font-weight: 900;
}

.card-arrow {
  color: var(--purple);
  font-size: 1.6rem;
}

.set-card {
  display: flex;
  min-height: 220px;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px;
}

.set-card:nth-child(3n + 2) {
  box-shadow: 0 14px 40px rgba(28, 130, 99, 0.09);
}

.set-count {
  margin-bottom: 18px;
  color: var(--purple);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.word-preview {
  min-height: 26px;
  color: var(--muted);
  line-height: 1.6;
}

.set-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

.empty-state {
  max-width: 720px;
  margin: 64px auto;
  border: 2px dashed #dcd4f2;
  border-radius: 28px;
  padding: 58px 36px;
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
}

.empty-state.compact {
  margin-block: 30px 64px;
}

.empty-state p {
  max-width: 480px;
  margin: 0 auto 24px;
  color: var(--muted);
  line-height: 1.6;
}

.empty-sparkle {
  display: grid;
  width: 70px;
  height: 70px;
  place-items: center;
  margin: 0 auto 20px;
  border-radius: 24px 24px 24px 8px;
  color: var(--purple-dark);
  background: var(--yellow);
  font-size: 1.5rem;
  font-weight: 900;
  transform: rotate(-4deg);
}

.section-block {
  margin-top: 64px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h2,
.section-heading p {
  margin-bottom: 0;
}

.session-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  text-decoration: none;
}

.session-row + .session-row {
  border-top: 1px solid var(--line);
}

.session-row div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.session-row span:not(.score-pill) {
  color: var(--muted);
  font-size: 0.88rem;
}

.score-pill {
  min-width: 68px;
  border-radius: 999px;
  padding: 8px 12px;
  text-align: center;
  font-weight: 900;
}

.score-pill.great,
.score-ring.great {
  color: var(--green);
  background: var(--mint);
}

.score-pill.growing,
.score-ring.growing {
  color: #8c6800;
  background: #fff1bd;
}

.score-pill.practice,
.score-ring.practice {
  color: #a7463c;
  background: var(--coral-soft);
}

.page-footer-link {
  margin-top: 42px;
  text-align: center;
}

.narrow-page {
  max-width: 660px;
  margin-inline: auto;
}

.stacked-form {
  margin-top: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  background: white;
  box-shadow: var(--shadow);
}

.field + .field {
  margin-top: 24px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-weight: 850;
}

.field input,
.field textarea,
.auth-card input {
  width: 100%;
  border: 1.5px solid #dcd9e5;
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--ink);
  outline: none;
  background: #fff;
  transition: border 150ms ease, box-shadow 150ms ease;
}

.field textarea {
  min-height: 240px;
  resize: vertical;
  line-height: 1.7;
}

.field input:focus,
.field textarea:focus,
.auth-card input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px var(--purple-soft);
}

.field-hint {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.5;
}

.form-actions {
  margin-top: 28px;
}

.form-errors {
  margin-bottom: 24px;
  border-radius: 14px;
  padding: 16px 18px;
  color: #963a32;
  background: var(--coral-soft);
}

.form-errors p {
  margin-bottom: 6px;
  font-weight: 850;
}

.form-errors ul {
  margin-block: 0;
  padding-left: 20px;
}

.danger-zone {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  padding-top: 30px;
}

.danger-zone p {
  color: var(--muted);
}

.panel {
  padding: 30px;
}

.word-cloud {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.word-cloud span {
  border-radius: 12px;
  padding: 11px 16px;
  color: var(--purple-dark);
  background: var(--purple-soft);
  font-size: 1.08rem;
  font-weight: 800;
}

.bottom-actions {
  justify-content: space-between;
  margin-top: 24px;
}

.danger-link {
  color: var(--coral);
  font-weight: 800;
}

.practice-page {
  max-width: 880px;
  margin: 0 auto;
  text-align: center;
}

.practice-page > h1 {
  margin-inline: auto;
}

.practice-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.practice-header span {
  color: var(--muted);
  font-weight: 800;
}

.practice-header strong {
  text-align: right;
}

.progress-track {
  height: 10px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebe8f1;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--purple), #9e86ef);
  transition: width 260ms ease;
}

.word-stage {
  display: flex;
  min-height: 360px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-block: 28px;
  border: 1px solid var(--line);
  border-radius: 32px;
  padding: 42px;
  background: white;
  box-shadow: var(--shadow);
}

.word-stage p {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
}

.practice-word {
  font-size: clamp(4.3rem, 13vw, 8.5rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.015em;
}

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.answer-button {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 18px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.answer-button:hover {
  transform: translateY(-2px);
  filter: saturate(1.1);
}

.answer-button span {
  font-size: 1.7rem;
}

.answer-button.incorrect {
  color: #a7463c;
  background: var(--coral-soft);
}

.answer-button.correct {
  color: #176b50;
  background: var(--mint);
}

.practice-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.85rem;
}

.score-ring {
  display: flex;
  width: 190px;
  height: 190px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 34px auto;
  border-radius: 50%;
}

.score-ring strong {
  font-size: 3.4rem;
  line-height: 1;
}

.score-ring span {
  margin-top: 8px;
  font-weight: 750;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-block: 32px;
  text-align: left;
}

.result-word {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1.1rem;
  font-weight: 800;
}

.result-word.correct {
  color: var(--green);
  background: var(--mint);
}

.result-word.incorrect {
  color: #a7463c;
  background: var(--coral-soft);
}

.practice-finish-actions {
  justify-content: center;
}

.reward {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  animation: reward-fade 1.1s ease forwards;
}

.reward-message {
  border-radius: 20px;
  padding: 18px 26px;
  color: #644800;
  background: var(--yellow);
  box-shadow: 0 20px 60px rgba(81, 61, 5, 0.22);
  font-size: 1.5rem;
  font-weight: 900;
  animation: reward-pop 650ms cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

.confetti {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  height: 20px;
  border-radius: 3px;
  background: var(--coral);
  animation: confetti-burst 900ms ease-out forwards;
}

.confetti:nth-of-type(3n) {
  background: var(--purple);
}

.confetti:nth-of-type(3n + 1) {
  background: #4fc49b;
}

.confetti-1 { --x: -190px; --y: -140px; --r: 80deg; }
.confetti-2 { --x: -120px; --y: -210px; --r: -95deg; }
.confetti-3 { --x: -35px; --y: -180px; --r: 150deg; }
.confetti-4 { --x: 80px; --y: -210px; --r: -130deg; }
.confetti-5 { --x: 180px; --y: -130px; --r: 190deg; }
.confetti-6 { --x: 185px; --y: 90px; --r: -160deg; }
.confetti-7 { --x: 45px; --y: 170px; --r: 210deg; }
.confetti-8 { --x: -150px; --y: 120px; --r: -220deg; }

@keyframes reward-pop {
  0% { opacity: 0; transform: scale(0.5) rotate(-6deg); }
  60% { opacity: 1; transform: scale(1.08) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes reward-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

@keyframes confetti-burst {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.2); }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)); }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.stat-card span,
.stat-card small {
  color: var(--muted);
}

.stat-card strong {
  margin-block: 8px 4px;
  font-size: 2.5rem;
  line-height: 1;
  letter-spacing: -0.05em;
}

.trend-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  gap: 22px;
}

.bar-chart,
.focus-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 58px minmax(80px, 1fr) 48px 58px;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}

.bar-row time,
.bar-row small {
  color: var(--muted);
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #eeeaf5;
}

.bar-track span {
  display: block;
  min-width: 4px;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--purple), #9b83e9);
}

.focus-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 12px;
  padding: 13px 15px;
  background: #f7f5fb;
}

.focus-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.all-clear {
  color: var(--muted);
  text-align: center;
}

.all-clear span {
  color: #d49e00;
  font-size: 2.2rem;
}

.flash-wrap {
  position: relative;
  z-index: 30;
}

.flash {
  margin-top: 18px;
  border-radius: 13px;
  padding: 13px 16px;
  font-weight: 750;
}

.flash.notice {
  color: #176b50;
  background: var(--mint);
}

.flash.alert {
  color: #963a32;
  background: var(--coral-soft);
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 36px 20px;
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 36px;
  background: white;
  box-shadow: var(--shadow);
}

.auth-brand {
  justify-content: center;
  margin-bottom: 32px;
}

.auth-card h1 {
  margin-bottom: 8px;
  font-size: 2.2rem;
  text-align: center;
}

.auth-intro {
  margin-bottom: 28px;
  color: var(--muted);
  text-align: center;
}

.auth-card .field {
  margin-top: 18px;
}

.auth-card .button {
  width: 100%;
  margin-top: 24px;
}

.auth-options {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-options input {
  width: auto;
}

.auth-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  color: var(--purple-dark);
  font-size: 0.9rem;
  font-weight: 750;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 28px, 1120px);
  }

  .main-content {
    padding-block: 38px 60px;
  }

  .site-nav > a {
    display: none;
  }

  .heading-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-grid,
  .set-grid,
  .stat-grid,
  .trend-grid {
    grid-template-columns: 1fr;
  }

  .heading-actions,
  .heading-actions .button,
  .heading-actions form,
  .heading-actions form .button {
    width: 100%;
  }

  .word-stage {
    min-height: 300px;
    padding-inline: 20px;
  }

  .answer-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 56px 1fr 42px;
  }

  .bar-row small {
    display: none;
  }

  .stacked-form,
  .panel,
  .auth-card {
    padding: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
