:root {
  --bg: #FAF7F1;
  --surface: #FFFFFF;
  --surface-2: #F1EAE0;
  --border: #E7DFD1;
  --text: #241C13;
  --text-dim: #6E6151;
  --text-soft: #9A8E7C;
  --accent: #FF6A2B;
  --accent-ink: #C24A12;
  --success: #2F8F5B;
  --success-bg: #E5F3EA;
  --danger: #D8483C;
  --danger-bg: #FBEAE8;
  --amber: #E0952B;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(36, 28, 19, 0.06);
  --shadow-md: 0 10px 28px -12px rgba(36, 28, 19, 0.22);
  --font-head: "Unbounded", "Golos Text", sans-serif;
  --font-body: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* [hidden] loses to any later class rule that sets display (e.g. .btn),
   since both have identical specificity — force it to win globally. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  position: relative;
  z-index: 1;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(250, 247, 241, 0.9);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.brand {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
}

.topnav a {
  position: relative;
  padding: 4px 0;
  transition: color 0.15s ease;
}

.topnav a:hover {
  color: var(--text);
}

.topnav a.active {
  color: var(--text);
}

.topnav a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: color 0.15s ease;
}

.logout-form button:hover {
  color: var(--danger);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 100px;
  padding: 13px 22px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(255, 106, 43, 0.55);
}

.btn-primary:hover {
  background: var(--accent-ink);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: default;
  transform: none;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-quiz {
  background: var(--text);
  color: #fff;
}

.btn-quiz:hover {
  background: var(--accent-ink);
}

.btn-block {
  width: 100%;
}

/* Login */
body.page-login {
  background: radial-gradient(130% 160% at 20% 10%, #FF8A50 0%, var(--accent) 40%, var(--accent-ink) 100%);
}

body.page-login::before {
  opacity: 0.05;
  mix-blend-mode: overlay;
}

body.page-login .container {
  padding: 0;
}

.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: 0 30px 60px -20px rgba(36, 20, 10, 0.45);
  text-align: center;
  animation: card-in 0.35s ease;
}

.login-brand-icon {
  font-size: 38px;
  display: inline-block;
}

.login-card h1 {
  font-size: 24px;
  margin: 10px 0 8px;
}

.login-tagline {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0 0 28px;
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.login-form input {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.login-form input:focus {
  border-color: var(--accent);
  outline: none;
}

.login-form .btn {
  margin-top: 6px;
}

.error {
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin: 0;
}

/* Hero */
.hero {
  margin-bottom: 20px;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 32px;
}

.hero-sub {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
}

.level-chip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  min-width: 140px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}

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

.level-chip-num {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-ink);
}

.level-chip-bar {
  display: block;
  height: 5px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.level-chip-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* Daily quest */
.quest-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(100deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface));
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.quest-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.quest-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
  flex-basis: 100%;
}

.quest-title {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
}

.quest-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
  white-space: nowrap;
}

/* Stat strip */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.stat-value {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.stat-streak.is-cold .stat-value {
  color: var(--text-soft);
}

.stat-streak.is-active .stat-value {
  color: var(--accent-ink);
}

.flame {
  display: inline-block;
  filter: grayscale(1) opacity(0.5);
}

.flame-lit {
  filter: none;
  animation: flame-pulse 1.6s ease-in-out infinite;
}

@keyframes flame-pulse {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  50% { transform: scale(1.12) rotate(2deg); }
}

/* Subject grid + cards */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.subject-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: card-in 0.4s ease backwards;
}

.subject-grid .subject-card:nth-child(1) { animation-delay: 0.02s; }
.subject-grid .subject-card:nth-child(2) { animation-delay: 0.08s; }
.subject-grid .subject-card:nth-child(3) { animation-delay: 0.14s; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.subject-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent, var(--border));
}

.subject-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.subject-icon {
  font-size: 26px;
}

.subject-icon-lg {
  font-size: 40px;
}

.subject-card h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

/* Progress ring */
.ring {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--accent)) calc(var(--percent, 0) * 1%), var(--surface-2) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ring-inner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-value {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
}

