﻿:root {
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  color: #1f2a37;
  background: #f5f7fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #e0edff, #fdf2f8);
  color: inherit;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.page-header,
footer {
  text-align: center;
  padding: 1.5rem;
}

.page-header h1 {
  margin-bottom: 0.5rem;
}

.card {
  background: #fff;
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(31, 42, 55, 0.08);
}

.scoreboard {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-weight: 600;
  color: #1f2a37;
}

.scoreboard span {
  background: #eef2ff;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.95rem;
}

.result-meta {
  margin: 0.35rem 0;
  color: #475569;
  font-weight: 500;
}

.attempt-hint {
  margin: 0.75rem 0 0.25rem;
  color: #6b7280;
  font-size: 0.95rem;
}

.keyboard {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.keyboard-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(60px, 1fr));
  gap: 0.5rem;
}

.keyboard button {
  background: #fff;
  border: 1px solid #c5ced9;
  border-radius: 16px;
  font-size: 1.2rem;
  padding: 0.8rem 0;
  box-shadow: inset 0 -4px 0 rgba(31, 42, 55, 0.05);
  transition: background-color 120ms ease, color 120ms ease;
}

.keyboard button:hover {
  background: #4b6bfb;
  color: #fff;
}

.keyboard button[data-action] {
  font-size: 1rem;
}

#practice.card {
  width: min(900px, 100%);
  align-self: center;
}

.target-form label {
  font-weight: 600;
}

.form-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

input[type="number"] {
  flex: 1;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid #c5ced9;
  font-size: 1rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.answer-field {
  flex: 1;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid #c5ced9;
  font-size: 1rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.answer-field.correct {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.answer-field.incorrect {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button[type="submit"] {
  background: #4b6bfb;
  color: #fff;
  box-shadow: 0 6px 20px rgba(75, 107, 251, 0.3);
}

button.secondary {
  background: #e8ecfb;
  color: #1f2a37;
}

button.next-primary:not(:disabled) {
  background: #4b6bfb;
  color: #fff;
  box-shadow: 0 6px 20px rgba(75, 107, 251, 0.3);
}

button.pill {
  background: #fff;
  color: #1f2a37;
  border: 1px solid #c5ced9;
  box-shadow: none;
  transition: background-color 120ms ease, color 120ms ease, transform 150ms ease,
    box-shadow 150ms ease;
}

button.pill:hover {
  background: #4b6bfb;
  color: #fff;
  transform: none;
}

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

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.quick-buttons {
  margin-top: 1rem;
  --quick-btn-width: clamp(48px, 5vw, 62px);
  --quick-gap: 0.45rem;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(10, var(--quick-btn-width));
  justify-content: flex-start;
  gap: var(--quick-gap);
}

.quick-buttons .button-row + .button-row {
  margin-top: 0.75rem;
}

.quick-buttons .pill {
  width: var(--quick-btn-width);
  text-align: center;
  justify-self: start;
}

.pill.placeholder {
  visibility: hidden;
  pointer-events: none;
  display: inline-block;
}

.practice-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.link-button {
  background: transparent;
  color: #4b6bfb;
  padding: 0;
  box-shadow: none;
  border-radius: 0;
}

.prompt {
  font-size: 1.5rem;
  margin: 1rem 0;
}

.answer-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

#answer-input {
  flex: 1;
}

.feedback {
  min-height: 2.75rem;
  margin-top: 0.5rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
}

.feedback.success {
  color: #0f6a23;
  background: #ecfdf3;
  border-color: rgba(34, 197, 94, 0.4);
}

.feedback.error {
  color: #9f1239;
  background: #fff1f2;
  border-color: rgba(244, 63, 94, 0.4);
}

footer {
  color: #4b5563;
  font-size: 0.95rem;
}

.sr-only {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  width: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
}

.hint {
  font-size: 1rem;
  color: #4b5563;
  margin: 0.75rem 0 0.25rem;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(55px, 1fr));
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.choice-grid button {
  border: 1px solid #c5ced9;
  background: #fff;
  color: #1f2a37;
  border-radius: 12px;
  padding: 0.45rem 0;
  font-size: 1rem;
  box-shadow: none;
  transition: background-color 120ms ease, color 120ms ease, transform 150ms ease,
    box-shadow 150ms ease;
}

.choice-grid button:hover {
  background: #4b6bfb;
  color: #fff;
  transform: none;
}

.choice-grid button.correct {
  background: #22c55e;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.choice-grid button.incorrect {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.animate-pop {
  animation: pop 220ms ease;
}

input[type="number"].correct {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

input[type="number"].incorrect {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
  animation: shake 230ms ease;
}

@keyframes pop {
  0% {
    transform: scale(0.96);
  }
  60% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  50% {
    transform: translateX(2px);
  }
  75% {
    transform: translateX(-1px);
  }
}

#confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  transform: translate3d(0, -60px, 0) rotate(0deg);
  animation: confetti-fall var(--confetti-duration, 1.5s) linear forwards;
  animation-delay: var(--confetti-delay, 0s);
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate3d(0, -60px, 0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(
        var(--confetti-drift, 0px),
        110vh,
        0
      )
      rotate(var(--confetti-rotation, 360deg));
  }
}

@media (max-width: 540px) {
  .scoreboard {
    flex-direction: column;
  }

  .form-row,
  .answer-form {
    flex-direction: column;
  }

  button,
  input[type="number"] {
    width: 100%;
  }

  .button-row {
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  }

  .button-row.row-first .placeholder {
    display: none;
  }

  .quick-buttons .pill {
    width: 100%;
  }
}
