* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  font-family: Georgia, "Times New Roman", serif;
  color: #18352a;
  background:
    radial-gradient(circle at top left, rgba(190, 208, 164, 0.7), transparent 34%),
    linear-gradient(135deg, #eef4e6 0%, #c7d3b0 48%, #486b4a 100%);
}

.page-card {
  width: min(680px, 100%);
  padding: 56px 48px;
  text-align: center;
  background: rgba(247, 250, 240, 0.9);
  border: 1px solid rgba(72, 107, 74, 0.25);
  border-radius: 28px;
  box-shadow: 0 24px 70px rgba(24, 53, 42, 0.28);
}

.eyebrow {
  margin: 0 0 14px;
  font-family: Arial, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #5f7f59;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 4.8rem);
  line-height: 1;
  color: #204934;
}

p {
  max-width: 520px;
  margin: 22px auto 0;
  font-size: 1.25rem;
  line-height: 1.7;
  color: #375541;
}

.button-link,
button {
  display: inline-block;
  margin-top: 28px;
  padding: 14px 24px;
  border: 0;
  border-radius: 999px;
  font-family: Arial, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  color: #f7faf0;
  background: #2f563b;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(24, 53, 42, 0.22);
  transition: transform 0.2s ease, background 0.2s ease;
}

.button-link:hover,
button:hover {
  transform: translateY(-2px);
  background: #18352a;
}

.flashcard-page {
  width: min(980px, 100%);
  text-align: left;
}

.flashcard-page .eyebrow,
.flashcard-page h1,
.flashcard-page > p {
  text-align: center;
}

.back-link {
  display: inline-block;
  margin-bottom: 24px;
  font-family: Arial, sans-serif;
  font-weight: 700;
  color: #2f563b;
  text-decoration: none;
}

.back-link:hover {
  color: #18352a;
}

.flashcard-form {
  display: grid;
  gap: 14px;
  margin-top: 34px;
}

label,
h2,
h3 {
  color: #204934;
}

label {
  font-family: Arial, sans-serif;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 14px;
  border: 1px solid rgba(72, 107, 74, 0.35);
  border-radius: 16px;
  font: inherit;
  color: #18352a;
  background: #fbfdf6;
}

textarea:focus {
  outline: 3px solid rgba(95, 127, 89, 0.3);
  border-color: #5f7f59;
}

.flashcard-form button {
  justify-self: start;
}

.saved-section {
  margin-top: 44px;
}

.saved-section h2 {
  margin: 0 0 18px;
  font-size: 1.8rem;
}

.flashcard-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.flashcard {
  padding: 24px;
  border: 1px solid rgba(72, 107, 74, 0.22);
  border-radius: 22px;
  background: rgba(238, 244, 230, 0.86);
  animation: cardRise 0.55s ease both;
}

.flashcard--mini {
  display: grid;
  gap: 14px;
}

.mini-flip {
  width: 100%;
  min-height: 180px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  perspective: 900px;
  cursor: pointer;
  box-shadow: none;
}

.mini-flip:hover {
  transform: none;
}

.mini-flip__inner {
  position: relative;
  display: block;
  width: 100%;
  min-height: 180px;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.mini-flip.is-flipped .mini-flip__inner {
  transform: rotateY(180deg);
}

.mini-flip__face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  backface-visibility: hidden;
  text-align: left;
}

.mini-flip__face--front {
  background: linear-gradient(145deg, #f7faf0, #d8e4c8);
  border: 1px solid rgba(72, 107, 74, 0.28);
}

.mini-flip__face--back {
  background: linear-gradient(145deg, #204934, #355c42);
  color: #eef4e6;
  transform: rotateY(180deg);
}

.mini-flip__label {
  font-family: Arial, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.75;
}

.mini-flip__text {
  font-size: 1rem;
  line-height: 1.5;
}

.study-arena {
  margin-top: 10px;
  margin-bottom: 44px;
  padding: 28px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(190, 208, 164, 0.45), transparent 38%),
    rgba(238, 244, 230, 0.72);
  border: 1px solid rgba(72, 107, 74, 0.22);
  overflow: hidden;
}

.study-arena__header {
  text-align: center;
}

.study-arena__header h2 {
  margin: 0;
  font-size: 2rem;
}

.study-arena__subtitle {
  max-width: 620px;
  margin: 12px auto 0;
  font-size: 1rem;
}

.mode-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.mode-picker__btn {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin-top: 0;
  padding: 16px 12px;
  border-radius: 18px;
  background: rgba(247, 250, 240, 0.92);
  color: #204934;
  box-shadow: inset 0 0 0 1px rgba(72, 107, 74, 0.18);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.mode-picker__btn:hover,
.mode-picker__btn.is-active {
  transform: translateY(-3px);
  background: #2f563b;
  color: #f7faf0;
  box-shadow: 0 14px 28px rgba(24, 53, 42, 0.24);
}

.mode-picker__icon {
  font-size: 1.2rem;
}

.game-container {
  margin-top: 28px;
}

.game-message,
.game-progress,
.game-win {
  max-width: none;
  margin: 0;
  text-align: center;
  font-size: 1rem;
}

.game-win {
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(95, 127, 89, 0.18);
  animation: winPop 0.55s ease;
}

.flip-mode {
  position: relative;
  display: grid;
  gap: 18px;
}

.flip-mode__glow {
  position: absolute;
  top: 40px;
  left: 50%;
  width: min(420px, 80%);
  height: 220px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(190, 208, 164, 0.55), transparent 70%);
  filter: blur(18px);
  pointer-events: none;
  animation: glowPulse 3.5s ease-in-out infinite;
}

.flip-stage {
  position: relative;
  z-index: 1;
  perspective: 1400px;
  min-height: 320px;
}

.flip-card {
  position: relative;
  width: 100%;
  min-height: 320px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.34, 1.15, 0.64, 1);
  cursor: pointer;
  box-shadow: none;
}

