/* ══════════════════════════════════════════════════════════════════
   WORD PLAY — Game CSS v108
   ══════════════════════════════════════════════════════════════════ */

/* ─── SCREEN TRANSITIONS ────────────────────────────────────────── */
.game-screen { display: none; }
.game-screen.active { display: block; }

/* ─── START SCREEN ──────────────────────────────────────────────── */
.game-start {
  background: var(--paper);
  border: 1.5px solid var(--border-soft);
  border-radius: 10px;
  box-shadow: 0 2px 18px rgba(0,0,0,.08);
  padding: 36px 28px;
  text-align: center;
  margin-top: 8px;
}
.game-start h2 {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--ink);
}
.game-start p { color: var(--muted-deep); font-size: 0.92rem; line-height: 1.6; margin-bottom: 20px; }

.game-stats-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 20px 0;
  padding: 16px;
  background: var(--cream-deep);
  border-radius: 8px;
}
.game-stat { text-align: center; }
.game-stat-val {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}
.game-stat-label {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.game-btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

/* ─── BUTTONS ───────────────────────────────────────────────────── */
.game-btn {
  padding: 13px 28px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 48px;
  transition: background .12s, opacity .12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.game-btn:active { transform: scale(0.97); }
.game-btn.primary { background: var(--amber); color: #1A1A1A; }
.game-btn.primary:hover { background: var(--accent-dark); color: #1A1A1A; }
.game-btn.secondary { background: var(--ink); color: var(--paper); opacity: .75; }
.game-btn.secondary:hover { background: var(--amber); color: #1A1A1A; opacity: 1; }
.game-btn.ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--ink);
}
.game-btn.ghost:hover { background: var(--cream-deep); }
.game-btn.small { padding: 8px 18px; font-size: 0.82rem; min-height: 38px; }

/* ─── PLAY CARD ─────────────────────────────────────────────────── */
.game-play {
  background: var(--paper);
  border: 1.5px solid var(--border-soft);
  border-radius: 10px;
  box-shadow: 0 2px 18px rgba(0,0,0,.08);
  padding: 0 0 22px;
  margin-top: 8px;
  overflow: hidden;
  will-change: transform;
  user-select: none;
}

/* Amber progress bar flush at top of card */
.gp-prog {
  height: 4px;
  background: var(--hairline);
}
.gp-prog-fill {
  height: 100%;
  background: var(--amber);
  transition: width .4s ease;
}

/* Stage badge + counter row */
.gp-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px 0;
}
.gp-badge {
  background: rgba(184,134,11,.12);
  color: var(--amber);
  font-family: var(--font-sans);
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
}
.gp-counter {
  font-family: var(--font-sans);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
  display: flex;
  align-items: center;
}
.gp-streak {
  color: var(--amber);
  font-weight: 800;
}

/* Content sections — consistent side padding */
.game-term,
.game-prompt,
.game-options,
.game-feedback,
.game-example,
.gp-actions {
  padding-left: 26px;
  padding-right: 26px;
}

/* Term (the word / gapped sentence / definition) */
.game-term {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  padding-top: 20px;
  padding-bottom: 6px;
  line-height: 1.2;
}

/* Sentence-completion gap */
.game-gap {
  border-bottom: 3px solid var(--accent);
  padding: 0 6px;
  margin: 0 2px;
  display: inline-block;
  min-width: 80px;
  color: var(--accent);
}

/* Stage sub-prompt */
.game-prompt {
  font-style: italic;
  color: var(--muted-deep);
  text-align: center;
  font-size: 0.92rem;
  padding-bottom: 16px;
  line-height: 1.5;
}

/* ─── OPTIONS ───────────────────────────────────────────────────── */
.game-options { display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }
.game-option {
  width: 100%;
  padding: 14px 18px;
  text-align: left;
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--hairline);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  min-height: 52px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.game-option:active { transform: scale(0.97); }
.game-option:hover:not(:disabled) { background: var(--color-option-bg-hover); border-color: var(--amber); }
.game-option.correct { background: var(--color-success-bg); color: var(--color-success-text); border-color: var(--color-success-border); font-weight: 700; }
.game-option.wrong   { background: var(--color-error-bg); color: var(--color-error-text); border-color: var(--color-error-border); text-decoration: line-through; }
.game-option:disabled { cursor: default; opacity: 0.75; }

/* ─── FEEDBACK & EXAMPLE ────────────────────────────────────────── */
.game-feedback {
  min-height: 0;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  padding-top: 8px;
  padding-bottom: 2px;
}
.game-feedback.correct {
  background: var(--color-success-bg);
  border-left: 3px solid var(--color-success-border);
  padding: 12px 26px;
  color: var(--color-success-text);
  font-weight: 700;
  text-align: left;
  margin-top: 6px;
}
.game-feedback.wrong {
  background: var(--color-error-bg);
  border-left: 3px solid var(--color-error-border);
  padding: 12px 26px;
  color: var(--color-error-text);
  font-weight: 600;
  text-align: left;
  margin-top: 6px;
}

.game-example {
  font-style: italic;
  color: var(--muted-deep);
  font-size: 0.9rem;
  text-align: center;
  padding-top: 8px;
  padding-bottom: 4px;
  line-height: 1.5;
  border-top: 1px solid var(--border-soft);
  margin-top: 12px;
}

/* ─── ACTION ROW (continue button + hint link) ──────────────────── */
.gp-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding-top: 14px;
}

/* "Need a hint?" — subtle text link below the Continue button */
.gp-link {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: .8rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px 0;
  text-align: center;
  align-self: center;
  -webkit-tap-highlight-color: transparent;
}
.gp-link:hover { color: var(--amber); }
.gp-link:disabled { opacity: .35; cursor: default; text-decoration: none; }

#gBtnNext {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 14px;
  border-radius: 8px;
  animation: nextBtnIn .2s ease-out;
}
@keyframes nextBtnIn { from { opacity:0; transform:scale(.94) } to { opacity:1; transform:scale(1) } }

