/* ============================================================
   Tile Trainer - game-specific styles (theme-reactive, --g-* only)
   ============================================================ */
.tt-wrap { display:flex; flex-direction:column; gap:18px; padding-bottom:8px; }

/* ---------- tier tabs ---------- */
.tt-tabs { display:flex; gap:8px; flex-wrap:wrap; }
.tt-tab {
  flex:1 1 auto; min-width:0; cursor:pointer; font:inherit; font-size:13px; font-weight:700;
  color:var(--g-fg); background:linear-gradient(180deg, rgba(255,255,255,.30), var(--g-card));
  border:1px solid var(--g-line); border-radius:11px; padding:9px 12px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.22), var(--g-shadow-sm);
  transition:border-color .15s, color .15s, transform .1s, box-shadow .15s;
}
.tt-tab:hover { border-color:var(--g-accent); color:var(--g-accent); transform:translateY(-1px); }
.tt-tab:focus-visible { outline:2px solid var(--g-accent); outline-offset:2px; }
.tt-tab.is-sel {
  background:linear-gradient(180deg, var(--g-accent-lt), var(--g-accent));
  color:var(--g-on-accent,#fff); border-color:transparent;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.18), 0 4px 12px var(--g-accent-soft);
  text-shadow:0 1px 1px rgba(0,0,0,.18);
}

/* ---------- score line ---------- */
.tt-score {
  display:flex; align-items:center; gap:7px; flex-wrap:wrap;
  font-size:13px; color:var(--g-muted);
}
.tt-score b { color:var(--g-heading); font-weight:800; font-variant-numeric:tabular-nums; }
.tt-score-k { letter-spacing:.04em; text-transform:uppercase; font-size:11px; font-weight:700; }
.tt-score-sep { opacity:.5; }

/* ---------- question card ---------- */
.tt-card {
  background:linear-gradient(180deg, rgba(255,255,255,.35), var(--g-card));
  border:1px solid var(--g-line); border-radius:var(--g-radius);
  box-shadow:var(--g-shadow-md); padding:20px 20px 22px;
  display:flex; flex-direction:column; gap:16px;
}
.tt-q { font-family:var(--serif,Georgia,serif); font-size:19px; font-weight:700; color:var(--g-heading); line-height:1.35; }
.tt-q .tt-em {
  color:var(--g-heading); background:var(--g-accent-soft);
  padding:1px 5px; border-radius:5px; box-shadow:inset 0 -2px 0 var(--g-accent);
}
.tt-hint {
  font-size:13.5px; color:var(--g-fg); line-height:1.55;
  border-left:3px solid var(--g-accent); padding:8px 12px; background:var(--g-accent-soft);
  border-radius:0 8px 8px 0;
}
.tt-hint b { color:var(--g-heading); }

/* tile row (lane 1 + lane 3) */
.tt-tiles { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.tt-tiles .tl {
  position:relative; width:52px; height:72px; display:block;
  background:linear-gradient(165deg,#fdfcf7,#ece4d2);
  border:1px solid rgba(60,50,30,.22); border-radius:8px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.85), 0 2px 5px rgba(0,0,0,.16);
}
.tt-tiles .tl svg { width:100%; height:100%; display:block; }
.tt-tiles .tl .tl-img { width:100%; height:100%; display:block; object-fit:contain; pointer-events:none; }
.tt-tiles .tl .cnr {
  position:absolute; top:1px; left:3px; z-index:3; display:block !important;
  font-family:var(--sans,system-ui,-apple-system,"Segoe UI",sans-serif);
  font-size:11px; font-weight:800; line-height:1.2; text-align:center; color:#3A2E20;
  background:none; box-shadow:none;
}

/* lane 3 clickable chips */
.tt-chip {
  position:relative; padding:0; cursor:pointer; width:54px; height:74px;
  background:linear-gradient(165deg,#fdfcf7,#ece4d2);
  border:2px solid var(--g-line); border-radius:9px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.6), var(--g-shadow-sm);
  transition:border-color .15s, box-shadow .15s, transform .1s;
}
.tt-chip:hover { transform:translateY(-2px); border-color:var(--g-accent); }
.tt-chip:focus-visible { outline:2px solid var(--g-accent); outline-offset:2px; }
.tt-chip:disabled { cursor:default; opacity:.94; }
.tt-chip:disabled:hover { transform:none; }
.tt-chip.is-sel { border-color:var(--g-accent); box-shadow:0 0 0 3px var(--g-accent-soft), var(--g-shadow-sm); }
.tt-chip.is-right { border-color:#2E8B6B; box-shadow:0 0 0 3px rgba(46,139,107,.30); }
.tt-chip.is-wrong { border-color:#C0392B; box-shadow:0 0 0 3px rgba(192,57,43,.28); }
.tt-chip .tl { width:100%; height:100%; border:0; box-shadow:none; background:none; }

/* option buttons (lane 1 + lane 2) */
.tt-opts { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.tt-opt {
  cursor:pointer; font:inherit; font-size:14px; font-weight:700; text-align:left; color:var(--g-fg);
  background:linear-gradient(180deg, rgba(255,255,255,.30), var(--g-card));
  border:1px solid var(--g-line); border-radius:11px; padding:12px 14px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.22), var(--g-shadow-sm);
  transition:border-color .15s, color .15s, transform .1s, box-shadow .15s;
}
.tt-opt:hover { border-color:var(--g-accent); color:var(--g-accent); transform:translateY(-1px); }
.tt-opt:focus-visible { outline:2px solid var(--g-accent); outline-offset:2px; }
.tt-opt.is-sel { border-color:var(--g-accent); box-shadow:0 0 0 3px var(--g-accent-soft); }
/* Ink follows the theme so a judged answer stays legible on dark cards;
   the brighter border and halo carry the verdict instead. */
.tt-opt.is-right { border-color:#5CBE99; color:var(--g-fg); box-shadow:0 0 0 3px rgba(92,190,153,.32); }
.tt-opt.is-wrong { border-color:#E88475; color:var(--g-fg); box-shadow:0 0 0 3px rgba(232,132,117,.28); }
.tt-opt small { display:block; font-weight:600; font-size:11.5px; color:var(--g-muted); margin-top:3px; }
.tt-opt.is-right small, .tt-opt.is-wrong small { color:var(--g-fg); }

/* ---------- controls ---------- */
.tt-controls { display:flex; gap:10px; flex-wrap:wrap; }
.tt-btn {
  cursor:pointer; font:inherit; font-size:14px; font-weight:700; color:var(--g-fg);
  background:linear-gradient(180deg, rgba(255,255,255,.30), var(--g-card));
  border:1px solid var(--g-line); border-radius:11px; padding:11px 20px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.22), var(--g-shadow-sm);
  transition:border-color .15s, color .15s, transform .1s, box-shadow .15s;
}
.tt-btn:hover:not(:disabled) { border-color:var(--g-accent); color:var(--g-accent); transform:translateY(-1px); }
.tt-btn:active:not(:disabled) { transform:translateY(1px); }
.tt-btn:focus-visible { outline:2px solid var(--g-accent); outline-offset:2px; }
.tt-btn:disabled { opacity:.5; cursor:default; }
.tt-btn.is-on { background:linear-gradient(180deg, var(--g-accent-lt), var(--g-accent)); color:var(--g-on-accent,#fff); border-color:transparent;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.18), 0 4px 12px var(--g-accent-soft); text-shadow:0 1px 1px rgba(0,0,0,.18); }

/* feedback line: only the short verdict carries color; the explanation stays
   in normal type so a long rule never turns into a wall of red text */
.tt-feedback { font-size:14px; line-height:1.5; min-height:1.2em; }
.tt-feedback b { color:var(--g-heading); font-weight:800; }
.tt-feedback.ok { border-left:3px solid #2E8B6B; padding-left:10px; }
.tt-feedback.no { border-left:3px solid #C0392B; padding-left:10px; }
.tt-feedback.muted { color:var(--g-muted); font-weight:600; }
.tt-feedback-detail {
  display:block; margin-top:5px; font-size:12.8px; font-weight:500;
  color:var(--g-muted); line-height:1.55;
}

/* ---------- HUD extras + mastery panel ---------- */
.tt-tab-n {
  display:inline-block; margin-left:6px; font-size:11px; font-weight:700;
  opacity:.72; font-variant-numeric:tabular-nums;
}
.tt-tab.is-sel .tt-tab-n { opacity:.95; }
.tt-review-tag {
  font-size:11px; font-weight:700; color:var(--g-heading);
  background:var(--g-accent-soft); border:1px solid var(--g-line);
  border-radius:999px; padding:2px 8px;
}
.tt-review-tag[hidden] { display:none; }

.tt-progress {
  border:1px solid var(--g-line); border-radius:12px; overflow:hidden;
  background:linear-gradient(180deg, rgba(255,255,255,.22), var(--g-card));
  box-shadow:var(--g-shadow-sm);
}
.tt-progress > summary {
  display:flex; align-items:center; gap:10px; flex-wrap:wrap; cursor:pointer;
  list-style:none; padding:11px 14px; font-size:13px; color:var(--g-muted);
}
.tt-progress > summary::-webkit-details-marker { display:none; }
.tt-progress > summary::before {
  content:''; width:7px; height:7px; flex:0 0 auto;
  border-right:2px solid var(--g-accent); border-bottom:2px solid var(--g-accent);
  transform:rotate(-45deg); transition:transform .15s;
}
.tt-progress[open] > summary::before { transform:rotate(45deg); }
.tt-progress > summary:focus-visible { outline:2px solid var(--g-accent); outline-offset:-2px; }
.tt-progress-title { font-size:11px; letter-spacing:.04em; text-transform:uppercase; font-weight:700; }
.tt-progress > summary b { color:var(--g-heading); font-variant-numeric:tabular-nums; }
.tt-progress-hint { margin-left:auto; font-size:11.5px; }
.tt-progress-note {
  margin:0; padding:0 14px 14px; font-size:11.8px; line-height:1.55; color:var(--g-muted);
}
.tt-grid { padding:0 14px 12px; display:flex; flex-direction:column; gap:4px; }
.tt-grid-row {
  display:grid; grid-template-columns:minmax(0,1fr) 46px 46px 46px;
  gap:6px; align-items:center;
}
.tt-grid-head {
  font-size:11px; text-transform:uppercase; letter-spacing:.04em;
  color:var(--g-muted); font-weight:700; padding-bottom:2px;
}
.tt-grid-head span:not(:first-child) { text-align:center; }
.tt-grid-name {
  font-size:12.5px; color:var(--g-fg);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.tt-cell {
  height:18px; display:flex; align-items:center; justify-content:center; gap:3px;
  border:1px solid var(--g-line); border-radius:5px; background:var(--g-card);
  color:var(--g-muted);
}
.tt-cell i { width:6px; height:6px; border-radius:50%; background:currentColor; opacity:.45; display:block; }
.tt-cell.is-1 i:nth-child(1),
.tt-cell.is-2 i:nth-child(-n+2),
.tt-cell.is-3 i { background:var(--g-accent); opacity:1; }
.tt-cell.is-3 { border-color:var(--g-accent); box-shadow:inset 0 0 0 1px var(--g-accent-soft); }
.tt-cell.is-na { color:var(--g-muted); font-size:12px; background:transparent; border-style:dashed; }
.tt-rule-note {
  font-size:11.8px; line-height:1.5; color:var(--g-muted);
  border-top:1px dashed var(--g-line); padding-top:10px;
}

/* lane 3 legend */
.tt-legend { display:flex; gap:14px; flex-wrap:wrap; font-size:12px; color:var(--g-muted); }
.tt-legend span { display:inline-flex; align-items:center; gap:6px; }
.tt-legend i { width:14px; height:14px; border-radius:4px; display:inline-block; border:2px solid; }
.tt-legend .lg-sel { border-color:var(--g-accent); background:var(--g-accent-soft); }
.tt-legend .lg-right { border-color:#2E8B6B; background:rgba(46,139,107,.22); }
.tt-legend .lg-wrong { border-color:#C0392B; background:rgba(192,57,43,.18); }

/* end-of-round summary */
.tt-summary { text-align:center; display:flex; flex-direction:column; gap:12px; align-items:center; padding:8px 0; }
.tt-summary .tt-big { font-family:var(--serif,Georgia,serif); font-size:34px; font-weight:800; color:var(--g-heading); }
.tt-summary .tt-sub { font-size:14px; color:var(--g-muted); max-width:46ch; }
.tt-summary-stats { font-size:12.5px; color:var(--g-muted); font-variant-numeric:tabular-nums; }
.tt-review {
  font-size:13px; color:var(--g-fg); background:var(--g-accent-soft);
  border-radius:9px; padding:8px 12px; max-width:100%;
}
.tt-review b { color:var(--g-heading); }

/* ---------- compliance note ---------- */
.tt-note { font-size:12px; line-height:1.6; color:var(--g-muted); border-top:1px solid var(--g-line); padding-top:14px; }
.tt-link { color:var(--g-accent-dk); font-weight:700; text-decoration:none; border-bottom:1px solid var(--g-accent-soft); }
.tt-link:hover { color:var(--g-accent); }

/* ---------- help dialog ---------- */
.tt-help { border:0; padding:0; background:transparent; max-width:560px; }
.tt-help::backdrop { background:rgba(8,20,14,.5); backdrop-filter:blur(4px); }
.tt-help-card {
  background:var(--g-panel); color:var(--g-fg); border:1px solid var(--g-line);
  border-top:3px solid var(--g-accent); border-radius:18px; box-shadow:var(--g-shadow-lg);
  max-height:86vh; overflow:auto;
}
.tt-help-head { display:flex; align-items:center; justify-content:space-between; padding:18px 20px 8px; }
.tt-help-head h2 { font-family:var(--serif,Georgia,serif); font-size:21px; color:var(--g-heading); margin:0; }
.tt-help-x { width:34px; height:34px; border-radius:50%; border:1px solid var(--g-line); background:var(--g-card);
  font-size:20px; line-height:1; cursor:pointer; color:var(--g-strong); }
.tt-help-x:hover { border-color:var(--g-accent); color:var(--g-accent); }
.tt-help-body { padding:4px 22px 22px; font-size:14px; line-height:1.62; }
.tt-help-body h3 { font-family:var(--serif,Georgia,serif); font-size:16px; color:var(--g-heading); margin:18px 0 4px; }
.tt-help-body p { margin:6px 0; color:var(--g-fg); }
.tt-help-body b { color:var(--g-strong); }

@media (max-width:560px){
  .tt-opts { grid-template-columns:1fr; }
  .tt-q { font-size:17px; }
  .tt-tiles .tl { width:44px; height:62px; }
  .tt-chip { width:46px; height:64px; }
  .tt-progress-hint { margin-left:0; width:100%; }
  .tt-grid-row { grid-template-columns:minmax(0,1fr) 40px 40px 40px; }
  .tt-tab { font-size:12px; padding:9px 8px; }
}
/* Short geometric sparks on a scored or a missed play. No glyphs or assets. */
.tt-spark {
  position: fixed; display: block; width: 7px; height: 7px;
  margin: -3.5px 0 0 -3.5px; border-radius: 50%;
  pointer-events: none; z-index: 90;
  animation: tt-spark-out .6s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes tt-spark-out {
  0%   { opacity: .95; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx),var(--dy)) scale(.3); }
}
@media (prefers-reduced-motion: reduce) { .tt-spark { display: none; } }


/* ---------- top bar brand ----------
   The shared shell styles .mj-title and .mj-tools but not the .mj-brand
   wrapper or the .mj-sub line. Default h1/p margins plus wrapping made this
   block 82-122px tall inside a 58px bar, which lifted the game title out of
   the viewport on narrow screens. Keep both lines single-row and shrinkable. */
.mj-brand { display:flex; flex-direction:column; justify-content:center;
  gap:1px; min-width:0; }
.mj-brand .mj-title { margin:0; }
.mj-brand .mj-sub { margin:0; min-width:0; font-size:11.5px; line-height:1.25;
  color:var(--g-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }


/* The related-reading block lives outside the game frame and cannot be
   reached while the document is locked. Keeping it out of layout means a
   fullscreen exit can never expose it as stray content under the game. */
.tt-see-also { display:none; }
