.ck-study-app {
  --ck-surface: #f4f8fc;
  --ck-panel: #ffffff;
  --ck-border: #dbe5f0;
  --ck-muted: #64748b;
  --ck-heading: #1e293b;
  /* Soft pastel palette — steel/sky blue replaces the previous heavy navy
     (#0f4f8c). Mint accents replace the saturated green elsewhere. */
  --ck-primary: #38a3c4;
  --ck-primary-soft: #e0f2fe;
  --ck-primary-hover: #2c7da0;
  --ck-shadow: 0 10px 24px rgba(56, 163, 196, 0.10);
  --ck-warm:        #8b7355;
  --ck-warm-text:   #5c4a3a;
  --ck-warm-soft:   #faf8f6;
  --ck-warm-bg:     #f3efe9;
  --ck-warm-border: #ddd5ca;
  --ck-text:        #44403a;
  --ck-text-secondary: #736b62;
  --ck-btn-bg:      #f8f7f5;
  --ck-btn-border:  #d8d4ce;
  --ck-btn-hover:   #f0ece7;
  --ck-btn-text:    #1d3550;
  --ck-node-bg:     #fff;
  --ck-node-border: #ddd8d1;
  --ck-node-hover:  #bfb5a8;
  --ck-content-border: #e5e0d9;
  --ck-content-text: #3d3a36;
  --ck-focus-bg:    #f7f5f2;
  --ck-board-bg:    #edf2f7;
  --ck-tabs-bg:     #edf3fa;
  --ck-tabs-border: #d4e0ed;
  --ck-tabs-text:   #27405a;
  --ck-overlay-bg:  rgba(0, 0, 0, 0.35);
  --ck-dialog-bg:   #fff;
  --ck-success:     #3aa66b;
  --ck-error:       #e05a5a;
  --ck-info-bg:     #eef6ff;
  --ck-info-border: #cfe1f6;
  --ck-info-text:   #2f4c68;
  --ck-success-bg:  #edf9f1;
  --ck-success-border: #b9e1c8;
  --ck-success-text: #1f6b3d;
  --ck-error-bg:    #fff3f3;
  --ck-error-border: #f0c2c2;
  --ck-error-text:  #9f2e2e;
  --ck-nag-good: #15803d;
  --ck-nag-brilliant: #0f766e;
  --ck-nag-interesting: #7c3aed;
  --ck-nag-mistake: #dc2626;
  --ck-nag-blunder: #b91c1c;
  --ck-nag-dubious: #d97706;
  --ck-nag-equal: #64748b;
  --ck-nag-unclear: #7c3aed;
  --ck-nag-white-advantage: #15803d;
  --ck-nag-black-advantage: #6d28d9;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: 100%;
  color: var(--ck-heading);
  position: relative;
  overflow: visible;
}

.ck-study-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.ck-study-top > :first-child {
  flex: 1 1 100%;
  min-width: 0;
}

.ck-study-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--ck-heading);
}

.ck-study-meta {
  margin: 3px 0 0;
  color: var(--ck-muted);
  font-size: 13px;
}

/* --- Breadcrumb --- */
.ck-study-breadcrumb {
  padding: 8px 16px;
  background: var(--ck-warm-bg, #fdf0de);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
}

.ck-breadcrumb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
}

.ck-breadcrumb-item {
  color: var(--ck-text-secondary);
  white-space: nowrap;
}

.ck-breadcrumb-item:not(:last-child)::after {
  content: "›";
  margin: 0 8px;
  color: var(--ck-node-hover);
  font-weight: 600;
}

.ck-breadcrumb-item.is-current {
  color: var(--ck-warm, #b5751f);
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
}

.ck-study-top-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.ck-study-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--ck-btn-border);
  border-radius: 10px;
  background: var(--ck-btn-bg);
  color: var(--ck-btn-text);
  min-height: 38px;
  padding: 0 12px;
  font-size: 14px;
  line-height: 1.1;
  cursor: pointer;
}

.ck-study-menu-toggle-icon {
  font-size: 15px;
  line-height: 1;
}

.ck-study-menu-toggle-label {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.ck-study-menu-toggle:hover {
  background: var(--ck-btn-hover);
}

.ck-study-app:not(.is-picker-collapsed) .ck-study-menu-toggle {
  background: var(--ck-warm-bg, #fdf0de);
  border-color: var(--ck-warm-border, #eacda0);
}

.ck-study-tabs {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 8px;
  background: var(--ck-tabs-bg);
  border: 1px solid var(--ck-tabs-border);
  border-radius: 999px;
  padding: 4px;
}

.ck-study-tab-btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ck-tabs-text);
  background: transparent;
  cursor: pointer;
}

.ck-study-tab-btn.is-active {
  color: #fff;
  background: var(--ck-primary);
  box-shadow: 0 6px 14px rgba(56, 163, 196, 0.25);
}

.ck-study-panel {
  background: linear-gradient(180deg, var(--ck-panel) 0%, var(--ck-panel) 100%);
  border: 1px solid var(--ck-border);
  border-radius: 14px;
  box-shadow: var(--ck-shadow);
}

.ck-study-picker-wrap {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 80;
  width: min(460px, calc(100% - 10px));
  margin: 0;
  padding: 30px 12px 12px;
  max-height: 320px;
  overflow: auto;
  box-shadow: 0 20px 40px rgba(12, 42, 77, 0.18);
  animation: ckPickerOpen 0.15s ease-out;
}

/* No injected heading text here to avoid overlap with section title. */
.ck-study-picker-wrap::before {
  content: none;
}

.ck-study-app.is-picker-collapsed [data-study-role="picker-wrap"] {
  display: none;
}

.ck-study-picker-panel {
  display: block;
}

.ck-study-picker-panel[hidden] {
  display: none;
}

@keyframes ckPickerOpen {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ck-study-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(320px, 430px);
  gap: 14px;
}

.ck-study-main,
.ck-study-right,
.ck-study-games {
  padding: 14px;
}

.ck-study-main {
  display: grid;
  gap: 12px;
  align-content: start;
}

.ck-study-status {
  margin: 0;
  color: var(--ck-muted);
  font-size: 13px;
}

.ck-study-board-wrap {
  width: min(100%, 340px);
  aspect-ratio: 1;
  margin-inline: auto;
  position: relative;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: var(--ck-board-bg);
}

.ck-study-board {
  width: 100%;
  height: 100%;
}

.ck-study-board-wrap coord {
  font-family: "Noto Sans", "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #a58362;
  opacity: 1;
  text-shadow: none;
}

.ck-study-board-wrap coords.files coord,
.ck-study-board-wrap coords.ranks coord {
  color: #a58362;
}

.ck-board-error-marker {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e05a5a;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.88);
  opacity: 0;
  transition: transform 0.14s ease, opacity 0.14s ease;
  z-index: 7;
}