/* ─── REFERENCE PANEL ───────────────────────────────────────────── */
.game-ref-panel {
  margin-top: 16px;
  border: 1.5px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
}
.game-ref-head {
  padding: 10px 16px;
  background: var(--cream-deep);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted-deep);
  cursor: pointer;
  user-select: none;
}
.game-ref-body { padding: 12px 16px; display: none; }
.game-ref-body.open { display: block; }
.game-ref-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.88rem;
  line-height: 1.5;
}
.game-ref-item:last-child { border-bottom: none; }
.game-ref-item .ref-term { font-weight: 700; color: var(--ink); }
.game-ref-item .ref-def  { color: var(--muted-deep); font-size: 0.85rem; }
.game-ref-item .ref-ex   { font-style: italic; color: var(--muted); font-size: 0.82rem; margin-top: 2px; }

.ref-stage-track { display: flex; gap: 3px; margin-top: 6px; }
.ref-stage-pip {
  width: 18px; height: 4px; border-radius: 2px;
  background: var(--cream-deep);
  transition: background 0.2s;
}
.ref-stage-pip.filled         { background: var(--accent); }
.ref-stage-pip.filled-brittle { background: var(--amber) !important; opacity: 0.6; }

/* ─── COMPLETION SCREEN ─────────────────────────────────────────── */
.game-completion {
  background: var(--paper);
  border: 1.5px solid var(--border-soft);
  border-top: 4px solid var(--green);
  border-radius: 10px;
  box-shadow: 0 2px 18px rgba(0,0,0,.08);
  padding: 40px 28px;
  text-align: center;
  margin-top: 8px;
}
.game-completion h2 {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--ink);
}
.game-completion > p { color: var(--muted-deep); margin-bottom: 8px; font-size: 0.92rem; }

/* ─── MASTERY MAP ───────────────────────────────────────────────── */
#gMasteryMap { margin: 16px 0; text-align: left; }
.mastery-group { margin-bottom: 14px; }
.mastery-group-label {
  font-family: var(--font-sans);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.mastery-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: .72rem;
  font-weight: 700;
  margin: 3px 4px 3px 0;
}
.mastery-chip.strong     { background: rgba(46,125,82,.15);   color: var(--green); }
.mastery-chip.brittle    { background: rgba(184,134,11,.12);  color: var(--amber); }
.mastery-chip.unmastered { background: rgba(192,57,43,.10);   color: var(--red);   }

/* ─── TOAST ─────────────────────────────────────────────────────── */
.game-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20,20,20,0.92);
  color: #F0F0F0;
  padding: 10px 20px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}
