:root {
  --ink: #14213d;
  --muted: #5b6478;
  --bg: #f6f8ff;
  --panel: #ffffff;
  --primary: #6554ff;
  --primary-dark: #4537c7;
  --accent: #00c2a8;
  --sun: #ffca3a;
  --pink: #ff6bcb;
  --danger: #ef476f;
  --success: #06d6a0;
  --shadow: 0 18px 45px rgba(20, 33, 61, 0.12);
  --radius: 24px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 107, 203, 0.18), transparent 28%),
    radial-gradient(circle at 90% 0%, rgba(0, 194, 168, 0.18), transparent 30%),
    linear-gradient(135deg, #f7f3ff 0%, #eef7ff 52%, #fff8e7 100%);
  color: var(--ink);
  min-height: 100vh;
}

.app-shell { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 24px 0 40px; }

.hero {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 20px;
  padding: 30px;
  border-radius: 32px;
  background: linear-gradient(135deg, rgba(101, 84, 255, 0.95), rgba(0, 194, 168, 0.82));
  color: white;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "✨";
  position: absolute;
  right: 22px;
  top: 10px;
  font-size: 52px;
  opacity: .45;
  transform: rotate(15deg);
}

.hero h1 { margin: 4px 0 12px; font-size: clamp(2rem, 4vw, 4rem); line-height: 0.98; max-width: 820px; }
.hero p { margin: 0; max-width: 720px; font-size: 1.05rem; opacity: .94; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 800; opacity: .82; margin-bottom: 8px !important; }

.score-card {
  align-self: center;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 24px;
  padding: 22px;
  backdrop-filter: blur(12px);
}
.score-card span, .score-card small { display: block; opacity: .9; }
.score-card strong { display: block; font-size: 3rem; margin: 8px 0; }

.tabs {
  display: flex;
  gap: 12px;
  margin: 22px 0;
  padding: 8px;
  background: rgba(255,255,255,.72);
  border-radius: 22px;
  box-shadow: 0 8px 25px rgba(20,33,61,.08);
  position: sticky;
  top: 10px;
  z-index: 10;
  backdrop-filter: blur(10px);
}
.tab-button {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 800;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  flex: 1;
  transition: .2s ease;
}
.tab-button:hover { background: #eef0ff; color: var(--primary); }
.tab-button.active { background: var(--ink); color: white; }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: pop .25s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin: 20px 0;
}
.section-heading h2 { font-size: clamp(1.8rem, 3vw, 2.6rem); margin: 0 0 8px; }
.section-heading p { margin: 0; color: var(--muted); }

button { font: inherit; }
.primary-btn, .ghost-btn, .danger-btn, .small-btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.primary-btn { background: var(--primary); color: white; box-shadow: 0 10px 22px rgba(101,84,255,.25); }
.primary-btn:hover, .ghost-btn:hover, .danger-btn:hover, .small-btn:hover { transform: translateY(-2px); }
.ghost-btn { background: #edf1ff; color: var(--primary-dark); }
.danger-btn { background: #ffe3ea; color: #a51236; }
.small-btn { padding: 8px 12px; background: var(--sun); color: #402d00; }

.cards-grid { display: grid; gap: 16px; margin: 18px 0; }
.cards-grid.three { grid-template-columns: repeat(3, 1fr); }
.mini-card, .practice-box, .result-card, .relative-item {
  background: rgba(255,255,255,.84);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(20,33,61,.08);
}
.mini-card { padding: 20px; }
.mini-card span {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: #ecf0ff;
  color: var(--primary);
  font-weight: 900;
}
.mini-card h3 { margin: 14px 0 8px; }
.mini-card p { margin: 0; color: var(--muted); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  background: white;
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 8px 25px rgba(20,33,61,.07);
}
select, input, textarea {
  border: 2px solid #e1e7ff;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  background: white;
  color: var(--ink);
  outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(101,84,255,.12); }

.study-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.study-card {
  min-height: 112px;
  border: 0;
  border-radius: 20px;
  padding: 16px;
  text-align: left;
  background: linear-gradient(135deg, #fff, #f1f5ff);
  box-shadow: 0 8px 22px rgba(20,33,61,.08);
  cursor: pointer;
}
.study-card strong { display: block; font-size: 1.05rem; margin-bottom: 10px; }
.study-card span { color: var(--muted); }
.study-card.revealed { background: linear-gradient(135deg, #ecfff9, #fff8db); }

.practice-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.practice-box { padding: 22px; }
.box-title { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 16px; }
.box-title h3 { margin: 0; }
.box-title p { margin: 0; color: var(--muted); font-weight: 700; }
.question-card {
  border-radius: 20px;
  padding: 18px;
  background: #f3f6ff;
  margin-bottom: 14px;
  font-weight: 850;
}
.option-grid { display: grid; gap: 10px; }
.option-btn {
  border: 2px solid #e1e7ff;
  background: white;
  border-radius: 16px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  font-weight: 750;
}
.option-btn.correct { border-color: var(--success); background: #e8fff8; }
.option-btn.wrong { border-color: var(--danger); background: #fff0f4; }
.answer-input { width: 100%; margin-bottom: 12px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.feedback { min-height: 28px; font-weight: 800; color: var(--muted); }
.feedback.good { color: #008f70; }
.feedback.bad { color: #c0264d; }

.grammar-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 18px 0 22px; }
.grammar-strip article { padding: 14px; background: #fff; border-left: 6px solid var(--accent); border-radius: 16px; box-shadow: 0 8px 20px rgba(20,33,61,.06); }

.relative-list { display: grid; gap: 16px; }
.relative-item { padding: 20px; }
.relative-top { display: flex; gap: 12px; align-items: flex-start; }
.badge {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--ink);
  color: white;
  font-weight: 900;
}
.relative-sentence { margin: 0 0 14px; font-weight: 780; line-height: 1.5; }
.relative-input { width: 100%; min-height: 82px; resize: vertical; margin: 10px 0; }
.relative-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.attempts { color: var(--muted); font-size: .92rem; font-weight: 750; }
.model-answer { display: none; margin-top: 12px; padding: 14px; border-radius: 16px; background: #f3f6ff; color: var(--ink); }
.model-answer.show { display: block; }
.done { border: 2px solid rgba(6,214,160,.4); }

.results-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.result-card { padding: 24px; }
.result-card span { color: var(--muted); font-weight: 850; }
.result-card strong { display: block; font-size: 2.4rem; margin: 8px 0; }
.result-card.big { grid-column: span 1; background: linear-gradient(135deg, #fff, #effffb); }

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 100; }
.confetti-piece { position: absolute; width: 10px; height: 16px; border-radius: 4px; animation: fall 900ms ease-out forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: 0; } }

@media (max-width: 850px) {
  .hero, .practice-layout, .cards-grid.three, .results-grid { grid-template-columns: 1fr; }
  .tabs { flex-direction: column; position: static; }
  .section-heading { flex-direction: column; align-items: stretch; }
}
