/* =========================================================
   Chalkplay — playable game templates (js/games/)
   Built on the tokens in styles.css. Each game takes its
   family colour from data-cat: --c (main), --t (tint), --d (dark).
   ========================================================= */

.cg {
  --c: var(--blue, #3D7EEA);
  --t: #E8F0FD;
  --d: #1F4FA8;
  --ok: var(--green, #1E6B52);
  --ok-t: var(--green-3, #E2F1E9);
  --bad: #C8412B;
  --bad-t: #FDECE6;

  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100%;
  border-radius: inherit;
  background: var(--paper, #FBF8F2);
  color: var(--ink, #1B2232);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 16px;
  line-height: 1.45;
  -webkit-user-select: none;
  user-select: none;
}
.cg[data-cat="quiz"]   { --c: #3D7EEA; --t: #E8F0FD; --d: #1F4FA8; }
.cg[data-cat="match"]  { --c: #7C5CE6; --t: #F0ECFD; --d: #4B33A8; }
.cg[data-cat="words"]  { --c: #EB6544; --t: #FDECE6; --d: #A9401F; }
.cg[data-cat="visual"] { --c: #2E9A5B; --t: #E4F4EA; --d: #1C6B3D; }

.cg:fullscreen, :fullscreen > .stage > .cg { font-size: 19px; }
.cg:fullscreen .cg-body, :fullscreen > .stage > .cg .cg-body { padding: 28px 40px 36px; }

/* A stage (styles.css) holding a game grows with it instead of clipping. */
.stage.has-game { overflow: visible; }
/* Inside the activity page's board the board title and full-screen button
   already exist, so the game bar drops its own. */
.play-stage .cg-fs, .play-stage .cg-template-name { display: none; }
.play-stage:fullscreen { display: flex; flex-direction: column; overflow: auto; }
.play-stage:fullscreen .stage.has-game { flex: 1; aspect-ratio: auto; }

/* ---------- Bar ---------- */
.cg-bar {
  display: flex; align-items: center; gap: 10px; border-radius: inherit; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
  min-height: 52px; padding: 6px 8px 6px 14px;
  border-bottom: 1px solid var(--line, #E8E1D3);
  background: rgba(255, 255, 255, .7);
}
.cg-template { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; color: var(--d); white-space: nowrap; }
.cg-template .i { width: 28px; height: 28px; padding: 5px; border-radius: 8px; background: var(--t); color: var(--d); stroke-width: 2.2; }
.cg-progress { flex: 1; min-width: 0; overflow: hidden; color: var(--ink-3, #7C8498); font-size: 14px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.cg-progress:not(:empty)::before { content: "·"; margin-right: 8px; }
.cg-stats { display: flex; gap: 6px; }
.cg-stat { display: inline-flex; align-items: baseline; gap: 6px; height: 34px; padding: 0 12px; border-radius: 99px; background: var(--card, #fff); border: 1px solid var(--line, #E8E1D3); line-height: 32px; }
.cg-stat small { font-size: 12px; font-weight: 700; color: var(--ink-3, #7C8498); }
.cg-stat b { font-family: var(--font-display, inherit); font-size: 16px; font-variant-numeric: tabular-nums; }
.cg-stat.is-bad b { color: var(--bad); }
.cg-icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2, #4A5367);
}
.cg-icon-btn:hover { background: var(--paper-2, #F4EFE5); color: var(--ink, #1B2232); }
.cg-icon-btn .i { width: 20px; height: 20px; }

.cg-body { position: relative; display: flex; flex: 1; flex-direction: column; min-height: 0; padding: clamp(14px, 2.6vw, 28px); }
.cg-body[data-mode="screen"] { justify-content: center; }

/* ---------- Start & results screens ---------- */
.cg-screen { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 520px; margin: auto; text-align: center; animation: cg-rise .35s ease backwards; }
.cg-badge { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 22px; background: var(--t); color: var(--d); rotate: -4deg; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .06); }
.cg-badge .i { width: 40px; height: 40px; stroke-width: 1.8; }
.cg-badge.is-trophy { background: var(--yellow-2, #FFE8A6); color: #8A5E00; }
.cg-heading { font-family: var(--font-display, inherit); font-size: clamp(24px, 3.4vw, 34px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.cg-lead { color: var(--ink-2, #4A5367); font-size: 17px; }
.cg-steps { display: grid; gap: 6px; margin: 2px 0 8px; text-align: left; }
.cg-steps li { position: relative; padding-left: 22px; color: var(--ink-2, #4A5367); font-size: 15px; }
.cg-steps li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.cg-score { font-family: var(--font-display, inherit); font-size: clamp(44px, 7vw, 64px); font-weight: 800; letter-spacing: -.04em; line-height: 1; color: var(--d); font-variant-numeric: tabular-nums; }
.cg-score-label { margin-top: -8px; color: var(--ink-3, #7C8498); font-weight: 700; }
.cg-details { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0; }
.cg-details > div { min-width: 104px; padding: 8px 14px; border-radius: 14px; background: var(--card, #fff); border: 1px solid var(--line, #E8E1D3); }
.cg-details dt { font-size: 12px; font-weight: 700; color: var(--ink-3, #7C8498); }
.cg-details dd { margin: 0; font-family: var(--font-display, inherit); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cg-review { width: 100%; max-height: 220px; overflow-y: auto; border-radius: 14px; background: var(--card, #fff); border: 1px solid var(--line, #E8E1D3); text-align: left; -webkit-user-select: text; user-select: text; }
.cg-review li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 14px; border-bottom: 1px solid var(--line, #E8E1D3); font-size: 15px; font-weight: 600; }
.cg-review li:last-child { border-bottom: 0; }
.cg-review small { display: block; font-weight: 500; font-size: 13px; color: var(--ink-3, #7C8498); }
.cg-review-text { flex: 1; min-width: 0; }
.cg-mark { display: grid; place-items: center; flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; font-size: 12px; font-weight: 800; }
.cg-mark.is-ok { background: var(--ok-t); color: var(--ok); }
.cg-mark.is-bad { background: var(--bad-t); color: var(--bad); }
.cg-mark.is-skip { background: var(--paper-2, #F4EFE5); color: var(--ink-3, #7C8498); }
.cg-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 4px; }

/* ---------- Feedback line ---------- */
.cg-feedback { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; min-height: 44px; }
.cg-feedback:empty { visibility: hidden; }
.cg-verdict { font-size: 16px; color: var(--ink-2, #4A5367); animation: cg-rise .25s ease backwards; }
.cg-verdict b { color: var(--ink, #1B2232); }
.cg-verdict.is-ok b { color: var(--ok); }
.cg-verdict.is-bad b { color: var(--bad); }

.cg-problem { display: grid; gap: 8px; align-content: center; height: 100%; padding: 24px; background: var(--paper, #FBF8F2); color: var(--ink-2, #4A5367); text-align: center; }
.cg-problem b { font-family: var(--font-display, inherit); font-size: 20px; color: var(--ink, #1B2232); }
.cg-problem ul { display: grid; gap: 2px; }

/* ---------- Quiz (Gameshow, Win or lose) ---------- */
.cg-quiz { display: flex; flex: 1; flex-direction: column; gap: 14px; width: 100%; max-width: 860px; margin: 0 auto; }
.cg-prompt-card {
  display: flex; align-items: center; gap: 16px; min-height: 96px; padding: 18px 20px 18px 24px;
  border-radius: 18px; background: var(--card, #fff); box-shadow: var(--shadow, 0 10px 28px -6px rgba(27, 34, 50, .12));
  animation: cg-rise .3s ease backwards;
}
.cg-prompt { flex: 1; font-family: var(--font-display, inherit); font-size: clamp(19px, 2.4vw, 26px); font-weight: 700; letter-spacing: -.015em; line-height: 1.25; text-wrap: balance; }

.cg-ring { position: relative; flex: none; width: 64px; height: 64px; }
.cg-ring svg { width: 100%; height: 100%; rotate: -90deg; }
.cg-ring-track { fill: var(--d); }
.cg-ring-fill { fill: none; stroke: var(--yellow, #FFC845); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 100; transition: stroke-dashoffset .1s linear; transform: scale(.82); transform-origin: center; }
.cg-ring-num { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-family: var(--font-display, inherit); font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cg-ring.is-low .cg-ring-track { fill: var(--bad); }
.cg-ring.is-low .cg-ring-num { animation: cg-pulse 1s ease infinite; }

.cg-lifelines { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cg-lifeline {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 10px;
  border-radius: 99px; border: 1.5px solid var(--line-2, #D9D0BE); background: var(--card, #fff);
  font-weight: 800; font-size: 14px; color: var(--ink, #1B2232);
  transition: border-color .15s, background-color .15s, opacity .15s;
}
.cg-lifeline .i { width: 18px; height: 18px; color: var(--c); }
.cg-lifeline:hover:not(:disabled) { border-color: var(--c); background: var(--t); }
.cg-lifeline:disabled { opacity: .4; cursor: default; }
.cg-lifeline.is-active { opacity: 1; border-color: var(--yellow, #FFC845); background: var(--yellow-2, #FFE8A6); }

.cg-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cg-answer {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px 12px 12px;
  border: 0; border-radius: 14px; background: var(--c); color: #fff; text-align: left;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .16); font-weight: 700; font-size: clamp(16px, 1.8vw, 19px); line-height: 1.25;
  transition: transform .12s, background-color .2s, opacity .2s, box-shadow .2s;
  animation: cg-rise .3s ease backwards;
}
.cg-answer:nth-child(2) { animation-delay: .04s; }
.cg-answer:nth-child(3) { animation-delay: .08s; }
.cg-answer:nth-child(4) { animation-delay: .12s; }
.cg-answer:hover:not(:disabled) { background: var(--d); transform: translateY(-2px); }
.cg-answer:active:not(:disabled) { transform: translateY(1px); }
.cg-answer:disabled { cursor: default; }
.cg-key { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .22); font-size: 14px; font-weight: 800; }
.cg-answer-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cg-answer.is-hidden { visibility: hidden; }
.cg-answer.is-dim { opacity: .35; }
.cg-answer.is-correct { background: var(--ok); opacity: 1; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .2), 0 0 0 4px var(--ok-t); }
.cg-answer.is-correct .cg-key::after { content: "✓"; }
.cg-answer.is-wrong { background: var(--bad); opacity: 1; animation: cg-shake .4s ease; }
.cg-answer.is-wrong .cg-key::after { content: "✗"; }
.cg-answer.is-correct .cg-key, .cg-answer.is-wrong .cg-key { font-size: 0; }
.cg-answer.is-correct .cg-key::after, .cg-answer.is-wrong .cg-key::after { font-size: 16px; }
.cg-answer:disabled:not(.is-correct):not(.is-wrong):not(.is-dim) { opacity: .55; }

/* Win or lose stakes */
.cg-stake-panel { display: grid; gap: 10px; justify-items: center; }
.cg-step { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink-2, #4A5367); text-align: center; }
.cg-step-num { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--ink, #1B2232); color: #fff; font-size: 13px; font-weight: 800; }
.cg-stakes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cg-stake {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 96px; height: 58px; padding: 0 16px;
  border-radius: 14px; border: 2px solid var(--line-2, #D9D0BE); background: var(--card, #fff); line-height: 1.1;
  transition: border-color .15s, background-color .15s, transform .12s, opacity .15s;
}
.cg-stake small { font-size: 12px; font-weight: 700; color: var(--ink-3, #7C8498); }
.cg-stake b { font-family: var(--font-display, inherit); font-size: 22px; font-weight: 800; color: var(--d); }
.cg-stake:hover:not(:disabled) { border-color: var(--c); background: var(--t); transform: translateY(-2px); }
.cg-stake.is-pass b { color: var(--ink-2, #4A5367); }
.cg-stake:disabled { opacity: .4; cursor: default; }
.cg-stake.is-selected { opacity: 1; border-color: var(--yellow, #FFC845); background: var(--yellow-2, #FFE8A6); }

/* ---------- Letter guess ---------- */
.cg-lg { display: flex; flex: 1; flex-direction: column; align-items: center; gap: 16px; width: 100%; max-width: 760px; margin: 0 auto; }
.cg-lg-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 20px; width: 100%; }
.cg-lg-lives { display: flex; gap: 4px; }
.cg-heart { width: 30px; height: 30px; fill: var(--c); stroke: var(--d); stroke-width: 1.5; transition: fill .3s, stroke .3s, opacity .3s, transform .3s; }
.cg-heart.is-lost { fill: transparent; stroke: var(--line-2, #D9D0BE); }
.cg-heart.is-popping { animation: cg-pop .45s ease; }
.cg-lg-clue { flex: 1 1 280px; max-width: 520px; padding: 10px 16px; border-radius: 14px; background: var(--card, #fff); border: 1px solid var(--line, #E8E1D3); font-weight: 600; text-align: center; }
.cg-lg-clue span { display: block; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--c); }
.cg-lg-clue.is-empty { flex: none; color: var(--ink-3, #7C8498); }
.cg-lg-word {
  container-type: inline-size;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 26px; width: 100%; padding: 8px 0;
}
.cg-lg-group { display: flex; gap: clamp(3px, 1cqi, 8px); }
.cg-lg-slot {
  display: grid; place-items: end center; width: clamp(18px, calc((100cqi - 8px * var(--n, 8)) / var(--n, 8)), 46px); height: 52px; padding-bottom: 6px;
  border-bottom: 4px solid var(--ink, #1B2232); font-family: var(--font-display, inherit); font-size: clamp(18px, 3.6vw, 32px); font-weight: 800; line-height: 1;
}
.cg-lg-slot.is-new { animation: cg-rise .25s ease backwards; }
.cg-lg-slot.is-symbol { border-bottom-color: transparent; }
.cg-lg-slot.is-missed { color: var(--bad); border-bottom-color: var(--bad); }
.cg-lg-keys { display: grid; gap: 6px; justify-items: center; width: 100%; }
.cg-lg-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.cg-lg-key {
  width: clamp(28px, 7.4vw, 46px); height: clamp(38px, 6vw, 48px); padding: 0;
  border: 1.5px solid var(--line-2, #D9D0BE); border-radius: 10px; background: var(--card, #fff);
  font-family: var(--font-display, inherit); font-weight: 800; font-size: clamp(14px, 2vw, 18px);
  box-shadow: inset 0 -3px 0 rgba(27, 34, 50, .06);
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
.cg-lg-key:hover:not(:disabled) { border-color: var(--c); background: var(--t); }
.cg-lg-key:active:not(:disabled) { transform: translateY(1px); }
.cg-lg-key:disabled { cursor: default; }
.cg-lg-key.is-hit { border-color: var(--c); background: var(--c); color: #fff; }
.cg-lg-key.is-miss { border-color: var(--paper-3, #EAE3D4); background: var(--paper-2, #F4EFE5); color: var(--ink-3, #7C8498); text-decoration: line-through; }
.cg-lg-key:disabled:not(.is-hit):not(.is-miss) { opacity: .45; }

/* ---------- Word search ---------- */
.cg-ws { display: flex; gap: 24px; align-items: flex-start; justify-content: center; width: 100%; }
.cg-ws-board {
  position: relative; flex: 0 1 auto; width: min(64vh, 560px); min-width: 0; aspect-ratio: 1; padding: 6px;
  border-radius: 16px; background: var(--card, #fff); box-shadow: var(--shadow, 0 10px 28px -6px rgba(27, 34, 50, .12));
  touch-action: none; cursor: pointer; container-type: inline-size;
}
.cg:fullscreen .cg-ws-board, :fullscreen > .stage .cg-ws-board { width: min(74vh, 820px); }
.cg-ws-board:focus { outline: none; }
.cg-ws-board:focus-visible:not(.is-pointer) { outline: 3px solid var(--blue, #3D7EEA); outline-offset: 3px; }
.cg-ws-board.is-miss { animation: cg-shake .35s ease; }
.cg-ws-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); width: 100%; height: 100%; }
.cg-ws-cell {
  display: grid; place-items: center; border-radius: 6px;
  font-family: var(--font-display, inherit); font-weight: 700; font-size: calc((100cqi - 12px) / var(--n) * .52); line-height: 1;
  color: #3D4558; pointer-events: none;
}
.cg-ws-board:focus-visible:not(.is-pointer) .cg-ws-cell.is-cursor { box-shadow: inset 0 0 0 2.5px var(--blue, #3D7EEA); }
.cg-ws-marks { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); overflow: visible; pointer-events: none; }
.cg-ws-marks:last-child { z-index: 2; }
.cg-ws-marks line { stroke-width: .76; stroke-linecap: round; vector-effect: none; }
.cg-ws-selecting { stroke: var(--yellow, #FFC845); stroke-opacity: .55; }
.cg-ws-found { stroke-opacity: .32; animation: cg-fade .25s ease backwards; }
.cg-ws-revealed { stroke: var(--ink-3, #7C8498); stroke-opacity: .18; stroke-dasharray: .3 .25; }
.c0 { --hl: #3D7EEA; } .c1 { --hl: #EB6544; } .c2 { --hl: #2E9A5B; } .c3 { --hl: #7C5CE6; } .c4 { --hl: #E9A50F; } .c5 { --hl: #DD4F8A; }
.cg-ws-found { stroke: var(--hl); }
.cg-ws-side { display: flex; flex: 0 0 220px; flex-direction: column; gap: 12px; }
.cg-ws-title { font-family: var(--font-display, inherit); font-size: 17px; font-weight: 700; }
.cg-ws-list { display: grid; gap: 4px; }
.cg-ws-list li { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 10px; background: var(--card, #fff); border: 1px solid var(--line, #E8E1D3); font-weight: 700; transition: background-color .2s, color .2s; }
.cg-ws-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line-2, #D9D0BE); }
.cg-ws-list li.is-found { background: transparent; color: var(--ink-3, #7C8498); text-decoration: line-through; text-decoration-thickness: 2px; }
.cg-ws-list li.is-found .cg-ws-dot { border-color: var(--hl); background: var(--hl); }
.cg-ws-list li.is-missed { color: var(--bad); }
.cg-ws-status { min-height: 1.45em; font-size: 14px; color: var(--ink-2, #4A5367); }
.cg-ws-side .btn { align-self: flex-start; }

/* ---------- Labelled diagram ---------- */
.cg-ld {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
  grid-template-areas: "stage slots" "bottom bottom"; gap: 18px 44px; align-items: start; width: 100%; max-width: 980px; margin: 0 auto;
}
.cg-ld-leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 1; }
.cg-ld-leader { fill: none; stroke: var(--d); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: .4; }
.cg-ld-leader.is-filled { opacity: .7; stroke-dasharray: none; }
.cg-ld-stage { grid-area: stage; display: flex; justify-content: center; min-width: 0; }
.cg-ld-figure { position: relative; display: inline-block; max-width: 100%; border-radius: 16px; overflow: visible; }
.cg-ld-img { display: block; max-width: 100%; max-height: min(56vh, 520px); width: auto; height: auto; border-radius: 16px; box-shadow: var(--shadow, 0 10px 28px -6px rgba(27, 34, 50, .12)); pointer-events: none; }
.cg:fullscreen .cg-ld-img, :fullscreen > .stage .cg-ld-img { max-height: 66vh; }
.cg-ld-pin {
  position: absolute; z-index: 2; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; translate: -50% -50%;
  border: 2.5px solid #fff; border-radius: 50%; background: var(--ink, #1B2232); color: #fff; font-size: 13px; font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: background-color .15s, transform .15s;
}
.cg-ld-pin.is-filled { background: var(--c); }
.cg-ld-pin.is-target, .cg-ld-pin.is-hover { transform: scale(1.18); background: var(--yellow, #FFC845); color: var(--ink, #1B2232); }
.cg-ld-pin.is-correct { background: var(--ok); }
.cg-ld-pin.is-wrong { background: var(--bad); }
.cg-ld-pin:disabled { cursor: default; }
.cg-ld-slots { grid-area: slots; z-index: 2; display: grid; gap: 8px; align-self: center; }
.cg-ld-slot {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 5px 8px 5px 6px;
  border: 2px dashed var(--line-2, #D9D0BE); border-radius: 12px; background: rgba(255, 255, 255, .7); text-align: left;
  transition: border-color .15s, background-color .15s;
}
.cg-ld-slot .cg-ld-num { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--ink, #1B2232); color: #fff; font-size: 12px; font-weight: 800; }
.cg-ld-empty { color: var(--ink-3, #7C8498); font-size: 13px; font-weight: 600; }
.cg-ld-slot.is-filled { border-style: solid; border-color: var(--c); background: var(--card, #fff); }
.cg-ld-slot.is-filled .cg-ld-num { background: var(--c); }
.cg-ld-slot.is-target { border-color: var(--yellow, #FFC845); }
.cg-ld-slot.is-hover { border-color: var(--yellow, #FFC845); background: var(--yellow-2, #FFE8A6); }
.cg-ld-slot.is-correct { border-color: var(--ok); background: var(--ok-t); }
.cg-ld-slot.is-correct .cg-ld-num { background: var(--ok); }
.cg-ld-slot.is-wrong { border-color: var(--bad); background: var(--bad-t); }
.cg-ld-slot.is-wrong .cg-ld-num { background: var(--bad); }
.cg-ld-slot:disabled { cursor: default; }
.cg-ld-slot .cg-ld-label { flex: 1; min-width: 0; box-shadow: none; background: transparent; border: 0; padding: 0; height: auto; }
.cg-ld-mark { width: 18px; height: 18px; margin-left: auto; stroke-width: 3; }
.cg-ld-slot.is-correct .cg-ld-mark { color: var(--ok); }
.cg-ld-slot.is-wrong .cg-ld-mark { color: var(--bad); }
.cg-ld-bottom { grid-area: bottom; display: grid; gap: 12px; justify-items: center; }
.cg-ld-hint { color: var(--ink-2, #4A5367); font-size: 15px; text-align: center; min-height: 1.45em; }
.cg-ld-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cg-ld-label {
  display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1.5px solid var(--line-2, #D9D0BE); background: var(--card, #fff); color: var(--ink, #1B2232);
  font-weight: 700; font-size: 15px; white-space: nowrap; touch-action: none; cursor: grab;
  box-shadow: 0 2px 0 var(--line, #E8E1D3); transition: border-color .15s, background-color .15s, transform .12s, opacity .15s;
}
.cg-ld-tray .cg-ld-label:hover { border-color: var(--c); transform: translateY(-2px); }
.cg-ld-label.is-selected { border-color: var(--yellow, #FFC845); background: var(--yellow-2, #FFE8A6); }
.cg-ld-label.is-dragging { opacity: .35; }
.cg-ld-ghost { position: absolute; left: 0; top: 0; z-index: 50; pointer-events: none; border-color: var(--c); box-shadow: var(--shadow-lg, 0 28px 56px -12px rgba(27, 34, 50, .22)); cursor: grabbing; rotate: -3deg; }
.cg-ld-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------- Flip tiles ---------- */
.cg-ft { display: flex; flex: 1; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.cg-ft-toolbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cg-ft-toolbar .chip .i { width: 16px; height: 16px; }
.cg-ft-deck { display: flex; align-items: center; justify-content: center; gap: clamp(8px, 2vw, 24px); width: 100%; margin: 6px 0; }
.cg-ft-stack { position: relative; width: min(100%, 520px); aspect-ratio: 16 / 10.5; perspective: 1400px; }
.cg-ft-under { position: absolute; inset: 0; border-radius: 22px; background: var(--d); rotate: 4deg; translate: 6px 4px; opacity: .9; }
.cg-ft-card {
  position: absolute; inset: 0; padding: 0; border: 0; border-radius: 22px; background: transparent;
  touch-action: pan-y; -webkit-tap-highlight-color: transparent;
}
.cg-ft-card:focus-visible { outline: 3px solid var(--yellow, #FFC845); outline-offset: 4px; }
.cg-ft-card.is-in-right { animation: cg-in-right .3s ease backwards; }
.cg-ft-card.is-in-left { animation: cg-in-left .3s ease backwards; }
.cg-ft-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3, .7, .3, 1); }
.cg-ft-inner.is-flipped { transform: rotateY(180deg); }
.cg-ft-face {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 28px 32px;
  border-radius: 22px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .14);
}
.cg-ft-face.is-front { background: var(--c); color: #fff; }
.cg-ft-face.is-back { background: var(--card, #fff); color: var(--ink, #1B2232); border: 3px solid var(--c); transform: rotateY(180deg); box-shadow: inset 0 -6px 0 var(--t); }
.cg-ft-card.is-alt .cg-ft-face.is-front { background: var(--d); }
.cg-ft-face::after { content: ""; position: absolute; right: 0; bottom: 0; width: 48px; height: 48px; border-radius: 0 0 22px 0; background: linear-gradient(135deg, transparent 50%, rgba(255, 255, 255, .3) 50%); }
.cg-ft-face.is-back::after { background: linear-gradient(135deg, transparent 50%, var(--t) 50%); }
.cg-ft-text { font-family: var(--font-display, inherit); font-size: clamp(22px, 3.6vw, 40px); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; text-align: center; overflow-wrap: anywhere; text-wrap: balance; }
.cg-ft-face.is-back .cg-ft-text { font-family: var(--font-body, inherit); font-size: clamp(18px, 2.6vw, 28px); font-weight: 700; letter-spacing: 0; }
.cg-ft-nav {
  display: grid; place-items: center; flex: none; width: 52px; height: 52px; padding: 0;
  border: 1.5px solid var(--line-2, #D9D0BE); border-radius: 50%; background: var(--card, #fff); color: var(--ink, #1B2232);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(27, 34, 50, .06)); transition: border-color .15s, transform .12s, opacity .15s;
}
.cg-ft-nav .i { width: 22px; height: 22px; stroke-width: 2.4; }
.cg-ft-nav:hover:not(:disabled) { border-color: var(--ink-3, #7C8498); transform: scale(1.05); }
.cg-ft-nav:disabled { opacity: .35; cursor: default; }
.cg-ft-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; font-weight: 700; color: var(--ink-3, #7C8498); }
.cg-ft-dot { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; background: transparent; }
.cg-ft-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2, #D9D0BE); transition: background-color .15s, transform .15s; }
.cg-ft-dot.is-seen::before { background: var(--c); opacity: .45; }
.cg-ft-dot.is-current::before { background: var(--d); opacity: 1; transform: scale(1.35); }
.cg-ft-help { font-size: 13px; color: var(--ink-3, #7C8498); }

/* ---------- Motion ---------- */
@keyframes cg-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cg-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cg-shake { 0%, 100% { translate: 0; } 25% { translate: -5px; } 50% { translate: 4px; } 75% { translate: -2px; } }
@keyframes cg-pulse { 50% { transform: scale(1.15); } }
@keyframes cg-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes cg-in-right { from { opacity: 0; transform: translateX(40px) rotate(2deg); } to { opacity: 1; transform: none; } }
@keyframes cg-in-left { from { opacity: 0; transform: translateX(-40px) rotate(-2deg); } to { opacity: 1; transform: none; } }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .cg-template-name { display: none; }
  .cg-stat { padding: 0 10px; }
  .cg-answers { grid-template-columns: 1fr; }
  .cg-answer { min-height: 54px; }
  .cg-prompt-card { min-height: 0; padding: 14px 14px 14px 18px; }
  .cg-ring { width: 52px; height: 52px; }
  .cg-ws { flex-direction: column; align-items: center; gap: 16px; }
  .cg-ws-board { width: min(100%, 520px); }
  .cg-ws-side { flex: none; width: 100%; }
  .cg-ws-list { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .cg-ld { grid-template-columns: 1fr; grid-template-areas: "stage" "slots" "bottom"; gap: 16px; }
  .cg-ld-slots { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); width: 100%; }
  .cg-ld-slot { min-height: 40px; }
  .cg-ld-empty { font-size: 12px; }
  .cg-ld-pin { width: 24px; height: 24px; font-size: 12px; border-width: 2px; }
  .cg-ft-nav { width: 44px; height: 44px; }
  .cg-ft-deck { gap: 6px; }
}
@media (max-width: 420px) {
  .cg-progress { display: none; }
  .cg-stakes .cg-stake { min-width: 0; flex: 1 1 40%; }
}
