* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Verdana, Arial, sans-serif;
  background: #f6f7fb;
  color: #111827;
}

.container {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
}

.page {
  padding: 32px 0 60px;
}

.site-header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  color: #0f172a;
  font-size: 18px;
  margin-left: 8px;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 17px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 8px;
}

.nav-link {
  text-decoration: none;
  color: #334155;
  font-size: 14px;
  font-weight: 600;
}

.button-link {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
  margin-bottom: 24px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
}

.button-secondary {
  border-color: #e2e8f0;
  color: #334155;
  background: #ffffff;
}

.button-delete:hover,
.button-delete:focus-visible {
  border-color: #fca5a5;
  background: #fee2e2;
  color: #b91c1c;
}

.button-danger {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fee2e2;
}

.button-danger:hover {
  border-color: #fca5a5;
  background: #fecaca;
  color: #991b1b;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.input,
.textarea,
select {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  border: 1px solid #e2e8f0;
  padding: 10px;
}

.table th {
  background: #f1f5f9;
  text-align: left;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 6px 10px;
  text-decoration: none;
  color: #334155;
  font-size: 13px;
}

.pill-fit {
  justify-self: start;
  width: fit-content;
}

.pill:hover {
  border-color: #16a34a;
  background: #dcfce7;
  color: #166534;
}

.quiz-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.quiz-header h1 {
  margin: 0;
}

.quiz-header .text-muted {
  margin: 4px 0 0;
}

.quiz-header {
  padding: 8px 0;
}

.quiz-wrapper canvas {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
}

.quiz-wrapper #answer {
  max-width: 360px;
}

.quiz-stats {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  color: #334155;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.result-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 120;
}

.result-modal {
  width: min(520px, 92vw);
  background: linear-gradient(135deg, #fefefe 0%, #f6fff8 100%);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  padding: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.result-modal::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle at center, #ffd700 0%, rgba(255, 215, 0, 0.2) 60%, transparent 70%);
}

.result-modal-title {
  font-size: 26px;
  margin: 0 0 6px;
}

.result-modal-trophy {
  font-size: 48px;
  margin: 6px auto 12px;
  width: 60px;
  height: 60px;
  position: relative;
}

.result-modal-trophy .trophy-half {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: none;
  opacity: 1;
  transform: translateX(0);
}

.result-modal-trophy .trophy-half.left {
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.result-modal-trophy .trophy-half.right {
  clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%);
}

.result-modal-trophy.lost .trophy-half {
  filter: grayscale(100%);
}

.result-modal-trophy.lost .trophy-half.left {
  animation: trophy-split-left 0.9s ease-in-out forwards;
}

.result-modal-trophy.lost .trophy-half.right {
  animation: trophy-split-right 0.9s ease-in-out forwards;
}

.result-modal-trophy.win .trophy-half {
  animation: trophy-win 1.2s ease-in-out infinite;
}

.result-modal-trophy.win .trophy-half.left {
  animation-delay: 0s;
  clip-path: none;
}

.result-modal-trophy.win .trophy-half.right {
  animation-delay: 0.1s;
  display: none;
}

@keyframes trophy-split-left {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(-10px) rotate(-8deg); opacity: 1; }
}

@keyframes trophy-split-right {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(10px) rotate(8deg); opacity: 1; }
}

@keyframes trophy-win {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  30% { transform: translateY(-4px) rotate(-2deg) scale(1.03); }
  60% { transform: translateY(0) rotate(2deg) scale(1); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

.result-modal-subtitle {
  color: #2f6f3e;
  font-weight: 700;
  margin-bottom: 14px;
}

.result-modal-stats {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin-top: 8px;
}

.result-modal-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.text-muted {
  color: #6b7280;
}

.login-links {
  font-size: 12px;
  margin: 14px 0 0;
  text-align: center;
}

.login-links a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}

.login-error {
  color: #dc2626;
  font-weight: 700;
  font-size: 13px;
  margin: 6px 0 12px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 8px 10px;
}

.login-links-sep {
  margin: 0 6px;
  color: #94a3b8;
}

.recaptcha-wrap {
  display: flex;
  justify-content: center;
}

@media (max-width: 640px) {
  .quiz-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .quiz-header h1 {
    font-size: 20px;
  }

  .quiz-header .button {
    align-self: flex-start;
  }
}

