.cb-wrap { max-width: 980px; margin: 0 auto; padding: 8px 16px 40px; }
.cb-h1 { text-align: center; font-size: clamp(26px, 5vw, 40px); margin: 6px 0 8px; color: var(--ink, #14213D); }
.cb-intro { text-align: center; color: var(--muted, #556); line-height: 1.5; max-width: 620px; margin: 0 auto 14px; }
.cb-note { text-align: center; background: #fff3cd; border-radius: 10px; padding: 8px; font-weight: 700; }
.cb-tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 10px 0 16px; }
.cb-tab { border: 1.5px solid rgba(20,33,61,.15); background: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 700; cursor: pointer; font-size: 14px; }
.cb-tab[aria-selected="true"] { background: var(--ink, #14213D); color: #fff; border-color: var(--ink, #14213D); }
.cb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.cb-card { background: #fff; border: 0; border-radius: 16px; padding: 8px 8px 10px; cursor: pointer; box-shadow: 0 2px 10px rgba(20,33,61,.08); text-align: center; font: inherit; }
.cb-card img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.cb-card b { display: block; font-size: 17px; color: var(--ink, #14213D); margin-top: 4px; }
.cb-card span { font-size: 13px; color: var(--muted, #6b7785); }
.cb-card:focus-visible, .cb-btn:focus-visible, .cb-sw:focus-visible { outline: 3px solid var(--sun, #F4B942); outline-offset: 2px; }
.cb-colors { margin: 28px auto 0; max-width: 620px; text-align: center; }
.cb-colors h2 { font-size: 22px; }
.cb-colors ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; }
.cb-colors li { display: flex; align-items: center; gap: 6px; }
.cb-colors li span { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); display: inline-block; }
.cb-credit { text-align: center; font-size: 12px; color: var(--muted, #6b7785); margin-top: 18px; }

.cb-studio { position: fixed; inset: 0; z-index: 50; background: var(--cream, #FFFBF2); display: flex; flex-direction: column; }
.cb-studio[hidden] { display: none; }
.cb-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff; box-shadow: 0 1px 6px rgba(20,33,61,.12); }
.cb-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-title b { font-size: 22px; color: var(--ink, #14213D); }
.cb-title span { color: var(--muted, #6b7785); }
.cb-btn { border: 0; background: #eef2f1; border-radius: 10px; padding: 10px 12px; font-weight: 700; cursor: pointer; font: inherit; font-weight: 700; }
.cb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; }
.cb-stage canvas { max-width: 100%; max-height: 100%; background: #fff; border-radius: 14px; box-shadow: 0 2px 12px rgba(20,33,61,.15); touch-action: manipulation; cursor: crosshair; }
.cb-stage { position: relative; }
.cb-stage.is-zoomable { overflow: hidden; }
.cb-stage.is-zoomable canvas { touch-action: none; }
.cb-zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.cb-zoom[hidden] { display: none; }
.cb-zoom .cb-btn { width: 44px; height: 44px; padding: 0; font-size: 22px; box-shadow: 0 1px 6px rgba(20,33,61,.25); background: #fff; }
.cb-story-link { display: block; width: fit-content; margin: 0 auto 12px; padding: 10px 16px; border-radius: 12px; background: #fff3cd; color: var(--ink, #14213D); font-weight: 800; text-decoration: none; text-align: center; }
.cb-story-link[hidden], .cb-story[hidden], .cb-actions[hidden], #cb-story-body[hidden] { display: none; }
.cb-story { background: #fff; border-bottom: 1px solid rgba(20,33,61,.12); padding: 8px 12px; }
.cb-studio.is-reading .cb-story { flex: 1; min-height: 0; overflow-y: auto; }
.cb-studio.is-reading .cb-stage, .cb-studio.is-reading .cb-now, .cb-studio.is-reading .cb-palette,
.cb-studio.is-reading .cb-bonus-toggle, .cb-studio.is-reading .cb-actions:not(#cb-story-nav) { display: none; }
#cb-story-prev[hidden] { display: none; }
.cb-story-start { display: block; width: 100%; margin: 10px 0 4px; }
.cb-story-head { display: flex; align-items: baseline; gap: 8px; }
.cb-story-head b { color: var(--ink, #14213D); }
.cb-story-head span { color: var(--muted, #6b7785); font-size: 13px; }
.cb-story-hide { margin-left: auto; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 700; text-decoration: underline; cursor: pointer; color: var(--ink, #14213D); }
.cb-story-line { margin: 6px 0; }
.cb-story-line b { display: block; font-size: 17px; color: var(--ink, #14213D); }
.cb-story-line span { font-size: 13px; color: var(--muted, #6b7785); }
.cb-story-tip { margin: 8px 0 4px; font-size: 13px; font-weight: 700; color: var(--ink, #14213D); }
.cb-story-task { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 2px solid rgba(20,33,61,.12); border-radius: 12px; background: #fff; padding: 6px 10px; margin-bottom: 6px; cursor: pointer; font: inherit; }
.cb-story-task[aria-pressed="true"] { border-color: var(--ink, #14213D); }
.cb-story-task i { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(20,33,61,.2); }
.cb-story-task b { display: block; font-size: 16px; color: var(--ink, #14213D); }
.cb-story-task span { font-size: 13px; color: var(--muted, #6b7785); }
.cb-story-q { margin-top: 8px; }
.cb-story-q b { display: block; font-size: 17px; color: var(--ink, #14213D); }
.cb-story-q span { font-size: 13px; color: var(--muted, #6b7785); }
.cb-story-choices { display: flex; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.cb-story-choices button { min-width: 56px; min-height: 44px; border: 2px solid rgba(20,33,61,.15); border-radius: 12px; background: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.cb-story-choices button.is-right { background: #4D8B31; border-color: #4D8B31; color: #fff; }
.cb-story-answer { font-weight: 700; font-size: 15px; color: var(--ink, #14213D); min-height: 1.2em; }
.cb-now { text-align: center; font-size: 14px; color: var(--muted, #6b7785); }
.cb-now b { color: var(--ink, #14213D); font-size: 16px; }
.cb-palette { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 8px 12px; }
.cb-sw { width: 56px; height: 56px; border-radius: 50%; border: 3px solid rgba(20,33,61,.15); cursor: pointer; display: flex; align-items: flex-end; justify-content: center; padding: 0 0 4px; }
.cb-sw span { background: rgba(255,255,255,.92); border-radius: 6px; font-size: 11px; font-weight: 800; padding: 0 4px; color: #14213D; }
.cb-sw[aria-pressed="true"] { border-color: var(--ink, #14213D); transform: scale(1.12); }
.cb-palette[hidden] { display: none; }
.cb-palette-bonus { padding-top: 0; }
.cb-palette-bonus .cb-sw { width: 42px; height: 42px; }
.cb-bonus-toggle { align-self: center; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 700; color: var(--ink, #14213D); text-decoration: underline; cursor: pointer; padding: 2px 8px; }
.cb-actions { display: flex; gap: 10px; justify-content: center; padding: 4px 12px 14px; }
.cb-actions .kw-btn { min-width: 130px; }

.cb-sheet { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.cb-sheet[hidden] { display: none; }
.cb-box { background: #fff; width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 16px 16px 22px; }
.cb-box h3 { margin: 0 0 4px; font-size: 18px; }
.cb-box p { margin: 0 0 12px; font-size: 13px; color: var(--muted, #6b7785); }
.cb-wide { display: block; width: 100%; border: 0; border-radius: 14px; padding: 13px; font-size: 15px; font-weight: 800; background: var(--sea, #0B6E7C); color: #fff; cursor: pointer; margin-bottom: 10px; }
.cb-wide-dark { background: #374151; }
.cb-opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cb-opt { border: 0; background: #f3f4f6; border-radius: 14px; padding: 10px 2px; font-size: 12px; cursor: pointer; text-decoration: none; color: #14213D; display: flex; flex-direction: column; align-items: center; gap: 5px; font-family: inherit; }
.cb-opt i { font-style: normal; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; }
.cb-close { margin-top: 12px; width: 100%; border: 0; background: #eee; border-radius: 12px; padding: 10px; font-size: 14px; cursor: pointer; }

.cb-shared { text-align: center; }
.cb-shared-img { width: 100%; max-width: 520px; height: auto; border-radius: 16px; box-shadow: 0 4px 18px rgba(20,33,61,.15); margin: 10px 0; }

#cb-print-area { display: none; }
@media print {
  /* coloring.js moves #cb-print-area to the end of <body> before printing, so
     everything else can be removed from the layout. Hiding it with visibility
     kept its space, and a fixed box was sized to the phone's screen, which put
     the picture small in the top left corner of the paper. */
  @page { margin: 12mm; }
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  body > *:not(#cb-print-area) { display: none !important; }
  /* Sized in mm, not %: phones lay the printout out at their screen width
     (about 390px), so 100% only filled the top left of the paper. 186mm fits
     inside the margins of both A4 and US Letter. */
  html, body { width: auto !important; min-width: 0 !important; }
  #cb-print-area { display: block !important; position: static; width: 186mm; margin: 0 auto; background: #fff; }
  #cb-print-area img { display: block; width: 186mm; height: auto; max-width: none; max-height: 250mm; object-fit: contain; margin: 0 auto; }
}
