/* CA_Puzzle: the library, the set-up screen and the table. Colours have fallbacks so the screens look right without the site's own tokens. */
.cp-page { max-width: 60rem; margin: 0 auto; padding: 1rem 16px 3rem; }
.cp-page h1 { margin: .2rem 0 .6rem; }
.cp-page h2 { font-size: 1.05rem; margin: 1.4rem 0 .5rem; }
.cp-lead { max-width: 42rem; }
.cp-muted { color: #6b7280; }
.cp-note { font-size: .9rem; color: #475569; }
.cp-note.warn { color: #9a3412; background: #fff7ed; border: 1px solid #fdba74; border-radius: .5rem; padding: .5rem .75rem; }
.cp-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: .75rem 0; }
.cp-crumb { margin: 0; }
.cp-link { background: none; border: 0; padding: 0; color: #1d6fa5; cursor: pointer; font: inherit; }

.cp-primary, .cp-btn, .cp-danger { font: inherit; border-radius: .55rem; border: 1px solid #1d6fa5; cursor: pointer; padding: .55rem 1rem; min-height: 44px; }
.cp-primary { background: #1d6fa5; color: #fff; font-weight: 600; }
.cp-primary:disabled { opacity: .6; cursor: default; }
.cp-btn { background: #fff; color: #1d6fa5; }
.cp-danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.cp-primary.small, .cp-btn.small, .cp-danger.small { min-height: 38px; padding: .3rem .7rem; font-size: .9rem; }

/* picking a picture */
.cp-pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem; }
.cp-pic { border: 2px solid transparent; border-radius: .6rem; background: #fff; padding: .35rem; cursor: pointer; text-align: center; font: inherit; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.cp-pic img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: .4rem; display: block; }
.cp-pic span { display: block; margin-top: .3rem; font-size: .9rem; }
.cp-pic.sel { border-color: #1d6fa5; box-shadow: 0 0 0 3px rgba(29, 111, 165, .25); }
.cp-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.cp-chip { font: inherit; min-width: 4rem; min-height: 44px; border-radius: 999px; border: 1px solid #94a3b8; background: #fff; cursor: pointer; }
.cp-chip.sel { background: #1d6fa5; color: #fff; border-color: #1d6fa5; }
/* the set-up screen: short choices on top, the pictures below, a start bar that stays at the bottom of the screen */
.cp-settings { display: flex; flex-wrap: wrap; gap: .4rem 2rem; background: #fff; border: 1px solid #e2e8f0; border-radius: .7rem; padding: .2rem 1rem .8rem; margin-bottom: .6rem; }
.cp-settings .cp-note { flex-basis: 100%; margin: 0; }
.cp-setting h2 { margin: .7rem 0 .45rem; }
.cp-segs { display: inline-grid; grid-auto-flow: column; grid-auto-columns: auto; border: 1px solid #94a3b8; border-radius: .6rem; overflow: hidden; }
.cp-seg { font: inherit; min-height: 44px; padding: .3rem 1rem; border: 0; border-left: 1px solid #94a3b8; background: #fff; cursor: pointer; }
.cp-seg:first-child { border-left: 0; }
.cp-seg.sel { background: #1d6fa5; color: #fff; font-weight: 600; }
.cp-level-text { margin: .4rem 0 0; font-size: .88rem; color: #475569; max-width: 26rem; }
.cp-chip:focus-visible, .cp-seg:focus-visible, .cp-pic:focus-visible { outline: 3px solid rgba(29, 111, 165, .45); outline-offset: 2px; }
.cp-startbar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: .8rem; margin: 1.2rem -8px 0; padding: .6rem 8px; padding-bottom: calc(.6rem + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #e2e8f0; box-shadow: 0 -4px 14px rgba(0, 0, 0, .08); border-radius: .7rem .7rem 0 0; }
.cp-startbar img { width: 4.5rem; aspect-ratio: 3 / 2; object-fit: cover; border-radius: .35rem; flex: 0 0 auto; }
.cp-startinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cp-startinfo b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-startbar .cp-primary { flex: 0 0 auto; }
@media (max-width: 480px) { .cp-segs { display: grid; grid-auto-columns: minmax(0, 1fr); } .cp-seg { padding: .3rem .2rem; } .cp-chip { min-width: 3.4rem; } .cp-startbar img { width: 3.5rem; } .cp-pics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; } .cp-pic span { font-size: .82rem; } }

/* my puzzles */
.cp-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .75rem; }
.cp-item { display: grid; grid-template-columns: 9rem 1fr; gap: .4rem .9rem; align-items: center; background: #fff; border: 1px solid #e2e8f0; border-radius: .7rem; padding: .6rem; }
.cp-thumb { border: 0; padding: 0; background: none; cursor: pointer; }
.cp-thumb img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: .45rem; display: block; }
.cp-info { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.cp-sub { color: #64748b; font-size: .85rem; }
.cp-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; }
@media (min-width: 640px) { .cp-item { grid-template-columns: 9rem 1fr auto; } .cp-actions { grid-column: auto; justify-content: flex-end; } }

.cp-progress { height: 6px; background: rgba(0, 0, 0, .18); border-radius: 3px; overflow: hidden; }
.cp-progress span { display: block; height: 100%; background: #22c55e; transition: width .3s; }
.cp-progress.small { height: 5px; background: #e2e8f0; }

/* the table fills the screen */
.cp-play { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; background: #1f2933; color: #f8fafc; touch-action: none; user-select: none; -webkit-user-select: none; padding-bottom: env(safe-area-inset-bottom); }
.cp-top { display: flex; align-items: center; gap: .6rem; padding: .35rem .6rem; padding-top: calc(.35rem + env(safe-area-inset-top)); background: #111827; }
.cp-top .cp-btn { min-height: 40px; padding: .2rem .8rem; }
.cp-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-title .cp-sub { color: #94a3b8; margin-left: .4rem; }
.cp-stats { display: flex; gap: .8rem; font-variant-numeric: tabular-nums; }
.cp-play .cp-progress { border-radius: 0; height: 4px; }
.cp-stage { position: relative; flex: 1; min-height: 0; }
.cp-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: grab; }
.cp-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(17, 24, 39, .85); gap: .5rem; }
.cp-bar { width: min(20rem, 70vw); height: 10px; background: #374151; border-radius: 5px; overflow: hidden; }
.cp-bar span { display: block; height: 100%; background: #38bdf8; transition: width .15s; }
.cp-tools { display: flex; gap: .4rem; padding: .4rem .6rem; background: #111827; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cp-tools .cp-btn { flex: 0 0 auto; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; min-width: 48px; min-height: 48px; padding: .15rem .55rem; line-height: 1.15; background: #1f2937; color: #e5e7eb; border-color: #374151; }
.cp-tools .cp-btn span { font-size: .68rem; opacity: .85; }
.cp-tools .cp-btn.on { background: #0e7490; border-color: #22d3ee; color: #fff; }
.cp-hint { margin: 0; padding: .25rem .8rem .5rem; font-size: .78rem; color: #94a3b8; background: #111827; text-align: center; }
.cp-play .cp-btn { color: #e5e7eb; background: #1f2937; border-color: #374151; }

.cp-peek { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .8); }
.cp-peek img { max-width: 94vw; max-height: 80vh; border-radius: .5rem; box-shadow: 0 8px 40px rgba(0, 0, 0, .6); }
.cp-peek .cp-btn { position: absolute; top: calc(.6rem + env(safe-area-inset-top)); right: .6rem; }

.cp-done { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); }
.cp-card { background: #fff; color: #111827; border-radius: .9rem; padding: 1.2rem 1.6rem; text-align: center; max-width: 22rem; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.cp-card h2 { margin: 0 0 .5rem; font-size: 1.3rem; }
.cp-card .cp-row { justify-content: center; }
.cp-play .cp-card .cp-btn { background: #fff; color: #1d6fa5; border-color: #1d6fa5; }

@media (max-width: 480px) { .cp-title .cp-sub { display: none; } .cp-item { grid-template-columns: 6.5rem 1fr; } }
@media (prefers-reduced-motion: reduce) { .cp-progress span, .cp-bar span { transition: none; } }

/* a picture of your own */
.cp-own { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px dashed #94a3b8; }
.cp-own .cp-plus { font-size: 2.4rem; line-height: 1.6; }
/* "your own picture" as one compact row above the groups */
.cp-ownrow { display: flex; margin-bottom: .2rem; }
.cp-ownrow .cp-own { flex-direction: row; gap: .7rem; padding: .4rem .9rem; min-height: 56px; }
.cp-ownrow .cp-own .cp-plus { font-size: 1.6rem; line-height: 1; }
.cp-ownrow .cp-own span { margin-top: 0; }
.cp-ownrow .cp-own img { width: 4.5rem; aspect-ratio: 3 / 2; }
.cp-own:hover { border-color: #1d6fa5; }
.cp-own.sel { border-style: solid; }
.cp-file { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cp-own:focus-within { outline: 3px solid rgba(29, 111, 165, .45); outline-offset: 2px; }

.cp-group { margin: 1.2rem 0 .5rem; font-size: 1rem; color: #475569; }

.cp-credits { margin: .8rem 0 0; font-size: .85rem; color: #475569; }
.cp-credits summary { cursor: pointer; color: #1d6fa5; }
.cp-credits ul { margin: .5rem 0; padding-left: 1.1rem; display: grid; gap: .15rem; }
.cp-credits a { color: #1d6fa5; }
.cp-credit { display: block; color: #64748b; font-size: .75rem; margin-top: .1rem; }
.cp-peek-credit { position: absolute; bottom: .8rem; left: 0; right: 0; text-align: center; color: #e5e7eb; font-size: .85rem; margin: 0; }

/* puzzling together: the lobby on the first screen */
.cp-shared { margin-top: 1.6rem; padding-top: .4rem; border-top: 1px solid #e2e8f0; }
.cp-joinrow { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .6rem 0; }
.cp-joinrow input { font: inherit; min-height: 38px; width: 8rem; padding: .2rem .6rem; border: 1px solid #94a3b8; border-radius: .5rem; text-transform: uppercase; letter-spacing: .12em; }

/* ... and at the table: who is there, what they say */
.cp-players { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; padding: .3rem .6rem; background: #111827; font-size: .82rem; }
.cp-player { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem .1rem .35rem; border-radius: 999px; background: #1f2937; border: 1px solid var(--pc); }
.cp-player i, .cp-scores i { width: .7rem; height: .7rem; border-radius: 50%; background: var(--pc); display: inline-block; }
.cp-player.away { opacity: .45; }
.cp-code { margin-left: auto; color: #94a3b8; }
.cp-code b { color: #f8fafc; letter-spacing: .1em; }
.cp-offline { color: #fbbf24; flex-basis: 100%; }
.cp-toasts { position: absolute; top: 6.5rem; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; flex-direction: column; gap: .3rem; pointer-events: none; width: max-content; max-width: 92vw; }
.cp-toast { background: rgba(17, 24, 39, .92); color: #fff; border-left: 4px solid var(--pc); border-radius: .5rem; padding: .35rem .7rem; font-size: .9rem; box-shadow: 0 4px 16px rgba(0, 0, 0, .4); }
.cp-toast b { color: var(--pc); }
.cp-reactbar { display: flex; flex-wrap: wrap; gap: .35rem; padding: .4rem .6rem; background: #0b1220; }
.cp-reactbar .cp-btn { min-height: 38px; }
.cp-scores { list-style: none; padding: 0; margin: .4rem 0 .8rem; text-align: left; display: grid; gap: .25rem; }
.cp-scores li { display: flex; align-items: center; gap: .4rem; }
.cp-scores .cp-sub { font-size: .78rem; }
@media (max-width: 480px) { .cp-code { margin-left: 0; } .cp-toasts { top: 8rem; } }
