/* Color Flashcards – Teen2Teen 1 Unit 10 */

/* Kill site chrome on this standalone game page */
.arcade-header-bar,
.arcade-nav,
.nav-profile,
.profile-fab,
[data-theme-toggle],
.theme-toggle,
body > header,
.site-footer {
  display: none !important;
}

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: pan-y;
  background: #f4f6fb;
  color: #1e293b;
}
html[data-theme="dark"] body {
  background: #0f1117;
  color: #f1f5f9;
}

.fc-game {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  padding: max(6px, env(safe-area-inset-top, 0px)) 0 max(8px, env(safe-area-inset-bottom, 0px));
}

/* ---------- Topbar ---------- */
.fc-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  flex-shrink: 0;
}
.fc-back,
.fc-shuffle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid #d0d5dd;
  background: #fff;
  color: #334155;
  font-size: 16px;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.fc-back:active,
.fc-shuffle:active { transform: scale(0.94); }
html[data-theme="dark"] .fc-back,
html[data-theme="dark"] .fc-shuffle {
  border-color: rgba(148, 163, 184, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}
.fc-shuffle { font-size: 15px; }
.fc-shuffle.is-on {
  border-color: #818cf8;
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
}
html[data-theme="dark"] .fc-shuffle.is-on {
  border-color: #818cf8;
  background: rgba(129, 140, 248, 0.22);
  color: #c4b5fd;
}

.fc-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-theme="dark"] .fc-title { color: #94a3b8; }

.fc-badge {
  font-size: 12px;
  font-weight: 800;
  color: #6d28d9;
  background: rgba(124, 92, 255, 0.12);
  padding: 5px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
html[data-theme="dark"] .fc-badge {
  color: #c4b5fd;
  background: rgba(167, 139, 250, 0.18);
}

/* ---------- Progress ---------- */
.fc-progress {
  height: 4px;
  background: #e2e8f0;
  margin: 0 14px 8px;
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
html[data-theme="dark"] .fc-progress { background: rgba(148, 163, 184, 0.2); }
.fc-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #818cf8, #6366f1);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* ---------- Card stage ---------- */
.fc-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  perspective: 1400px;
  -webkit-perspective: 1400px;
}

.fc-card {
  width: 100%;
  max-width: 340px;
  height: min(58vh, 380px);
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}
.fc-card.dragging { cursor: grabbing; }
.fc-card:focus-visible .fc-face {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.55), 0 12px 32px rgba(15, 23, 42, 0.1);
}

@keyframes fc-pop-in {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.fc-pop { animation: fc-pop-in 0.28s cubic-bezier(0.22, 1, 0.36, 1); }

.fc-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  -webkit-transition: -webkit-transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.fc-card.is-flipped .fc-card-inner {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

.fc-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
  background: #fff;
  border: 2px solid #e2e8f0;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  /* critical: do NOT use overflow:hidden here — it breaks 3D in some browsers */
}
html[data-theme="dark"] .fc-face {
  background: #1a1d27;
  border-color: rgba(148, 163, 184, 0.25);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* Thin color accent along the top edge — ties the card to the color it teaches */
.fc-face::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16%;
  right: 16%;
  height: 5px;
  border-radius: 0 0 6px 6px;
  background: var(--card-color, #6366f1);
  opacity: 0.9;
}

.fc-front {
  z-index: 2;
  transform: rotateY(0deg);
  -webkit-transform: rotateY(0deg);
  justify-content: center;
}
.fc-back {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  gap: 12px;
  z-index: 1;
  justify-content: center;
}

.fc-img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  border-radius: 12px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 6px;
  box-sizing: border-box;
}

/* Shown only if the image fails to load (onerror swaps it in) */
.fc-img-fallback {
  display: none;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 14px;
  background: var(--card-color, #94a3b8);
  align-items: center;
  justify-content: center;
}
.fc-img-fallback span {
  font-size: clamp(1.1rem, 5vw, 1.5rem);
  font-weight: 800;
  text-transform: capitalize;
  color: var(--card-text, #fff);
}

.fc-hint {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  pointer-events: none;
  z-index: 3;
}

.fc-swatch {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--card-color, #6366f1);
  border: 3px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
  flex-shrink: 0;
}

.fc-word {
  margin: 0;
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 800;
  text-align: center;
  text-transform: capitalize;
  line-height: 1.25;
  color: #1e293b;
  padding: 0 8px;
}
html[data-theme="dark"] .fc-word { color: #f1f5f9; }

/* ---------- Audio button ---------- */
.fc-audio-btn {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s, box-shadow 0.2s;
  flex-shrink: 0;
}
.fc-audio-btn:hover { transform: scale(1.06); }
.fc-audio-btn:active { transform: scale(0.96); }
.fc-audio-btn.playing { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.28); }
.fc-audio-btn svg { position: relative; z-index: 2; transition: opacity 0.2s, transform 0.2s; }
.fc-audio-btn .wave {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px solid #6366f1;
  opacity: 0;
  pointer-events: none;
}
.fc-audio-btn.playing .wave { animation: fc-ripple 1.25s ease-out infinite; }
.fc-audio-btn.playing .wave:nth-child(2) { animation-delay: 0.3s; }
.fc-audio-btn.playing .wave:nth-child(3) { animation-delay: 0.6s; }
@keyframes fc-ripple {
  0% { transform: scale(0.85); opacity: 0.65; }
  100% { transform: scale(1.55); opacity: 0; }
}
.fc-audio-btn .eq {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.fc-audio-btn .eq span {
  width: 3px;
  height: 14px;
  background: #fff;
  border-radius: 2px;
}
.fc-audio-btn.playing svg { opacity: 0; transform: scale(0.5); }
.fc-audio-btn.playing .eq { opacity: 1; }
.fc-audio-btn.playing .eq span:nth-child(1) { animation: fc-eq 0.55s ease-in-out infinite; }
.fc-audio-btn.playing .eq span:nth-child(2) { animation: fc-eq 0.55s ease-in-out infinite 0.1s; }
.fc-audio-btn.playing .eq span:nth-child(3) { animation: fc-eq 0.55s ease-in-out infinite 0.2s; }
.fc-audio-btn.playing .eq span:nth-child(4) { animation: fc-eq 0.55s ease-in-out infinite 0.15s; }
@keyframes fc-eq {
  0%, 100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1.15); }
}

/* ---------- Controls row ---------- */
.fc-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 8px 16px 4px;
  flex-shrink: 0;
}
.fc-nav {
  appearance: none;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #4338ca;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  transition: border-color 0.15s, transform 0.12s;
}
.fc-nav:active { transform: scale(0.96); }
.fc-nav:disabled { opacity: 0.35; cursor: default; }
html[data-theme="dark"] .fc-nav {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.25);
  color: #c4b5fd;
}

.fc-nav.fc-nav-end {
  width: auto;
  min-width: 56px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  border-radius: 999px;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  color: #fff;
  border: none;
  box-shadow: 0 3px 0 #1e40af, 0 8px 16px rgba(37, 99, 235, 0.25);
}
html[data-theme="dark"] .fc-nav.fc-nav-end {
  background: linear-gradient(180deg, #60a5fa, #1d4ed8);
  box-shadow: 0 3px 0 #1e3a8a, 0 8px 16px rgba(37, 99, 235, 0.35);
}

/* ---------- Done screen (fallback if LAFinish is unavailable) ---------- */
.fc-done {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  gap: 6px;
}
.fc-trophy { font-size: 2.6rem; }
.fc-done h1 { margin: 0 0 4px; font-size: 1.5rem; font-weight: 900; }
.fc-done p { margin: 0 0 14px; color: #64748b; font-weight: 600; }
html[data-theme="dark"] .fc-done p { color: #94a3b8; }

.fc-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.fc-btn {
  appearance: none;
  border: none;
  background: linear-gradient(145deg, #818cf8, #6366f1);
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fc-btn.secondary {
  background: #fff;
  color: #4338ca;
  border: 2px solid #c7d2fe;
  box-shadow: none;
}
html[data-theme="dark"] .fc-btn.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.35);
}

/* ---------- Responsive ---------- */
@media (min-width: 900px) {
  .fc-game { max-width: 560px; }
  .fc-card { max-width: 400px; height: min(52vh, 380px); }
  .fc-nav { width: 56px; height: 56px; font-size: 1.8rem; }
  .fc-audio-btn { width: 72px; height: 72px; }
  .fc-word { font-size: 2.1rem; }
}

@media (max-width: 420px) {
  .fc-game { padding-left: 0; padding-right: 0; }
  .fc-face { padding: 12px; }
  .fc-word { font-size: 1.35rem; }
  .fc-title { font-size: 12px; }
  .fc-swatch { width: 46px; height: 46px; }
}

@media (max-height: 680px) {
  .fc-card { height: min(48vh, 300px); }
  .fc-audio-btn { width: 54px; height: 54px; }
  .fc-nav { width: 42px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .fc-pop { animation: none; }
  .fc-card-inner { transition: none; }
  .fc-audio-btn.playing .wave { animation: none; }
}