.progress-label {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

.overdue-flag {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--danger);
  font-weight: 600;
}

.next-topic {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-soft);
}

/* Subject page */
.back-link {
  display: inline-flex;
  align-items: center;
  margin-bottom: 20px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--text);
}

.empty-state {
  color: var(--text-dim);
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.subject-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.subject-head-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.subject-head h1 {
  margin: 0;
  font-size: 26px;
}

.subject-progress-label {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

/* Topic level-path list */
.topic-list {
  list-style: none;
  padding: 0;
  margin: 0 0 40px;
}

.topic-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.topic-item:hover {
  background: var(--surface-2);
}

.topic-marker-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topic-marker-wrap::before {
  content: "";
  position: absolute;
  top: 50%;
  bottom: -50%;
  width: 2px;
  background: var(--border);
  z-index: 0;
}

.topic-item:last-child .topic-marker-wrap::before {
  display: none;
}

.topic-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-head);
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-soft);
  position: relative;
  z-index: 1;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.marker-done {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.marker-in_progress {
  background: #fff;
  border-color: var(--amber);
  color: var(--amber);
}

.marker-overdue {
  border-color: var(--danger);
  color: var(--danger);
}

.topic-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topic-title:hover {
  color: var(--accent-ink);
}

.overdue-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-bg);
  padding: 2px 8px;
  border-radius: 100px;
  white-space: nowrap;
}

.topic-deadline {
  color: var(--text-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Topic detail page */
.topic-head h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.topic-deadline-full {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 24px;
}

.status-form {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  background: var(--surface-2);
  border-radius: 100px;
  margin-bottom: 36px;
}

.status-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 100px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.status-btn:hover {
  color: var(--text);
}

.status-btn:active {
  transform: scale(0.96);
}

.status-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.status-btn.status-done.active {
  color: var(--success);
}

.status-btn.status-in_progress.active {
  color: var(--amber);
}

.topic-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 36px;
}

.topic-actions .status-form {
  margin-bottom: 0;
}

/* Subject CTA row + sprint timer */
.subject-cta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.study-form {
  margin: 0;
}

.sprint-widget {
  margin-top: 16px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
}

.sprint-time {
  display: block;
  font-family: var(--font-head);
  font-size: 40px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
}

.sprint-caption {
  margin: 6px 0 16px;
  color: var(--text-dim);
  font-size: 13px;
}

.sprint-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* Resources */
.resources-title {
  font-size: 16px;
  color: var(--text-dim);
  border: none;
  padding: 0;
  margin: 0 0 12px;
}

.resource-list {
  list-style: none;
  padding: 0;
  margin: 0 0 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.resource-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 14px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.resource-item:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}

.resource-item a {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  min-width: 0;
}

.resource-type {
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
  font-weight: 500;
}

.resource-item:hover .resource-name {
  color: var(--accent-ink);
}

.resource-name {
  transition: color 0.15s ease;
}

.resource-source {
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
}

/* Toasts */
.toast-layer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-in {
  opacity: 1;
  transform: translateY(0);
}

.toast-out {
  opacity: 0;
  transform: translateY(8px);
}

.toast-error {
  background: var(--danger);
}

/* Confetti */
.confetti-piece {
  position: fixed;
  width: 7px;
  height: 10px;
  pointer-events: none;
  z-index: 60;
  border-radius: 2px;
  animation: confetti-fly 0.85s ease-out forwards;
}

@keyframes confetti-fly {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

/* Settings */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 380px;
  margin-top: 20px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.settings-field input {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.settings-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.save-banner {
  background: var(--success-bg);
  color: var(--success);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  display: inline-block;
  margin: 12px 0 0;
}

.push-block {
  max-width: 420px;
  margin-top: 16px;
}

.push-status {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-dim);
}

.push-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* Progress page */
.section-title {
  font-size: 16px;
  margin: 36px 0 14px;
}

.xp-block {
  margin-top: 12px;
}

.xp-bar {
  height: 10px;
  background: var(--surface-2);
  border-radius: 100px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
  transition: width 0.3s ease;
}

.xp-caption {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.quiz-xp-note {
  margin: -8px 0 0;
  font-size: 12px;
  color: var(--text-soft);
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 4px;
  max-width: 420px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--surface-2);
}

.heatmap-cell.level-1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); }
.heatmap-cell.level-2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
.heatmap-cell.level-3 { background: color-mix(in srgb, var(--accent) 80%, var(--surface-2)); }
.heatmap-cell.level-4 { background: var(--accent-ink); }