.ck-board-error-marker.is-visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.ck-board-success-marker {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #3aa66b;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.88);
  opacity: 0;
  transition: transform 0.14s ease, opacity 0.14s ease;
  z-index: 7;
}

.ck-board-success-marker.is-visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.ck-board-nag-marker {
  position: absolute;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 8px rgba(35, 31, 26, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 0;
  transition: transform 0.12s ease, opacity 0.12s ease;
  z-index: 8;
}

.ck-board-nag-marker.is-visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 0.92;
}

.ck-board-nag-marker.is-nag-good {
  background: var(--ck-nag-good);
}

.ck-board-nag-marker.is-nag-brilliant {
  background: var(--ck-nag-brilliant);
}

.ck-board-nag-marker.is-nag-mistake {
  background: var(--ck-nag-mistake);
}

.ck-board-nag-marker.is-nag-blunder {
  background: var(--ck-nag-blunder);
}

.ck-board-nag-marker.is-nag-interesting {
  background: var(--ck-nag-interesting);
}

.ck-board-nag-marker.is-nag-dubious {
  background: var(--ck-nag-dubious);
}

.ck-board-nag-marker.is-nag-equal {
  background: var(--ck-nag-equal);
}

.ck-board-nag-marker.is-nag-unclear {
  background: var(--ck-nag-unclear);
}

.ck-board-nag-marker.is-nag-white-advantage {
  background: var(--ck-nag-white-advantage);
}

.ck-board-nag-marker.is-nag-black-advantage {
  background: var(--ck-nag-black-advantage);
}

.ck-study-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ck-study-control-btn {
  border: 1px solid var(--ck-btn-border);
  background: var(--ck-btn-bg);
  color: var(--ck-btn-text);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 36px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  /* Smooth hover for ALL control buttons (replaces the per-button
     `transition: opacity` that was removed when the old .ck-flip/dark/focus
     -toggle rules were consolidated — without this the muted view-tools snap
     on hover instead of fading). */
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.ck-study-control-btn[data-study-control="first"],
.ck-study-control-btn[data-study-control="prev"],
.ck-study-control-btn[data-study-control="play"],
.ck-study-control-btn[data-study-control="next"],
.ck-study-control-btn[data-study-control="last"] {
  width: 38px;
  min-width: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
}

.ck-study-control-btn[data-study-control="theory-prev"],
.ck-study-control-btn[data-study-control="theory-next"] {
  width: 38px;
  min-width: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
}

.ck-study-control-btn[data-study-control="theory-prev"] {
  margin-left: 0;
}

.ck-study-control-btn:hover {
  background: var(--ck-btn-hover);
}

.ck-study-control-btn.is-disabled,
.ck-study-control-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== Control row hierarchy: navigation vs view-tools =====
   The row centres as a whole (justify-content above). The 5 navigation buttons
   stay full-size/full-contrast (primary); the view-tools (flip / analysis /
   dark / focus / move-tree) are muted + slightly smaller and set apart by a
   thin divider, so 10+ controls read as two scannable groups instead of one
   undifferentiated icon wall. */
.ck-study-control-btn[data-study-control="flip"],
.ck-study-control-btn[data-study-control="analysis"],
.ck-study-control-btn[data-study-control="dark-mode"],
.ck-study-control-btn[data-study-control="focus-mode"],
.ck-study-control-btn[data-study-control="toggle-move-tree"] {
  color: var(--ck-text-secondary, #736b62);
  min-height: 32px;
  padding: 6px 8px;
}
.ck-study-control-btn[data-study-control="flip"]:hover,
.ck-study-control-btn[data-study-control="analysis"]:hover,
.ck-study-control-btn[data-study-control="dark-mode"]:hover,
.ck-study-control-btn[data-study-control="focus-mode"]:hover,
.ck-study-control-btn[data-study-control="toggle-move-tree"]:hover {
  color: var(--ck-btn-text);
}
/* thin divider before the first view-tool (flip is always present in both
   theory + practice mode, so the separator is stable across modes). */
.ck-study-control-btn[data-study-control="flip"] {
  margin-left: 10px;
  position: relative;
}
.ck-study-control-btn[data-study-control="flip"]::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  width: 1px;
  height: 22px;
  transform: translateY(-50%);
  background: var(--ck-btn-border);
}
/* Play / autoplay = solid accent button so it can NEVER be mistaken for the
   "next move" chevron (the old ⏵ vs ▶ unicode looked nearly identical). */
.ck-study-control-btn.ck-play-toggle {
  background: var(--ck-primary);
  border-color: var(--ck-primary);
  color: #fff;
}
.ck-study-control-btn.ck-play-toggle:hover {
  background: var(--ck-primary);
  filter: brightness(1.08);
}

.ck-study-content {
  border-top: 1px solid var(--ck-content-border);
  padding-top: 10px;
  color: var(--ck-content-text);
  font-size: 14px;
  line-height: 1.6;
  max-height: 200px;
  overflow: auto;
}

.ck-study-section + .ck-study-section {
  margin-top: 14px;
}

.ck-study-section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ck-text);
}