.game-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── CHAPTER NAV ───────────────────────────────────────────────── */
.chapter-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: 800px;
  flex-wrap: wrap;
}
.chapter-nav::-webkit-scrollbar { display: none; }
.chapter-nav-wrap { max-width: 800px; margin: 0 auto; padding: 0; }
.chapter-nav-btn {
  flex: 1 1 auto;
  min-width: 80px;
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  background: transparent;
  border: 1.5px solid var(--hairline);
  border-radius: 6px;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
  cursor: pointer;
  display: inline-block;
}
.chapter-nav-btn:hover { color: var(--ink); border-color: var(--ink); }
.chapter-nav-btn.active { background: var(--amber); color: #1A1A1A; border-color: var(--amber); }

@media (max-width: 480px) {
  .chapter-nav { flex-wrap: nowrap; }
  .chapter-nav-btn { flex-shrink: 0; font-size: 0.62rem; padding: 8px 10px; letter-spacing: 1px; }
}
@media (max-width: 380px) {
  .chapter-nav-btn { min-width: 60px; }
}

/* ─── PRODUCTION INPUT ──────────────────────────────────────────── */
.gp-input-wrap {
  padding: 0 26px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#gInput {
  padding: 11px 14px;
  font-family: var(--font-sans);
  font-size: .95rem;
  border: 1.5px solid var(--hairline);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  box-sizing: border-box;
  width: 100%;
}
#gInput:focus { outline: none; border-color: var(--amber); }
body.dark #gInput {
  background: #1a1a1a !important;
  color: #f0f0f0 !important;
  border-color: rgba(255,255,255,.2) !important;
}
body.dark #gInput:focus { border-color: var(--amber) !important; }

/* ─── RESPONSIVE ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .gp-meta,
  .game-term,
  .game-prompt,
  .game-options,
  .game-feedback,
  .game-example,
  .gp-input-wrap,
  .gp-actions          { padding-left: 18px; padding-right: 18px; }
  .game-start,
  .game-completion     { padding: 28px 18px; }
  .game-btn            { padding: 12px 16px; font-size: 0.85rem; }
}
@media (max-width: 380px) {
  .gp-badge            { font-size: .55rem; letter-spacing: 1.5px; }
  .game-term           { font-size: 1.4rem; }
}

/* ══════════════════════════════════════════════════════════════════
   DARK MODE (v108)
   ══════════════════════════════════════════════════════════════════ */

body.dark .game-start,
body.dark .game-play,
body.dark .game-completion {
  background: var(--paper) !important;
  border-color: rgba(255,255,255,.1) !important;
  color: var(--ink) !important;
  box-shadow: none !important;
}
body.dark .game-start h2,
body.dark .game-completion h2 { color: var(--ink) !important; }
body.dark .game-term           { color: #FFFFFF !important; }
body.dark .game-prompt         { color: rgba(255,255,255,.6) !important; }
body.dark .game-example        { color: rgba(255,255,255,.5) !important; border-top-color: rgba(255,255,255,.1) !important; }
body.dark .game-feedback { color: var(--ink) !important; }
body.dark .game-feedback.correct {
  background: var(--color-success-bg) !important;
  border-left-color: var(--color-success-border) !important;
  color: var(--color-success-text) !important;
}
body.dark .game-feedback.wrong {
  background: var(--color-error-bg) !important;
  border-left-color: var(--color-error-border) !important;
  color: var(--color-error-text) !important;
}

body.dark .gp-prog { background: rgba(255,255,255,.12); }
body.dark .gp-badge { background: rgba(201,160,80,.15); }

body.dark .game-option,
body.dark .game-btn {
  background: rgba(255,255,255,.07) !important;
  border-color: rgba(255,255,255,.18) !important;
  color: #F0F0F0 !important;
}
body.dark .game-option:hover:not(:disabled),
body.dark .game-btn:hover {
  background: rgba(255,255,255,.14) !important;
  border-color: var(--amber) !important;
}
body.dark .game-btn.primary {
  background: var(--amber) !important;
  color: #1A1A1A !important;
  border-color: var(--amber) !important;
}
body.dark .game-btn.primary:hover { background: var(--accent-dark) !important; }
body.dark .game-option.correct {
  background: rgba(39,174,96,.20) !important;
  border-color: #4CAF82 !important;
  color: #A0E8B0 !important;
  font-weight: 700 !important;
}
body.dark .game-option.wrong {
  background: rgba(192,57,43,.20) !important;
  border-color: #E05A4A !important;
  color: #FFA090 !important;
}
body.dark .gp-link { color: rgba(255,255,255,.4) !important; }
body.dark .gp-link:hover { color: var(--amber) !important; }

body.dark .game-stats-row { background: rgba(255,255,255,.06) !important; }
body.dark .game-stat-val   { color: var(--amber) !important; }
body.dark .game-stat-label { color: rgba(255,255,255,.45) !important; }

body.dark .game-ref-panel { border-color: rgba(255,255,255,.08) !important; }
body.dark .game-ref-head  { background: rgba(255,255,255,.05) !important; color: var(--amber) !important; }
body.dark .game-ref-item .ref-term { color: #FFFFFF !important; }
body.dark .game-ref-item .ref-def  { color: rgba(255,255,255,.55) !important; }
body.dark .game-ref-item .ref-ex   { color: rgba(255,255,255,.38) !important; }
body.dark .ref-stage-pip { background: rgba(255,255,255,.12); }

/* chapter-nav is intentionally shown on flashcard and game pages */