.progress-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 480px;
}

.progress-bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 60px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.progress-bar-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar-value {
  height: 100%;
  border-radius: 100px;
}

.progress-bar-pct {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.badge-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.badge-card.badge-locked {
  opacity: 0.45;
}

.badge-icon {
  font-size: 22px;
}

.badge-title {
  font-weight: 600;
  font-size: 13px;
}

.badge-desc {
  font-size: 12px;
  color: var(--text-dim);
}

/* Quiz */
.quiz-question {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 14px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.quiz-question-text {
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 12px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.quiz-option:hover {
  background: var(--surface-2);
}

.quiz-option input {
  accent-color: var(--accent);
}

.quiz-question-correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.quiz-question-incorrect {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.quiz-explanation {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-dim);
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

.quiz-result {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
  padding: 16px;
  text-align: center;
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.quiz-result-perfect {
  background: var(--success-bg);
  color: var(--success);
}

/* Water tracker */
.water-section {
  margin-top: 8px;
}

.water-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.water-bottle-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
}

.water-bottle-svg {
  width: 96px;
  height: 192px;
  filter: drop-shadow(0 6px 10px rgba(36, 28, 19, 0.12));
}

.bottle-outline {
  fill: rgba(255, 255, 255, 0.55);
  stroke: var(--border);
  stroke-width: 3;
  stroke-linejoin: round;
}

.bottle-water {
  fill: url(#waterGrad);
  transition: y 0.6s cubic-bezier(0.34, 1.2, 0.64, 1), height 0.6s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.bottle-highlight {
  fill: rgba(255, 255, 255, 0.4);
}

.bottle-cap {
  fill: #2E6FA8;
}

.bottle-cap-line {
  stroke: rgba(255, 255, 255, 0.45);
  stroke-width: 1.5;
}

.bottle-rib {
  stroke: var(--border);
  stroke-width: 1.5;
  opacity: 0.55;
}

.water-info {
  flex: 1;
  min-width: 200px;
}

.water-info {
  flex: 1;
  min-width: 200px;
}

.water-info h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.water-amount {
  margin: 0 0 14px;
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.water-quick-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.water-btn {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.water-btn:hover {
  border-color: #3A6EA5;
  transform: translateY(-1px);
}

.water-custom-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.water-custom-form input {
  width: 100px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}

.water-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-soft);
}

.water-hint a {
  color: var(--text-dim);
  text-decoration: underline;
}

/* Game */
.nav-game {
  background: var(--surface-2);
  padding: 4px 10px !important;
  border-radius: 100px;
}

.nav-game.active::after {
  display: none;
}

.game-header {
  margin-bottom: 20px;
}

.game-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.game-wrap {
  max-width: 700px;
  margin: 0 auto;
}

.game-hud {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
}

.quiz-app {
  max-width: 720px;
  margin: 0 auto;
}

.quiz-screen-title {
  font-size: 20px;
  margin: 0 0 16px;
}

/* Category cards */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.category-card {
  --cat-color: var(--accent);
  background: linear-gradient(150deg, color-mix(in srgb, var(--cat-color) 16%, var(--surface)), var(--surface));
  border: 1.5px solid color-mix(in srgb, var(--cat-color) 30%, var(--border));
  border-radius: var(--radius-lg);
  padding: 26px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: card-in 0.35s ease backwards;
}

.category-grid .category-card:nth-child(1) { animation-delay: 0.02s; }
.category-grid .category-card:nth-child(2) { animation-delay: 0.06s; }
.category-grid .category-card:nth-child(3) { animation-delay: 0.1s; }
.category-grid .category-card:nth-child(4) { animation-delay: 0.14s; }
.category-grid .category-card:nth-child(5) { animation-delay: 0.18s; }
.category-grid .category-card:nth-child(6) { animation-delay: 0.22s; }

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--cat-color);
}

.category-icon {
  font-size: 40px;
  line-height: 1;
}

.category-icon-lg {
  font-size: 60px;
}

.category-title {
  font-weight: 700;
  font-family: var(--font-head);
  font-size: 14px;
  text-align: center;
  color: var(--text);
}

.games-hub-grid {
  max-width: 480px;
}

.games-hub-sub {
  font-size: 12px;
  color: var(--text-dim);
}

/* Memory game */
.memory-hud {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  flex-wrap: wrap;
}

.memory-hud .quiz-back {
  margin: 0 auto 0 0;
}

.memory-grid {
  --cat-color: var(--accent);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.memory-card {
  position: relative;
  min-height: 92px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.memory-card:hover:not(.is-flipped):not(.is-matched) {
  transform: translateY(-2px);
  border-color: var(--cat-color);
}

.memory-card-back {
  font-size: 24px;
  font-weight: 700;
  color: var(--cat-color);
}

.memory-card-front {
  display: none;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.memory-card.is-flipped {
  border-color: var(--cat-color);
  background: var(--surface);
}

.memory-card.is-flipped .memory-card-back {
  display: none;
}

.memory-card.is-flipped .memory-card-front {
  display: block;
}

.memory-card.is-matched {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
  cursor: default;
  opacity: 0.85;
}

.memory-card.is-matched .memory-card-back {
  display: none;
}

.memory-card.is-matched .memory-card-front {
  display: block;
}

/* Difficulty screen */
.quiz-back {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: 24px;
  font-family: inherit;
  transition: color 0.15s ease;
}

.quiz-back:hover {
  color: var(--text);
}

.category-hero {
  --cat-color: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  text-align: center;
}

.category-hero h2 {
  margin: 0;
  font-size: 24px;
}

.difficulty-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.difficulty-btn {
  border: none;
  border-radius: 100px;
  padding: 14px 22px;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.difficulty-easy {
  background: var(--success);
}

.difficulty-medium {
  background: var(--amber);
}

.difficulty-hard {
  background: var(--danger);
}

/* Quiz round */
.quiz-progress {
  height: 6px;
  background: var(--surface-2);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 10px;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.quiz-counter {
  margin: 0 0 18px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.trivia-card {
  --cat-color: var(--accent);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-top: 4px solid var(--cat-color);
  border-radius: var(--radius-lg);
  padding: 30px 26px;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.trivia-card.card-in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.trivia-question {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 22px;
  text-wrap: balance;
}

.trivia-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.trivia-option {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.trivia-option:hover:not(:disabled) {
  border-color: var(--cat-color);
  transform: translateY(-1px);
}

.trivia-option:disabled {
  cursor: default;
}

.option-correct {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

.option-wrong {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

/* Results */
.results-card {
  --cat-color: var(--accent);
  text-align: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  box-shadow: var(--shadow-sm);
  animation: card-in 0.3s ease;
}

.results-stars {
  font-size: 38px;
  letter-spacing: 8px;
  margin-bottom: 12px;
}

.results-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.results-card p {
  margin: 0 0 26px;
  color: var(--text-dim);
  font-size: 14px;
}

.results-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 760px) {
  .login-card {
    padding: 32px 24px;
  }

  .container {
    padding: 24px 16px 60px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .topic-item {
    grid-template-columns: 32px 1fr;
  }

  .topic-deadline {
    grid-column: 2;
    padding-left: 0;
  }

  .topbar {
    flex-wrap: wrap;
    row-gap: 10px;
    padding: 14px 16px;
  }

  .topnav {
    width: 100%;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
  }

  .stat-strip {
    grid-template-columns: 1fr;
  }

  .progress-bar-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .progress-bar-pct {
    text-align: left;
  }

  .heatmap {
    grid-template-columns: repeat(10, 1fr);
  }

  .trivia-options {
    grid-template-columns: 1fr;
  }

  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .memory-card {
    min-height: 76px;
    font-size: 11px;
  }
}
