/* ============================================================
   PALABRA QUEST — Memory Deck  (css/games/flash.css)
   Every selector is prefixed with .g-flash. Reuses the shared
   tokens and the .card / .hud / .bar / .chip / .toggle components.
   ============================================================ */

.g-flash { --accent: var(--c-sky); }

/* ---------- Start screen ---------- */
.g-flash-hero { display: grid; grid-template-columns: 1.5fr 1fr; gap: var(--sp-6); align-items: center; overflow: hidden; }
.g-flash-hero::before {
  content: ''; position: absolute; top: -45%; left: -8%; width: 360px; height: 360px; border-radius: 50%;
  background: var(--c-sky); opacity: 0.14; filter: blur(80px); pointer-events: none;
}
.g-flash-hero-text { position: relative; }
.g-flash-hero h2 { margin-bottom: 8px; font-size: clamp(1.6rem, 3.4vw, 2.25rem); }
.g-flash-hero p { margin: 0; max-width: 52ch; }
.g-flash-hero-side { position: relative; display: grid; gap: 14px; }
.g-flash-hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.g-flash-hero-stats .stat { text-align: center; }

/* Decorative fan of three mini cards */
.g-flash-fan { position: relative; height: 104px; }
.g-flash-fan i {
  position: absolute; left: 50%; top: 10px; width: 62px; height: 82px; margin-left: -31px; border-radius: 12px;
  display: grid; place-items: center; font-style: normal; font-family: var(--font-display); font-size: 1.9rem; font-weight: 900; color: var(--c-amber);
  background: linear-gradient(160deg, rgba(255,255,255,0.14), rgba(255,255,255,0.04)); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md); transform-origin: 50% 130%;
  animation: g-flash-fan-float 4s ease-in-out infinite;
}
.g-flash-fan i:nth-child(1) { transform: rotate(-18deg) translateX(-12px); color: var(--c-mint); animation-delay: -0.6s; }
.g-flash-fan i:nth-child(2) { transform: translateY(-8px); z-index: 2; animation-delay: -1.8s; }
.g-flash-fan i:nth-child(3) { transform: rotate(18deg) translateX(12px); color: var(--c-lav); animation-delay: -3s; }
@keyframes g-flash-fan-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }

