.g-page { max-width: 880px; }
.modes { margin-bottom: 8px; }
.hint { min-height: 1.5em; margin: 0 0 8px; color: var(--muted); font-weight: 700; line-height: 1.45; }
.stage { position: relative; width: min(100%, calc(64vh * 4 / 3)); margin: 0 auto; line-height: 0; }
.stage canvas { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; touch-action: none; cursor: crosshair; border-radius: 20px; border: 2px solid var(--line-strong); box-shadow: var(--shadow); background: #fff; }
/* the flipbook looks like a little book: a binding down the left, and a stack of page edges (set in game.js) */
.stage.book { width: min(calc(100% - 44px), calc(64vh * 4 / 3)); margin: 0 16px 26px auto; }
@media (min-width: 700px) { .stage.book { margin: 0 auto 26px; } }
.stage.book canvas { border-radius: 4px 12px 12px 4px; border-color: #b9b19c; }
.stage.book::before { content: ""; position: absolute; z-index: 1; left: -26px; top: 0; bottom: 0; width: 28px; border-radius: 8px 2px 2px 8px; pointer-events: none;
  background: radial-gradient(circle at 10px 50%, #1c2238 0 4px, transparent 4.5px) 0 0 / 28px 34px repeat-y, linear-gradient(90deg, #8a5a2b, #b9824a 45%, #7a4d22); box-shadow: 2px 0 6px rgba(0, 0, 0, 0.3); }
.stage.book::after { content: ""; position: absolute; z-index: 2; left: -17px; top: 0; bottom: 0; width: 26px; pointer-events: none;
  background: radial-gradient(ellipse 13px 5px at 50% 50%, transparent 0 55%, #d8dbe6 58% 78%, transparent 82%) 0 0 / 26px 34px repeat-y; }
.stage.book.playing canvas { cursor: grab; }
.thumbrow { display: flex; align-items: center; gap: 12px; margin: 4px 0 0; font-weight: 700; color: var(--muted); }
.thumbrow[hidden] { display: none; }
.thumbrow input { flex: 1; height: 34px; accent-color: var(--gold-deep); }
.stage.pick canvas { cursor: grab; }
.stage.playing canvas { cursor: default; }
/* full screen while it plays: the picture as big as the screen allows, on black, with Stop and Exit in the corner */
body.fullview { overflow: hidden; }
.stage.full, .stage.full.book { position: fixed; inset: 0; z-index: 1000; width: auto; margin: 0; background: #000; display: flex; align-items: center; justify-content: center; }
.stage.full canvas { width: min(100vw, calc(100dvh * 4 / 3)); border: 0; border-radius: 0; box-shadow: none; }
.stage.full::before, .stage.full::after { display: none; }
.fullbar { position: absolute; z-index: 3; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); left: max(10px, env(safe-area-inset-left)); display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; line-height: normal; pointer-events: none; }
.fullbar[hidden] { display: none; }
.fullbar .g-btn { pointer-events: auto; background: rgba(20, 20, 30, 0.72); color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.fullbar .turnhint { display: none; color: rgba(255, 255, 255, 0.8); font-size: 0.9rem; margin-right: auto; }
@media (orientation: portrait) and (max-width: 700px) { .fullbar .turnhint { display: inline; } }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; }
.row.left { justify-content: flex-start; }
.row.main { margin: 12px 0; }
.row.main .g-btn { font-size: 1.05rem; padding: 12px 20px; }
.g-panel { display: grid; gap: 12px; margin-bottom: 12px; }
.g-panel[hidden] { display: none; }
.opt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.lbl { min-width: 84px; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.palette { gap: 8px; }
.sw { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--line-strong); cursor: pointer; padding: 0; touch-action: manipulation; }
.sw[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft), 0 0 0 5px var(--gold); transform: scale(1.08); }
.sz { display: inline-grid; place-items: center; min-width: 46px; }
.sz i { display: block; border-radius: 50%; background: currentColor; }
.tick { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tick input { width: 20px; height: 20px; accent-color: var(--gold-deep); }
.note { min-height: 1.4em; margin: 4px 0 0; text-align: center; color: var(--muted); font-weight: 700; }
.strip { position: relative; display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 4px; scrollbar-width: thin; }
.strip[hidden] { display: none; }
.fr { position: relative; flex: none; width: 84px; padding: 0; border-radius: 12px; border: 3px solid var(--line-strong); background: #fff; cursor: pointer; overflow: hidden; line-height: 0; }
.fr canvas { width: 100%; height: auto; display: block; }
.fr span { position: absolute; left: 4px; top: 4px; min-width: 20px; padding: 2px 5px; border-radius: 8px; font: 800 0.72rem/1.2 var(--font); color: #fff; background: rgba(20, 24, 40, 0.7); text-align: center; }
.fr[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.rules { margin-top: 18px; color: var(--muted); }
.rules li { margin: 4px 0; line-height: 1.5; }
@media (max-width: 520px) { .lbl { min-width: 0; width: 100%; } .sw { width: 34px; height: 34px; } .row.main .g-btn { flex: 1 1 auto; padding: 11px 12px; font-size: 0.98rem; } }
.note .g-btn { margin-left: 6px; padding: 6px 12px; }
.tunesel { font: 700 1rem var(--font); color: var(--ink); background: var(--surface-2); border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 9px 12px; max-width: 100%; }
/* background picker: small pictures in a grid */
.g-chips.bggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; padding: 8px; border-radius: 18px; width: 100%; max-height: 236px; overflow-y: auto; }
.bgsw { display: grid; gap: 3px; justify-items: center; padding: 4px 4px 5px; border-radius: 12px; border: 2px solid transparent; font-size: 0.72rem; font-weight: 700; line-height: 1.15; text-align: center; }
.bgsw canvas { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 8px; display: block; box-shadow: 0 0 0 1px var(--line-strong); }
.bgsw[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); box-shadow: none; }
/* shapes and stickers */
.shp { min-width: 46px; font-size: 1.25rem; line-height: 1; }
#stickRow { display: grid; gap: 10px; }
#stickRow[hidden] { display: none; }
.stickgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; max-height: 168px; overflow-y: auto; padding: 6px; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-edge); }
.stk { height: 48px; padding: 0; border-radius: 12px; border: 2px solid transparent; background: none; font-size: 1.7rem; line-height: 1; cursor: pointer; touch-action: manipulation; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.stk:hover { background: var(--glass-soft); }
.stk[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); }
.stk:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.palette[hidden] { display: none; }
@media (max-width: 520px) {
  #stickSets { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  #stickSets .g-chip { flex: none; }
  .stickgrid { max-height: 132px; }
  #tools .g-chip { padding: 6px 11px; }
}
/* hand-drawn people */
#toneRows { display: grid; gap: 8px; }
#toneRows[hidden] { display: none; }
#toneRows .lbl { min-width: 44px; }
#toneRows .palette { justify-content: flex-start; }
.stickgrid.people { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); max-height: 196px; }
.stk.person { height: auto; padding: 2px; background: #fffdf6; }
.stk.person canvas { width: 100%; height: auto; display: block; }
.stk.person[aria-pressed="true"] { background: #fff1c8; }
.sw.mixed { background: conic-gradient(#1f1b1a 0 17%, #4a2f1d 0 33%, #8b5a2b 0 50%, #e2b653 0 67%, #c0562a 0 83%, #b9bcc2 0); }
/* nothing in a panel may push it wider than the screen */
.g-panel > *, #stickRow > *, .row > .g-chips { min-width: 0; max-width: 100%; }
#toneRows .sw { width: 30px; height: 30px; border-width: 2px; }
#toneRows .palette { gap: 6px; }
.sw.mixed.own { background: conic-gradient(#e5484d 0 17%, #f5a623 0 33%, #f5d90a 0 50%, #2fb36d 0 67%, #3b82f6 0 83%, #8a5ce0 0); }
@media (max-width: 520px) { #toneRows .sw { width: 25px; height: 25px; } #toneRows .palette { gap: 5px; flex-wrap: nowrap; } }
@media (max-width: 359px) { #toneRows .palette { flex-wrap: wrap; } } /* the smallest phones: the swatches go onto two lines rather than off the edge */
/* the Joints tool */
#jointRow { display: grid; gap: 10px; }
#jAdd[aria-pressed="true"], #jBend[aria-pressed="true"], #joinThing[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); }
/* the Text tool */
#textRow { display: grid; gap: 10px; }
#textIn { flex: 1 1 260px; min-width: 0; max-width: 520px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line, #3a3f5c); background: #fffdf6; color: #1f2430; font: 700 18px var(--font, sans-serif); resize: vertical; }
#textIn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
/* the background picker: tabs, then the tiles of the open tab */
.bgpick { flex: 1 1 100%; min-width: 0; display: grid; gap: 8px; }
.bgtabs .g-chip { position: relative; }
.bgtabs .g-chip.has::after { content: ""; position: absolute; top: 5px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