.ck-study-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.ck-study-sublist {
  list-style: none;
  margin: 6px 0 0 16px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.ck-toc-group {
  margin: 0;
}

.ck-toc-toggle {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ck-btn-text);
  text-align: left;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.ck-toc-toggle:hover {
  background: #fef8f0;
  border-color: var(--ck-warm-border, #eacda0);
  border-left-color: var(--ck-warm, #b5751f);
}

.ck-toc-caret {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  color: var(--ck-text-secondary);
  transform: rotate(0deg);
  transition: transform 0.14s ease;
}

.ck-toc-group.is-collapsed > .ck-toc-toggle .ck-toc-caret {
  transform: rotate(-90deg);
}

.ck-toc-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ck-text);
}

.ck-toc-theory-group > .ck-toc-toggle .ck-toc-label {
  font-size: 12px;
  font-weight: 700;
}

.ck-study-item {
  margin: 0;
}

.ck-study-item-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--ck-btn-border);
  border-left: 3px solid transparent;
  border-radius: 10px;
  background: var(--ck-node-bg);
  padding: 10px;
  cursor: pointer;
}

.ck-study-item-btn:hover {
  border-color: var(--ck-warm-border, #eacda0);
  background: var(--ck-warm-soft, #fef8f0);
}

.ck-study-item-btn.is-active {
  border-color: var(--ck-primary);
  border-left-color: var(--ck-primary);
  background: var(--ck-primary-soft);
}

.ck-study-item-btn.is-disabled,
.ck-study-item-btn:disabled {
  border-color: #d9e2ef;
  border-left-color: #d9e2ef;
  background: #f3f6fb;
  color: #7b8ca1;
  cursor: not-allowed;
  opacity: 0.9;
}

.ck-study-item-btn.is-disabled:hover,
.ck-study-item-btn:disabled:hover {
  border-color: #d9e2ef;
  background: #f3f6fb;
}

.ck-study-item-title {
  display: block;
  font-weight: 700;
  color: var(--ck-text);
  font-size: 12.5px;
}

.ck-study-item-desc {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ck-text-secondary);
}

.ck-study-item-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.3;
  font-weight: 700;
}

.ck-study-item-badge.is-empty-pgn {
  background: #fff2d9;
  color: #8c5c08;
  border: 1px solid #f3d7a2;
}

