:root {
  --ink: #14281d;
  --muted: #526b5d;
  --bg: #f2f8f5;
  --surface: #ffffff;
  --line: #d3e5dc;
  --green: #1f8a7e;
  --green-dark: #12534c;
  --green-light: #e6f6f4;
  --shamrock: #10b981;
  --sun: #f4a261;
  --coral: #d9603f;
  --gold: #f59e0b;
  --display: "Bricolage Grotesque", system-ui, -apple-system, sans-serif;
  --body: "Lexend", system-ui, -apple-system, sans-serif;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(18, 83, 76, 0.08);
  --shadow-sm: 0 3px 10px rgba(18, 83, 76, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--body);
  background-color: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--shamrock), var(--green-dark));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.3rem;
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.3);
}

.brand-text h1 {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--green-dark);
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Controls */
.controls-bar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.select-wrap select {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 1.8rem 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23526b5d%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.4-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem top 50%;
  background-size: 0.65rem auto;
}

.mode-pills {
  display: flex;
  background: var(--bg);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.mode-btn {
  font-family: var(--body);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--surface);
  color: var(--green-dark);
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--bg);
  border-color: var(--green);
}

/* Arena */
main {
  max-width: 1100px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem;
  flex: 1;
}

/* Top Info Bar */
.game-info-bar {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1rem 1.4rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.info-title h2 {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--green-dark);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.info-title p {
  font-size: 0.85rem;
  color: var(--muted);
}

.score-stats {
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.stat-pill {
  background: var(--bg);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green-dark);
}

/* Memory Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  perspective: 1000px;
}

@media (max-width: 768px) {
  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
  }
}

@media (max-width: 480px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }
}

/* Flip Card */
.memory-card {
  height: 140px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  user-select: none;
}

.memory-card.flipped {
  transform: rotateY(180deg);
}

.memory-card.matched {
  transform: rotateY(180deg);
  pointer-events: none;
  animation: pulseMatched 0.4s ease;
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.card-back {
  background: linear-gradient(135deg, var(--green-dark), #0f403b);
  border: 3px solid #1f8a7e;
  color: #fff;
}

.card-back .card-pattern {
  font-size: 2.2rem;
  opacity: 0.85;
  transition: transform 0.2s ease;
}

.memory-card:hover .card-back .card-pattern {
  transform: scale(1.15);
}

.card-front {
  background: #ffffff;
  border: 3px solid var(--line);
  transform: rotateY(180deg);
  color: var(--ink);
}

.memory-card.matched .card-front {
  border-color: var(--shamrock);
  background: #f0fdf4;
}

.card-emoji {
  font-size: 2rem;
  margin-bottom: 0.3rem;
}

.card-text {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-dark);
  line-height: 1.2;
}

.card-subtext {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.card-voice-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(31, 138, 126, 0.15);
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--green-dark);
  cursor: pointer;
}

/* Quiz Mode Layout */
.quiz-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 0;
}

.quiz-speaker-box {
  background: var(--surface);
  border: 2px solid var(--green);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 500px;
  width: 100%;
}

.quiz-big-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--shamrock), var(--green-dark));
  border: none;
  color: #fff;
  font-size: 2.2rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.8rem;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.quiz-big-btn:hover {
  transform: scale(1.08);
}

.quiz-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  width: 100%;
  max-width: 700px;
}

@media (max-width: 580px) {
  .quiz-options-grid {
    grid-template-columns: 1fr;
  }
}

.quiz-option-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.quiz-option-card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(31, 138, 126, 0.15);
}

.quiz-option-card.correct {
  background: #f0fdf4;
  border-color: var(--shamrock);
}

.quiz-option-card.wrong {
  background: #fef2f2;
  border-color: #ef4444;
}

.quiz-opt-emo {
  font-size: 2.4rem;
}

.quiz-opt-text h4 {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--green-dark);
}

.quiz-opt-text p {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Flashcards Mode */
.flashcards-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 0;
}

.huge-flashcard {
  width: 100%;
  max-width: 480px;
  height: 280px;
  background: var(--surface);
  border: 3px solid var(--green);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.huge-flashcard:hover {
  transform: translateY(-3px);
}

.flashcard-emo {
  font-size: 4.5rem;
  margin-bottom: 0.5rem;
}

.flashcard-ga {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--green-dark);
}

.flashcard-en {
  font-size: 1.2rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.flash-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.btn-flash {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.6rem 1.4rem;
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--green-dark);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-flash:hover {
  background: var(--green-light);
  border-color: var(--green);
}

/* Win Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(18, 83, 76, 0.65);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 2.2rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

@keyframes pulseMatched {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.08); }
  100% { transform: rotateY(180deg) scale(1); }
}