.g-flash-settings {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border);
}
.g-flash-setting { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.g-flash-seg { display: inline-flex; padding: 4px; border-radius: 999px; background: rgba(0,0,0,0.28); border: 1px solid var(--border); }
.g-flash-seg button {
  padding: 7px 14px; border-radius: 999px; color: var(--text-2); font-weight: 600; font-size: 0.88rem; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.g-flash-seg button:hover { color: var(--text); }
.g-flash-seg button[aria-pressed="true"] { background: rgba(96,165,250,0.22); color: #dbeafe; box-shadow: inset 0 0 0 1px rgba(96,165,250,0.55); }
.g-flash-recall-toggle { color: var(--text); font-weight: 600; }
.g-flash-recall-toggle input:disabled ~ * { opacity: 0.45; }

.g-flash-decks { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.g-flash-deck.is-cats { grid-column: 1 / -1; }
.g-flash-deck {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; text-align: left;
  padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); color: var(--text);
  overflow: hidden; box-shadow: var(--shadow-sm); font: inherit;
  transition: transform var(--t-med) var(--ease), border-color var(--t-med), box-shadow var(--t-med), opacity var(--t-med);
}
.g-flash-deck::before {
  content: ''; position: absolute; top: -70px; right: -50px; width: 190px; height: 190px; border-radius: 50%;
  background: var(--accent); opacity: 0.12; filter: blur(46px); transition: opacity var(--t-med); pointer-events: none;
}
.g-flash-deck:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.g-flash-deck:hover:not(:disabled)::before { opacity: 0.26; }
.g-flash-deck:not(.is-cats) { cursor: pointer; }
.g-flash-deck:not(.is-cats):active:not(:disabled) { transform: translateY(0) scale(0.99); }
.g-flash-deck:disabled { cursor: not-allowed; opacity: 0.6; }
.g-flash-deck-icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.45rem;
  background: var(--surface-2); border: 1px solid var(--border); position: relative;
}
.g-flash-deck-body { display: flex; flex-direction: column; min-width: 0; position: relative; }
.g-flash-deck-name { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; line-height: 1.2; }
.g-flash-deck-desc { color: var(--text-2); font-size: 0.9rem; margin-top: 3px; line-height: 1.45; }
.g-flash-deck-count {
  position: relative; white-space: nowrap; font-size: 0.78rem; font-weight: 700; color: var(--accent);
  padding: 5px 10px; border-radius: 999px; background: rgba(0,0,0,0.25); border: 1px solid var(--border);
}
.g-flash-deck.is-empty .g-flash-deck-count { color: var(--c-mint); }
.g-flash-key {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-bottom-width: 2px;
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 500; color: var(--muted);
}
.g-flash-cats { margin-top: 12px; }
.g-flash-cats .chip { --cat: var(--c-amber); cursor: pointer; }
.g-flash-cats .chip:hover, .g-flash-cats .chip:focus-visible { color: var(--text); border-color: var(--cat); background: var(--surface-3); transform: translateY(-1px); }
.g-flash-cats .chip:active { transform: scale(0.97); }
.g-flash-note { text-align: center; }

/* ---------- Session: top, progress, HUD ---------- */
.g-flash .game-title { flex-wrap: wrap; row-gap: 6px; }
.g-flash-deckchip {
  display: inline-flex; align-items: center; gap: 8px; margin-left: 4px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
  font-family: var(--font-body); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.g-flash-deckchip-dir { color: var(--muted); font-family: var(--font-mono); font-size: 0.68rem; padding-left: 8px; border-left: 1px solid var(--border-strong); }
.g-flash-progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; font-weight: 600; }
.g-flash-progress .bar-fill { background: linear-gradient(90deg, #60a5fa, #a78bfa); box-shadow: 0 0 12px rgba(96,165,250,0.45); transition: width var(--t-slow) var(--ease); }

.g-flash-hud { gap: var(--sp-4); }
.g-flash-counts { display: flex; gap: 8px; flex-wrap: wrap; }
.g-flash-count {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 9px; border-radius: 999px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--border); font-size: 0.8rem; font-weight: 600; color: var(--text-2);
}
.g-flash-count i { width: 8px; height: 8px; border-radius: 50%; background: var(--rate); box-shadow: 0 0 8px var(--rate); }
.g-flash-count b { font-family: var(--font-display); font-size: 0.95rem; color: var(--text); min-width: 1ch; text-align: center; }
.g-flash-count.is-bump, .g-flash-xp.is-bump { animation: g-flash-pop 0.5s var(--ease-bounce); }
.g-flash-xp .val { color: var(--c-amber); }
@keyframes g-flash-pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* ---------- The card ---------- */
.g-flash-stage { position: relative; padding: 6px 0 2px; }
.g-flash-card {
  position: relative; width: min(100%, 660px); margin: 0 auto; perspective: 1500px; cursor: pointer; outline: none;
  border-radius: var(--r-xl); -webkit-tap-highlight-color: transparent;
}
.g-flash-card:focus-visible .g-flash-card-inner { box-shadow: 0 0 0 3px rgba(246,196,83,0.65); }
.g-flash-card-inner {
  display: grid; min-height: 340px; border-radius: var(--r-xl);
  transform-style: preserve-3d; -webkit-transform-style: preserve-3d;
  transition: transform 500ms var(--ease), box-shadow var(--t-fast);
}
.g-flash-card.is-flipped .g-flash-card-inner { transform: rotateY(180deg); }
.g-flash-face {
  grid-area: 1 / 1; position: relative; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 10px; text-align: center;
  padding: 58px 28px 24px; border-radius: var(--r-xl); border: 1px solid var(--border-strong);
  background: linear-gradient(160deg, rgba(255,255,255,0.11), rgba(255,255,255,0.035) 60%, rgba(96,165,250,0.08));
  box-shadow: var(--shadow-lg);
}
.g-flash-face::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.07) 45%, transparent 60%);
  background-size: 250% 100%; background-position: 100% 0; transition: background-position 900ms var(--ease);
}
.g-flash-card:hover .g-flash-face::before { background-position: 0 0; }
.g-flash-back {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, rgba(96,165,250,0.26), rgba(167,139,250,0.14) 55%, rgba(255,255,255,0.04));
  border-color: rgba(96,165,250,0.5);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(96,165,250,0.25), 0 10px 40px rgba(96,165,250,0.18);
}
.g-flash-face-top { position: absolute; top: 14px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.g-flash-cat {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  background: rgba(0,0,0,0.28); border: 1px solid var(--border); font-size: 0.74rem; font-weight: 700; color: var(--text-2); letter-spacing: 0.02em; white-space: nowrap;
}
.g-flash-face-body { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: 1; justify-content: center; min-width: 0; }
.g-flash-kind { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.g-flash-prompt { font-family: var(--font-display); font-size: clamp(1.7rem, 4.2vw, 2.6rem); font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.g-flash-prompt.is-es { font-size: clamp(1.9rem, 5vw, 3rem); letter-spacing: 0.01em; }
.g-flash-sub { color: var(--text-2); font-size: 0.95rem; }
.g-flash-flip-hint { color: var(--muted); font-size: 0.78rem; margin-top: 6px; }
.g-flash-flip-hint .kbd { font-size: 0.7rem; }

.g-flash-es-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.g-flash-es { font-family: var(--font-display); font-size: clamp(1.9rem, 5.4vw, 3.1rem); font-weight: 900; line-height: 1.15; letter-spacing: 0.01em; overflow-wrap: anywhere; }
.g-flash-es .accent-char { color: var(--c-amber); text-shadow: 0 0 18px rgba(246,196,83,0.55); }
.g-flash-say { font-size: 1.15rem; border: 1px solid var(--border); background: rgba(0,0,0,0.25); }
.g-flash-say:hover { background: var(--surface-3); transform: translateY(-1px); }
.g-flash-en { font-size: 1.15rem; color: var(--text); font-weight: 600; }
.g-flash-note { font-size: 0.85rem; color: var(--text-2); padding: 6px 12px; border-radius: 10px; background: rgba(0,0,0,0.22); border: 1px solid var(--border); }

/* Active recall input on the front */
.g-flash-recall { width: min(100%, 420px); margin-top: 6px; }
.g-flash-recall-label { font-size: 0.78rem; color: var(--text-2); margin-bottom: 8px; }
.g-flash-recall-label .kbd { font-size: 0.68rem; }
.g-flash-input { text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; padding: 12px 14px; }
.g-flash-recall .accent-bar { margin-top: 8px; }
.g-flash-recall .accent-key { min-width: 34px; height: 34px; font-size: 1rem; padding: 0 6px; }

/* Attempt result on the back */
.g-flash-attempt {
  width: min(100%, 440px); margin-top: 4px; padding: 10px 14px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: rgba(0,0,0,0.26); font-size: 0.9rem; animation: pop var(--t-med) var(--ease-bounce);
}
.g-flash-attempt.is-correct { border-color: rgba(56,217,196,0.55); background: rgba(56,217,196,0.12); }
.g-flash-attempt.is-accent { border-color: rgba(246,196,83,0.55); background: rgba(246,196,83,0.12); }
.g-flash-attempt.is-wrong { border-color: rgba(255,92,122,0.55); background: rgba(255,92,122,0.12); }
.g-flash-attempt.is-empty { color: var(--muted); }
.g-flash-attempt-title { font-family: var(--font-display); font-weight: 800; }
.g-flash-attempt-diff { margin-top: 4px; }
.g-flash-attempt-diff .diff { font-size: 1.2rem; }
.g-flash-attempt-sug { color: var(--text-2); margin-top: 4px; }
.g-flash-attempt-sug .kbd { font-size: 0.68rem; }

/* Card enter / leave */
@keyframes g-flash-in { from { opacity: 0; transform: translateX(44px) rotate(2deg) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes g-flash-out { to { opacity: 0; transform: translateX(-44px) rotate(-3deg) scale(0.94); } }
.g-flash-card.is-in { animation: g-flash-in 380ms var(--ease-bounce) both; }
.g-flash-card.is-out { animation: g-flash-out 320ms var(--ease) forwards; pointer-events: none; }

/* XP float */
.g-flash-float {
  position: absolute; right: 8%; top: 20px; z-index: 3; pointer-events: none;
  font-family: var(--font-display); font-weight: 900; font-size: 1.3rem; color: var(--rate);
  text-shadow: 0 2px 12px rgba(0,0,0,0.6); animation: g-flash-rise 1.1s var(--ease) both;
}
@keyframes g-flash-rise { 0% { opacity: 0; transform: translateY(14px) scale(0.8); } 20% { opacity: 1; transform: translateY(0) scale(1.1); } 100% { opacity: 0; transform: translateY(-46px) scale(1); } }

/* ---------- Rating row ---------- */
.g-flash-rate {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: min(100%, 660px); margin: 4px auto 0;
  transition: opacity var(--t-med), transform var(--t-med) var(--ease);
}
.g-flash-rate:not(.is-ready) { opacity: 0.45; transform: translateY(6px); }
.g-flash-rate-btn {
  position: relative; flex-direction: column; gap: 2px; padding: 12px 8px 10px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--rate); color: var(--text);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.g-flash-rate-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--rate); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.g-flash-rate-btn:disabled { opacity: 0.7; transform: none; }
.g-flash-rate-key {
  position: absolute; top: 6px; left: 8px; display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 5px;
  background: rgba(0,0,0,0.3); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 0.62rem; color: var(--muted);
}
.g-flash-rate-icon { font-family: var(--font-display); font-size: 1.25rem; font-weight: 900; line-height: 1; color: var(--rate); }
.g-flash-rate-label { font-weight: 700; font-size: 0.95rem; }
.g-flash-rate-tag { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--rate); min-height: 0.9em; line-height: 1; }
.g-flash-rate-btn.is-suggested { border-color: var(--rate); box-shadow: 0 0 0 1px var(--rate), 0 8px 26px rgba(0,0,0,0.4); animation: g-flash-suggest 1.5s ease-in-out infinite; }
.g-flash-rate-btn.is-picked { background: var(--rate); border-color: var(--rate); color: #0b1020; transform: scale(1.04); }
.g-flash-rate-btn.is-picked .g-flash-rate-icon, .g-flash-rate-btn.is-picked .g-flash-rate-tag { color: #0b1020; }
.g-flash-rate-btn.is-picked .g-flash-rate-key { color: #0b1020; border-color: rgba(0,0,0,0.3); background: rgba(255,255,255,0.3); }
@keyframes g-flash-suggest { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.g-flash-rate-hint { min-height: 1.4em; }

.g-flash-options {
  display: flex; align-items: center; justify-content: center; gap: 10px 22px; flex-wrap: wrap;
  padding: 10px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border);
}
.g-flash-options .toggle { color: var(--text); font-weight: 600; }
.g-flash-options .toggle input:disabled ~ * { opacity: 0.45; cursor: not-allowed; }
.g-flash-keys { white-space: nowrap; }

/* ---------- End screen ---------- */
.g-flash-end { overflow: hidden; }
.g-flash-end::before {
  content: ''; position: absolute; top: -40%; right: -10%; width: 380px; height: 380px; border-radius: 50%;
  background: var(--accent); opacity: 0.12; filter: blur(80px); pointer-events: none;
}
.g-flash-end > * { position: relative; }
.g-flash-end-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-5); flex-wrap: wrap; margin-top: 6px; }
.g-flash-end-count { display: flex; flex-direction: column; gap: 4px; }
.g-flash-bigcount { font-family: var(--font-display); font-size: clamp(3rem, 8vw, 4.5rem); font-weight: 900; line-height: 1; letter-spacing: -0.03em; background: linear-gradient(90deg, #60a5fa, #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.g-flash-newbest { align-self: flex-start; margin-top: 6px; }
.g-flash-end-ring { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.g-flash-end-stat { border-top: 3px solid var(--rate); }
.g-flash-again-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.g-flash-again-head h3 { margin: 0; }
.g-flash-again { display: grid; gap: 8px; margin: 12px 0 18px; }
.g-flash-again-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid rgba(255,92,122,0.35); background: rgba(255,92,122,0.07);
}
.g-flash-again-main { min-width: 0; }
.g-flash-again-es { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; overflow-wrap: anywhere; }
.g-flash-again-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.g-flash-clean { color: var(--c-mint); font-weight: 600; margin: 4px 0 16px; }
.g-flash-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .g-flash-decks { grid-template-columns: 1fr 1fr; }
  .g-flash-hero { grid-template-columns: 1fr; }
  .g-flash-fan { display: none; }
}
@media (max-width: 640px) {
  .g-flash-decks { grid-template-columns: 1fr; }
  .g-flash-deck { padding: 14px; gap: 12px; }
  .g-flash-deck-count { font-size: 0.72rem; padding: 4px 8px; }
  .g-flash-settings { padding: 12px; }
  .g-flash-seg button { padding: 7px 10px; font-size: 0.82rem; }
  /* Title and the Quit / Home control share one row; the deck chip wraps under the title. */
  .g-flash .game-topbar { flex-wrap: nowrap; align-items: flex-start; }
  .g-flash .game-title { flex: 1 1 0; min-width: 0; font-size: 1.25rem; }
  .g-flash .game-title .icon { width: 36px; height: 36px; flex-shrink: 0; }
  .g-flash-deckchip { margin-left: 0; }
  .g-flash-hud { padding: 10px 12px; }
  .g-flash-count { padding: 3px 9px 3px 8px; font-size: 0.74rem; gap: 5px; }
  .g-flash-count-label { display: none; }
  .g-flash-card-inner { min-height: 300px; }
  .g-flash-face { padding: 54px 16px 18px; }
  .g-flash-cat { font-size: 0.68rem; padding: 3px 8px; }
  .g-flash-prompt { font-size: clamp(1.5rem, 7vw, 2rem); }
  .g-flash-prompt.is-es { font-size: clamp(1.6rem, 7.5vw, 2.2rem); }
  .g-flash-es { font-size: clamp(1.7rem, 8vw, 2.4rem); }
  .g-flash-recall .accent-bar { gap: 4px; }
  .g-flash-recall .accent-key { min-width: 28px; height: 32px; font-size: 0.95rem; padding: 0 3px; }
  .g-flash-rate { gap: 6px; }
  .g-flash-rate-btn { padding: 12px 4px 8px; }
  .g-flash-rate-key { display: none; }
  .g-flash-rate-label { font-size: 0.85rem; }
  .g-flash-options { gap: 8px 16px; padding: 10px 12px; }
  .g-flash-keys { display: none; }
  .g-flash-float { right: 4%; top: 10px; font-size: 1.1rem; }
  .g-flash-again-row { flex-wrap: wrap; }
  .g-flash-actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .g-flash-card-inner { transition: none; }
  .g-flash-card.is-in, .g-flash-card.is-out, .g-flash-fan i, .g-flash-rate-btn.is-suggested { animation: none; }
  .g-flash-face::before { transition: none; }
}
