:root {
  --bg-a: #e0f2fe;
  --bg-b: #fef3c7;
  --primary: #2563eb;
  --secondary: #f97316;
  --accent: #22c55e;
  --card: rgba(255, 255, 255, 0.92);
  --text: #1f2937;
  --muted: #64748b;
  --danger: #ef4444;
  --shadow: 0 24px 70px rgba(31, 41, 55, 0.18);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at top left, var(--bg-a), transparent 38%), linear-gradient(135deg, var(--bg-b), #ffffff 54%, var(--bg-a));
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.background-shapes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.background-shapes span {
  position: absolute;
  font-size: clamp(2.5rem, 6vw, 5rem);
  opacity: 0.2;
  animation: float 8s ease-in-out infinite;
}

.background-shapes span:nth-child(1) { left: 6%; top: 12%; }
.background-shapes span:nth-child(2) { right: 9%; top: 8%; animation-delay: -2s; }
.background-shapes span:nth-child(3) { left: 12%; bottom: 10%; animation-delay: -4s; }
.background-shapes span:nth-child(4) { right: 16%; bottom: 14%; animation-delay: -1s; }
.background-shapes span:nth-child(5) { left: 45%; top: 4%; animation-delay: -3s; }
.background-shapes span:nth-child(6) { right: 42%; bottom: 5%; animation-delay: -5s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-18px) rotate(6deg); }
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 46px;
}

.hero, .card {
  background: var(--card);
  border: 4px solid rgba(255, 255, 255, 0.75);
  border-radius: 34px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero {
  padding: clamp(24px, 5vw, 48px);
  text-align: center;
}

h1, h2, h3 { margin: 0; line-height: 1.05; }
h1 { font-size: clamp(2.5rem, 7vw, 5.5rem); color: var(--primary); text-shadow: 3px 3px 0 rgba(255,255,255,0.8); }
h2 { font-size: clamp(2rem, 4vw, 3.3rem); color: var(--primary); }
h3 { font-size: 1.45rem; }
p { font-size: clamp(1.05rem, 2vw, 1.35rem); line-height: 1.5; }

.brand-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vw, 28px);
  max-width: 900px;
  margin: 0 auto;
  text-align: left;
}
.brand-logo {
  display: grid;
  place-items: center;
  width: clamp(86px, 13vw, 132px);
  height: clamp(86px, 13vw, 132px);
  border-radius: 34px;
  background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(255,255,255,0.62));
  box-shadow: 0 16px 36px rgba(0,0,0,0.12);
  font-size: clamp(3.2rem, 7vw, 5.4rem);
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--secondary);
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-subtitle {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 800;
}
.personal-card {
  max-width: 760px;
  margin: clamp(22px, 4vw, 34px) auto 0;
  padding: clamp(18px, 3vw, 26px);
  border-radius: 28px;
  background: rgba(255,255,255,0.74);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.75), 0 14px 32px rgba(0,0,0,0.08);
}
.personal-card p {
  margin: 10px 0 0;
}
.big-emoji { font-size: clamp(3.5rem, 9vw, 7rem); margin-bottom: 12px; }
.theme-grid, .table-grid, .choice-grid, .stats-grid {
  display: grid;
  gap: 16px;
}
.theme-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-top: 26px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 14px; }
.table-grid { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); margin-top: 22px; }
.choice-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 22px; }
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-top: 18px; }