.flip-card:hover {
  transform: translateY(-4px);
}

.flip-card.is-flipped {
  transform: rotateY(180deg);
}

.flip-card.is-flipped:hover {
  transform: rotateY(180deg) translateY(-4px);
}

.flip-card.is-exiting-left {
  animation: cardExitLeft 0.24s ease forwards;
}

.flip-card.is-exiting-right {
  animation: cardExitRight 0.24s ease forwards;
}

.flip-card.is-entering {
  animation: cardEnter 0.32s ease;
}

.flip-mode.is-shuffling .flip-card {
  animation: shuffleSpin 0.52s ease;
}

.flip-card__face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 36px;
  border-radius: 28px;
  backface-visibility: hidden;
  text-align: center;
}

.flip-card__front {
  background: linear-gradient(160deg, #f7faf0 0%, #dbe8cb 100%);
  border: 2px solid rgba(72, 107, 74, 0.28);
  box-shadow: 0 24px 50px rgba(24, 53, 42, 0.18);
}

.flip-card__back {
  background: linear-gradient(160deg, #18352a 0%, #355c42 100%);
  color: #eef4e6;
  transform: rotateY(180deg);
  box-shadow: 0 24px 50px rgba(24, 53, 42, 0.28);
}

.flip-card__label {
  font-family: Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.72;
}

.flip-card__text {
  max-width: none;
  margin: 0;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  line-height: 1.45;
}

.flip-mode__controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.ghost-button {
  margin-top: 0;
  padding: 10px 18px;
  background: rgba(47, 86, 59, 0.12);
  color: #204934;
  box-shadow: inset 0 0 0 1px rgba(72, 107, 74, 0.22);
}

.ghost-button:hover {
  background: #2f563b;
  color: #f7faf0;
}

.progress-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(47, 86, 59, 0.22);
  transition: transform 0.25s ease, background 0.25s ease;
}

.progress-dot.is-active {
  transform: scale(1.35);
  background: #2f563b;
}

.match-mode,
.quiz-mode,
.type-mode {
  display: grid;
  gap: 18px;
}

.match-score,
.quiz-scoreboard,
.type-scoreboard {
  max-width: none;
  margin: 0;
  text-align: center;
  font-size: 1rem;
}

.quiz-scoreboard {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
}

.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.match-tile {
  min-height: 130px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  perspective: 900px;
  cursor: pointer;
  box-shadow: none;
  animation: cardRise 0.45s ease both;
}

.match-tile:hover {
  transform: none;
}

.match-tile__inner {
  position: relative;
  display: block;
  width: 100%;
  min-height: 130px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.34, 1.1, 0.64, 1);
}

.match-tile.is-flipped .match-tile__inner {
  transform: rotateY(180deg);
}

.match-tile.is-matched .match-tile__inner {
  transform: rotateY(180deg) scale(0.96);
}

.match-tile.is-wrong .match-tile__inner {
  animation: wrongShake 0.45s ease;
}

.match-tile__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: 18px;
  backface-visibility: hidden;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.4;
}