.ck-study-empty {
  padding: 10px;
  border: 1px dashed var(--ck-warm-border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ck-text-secondary);
  background: var(--ck-warm-soft, #fef8f0);
}

.ck-study-empty--panel {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
}

.ck-study-empty-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ck-info-bg);
  color: var(--ck-info-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.ck-study-empty-body {
  display: grid;
  gap: 3px;
}

.ck-study-empty-body strong {
  color: var(--ck-text);
  font-size: 13px;
}

.ck-study-empty-body span {
  color: var(--ck-text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.ck-study-inline-state,
.ck-study-locked-state {
  display: grid;
  gap: 8px;
  border: 1px solid var(--ck-info-border);
  border-radius: 10px;
  background: var(--ck-info-bg);
  color: var(--ck-info-text);
  padding: 12px 14px;
}

.ck-study-inline-state strong,
.ck-study-locked-state strong {
  color: var(--ck-heading);
  font-size: 14px;
}

.ck-study-inline-state span,
.ck-study-locked-state span {
  font-size: 13px;
  line-height: 1.5;
}

.ck-study-locked-cta {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  background: var(--ck-primary);
  color: #fff;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.ck-study-locked-cta:hover {
  background: var(--ck-primary-hover);
  color: #fff;
  text-decoration: none;
}

.ck-game-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
}

.ck-game-item {
  border: 1px solid var(--ck-btn-border);
  background: var(--ck-node-bg);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 0;
  cursor: pointer;
}

.ck-game-item:hover {
  background: var(--ck-warm-soft, #fef8f0);
}

.ck-game-item.is-active {
  background: var(--ck-primary);
  color: #fff;
  border-color: var(--ck-primary);
}

.ck-study-right {
  display: grid;
  gap: 10px;
  align-content: start;
  position: sticky;
  top: 10px;
  align-self: start;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  padding-top: 58px;
}

.ck-practice-side {
  display: grid;
  gap: 10px;
}

.ck-practice-question {
  border: 1px solid var(--ck-warm-border, #eacda0);
  border-radius: 10px;
  background: var(--ck-warm-soft, #fef8f0);
  color: var(--ck-warm-text, #6b4310);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 600;
}

.ck-practice-turn {
  margin: 0;
  color: var(--ck-text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.ck-practice-notice {
  margin: 0;
  border: 1px solid var(--ck-warm-border, #eacda0);
  border-radius: 10px;
  background: var(--ck-warm-soft, #fef8f0);
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ck-content-text);
}

.ck-practice-notice.is-info {
  border-color: var(--ck-info-border);
  background: var(--ck-info-bg);
  color: var(--ck-info-text);
}

.ck-practice-notice.is-success {
  border-color: var(--ck-success-border);
  background: var(--ck-success-bg);
  color: var(--ck-success-text);
}

.ck-practice-notice.is-error {
  border-color: var(--ck-error-border);
  background: var(--ck-error-bg);
  color: var(--ck-error-text);
}

.ck-practice-controls-host .ck-study-controls {
  width: 100%;
}

.ck-move-tree {
  max-height: calc(100vh - 140px);
  overflow: auto;
  border: 1px solid var(--ck-warm-border, #eacda0);
  border-radius: 10px;
  padding: 10px;
  background: var(--ck-warm-soft, #fef8f0);
}

.ck-move-intro {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--ck-warm-border);
  border-radius: 8px;
  background: var(--ck-node-bg);
  color: var(--ck-warm-text, #6b4310);
  font-size: 12px;
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
}

.ck-move-line {
  margin: 0;
  padding: 0 0 6px;
}

.ck-move-line + .ck-move-line {
  margin-top: 2px;
}

.ck-move-seq {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 3px;
  white-space: normal;
  width: 100%;
}

.ck-move-token-wrap {
  display: inline-flex;
  align-items: baseline;
}

.ck-move-node {
  border: 1px solid var(--ck-node-border);
  background: var(--ck-node-bg);
  text-align: center;
  font-size: 12.5px;
  color: var(--ck-text);
  border-radius: 999px;
  padding: 3px 8px;
  line-height: 1.35;
  cursor: pointer;
}

.ck-move-node:hover {
  background: var(--ck-warm-bg);
  border-color: var(--ck-node-hover);
}

.ck-move-node.is-active {
  background: var(--ck-primary);
  color: #fff;
  border-color: var(--ck-primary);
}

.ck-move-note-inline {
  display: inline-block;
  max-width: 100%;
  border: 1px solid rgba(234, 205, 160, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 3px 7px;
  color: var(--ck-text-secondary);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.ck-move-variations {
  flex-basis: 100%;
  margin: 7px 0 5px 20px;
  padding: 8px 10px;
  border: 1px solid rgba(234, 205, 160, 0.86);
  border-left: 3px solid var(--ck-node-hover, #b5751f);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.58);
  display: grid;
  gap: 6px;
}

.ck-move-variation {
  display: block;
}

.ck-study-app.is-practice-mode [data-study-role="move-tree-section"] {
  display: none;
}

.ck-study-app.is-practice-mode [data-study-role="content"] {
  display: none;
}

/* ===== Teacher toggle: ẩn/hiện cây nước đi (move tree) =====
   Nút [data-study-control="toggle-move-tree"] chỉ render cho nhân viên ở 3 view
   study (theory / theoriescourse / theoriespractice). Khi bật, ẩn nguyên cột
   "Cây nước đi" và cho bàn cờ chiếm hết chiều ngang (board-wrap đã có
   margin-inline:auto nên tự căn giữa). Trạng thái nhớ ở localStorage phía
   client — xem theory-study-viewer.js. Guard :not(.is-practice-mode) để KHÔNG
   ẩn nhầm panel câu hỏi bài tập (cũng nằm trong .ck-study-right); ở chế độ bài
   tập, move tree đã bị is-practice-mode ẩn sẵn. */
.ck-study-app.is-movetree-hidden:not(.is-practice-mode) .ck-study-right {
  display: none;
}

.ck-study-app.is-movetree-hidden:not(.is-practice-mode) .ck-study-layout {
  grid-template-columns: 1fr;
}

/* Nút chỉ có nghĩa ở chế độ lý thuyết — ẩn nó khi đang ở chế độ bài tập để
   tránh gây hiểu nhầm (bấm không có tác dụng thấy được). */
.ck-study-app.is-practice-mode .ck-movetree-toggle {
  display: none;
}

/* Trạng thái active (đang ẩn cây nước đi) — mirror .ck-study-tab-btn.is-active */
.ck-study-control-btn.ck-movetree-toggle.is-active {
  color: #fff;
  background: var(--ck-primary);
  border-color: var(--ck-primary);
}

/* Focus mode + cây nước đi ẩn: tận dụng chỗ sidebar đã ẩn — phóng to bàn cờ lấp
   chiều cao + căn giữa thật (board-size mặc định trừ 540px cho sidebar nên khi
   ẩn cây sẽ dư khoảng trống lớn + lệch trái). Override để bàn cờ to theo chiều
   cao viewport và justify-self căn giữa trong cột 1fr. */
.ck-study-app.is-focus-mode.is-movetree-hidden:not(.is-practice-mode) {
  --ck-focus-board-size: min(calc(100vh - 104px), calc(100vw - 60px));
}
.ck-study-app.is-focus-mode.is-movetree-hidden:not(.is-practice-mode) .ck-study-main {
  justify-self: center;
  /* main width == board size; its default 14px side padding made the equally
     wide board-wrap overflow asymmetrically (~15px off-centre). Drop side
     padding so the board fills main exactly and centres pixel-perfectly. */
  padding-inline: 0;
}

.ck-study-app.is-practice-mode [data-study-control="first"],
.ck-study-app.is-practice-mode [data-study-control="prev"],
.ck-study-app.is-practice-mode [data-study-control="play"],
.ck-study-app.is-practice-mode [data-study-control="next"],
.ck-study-app.is-practice-mode [data-study-control="last"],
.ck-study-app.is-practice-mode [data-study-control="analysis"] {
  display: none;
}
/* theory-prev / theory-next = prev/next-GAME (ván) arrows: shown in practice too
   (controlled by the JS [hidden] attribute — visible only on multi-game items),
   so they are intentionally NOT force-hidden here. */

.ck-study-app.is-practice-mode [data-study-control="puzzle-answer"],
.ck-study-app.is-practice-mode [data-study-control="puzzle-retry"],
.ck-study-app.is-practice-mode [data-study-control="puzzle-next"],
.ck-study-app.is-practice-mode [data-study-control="puzzle-auto-next"] {
  background: var(--ck-primary);
  color: #fff;
  border-color: var(--ck-primary);
}

.ck-study-app.is-practice-mode [data-study-control="puzzle-answer"]:hover,
.ck-study-app.is-practice-mode [data-study-control="puzzle-retry"]:hover,
.ck-study-app.is-practice-mode [data-study-control="puzzle-next"]:hover,
.ck-study-app.is-practice-mode [data-study-control="puzzle-auto-next"]:hover {
  background: var(--ck-primary-hover);
}

.ck-study-app.is-practice-mode [data-study-control="puzzle-auto-next"].is-active {
  background: #158a58;
  border-color: #158a58;
}

.ck-study-app.is-practice-mode [data-study-control="puzzle-auto-next"].is-active:hover {
  background: #116f47;
}

.ck-study-app.is-variation-preview .ck-study-board-wrap {
  box-shadow: 0 0 0 3px rgba(15, 79, 140, 0.22);
}

.ck-study-board-wrap.is-variation-switch {
  animation: ckVariationSwitch 0.56s ease;
}

piece.ck-hint-blink {
  animation: ckHintBlink 0.35s ease-in-out 4;
  filter: drop-shadow(0 0 8px rgba(255, 212, 71, 0.9));
}

@keyframes ckVariationSwitch {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 0 rgba(15, 79, 140, 0.32);
  }
  45% {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 0 0 6px rgba(15, 79, 140, 0.16);
  }
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 0 rgba(15, 79, 140, 0);
  }
}

@keyframes ckHintBlink {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.12);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Legacy viewer mode: open table-of-contents as action-menu panel. */
.ck-study-app.ck-study-app--legacy {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "top"
    "body"
    "games";
  align-items: start;
}

.ck-study-app.ck-study-app--legacy .ck-study-top {
  grid-area: top;
}

.ck-study-app.ck-study-app--legacy [data-study-role="picker-wrap"] {
  position: absolute;
  top: 12px;
  right: 0;
  width: min(460px, calc(100% - 10px));
  padding: 12px;
  margin: 0;
  max-height: min(72vh, 560px);
  overflow: auto;
  z-index: 80;
  box-shadow: 0 20px 40px rgba(12, 42, 77, 0.18);
}

.ck-study-app.ck-study-app--legacy [data-study-role="picker-wrap"]::before {
  content: none;
}

.ck-study-app.ck-study-app--legacy.is-picker-collapsed [data-study-role="picker-wrap"] {
  display: none !important;
}

.ck-study-app.ck-study-app--legacy .ck-study-layout {
  grid-area: body;
}

.ck-study-app.ck-study-app--legacy .ck-study-games {
  grid-area: games;
}

.ck-study-app.ck-study-app--legacy .ck-study-list {
  max-height: none;
  overflow: visible;
}

.ck-study-app.ck-study-app--legacy .ck-study-board-wrap {
  width: min(100%, 430px);
}

@media (max-width: 1200px) {
  .ck-study-app.ck-study-app--legacy [data-study-role="picker-wrap"] {
    width: calc(100% - 8px);
    max-height: 62vh;
  }
}

@media (max-width: 1024px) {
  .ck-study-layout {
    grid-template-columns: 1fr;
  }

  .ck-study-board-wrap {
    width: min(100%, 320px);
  }

  .ck-study-right {
    position: static;
    max-height: none;
    overflow-y: visible;
    padding-top: 14px;
  }

  .ck-move-tree {
    max-height: 320px;
  }

  .ck-focus-toggle {
    display: none;
  }
}

@media (max-width: 768px) {
  .ck-study-board-wrap {
    width: min(100%, 300px);
  }

  .ck-board-nag-marker {
    min-width: 18px;
    height: 17px;
    padding: 0 4px;
    font-size: 10.5px;
  }

  .ck-study-tab-btn {
    padding: 7px 12px;
  }

  .ck-study-top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .ck-study-picker-wrap {
    width: calc(100% - 8px);
    max-height: 58vh;
  }

  .ck-move-variations {
    margin-left: 8px;
    padding: 7px 8px;
  }

  .ck-study-control-btn[data-study-control="theory-prev"],
  .ck-study-control-btn[data-study-control="theory-next"] {
    margin-left: 0;
  }
}

/* ===== Focus / view-tool buttons =====
   Muting, sizing and the group divider for the view-tools (flip / analysis /
   dark / focus / move-tree) live in the shared rules near .ck-study-controls so
   all 5 are styled consistently. Removed here: the old
   `.ck-focus-toggle { margin-left:auto }` (it pinned focus to the far right and
   broke the new grouped/centred control row) and the old per-button opacity
   muting that only covered flip+focus (now color-muted uniformly on all 5). */
.ck-flip-toggle svg { display: block; }

/* --- NAG Annotation Colors --- */
.ck-nag-good       { color: var(--ck-nag-good); font-weight: 700; }
.ck-nag-brilliant   { color: var(--ck-nag-brilliant); font-weight: 700; }
.ck-nag-interesting { color: var(--ck-nag-interesting); font-weight: 700; }
.ck-nag-mistake     { color: var(--ck-nag-mistake); font-weight: 700; }
.ck-nag-blunder     { color: var(--ck-nag-blunder); font-weight: 700; }
.ck-nag-dubious     { color: var(--ck-nag-dubious); font-weight: 700; }
.ck-nag-equal       { color: var(--ck-nag-equal); font-weight: 700; }
.ck-nag-unclear     { color: var(--ck-nag-unclear); font-weight: 700; }
.ck-nag-white-advantage { color: var(--ck-nag-white-advantage); font-weight: 700; }
.ck-nag-black-advantage { color: var(--ck-nag-black-advantage); font-weight: 700; }

/* --- Eval Bar (Stockfish Analysis) --- */
.ck-eval-bar {
  width: 24px;
  min-width: 24px;
  align-self: stretch;
  background: #333;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.ck-eval-bar[hidden] { display: none; }
.ck-eval-bar-fill {
  position: absolute;
  bottom: 0;
  width: 100%;
  background: #f0f0f0;
  transition: height 0.4s ease;
  border-radius: 0 0 4px 4px;
}
.ck-eval-label {
  position: absolute;
  top: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: #f0f0f0;
  line-height: 1;
  z-index: 1;
}
.ck-eval-label.is-black-winning {
  top: auto;
  bottom: 4px;
  color: #333;
}

/* Analysis Panel */
.ck-analysis-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--ck-border);
  border-radius: 8px;
  background: var(--ck-panel);
  font-size: 12px;
  font-family: "SF Mono", "Fira Code", monospace;
}
.ck-analysis-panel[hidden] { display: none; }
.ck-analysis-depth {
  color: var(--ck-muted);
  font-weight: 700;
  min-width: 24px;
}
.ck-analysis-score {
  font-weight: 700;
  color: var(--ck-heading);
  min-width: 40px;
}
.ck-analysis-pv {
  color: var(--ck-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Analysis toggle button active state */
[data-study-control="analysis"].is-active {
  background: var(--ck-primary);
  color: #fff;
  border-color: var(--ck-primary);
}

/* Board area with eval bar: flex layout */
.ck-study-main {
  display: grid;
  gap: 12px;
  align-content: start;
}

/* --- Checkmate Overlay --- */
.ck-checkmate-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: 4px;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.35) 0%, transparent 70%);
  animation: ck-checkmate-glow 2.2s ease-out forwards;
  pointer-events: none;
}
@keyframes ck-checkmate-glow {
  0% { opacity: 0; transform: scale(0.8); }
  20% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.05); }
}

/* --- Check Highlight --- */
.ck-study-app cg-board square.check {
  background: radial-gradient(
    ellipse at center,
    rgba(255, 25, 25, 0.9) 0%,
    rgba(220, 0, 0, 0.7) 30%,
    rgba(180, 0, 0, 0) 80%
  );
  animation: ck-check-pulse 1.2s ease-in-out 2;
}
@keyframes ck-check-pulse {
  0%, 100% { box-shadow: inset 0 0 0 rgba(255, 0, 0, 0); }
  50% { box-shadow: inset 0 0 12px 2px rgba(255, 30, 30, 0.6); }
}

/* --- Promotion Dialog --- */
.ck-promotion-overlay {
  position: absolute;
  inset: 0;
  z-index: 200;
  background: var(--ck-overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
}

.ck-promotion-dialog {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--ck-dialog-bg);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.ck-promotion-piece {
  width: 60px;
  height: 60px;
  border: 2px solid transparent;
  border-radius: 8px;
  background-color: var(--ck-warm-bg);
  background-size: cover;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s, background-color 0.12s;
}

.ck-promotion-piece:hover {
  border-color: var(--ck-primary, #0f4f8c);
  background-color: var(--ck-primary-soft);
  transform: scale(1.1);
}

@media (max-width: 480px) {
  .ck-promotion-piece {
    width: 48px;
    height: 48px;
  }
}

.ck-study-app.is-focus-mode {
  /* 2026-05-22 UX fix: widen sidebar from 420 → 480 so the 4 puzzle buttons
     (Xem đáp án / Làm lại / Câu tiếp theo / Auto next: Tắt) + 3 icon
     buttons (flip / dark / focus toggle) fit in a single row + single icon
     row instead of wrapping to 3 separate rows. Board size formula updated
     so the wider sidebar doesn't shrink the board on narrower viewports. */
  --ck-focus-side-width: 480px;
  --ck-focus-board-size: min(720px, calc(100vh - 88px), calc(100vw - 540px));
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--ck-focus-bg);
  overflow: hidden;
  padding: 10px;
  grid-template-areas: "body" !important;
  grid-template-columns: 1fr !important;
}

/* 2026-05-22 UX fix: compact puzzle control buttons in focus mode so all 4
   buttons (incl. "Auto next: Tắt" which has long label) fit in one row at
   480px sidebar. Without this, even at 480px the buttons would wrap. */
.ck-study-app.is-focus-mode .ck-study-controls {
  flex-wrap: wrap;
  gap: 6px;
  row-gap: 8px;
}

.ck-study-app.is-focus-mode .ck-study-control-btn[data-study-control="puzzle-answer"],
.ck-study-app.is-focus-mode .ck-study-control-btn[data-study-control="puzzle-retry"],
.ck-study-app.is-focus-mode .ck-study-control-btn[data-study-control="puzzle-next"],
.ck-study-app.is-focus-mode .ck-study-control-btn[data-study-control="puzzle-auto-next"] {
  padding: 8px 12px;
  font-size: 13px;
}

.ck-study-app.is-focus-mode .ck-study-top,
.ck-study-app.is-focus-mode .ck-study-breadcrumb,
.ck-study-app.is-focus-mode .ck-study-status,
.ck-study-app.is-focus-mode .ck-study-content,
.ck-study-app.is-focus-mode .ck-study-games,
.ck-study-app.is-focus-mode .ck-mobile-meta-pills,
.ck-study-app.is-focus-mode [data-study-role="picker-wrap"] {
  display: none !important;
}

.ck-study-app.is-focus-mode .ck-study-layout {
  grid-template-columns: var(--ck-focus-board-size) var(--ck-focus-side-width);
  gap: 16px;
  align-items: start;
  justify-content: center;
  max-width: none;
  margin: 0 auto;
  min-height: 0;
}

.ck-study-app.is-focus-mode .ck-study-main {
  width: var(--ck-focus-board-size);
  min-width: 0;
}

.ck-study-app.is-focus-mode .ck-study-board-wrap,
.ck-study-app.ck-study-app--legacy.is-focus-mode .ck-study-board-wrap {
  width: var(--ck-focus-board-size) !important;
  max-width: var(--ck-focus-board-size);
}

.ck-study-app.is-focus-mode .ck-study-right {
  width: var(--ck-focus-side-width);
  min-width: 0;
  padding-top: 0;
  position: sticky;
  top: 10px;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ck-study-app.is-focus-mode .ck-practice-side,
.ck-study-app.is-focus-mode .ck-practice-question,
.ck-study-app.is-focus-mode .ck-practice-notice,
.ck-study-app.is-focus-mode .ck-practice-controls-host,
.ck-study-app.is-focus-mode .ck-study-controls {
  min-width: 0;
}

.ck-study-app.is-focus-mode .ck-practice-question,
.ck-study-app.is-focus-mode .ck-practice-notice {
  overflow-wrap: anywhere;
}

.ck-study-app.is-focus-mode .ck-study-control-btn {
  max-width: 100%;
  white-space: normal;
}

.ck-study-app.is-focus-mode .ck-move-tree {
  max-height: calc(100vh - 100px);
  font-size: 15px;
  padding: 14px;
}

.ck-study-app.is-focus-mode .ck-move-node {
  font-size: 15px;
  padding: 5px 10px;
}

.ck-study-app.is-focus-mode .ck-move-intro {
  font-size: 14px;
}

.ck-study-app.is-focus-mode .ck-move-note-inline {
  font-size: 14px;
}

.ck-study-app.is-focus-mode .ck-move-seq {
  gap: 5px 4px;
}

.ck-study-app.is-focus-mode .ck-focus-toggle i::before {
  content: "\f066";
}

@media (max-width: 900px) {
  .ck-study-app.is-focus-mode {
    --ck-focus-side-width: min(100%, 420px);
    --ck-focus-board-size: min(calc(100vw - 20px), calc(100vh - 180px), 520px);
    overflow-y: auto;
  }

  .ck-study-app.is-focus-mode .ck-study-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .ck-study-app.is-focus-mode .ck-study-main,
  .ck-study-app.is-focus-mode .ck-study-board-wrap,
  .ck-study-app.ck-study-app--legacy.is-focus-mode .ck-study-board-wrap,
  .ck-study-app.is-focus-mode .ck-study-right {
    width: var(--ck-focus-board-size);
    max-width: 100%;
  }
  .ck-study-app.is-focus-mode .ck-study-right {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

/* ===== Dark Mode Toggle ===== */
/* Dark toggle muting/sizing handled by the shared view-tools rules; keep only
   the moon/sun swap (now FontAwesome <i> icons instead of inline SVG). */
.ck-dark-toggle .ck-icon-sun  { display: none; }
.ck-dark-toggle .ck-icon-moon { display: inline-block; }

/* ===== Dark Theme ===== */
html[data-theme="dark"] .ck-study-app {
  --ck-surface:       #141820;
  --ck-panel:         #1c2130;
  --ck-border:        #2e3648;
  --ck-muted:         #8b9dc3;
  --ck-heading:       #e2e8f0;
  --ck-primary:       #5b9cf5;
  --ck-primary-soft:  #1a2d48;
  --ck-primary-hover: #4a8be4;
  --ck-shadow:        0 10px 24px rgba(0, 0, 0, 0.3);
  --ck-warm:          #c9a06a;
  --ck-warm-text:     #dcc8a6;
  --ck-warm-soft:     #1e1c18;
  --ck-warm-bg:       #272318;
  --ck-warm-border:   #3d3628;
  --ck-text:          #cbd5e1;
  --ck-text-secondary:#8899a8;
  --ck-btn-bg:        #1e2536;
  --ck-btn-border:    #303a50;
  --ck-btn-hover:     #283044;
  --ck-btn-text:      #c8d4e2;
  --ck-node-bg:       #1c2130;
  --ck-node-border:   #303a50;
  --ck-node-hover:    #3d4860;
  --ck-content-border:#2e3648;
  --ck-content-text:  #b8c4d4;
  --ck-focus-bg:      #141820;
  --ck-board-bg:      #1a1e28;
  --ck-tabs-bg:       #1a2232;
  --ck-tabs-border:   #2e3648;
  --ck-tabs-text:     #94a8c4;
  --ck-overlay-bg:    rgba(0, 0, 0, 0.55);
  --ck-dialog-bg:     #1c2130;
  --ck-success:       #34d399;
  --ck-error:         #f87171;
  --ck-info-bg:       #162032;
  --ck-info-border:   #1e3a5f;
  --ck-info-text:     #93c5fd;
  --ck-success-bg:    #0d2818;
  --ck-success-border:#1a4d2e;
  --ck-success-text:  #6ee7b7;
  --ck-error-bg:      #2d1515;
  --ck-error-border:  #5c2020;
  --ck-error-text:    #fca5a5;
  --ck-nag-good: #4ade80;
  --ck-nag-brilliant: #5eead4;
  --ck-nag-interesting: #a78bfa;
  --ck-nag-mistake: #f87171;
  --ck-nag-blunder: #fca5a5;
  --ck-nag-dubious: #fbbf24;
  --ck-nag-equal: #94a3b8;
  --ck-nag-unclear: #c4b5fd;
  --ck-nag-white-advantage: #86efac;
  --ck-nag-black-advantage: #c4b5fd;
}

html[data-theme="dark"] .ck-dark-toggle .ck-icon-sun  { display: inline-block; }
html[data-theme="dark"] .ck-dark-toggle .ck-icon-moon { display: none; }

html[data-theme="dark"] .ck-study-panel {
  background: var(--ck-panel);
}

html[data-theme="dark"] .ck-study-tab-btn.is-active {
  box-shadow: 0 4px 12px rgba(91, 156, 245, 0.25);
}

html[data-theme="dark"] .ck-study-board-wrap coord,
html[data-theme="dark"] .ck-study-board-wrap coords.files coord,
html[data-theme="dark"] .ck-study-board-wrap coords.ranks coord {
  color: #a58362;
}

html[data-theme="dark"] .ck-board-error-marker {
  background: #dc4444;
}

html[data-theme="dark"] .ck-board-success-marker {
  background: #2d9d5a;
}

html[data-theme="dark"] .ck-board-nag-marker {
  border-color: rgba(255, 255, 255, 0.72);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.36);
}

html[data-theme="dark"] .ck-study-item-badge.is-empty-pgn {
  background: #3d3015;
  color: #e5b44a;
  border-color: #5a4420;
}

html[data-theme="dark"] .ck-study-item-btn.is-disabled,
html[data-theme="dark"] .ck-study-item-btn:disabled {
  border-color: var(--ck-border);
  background: var(--ck-surface);
  color: #5a6880;
}

html[data-theme="dark"] .ck-promotion-piece {
  background-color: var(--ck-warm-bg);
}

html[data-theme="dark"] .ck-promotion-piece:hover {
  background-color: var(--ck-primary-soft);
}

html[data-theme="dark"] .ck-study-picker-wrap {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] cg-board {
  filter: brightness(0.88);
}

/* ============================================================
   KIDS-CELEBRATE (2026-05-31): on a genuine puzzle solve, a friendly
   1-3 star burst + confetti over the board. Non-blocking, auto-dismisses.
   ============================================================ */
.ck-study-board-wrap { position: relative; }

.ck-solve-celebrate {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  opacity: 1;
  transition: opacity .45s ease;
}
.ck-solve-celebrate.is-leaving { opacity: 0; }

.ck-solve-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 26px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  animation: ckSolvePop .42s cubic-bezier(.18, 1.3, .4, 1) both;
}
html[data-theme="dark"] .ck-solve-card { background: rgba(30, 41, 59, 0.94); }

.ck-solve-stars { display: flex; gap: 6px; }
.ck-solve-star {
  font-size: 38px;
  line-height: 1;
  color: #d1d5db;
  transform: scale(0);
  animation: ckStarPop .4s cubic-bezier(.18, 1.5, .4, 1) both;
}
.ck-solve-star.is-on { color: #fbbf24; text-shadow: 0 2px 6px rgba(251, 191, 36, .5); }
.ck-solve-msg { font-size: 18px; font-weight: 800; color: #1e293b; }
html[data-theme="dark"] .ck-solve-msg { color: #f1f5f9; }

.ck-confetti-layer { position: absolute; inset: 0; overflow: hidden; }
.ck-confetti {
  position: absolute;
  top: -14px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation-name: ckConfettiFall;
  animation-timing-function: ease-in;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}

@keyframes ckSolvePop {
  0% { transform: scale(.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes ckStarPop {
  0% { transform: scale(0) rotate(-30deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes ckConfettiFall {
  0% { transform: translateY(-14px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(380px) rotate(540deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ck-confetti { display: none; }
  .ck-solve-card, .ck-solve-star { animation: none; transform: none; opacity: 1; }
}

/* ---- P16: overlay "Hết tim" ([Lives]) — thân thiện, không phạt --------- */
.ck-lives-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 60, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10500;
}
.ck-lives-card {
  background: #fff;
  border-radius: 22px;
  padding: 26px 30px;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.45);
  font-family: 'Inter', sans-serif;
}
.ck-lives-emoji { font-size: 52px; line-height: 1; margin-bottom: 8px; }
.ck-lives-card h3 { margin: 0 0 6px; font-size: 20px; font-weight: 800; color: #1e293b; }
.ck-lives-card p { margin: 0 0 16px; font-size: 14px; color: #475569; font-weight: 600; }
.ck-lives-retry {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 10px 22px -10px rgba(16, 185, 129, 0.7);
}
.ck-lives-retry:hover { transform: translateY(-1px); }