.btn, .theme-card, .table-card {
  border: 0;
  border-radius: 24px;
  padding: 18px 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 12px 0 rgba(0,0,0,0.12), 0 18px 30px rgba(0,0,0,0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn:hover, .theme-card:hover, .table-card:not(.locked):hover { transform: translateY(-4px) scale(1.02); filter: brightness(1.04); }
.btn:active, .theme-card:active, .table-card:active { transform: translateY(3px); box-shadow: 0 6px 0 rgba(0,0,0,0.12); }
.btn.secondary { background: linear-gradient(135deg, #64748b, #94a3b8); }
.btn.success { background: linear-gradient(135deg, #16a34a, #84cc16); }
.btn.warning { background: linear-gradient(135deg, #f59e0b, #f97316); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #f97316); }
.btn.full { width: 100%; font-size: 1.3rem; font-weight: 900; }

.theme-card { min-height: 170px; font-size: 1.25rem; font-weight: 900; }
.theme-card span, .table-card span { display: block; font-size: 3rem; margin-bottom: 8px; }
.selectable-theme {
  display: grid;
  place-items: center;
  gap: 6px;
}
.selectable-theme input {
  width: 26px;
  height: 26px;
  accent-color: var(--accent);
}
.table-card { min-height: 132px; font-weight: 900; font-size: 1.15rem; }
.table-card.locked { filter: grayscale(0.85); opacity: 0.55; cursor: not-allowed; background: linear-gradient(135deg, #94a3b8, #cbd5e1); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.card { padding: clamp(20px, 4vw, 34px); margin-top: 18px; }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; background: #fff; color: var(--primary); font-weight: 900; box-shadow: 0 8px 20px rgba(0,0,0,0.1); }

.problem-box { text-align: center; padding: 24px; border-radius: 30px; background: linear-gradient(135deg, rgba(255,255,255,0.72), rgba(255,255,255,0.95)); }
.problem { font-size: clamp(3.5rem, 11vw, 7rem); color: var(--primary); font-weight: 1000; margin: 20px 0; }
.answer-row { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.answer-input {
  width: min(260px, 100%);
  border: 4px solid var(--primary);
  border-radius: 24px;
  padding: 16px 18px;
  font-size: 2rem;
  text-align: center;
  font-weight: 900;
  background: #fff;
}
.feedback { min-height: 42px; font-size: 1.45rem; font-weight: 900; margin-top: 18px; }
.feedback.good { color: #15803d; }
.feedback.try { color: #c2410c; }

.progress-track { height: 24px; background: rgba(255,255,255,0.75); border-radius: 999px; overflow: hidden; margin: 18px 0; border: 3px solid rgba(255,255,255,0.9); }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--secondary)); border-radius: inherit; transition: width 0.35s ease; }
.stars { font-size: 1.25rem; letter-spacing: 2px; margin-top: 8px; }
.stat { background: #fff; border-radius: 24px; padding: 18px; text-align: center; box-shadow: 0 12px 26px rgba(0,0,0,0.08); }
.stat strong { display: block; font-size: 2rem; color: var(--primary); }

.settings-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.settings-row input, .settings-row select {
  border: 3px solid var(--primary);
  border-radius: 18px;
  padding: 12px 14px;
  background: #fff;
  min-height: 54px;
}
.name-card {
  display: grid;
  gap: 10px;
  max-width: 420px;
  margin: 22px auto 0;
  font-size: 1.25rem;
  font-weight: 900;
}
.name-input {
  width: 100%;
  border: 4px solid var(--primary);
  border-radius: 24px;
  padding: 16px 18px;
  font-size: 1.4rem;
  text-align: center;
  font-weight: 900;
  background: #fff;
}
.start-button {
  max-width: 520px;
  margin: 24px auto 0;
}
.color-card {
  max-width: 760px;
  margin: 22px auto 0;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255,255,255,0.68);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.7);
}
.color-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 58px;
  border-radius: 18px;
  color: #1f2937;
  font-weight: 1000;
  box-shadow: 0 10px 22px rgba(0,0,0,0.1);
}
.color-choice input {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
}
.color-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-dot {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.14);
}
.color-dot.active {
  outline: 3px solid var(--primary);
  transform: scale(1.08);
}
.color-blue { background: linear-gradient(135deg, #dbeafe, #38bdf8); }
.color-pink { background: linear-gradient(135deg, #fce7f3, #f472b6); }
.color-orange { background: linear-gradient(135deg, #ffedd5, #fb923c); }
.color-green { background: linear-gradient(135deg, #dcfce7, #4ade80); }
.profile-card {
  max-width: 760px;
  margin: 22px auto 0;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255,255,255,0.76);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.72), 0 12px 26px rgba(0,0,0,0.08);
}
.profile-card p {
  margin: 8px 0 0;
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.profile-button {
  border: 0;
  border-radius: 18px;
  padding: 14px;
  background: #fff;
  color: var(--primary);
  font-weight: 1000;
  box-shadow: 0 10px 22px rgba(0,0,0,0.1);
}
.profile-button span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.95rem;
}
.mistake-box {
  margin-top: 22px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 26px rgba(0,0,0,0.08);
}
.mistake-box h3 {
  color: var(--primary);
}
.good-box {
  background: rgba(220, 252, 231, 0.9);
}
.mistake-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.mistake-item {
  display: grid;
  gap: 5px;
  padding: 14px;
  border-radius: 18px;
  background: #fff7ed;
  border: 2px solid rgba(249, 115, 22, 0.28);
}
.mistake-item strong {
  color: var(--primary);
  font-size: 1.2rem;
}
.mistake-item span {
  color: var(--muted);
  font-weight: 800;
}

.diploma {
  position: relative;
  margin-top: 20px;
  padding: clamp(24px, 5vw, 52px);
  border: 10px double var(--secondary);
  border-radius: 28px;
  text-align: center;
  background: linear-gradient(135deg, #fff7ed, #ffffff, #ecfeff);
  box-shadow: var(--shadow);
}
.diploma-name { font-size: clamp(2.2rem, 6vw, 4.5rem); color: var(--primary); margin: 16px 0; font-weight: 1000; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; animation: confetti 3.2s linear forwards; }
@keyframes confetti { to { transform: translateY(110vh) rotate(720deg); } }

.hidden { display: none !important; }

@media (max-width: 720px) {
  .brand-header {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .brand-logo {
    margin: 0 auto;
  }
  .theme-grid { grid-template-columns: 1fr; }
  .topbar { align-items: stretch; }
  .topbar-left, .controls, .topbar .btn { width: 100%; }
  .topbar-left { justify-content: center; }
  .color-actions { justify-content: center; }
  .controls .btn { flex: 1; }
  .answer-row .btn { width: min(260px, 100%); }
}

@media print {
  body { background: #fff; }
  .background-shapes, .topbar, .controls, .no-print, .confetti { display: none !important; }
  .app-shell { width: 100%; padding: 0; }
  .card, .hero { box-shadow: none; border: 0; }
  .diploma { box-shadow: none; break-inside: avoid; }
}