.match-tile__face--front {
  background: linear-gradient(145deg, #355c42, #204934);
  color: #eef4e6;
  font-size: 1.6rem;
  font-weight: 700;
}

.match-tile__face--back {
  background: #f7faf0;
  color: #18352a;
  transform: rotateY(180deg);
  border: 1px solid rgba(72, 107, 74, 0.24);
}

.match-tile.is-matched .match-tile__face--back {
  background: linear-gradient(145deg, #c7d3b0, #eef4e6);
  box-shadow: 0 0 0 2px rgba(95, 127, 89, 0.45);
}

.quiz-card,
.type-card {
  padding: 28px;
  border-radius: 24px;
  background: linear-gradient(160deg, #f7faf0, #dbe8cb);
  border: 1px solid rgba(72, 107, 74, 0.24);
  text-align: center;
  animation: cardEnter 0.45s ease;
}

.quiz-card__label,
.type-card__label {
  display: block;
  font-family: Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #5f7f59;
}

.quiz-card__text,
.type-card__text {
  max-width: none;
  margin: 12px 0 0;
  font-size: 1.35rem;
}

.quiz-options {
  display: grid;
  gap: 12px;
}

.quiz-option {
  margin-top: 0;
  width: 100%;
  text-align: left;
  background: rgba(247, 250, 240, 0.95);
  color: #18352a;
  box-shadow: inset 0 0 0 1px rgba(72, 107, 74, 0.18);
  animation: optionSlide 0.45s ease both;
}

.quiz-option:hover {
  background: #2f563b;
  color: #f7faf0;
}

.quiz-option.is-correct {
  background: #355c42;
  color: #f7faf0;
  animation: correctPulse 0.55s ease;
}

.quiz-option.is-wrong {
  background: #6b3f34;
  color: #f7faf0;
  animation: wrongShake 0.45s ease;
}

.quiz-mode.quiz-burst::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(190, 208, 164, 0.35), transparent 60%);
  animation: burstFade 0.7s ease;
}

.quiz-mode {
  position: relative;
}

.type-form {
  display: grid;
  gap: 12px;
}

.type-form label {
  font-family: Arial, sans-serif;
  font-weight: 700;
}

.type-form input[type="text"] {
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(72, 107, 74, 0.35);
  border-radius: 16px;
  font: inherit;
  color: #18352a;
  background: #fbfdf6;
}

.type-form input[type="text"]:focus {
  outline: 3px solid rgba(95, 127, 89, 0.3);
  border-color: #5f7f59;
}

.type-form button {
  justify-self: start;
  margin-top: 0;
}

.type-feedback {
  max-width: none;
  margin: 0;
  min-height: 1.4rem;
  text-align: center;
  font-size: 1rem;
}

.type-feedback--success {
  color: #204934;
}

.type-feedback--error {
  color: #6b3f34;
}

.type-mode.type-success-pop {
  animation: winPop 0.55s ease;
}

.type-mode.type-shake {
  animation: wrongShake 0.45s ease;
}

@keyframes cardRise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(16px) rotateX(8deg);
  }

  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

@keyframes cardExitLeft {
  to {
    opacity: 0;
    transform: translateX(-36px) rotateY(-10deg);
  }
}

@keyframes cardExitRight {
  to {
    opacity: 0;
    transform: translateX(36px) rotateY(10deg);
  }
}

@keyframes shuffleSpin {
  0% {
    transform: rotateY(0) scale(1);
  }

  50% {
    transform: rotateY(180deg) scale(0.92);
  }

  100% {
    transform: rotateY(360deg) scale(1);
  }
}

@keyframes glowPulse {
  0%,
  100% {
    opacity: 0.65;
    transform: translateX(-50%) scale(1);
  }

  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.08);
  }
}

@keyframes wrongShake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-6px);
  }

  75% {
    transform: translateX(6px);
  }
}

@keyframes correctPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes optionSlide {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes burstFade {
  from {
    opacity: 0.8;
  }

  to {
    opacity: 0;
  }
}

@keyframes winPop {
  0% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.02);
  }

  100% {
    transform: scale(1);
  }
}

.flashcard h3 {
  margin: 0;
  font-size: 1.35rem;
}

.flashcard p,
.empty-message {
  max-width: none;
  margin: 14px 0 0;
  font-size: 1rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.card-actions button {
  margin-top: 0;
  padding: 10px 18px;
}

.delete-button {
  background: #6b3f34;
}

.delete-button:hover {
  background: #4d2d25;
}

#site-nav {
  margin-bottom: 24px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 18px;
}

.site-nav--logged-in {
  flex-direction: column;
}

.site-nav--logged-in p {
  margin: 0;
  font-size: 1rem;
}

.site-nav__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.button-link--small,
.site-nav button {
  margin-top: 0;
  padding: 10px 18px;
  font-size: 0.88rem;
}

.text-link {
  font-family: Arial, sans-serif;
  font-weight: 700;
  color: #2f563b;
  text-decoration: none;
}

.text-link:hover {
  color: #18352a;
}

.auth-page {
  text-align: left;
}

.auth-page .eyebrow,
.auth-page h1,
.auth-page > p {
  text-align: center;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 34px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(72, 107, 74, 0.35);
  border-radius: 16px;
  font: inherit;
  color: #18352a;
  background: #fbfdf6;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: 3px solid rgba(95, 127, 89, 0.3);
  border-color: #5f7f59;
}

.form-message {
  margin: 0;
  font-size: 0.95rem;
}

.form-message--error {
  color: #6b3f34;
}

.auth-switch {
  margin-top: 28px;
  text-align: center;
  font-size: 1rem;
}

.auth-notice {
  max-width: none;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 16px;
  text-align: center;
  font-size: 1rem;
  background: rgba(199, 211, 176, 0.55);
  border: 1px solid rgba(72, 107, 74, 0.25);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
}

@media (max-width: 560px) {
  body {
    padding: 20px;
  }

  .page-card {
    padding: 40px 24px;
    border-radius: 22px;
  }

  .card-actions {
    flex-direction: column;
  }

  .mode-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flip-card,
  .flip-stage {
    min-height: 260px;
  }
}
