/* ── Quiz / Mini-games — dark default, [data-theme="light"] overrides ──────── */

/* Backdrop */
.quiz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 3, 18, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 0;
  touch-action: none;
  overscroll-behavior: none;
}

@media (min-width: 600px) {
  .quiz-overlay { align-items: center; padding: 24px; }
}

/* Card */
@keyframes quiz-slide-up {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.quiz-modal {
  background: #26153d;
  border: 1px solid #3d2060;
  border-radius: 20px 20px 0 0;
  padding: 28px 24px calc(36px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 440px;
  max-height: 90dvh;
  overflow-y: auto;
  touch-action: pan-y;
  box-shadow: 0 -4px 40px rgba(0,0,0,0.5);
  animation: quiz-slide-up 0.28s cubic-bezier(0.22,1,0.36,1);
}

@media (min-width: 600px) {
  .quiz-modal { border-radius: 20px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
}

[data-theme="light"] .quiz-modal {
  background: #fff;
  border-color: #f3e8e0;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

/* Prompt label */
.quiz-prompt {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fb923c;
  margin: 0 0 10px;
}

[data-theme="light"] .quiz-prompt { color: #f97316; }

/* Big word */
.quiz-word {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #f0e8ff;
  margin: 0 0 22px;
  line-height: 1.1;
}

[data-theme="light"] .quiz-word { color: #1a1a2e; }

/* Textarea (unused currently but kept) */
.quiz-textarea {
  width: 100%;
  box-sizing: border-box;
  background: #1c0f2e;
  border: 1.5px solid #3d2060;
  border-radius: 10px;
  color: #f0e8ff;
  font: inherit;
  font-size: 0.9rem;
  padding: 10px 14px;
  resize: vertical;
  margin-bottom: 20px;
  transition: border-color 0.15s;
}
.quiz-textarea:focus { outline: none; border-color: #f97316; }

[data-theme="light"] .quiz-textarea { background: #f9fafb; border-color: #e5e7eb; color: #1a1a2e; }
[data-theme="light"] .quiz-textarea:focus { border-color: #f97316; }

/* Strip focus rings and tap highlights from all game buttons — these games are touch-first */
.quiz-overlay button,
.quiz-overlay button:focus,
.quiz-overlay button:focus-visible {
  outline: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* CTA button */
.quiz-btn {
  width: 100%;
  padding: 13px;
  border-radius: 50px;
  border: none;
  background: linear-gradient(90deg, #f97316, #ec4899);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.quiz-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* Choices */
.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.quiz-choice {
  text-align: left;
  background: #2e1a45;
  border: 1.5px solid #3d2060;
  border-radius: 12px;
  color: #c4b5d0;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  padding: 12px 16px;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

@media (hover: hover) {
  .quiz-choice:not(:disabled):hover {
    background: #3d2060;
    border-color: #6d40a0;
    color: #f0e8ff;
    transform: translateX(4px);
  }
}

.quiz-choice--correct {
  background: rgba(52,211,153,0.12) !important;
  border-color: #34d399 !important;
  color: #34d399 !important;
  font-weight: 600;
}

.quiz-choice--wrong {
  background: rgba(248,113,113,0.12) !important;
  border-color: #f87171 !important;
  color: #f87171 !important;
}

[data-theme="light"] .quiz-choice { background: #f9fafb; border-color: #e5e7eb; color: #374151; }
[data-theme="light"] .quiz-choice:not(:disabled):hover { background: #f3f4f6; border-color: #d1d5db; color: #1a1a2e; }
[data-theme="light"] .quiz-choice--correct { background: rgba(16,185,129,0.08) !important; border-color: #10b981 !important; color: #10b981 !important; }
[data-theme="light"] .quiz-choice--wrong   { background: rgba(239,68,68,0.08) !important; border-color: #ef4444 !important; color: #ef4444 !important; }

/* Feedback banners */
.quiz-feedback {
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: 10px;
  line-height: 1.5;
}

.quiz-feedback--pass {
  background: rgba(52,211,153,0.12);
  color: #34d399;
}

.quiz-feedback--fail {
  background: rgba(248,113,113,0.12);
  color: #f87171;
}

[data-theme="light"] .quiz-feedback--pass { background: rgba(16,185,129,0.08); color: #10b981; }
[data-theme="light"] .quiz-feedback--fail { background: rgba(239,68,68,0.08);   color: #ef4444; }

/* ── Word Duel ──────────────────────────────────────────────────────────────── */

.duel-modal { text-align: center; }
.duel-label { text-align: center; }

.duel-word {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #f0e8ff;
  margin: 0 0 6px;
  line-height: 1.1;
}

[data-theme="light"] .duel-word { color: #1a1a2e; }

.duel-arrow { font-size: 1.2rem; color: #7c6990; margin: 0 0 6px; }

.duel-meaning {
  font-size: 1.4rem;
  font-weight: 700;
  color: #c4b5d0;
  margin: 0 0 20px;
  line-height: 1.25;
}

[data-theme="light"] .duel-meaning { color: #374151; }

.duel-bar-track {
  height: 4px;
  background: #3d2060;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 24px;
}

[data-theme="light"] .duel-bar-track { background: #f3e8e0; }

.duel-bar-fill {
  height: 100%;
  background: #f97316;
  border-radius: 99px;
  transition: background 0.15s;
}

.duel--correct .duel-bar-fill { background: #34d399; }
.duel--wrong   .duel-bar-fill { background: #f87171; }

.duel-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.duel-btn {
  padding: 14px;
  border-radius: 50px;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: opacity 0.15s, transform 0.15s;
}
.duel-btn:disabled { opacity: 0.35; cursor: default; }

.duel-btn--false {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.35);
  color: #f87171;
}
.duel-btn--false:not(:disabled):hover { filter: brightness(1.15); transform: translateY(-1px); }

.duel-btn--true {
  background: rgba(52,211,153,0.12);
  border-color: rgba(52,211,153,0.35);
  color: #34d399;
}
.duel-btn--true:not(:disabled):hover { filter: brightness(1.15); transform: translateY(-1px); }

[data-theme="light"] .duel-btn--false { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.3); color: #ef4444; }
[data-theme="light"] .duel-btn--true  { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.3); color: #10b981; }

@keyframes duel-shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-7px); }
  40%      { transform: translateX(7px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

@keyframes duel-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.duel--correct .duel-modal { animation: duel-pop   0.25s ease-out; }
.duel--wrong   .duel-modal { animation: duel-shake 0.28s ease-out; }

/* ── Spell game ──────────────────────────────────────────────────────────────── */

.spell-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 20px;
}

.spell-space { width: 10px; flex-shrink: 0; }

.spell-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 42px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: lowercase;
}

.spell-box--hint {
  background: rgba(249,115,22,0.15);
  border: 2px solid #f97316;
  color: #fb923c;
}

.spell-box--empty {
  background: #1c0f2e;
  border: 2px dashed #3d2060;
  color: #c4b5d0;
  cursor: pointer;
  transition: border-color 0.15s;
}

.spell-box--filled {
  border-style: solid;
  border-color: #6d40a0;
  background: #2e1a45;
  color: #f0e8ff;
  cursor: pointer;
}

.spell-box--correct { background: rgba(52,211,153,0.12) !important; border-color: #34d399 !important; color: #34d399 !important; }
.spell-box--wrong   { background: rgba(248,113,113,0.12) !important; border-color: #f87171 !important; color: #f87171 !important; }

[data-theme="light"] .spell-box--empty  { background: #f9fafb; border-color: #d1d5db; color: #9ca3af; }
[data-theme="light"] .spell-box--filled { background: #f3f4f6; border-color: #9ca3af; color: #1a1a2e; }
[data-theme="light"] .spell-box--hint   { background: rgba(249,115,22,0.1); border-color: #f97316; color: #f97316; }
[data-theme="light"] .spell-box--correct { background: rgba(16,185,129,0.1) !important; border-color: #10b981 !important; color: #10b981 !important; }
[data-theme="light"] .spell-box--wrong   { background: rgba(239,68,68,0.1) !important; border-color: #ef4444 !important; color: #ef4444 !important; }

.spell-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
  min-height: 44px;
}

.spell-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 42px;
  background: #2e1a45;
  border: 1.5px solid #6d40a0;
  border-radius: 8px;
  color: #f0e8ff;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
}

@media (hover: hover) {
  .spell-chip:not(:disabled):hover { background: #3d2060; transform: translateY(-2px); }
}
.spell-chip--used { opacity: 0.2; cursor: default; }

[data-theme="light"] .spell-chip { background: #f3f4f6; border-color: #d1d5db; color: #1a1a2e; }
[data-theme="light"] .spell-chip:not(:disabled):hover { background: #e5e7eb; }

/* ── Flash Scramble ─────────────────────────────────────────────────────────── */

.fs-modal { text-align: center; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }

.fs-word-display { font-size: 2rem; font-weight: 800; color: #f0e8ff; letter-spacing: 0.05em; }
[data-theme="light"] .fs-word-display { color: #1a1a2e; }

.fs-flash { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.fs-flash-boxes { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; justify-content: center; }
.fs-flash-box { cursor: default; color: #fb923c; border-color: #f97316; background: rgba(249,115,22,0.12); }

@keyframes fs-scatter {
  0%   { transform: translate(0,0) rotate(0deg); opacity: 1; }
  55%  { transform: translate(var(--fsx), var(--fsy)) rotate(var(--fsr)); opacity: 0.5; }
  100% { transform: translate(calc(var(--fsx)*1.4), calc(var(--fsy)*1.4)) rotate(calc(var(--fsr)*1.3)); opacity: 0; }
}
.fs-flash-box--scatter { animation: fs-scatter 0.38s ease-in both; }

.fs-tile-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; touch-action: none; }

@keyframes fs-gap-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.fs-gap-indicator {
  width: 40px; height: 48px;
  border: 2px dashed #f97316;
  border-radius: 8px;
  background: rgba(249,115,22,0.08);
  flex-shrink: 0;
  pointer-events: none;
  animation: fs-gap-pop 0.14s cubic-bezier(0.34,1.56,0.64,1);
}

.fs-continue { margin-top: 24px; }

.fs-tile {
  width: 40px; height: 48px;
  background: #2e1a45;
  border: 1.5px solid #6d40a0;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 800; color: #f0e8ff;
  cursor: grab; user-select: none; touch-action: none;
  transition: background 0.12s, transform 0.12s, box-shadow 0.12s;
}
.fs-tile:hover { background: #3d2060; transform: translateY(-3px); box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.fs-tile:active { cursor: grabbing; }

.fs-tile--flash { background: rgba(249,115,22,0.12); border-color: #f97316; color: #fb923c; cursor: default; }

.fs-tile--ghost {
  position: fixed; z-index: 9999; pointer-events: none;
  transform: rotate(-6deg) scale(1);
  transform-origin: center;
  border-color: #f97316;
  background: #26153d;
  box-shadow: 0 10px 28px -6px rgba(249,115,22,0.45);
  transition: transform 0.14s cubic-bezier(0.34,1.56,0.64,1);
}
.fs-tile--ghost.fs-tile--lifted { transform: rotate(-6deg) scale(1.13); }

@keyframes fs-tile-wobble {
  0%   { transform: translateX(var(--slide-x)); }
  50%  { transform: translateX(0) scale(1.14) rotate(3deg); }
  68%  { transform: translateX(0) scale(0.93) rotate(-2deg); }
  82%  { transform: translateX(0) scale(1.05) rotate(1deg); }
  92%  { transform: translateX(0) scale(0.98); }
  100% { transform: none; }
}

@keyframes fs-tile-land {
  0%   { transform: scale(0.55) rotate(-8deg); }
  55%  { transform: scale(1.14) rotate(1deg); }
  78%  { transform: scale(0.94) rotate(-0.5deg); }
  100% { transform: none; }
}

.fs-tile--dragging { opacity: 0.3; }

.fs-tile--hover { border-color: #f97316 !important; background: rgba(249,115,22,0.15) !important; transform: scale(1.08); }
.fs-tile--scramble-flash { background: #2e1a45; border-color: #6d40a0; }

.fs-tile--correct { background: rgba(52,211,153,0.12) !important; border-color: #34d399 !important; color: #34d399 !important; cursor: default; }

@keyframes fs-tile-correct {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.fs-tile--correct { animation: fs-tile-correct 0.25s cubic-bezier(0.34,1.56,0.64,1); }

.fs-continue--muted { opacity: 0.3; pointer-events: none; }
.fs-continue--win   { background: rgba(52,211,153,0.12); border-color: #34d399; color: #34d399; opacity: 1; pointer-events: auto; }

[data-theme="light"] .fs-tile { background: #f9fafb; border-color: #d1d5db; color: #1a1a2e; }
[data-theme="light"] .fs-tile:hover { background: #f3f4f6; }
[data-theme="light"] .fs-tile--flash { background: rgba(249,115,22,0.1); }
[data-theme="light"] .fs-tile--ghost { background: #fff; }
[data-theme="light"] .fs-tile--scramble-flash { background: #f9fafb; border-color: #d1d5db; }
[data-theme="light"] .fs-tile--correct { background: rgba(16,185,129,0.1) !important; border-color: #10b981 !important; color: #10b981 !important; }
[data-theme="light"] .fs-continue--win { background: rgba(16,185,129,0.1); border-color: #10b981; color: #10b981; }
[data-theme="light"] .fs-gap-indicator { border-color: #f97316; background: rgba(249,115,22,0.06); }

/* ── Scramble Recognition ────────────────────────────────────────────────────── */

.sr-modal { min-height: 220px; }
.sr-meaning { font-size: 1.4rem; font-weight: 700; color: #f0e8ff; margin: 0 0 16px; text-align: center; }
[data-theme="light"] .sr-meaning { color: #1a1a2e; }
.sr-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sr-choice { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.04em; }

/* ── Clickable word cards (my-words page, keep separate) ────────────────────── */
.mw-card { cursor: pointer; }
