/* Calm Games · base: layout + the --g-* contract defaults (regular pack) + vars the vendored atlas needs. */
:root {
  --g-bg: #f3f2ef; --g-panel: #fff; --g-ink: #1d2226; --g-ink-2: #5e6b73; --g-accent: #d9480f; --g-accent-2: #2b5a86;
  --g-line: #1d2226; --g-line-w: 1.5; --g-grid: rgba(0,0,0,.08); --g-halo: #fff; --g-radius: 12px;
  --g-shadow: 0 1px 2px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
  --g-font: 15px/1.45 -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --g-font-display: 700 22px/1.2 -apple-system, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --g-texture: none;
  /* atlas.css reads these */
  --sans: -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif; --serif: "IBM Plex Serif", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --text: var(--g-ink); --bg: var(--g-bg); --bg2: var(--g-panel); --panel: var(--g-panel); --line: var(--g-grid);
  --muted: var(--g-ink-2); --ink: var(--g-ink); --accent: var(--g-accent); --card: var(--g-panel);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--g-bg); color: var(--g-ink); font: var(--g-font); background-image: var(--g-texture);
  -webkit-font-smoothing: antialiased; transition: background .25s ease, color .25s ease; }
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font: var(--g-font-display); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }

/* ── lobby (linkedin.com/games layout) ─────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 8px; }
.brand { font: var(--g-font-display); font-size: 24px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 28px; height: 28px; border-radius: 7px; background: var(--g-accent); display: inline-block; }
.styles-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.styles-bar .sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer;
  background: conic-gradient(var(--sw1) 0 50%, var(--sw2) 50% 80%, var(--sw3) 80% 100%); box-shadow: 0 0 0 1px rgba(0,0,0,.15) inset; }
.styles-bar .sw.on { border-color: var(--g-ink); }
.styles-bar .sw.home { background: var(--g-panel); position: relative; }
.styles-bar .sw.home::after { content: "⌂"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; }
.styles-bar a { font-size: 13px; color: var(--g-ink-2); text-decoration: none; margin-left: 6px; }
.lead { padding: 26px 0 12px; }
.lead h2 { font-size: 26px; }
.lead p { margin: 4px 0 0; color: var(--g-ink-2); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding: 12px 0 40px; }
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; gap: 14px; } }
.gcard { display: grid; grid-template-columns: 1fr 136px; min-height: 148px; background: var(--g-panel); border-radius: var(--g-radius);
  box-shadow: var(--g-shadow); overflow: hidden; text-decoration: none; color: inherit; position: relative;
  transition: transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s ease; }
.gcard .meta { padding: 22px 20px 18px; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; }
.gcard .played { font-size: 13px; color: var(--g-ink-2); display: flex; align-items: center; gap: 6px; }
.gcard .played .dots { display: inline-flex; }
.gcard .played .dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--g-accent-2); opacity: .55; margin-right: -4px; border: 2px solid var(--g-panel); }
.gcard h3 { font-size: 22px; line-height: 1.15; }
.gcard h3 .num { font-weight: 500; color: var(--g-ink-2); margin-left: .3em; }
.gcard .tag { font-size: 12.5px; color: var(--g-ink-2); }
.gcard .thumb { position: relative; background: var(--g-panel); overflow: hidden; }
.gcard .thumb canvas, .gcard .thumb .mount { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.gcard .thumb .atlas { position: absolute; inset: 0; border-radius: 0; }
.done-today { margin: 8px 0 24px; padding: 18px 20px; border-radius: var(--g-radius); background: var(--g-panel); box-shadow: var(--g-shadow); }
.done-today h3 { font-size: 20px; }
.done-today p { margin: 4px 0 0; color: var(--g-ink-2); }
.foot { padding: 10px 0 40px; font-size: 12.5px; color: var(--g-ink-2); }

/* ── game screen ───────────────────────────────────────────────────── */
body.game { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.gbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; flex: 0 0 auto; }
.gbar .l, .gbar .r { display: flex; align-items: center; gap: 12px; min-width: 0; }
.gbar .back { text-decoration: none; color: var(--g-ink-2); font-size: 14px; }
.gbar h1 { font-size: 20px; white-space: nowrap; }
.gbar h1 .num { font-weight: 500; color: var(--g-ink-2); margin-left: .3em; }
.gbar .hint { font-size: 12.5px; color: var(--g-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gbar .hint kbd { font: 11.5px var(--mono); padding: 1px 5px; border: 1px solid var(--g-grid); border-radius: 4px; background: var(--g-panel); color: var(--g-ink); }
.btn { border: 1px solid var(--g-grid); background: var(--g-panel); color: var(--g-ink); border-radius: var(--r-btn, 4px); padding: 7px 14px; cursor: pointer; font-size: 14px;
  transition: transform .12s cubic-bezier(.34,1.56,.64,1), background .15s; }
.btn.primary { background: var(--g-accent); color: var(--g-halo); border-color: var(--g-accent); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--g-ink-2); }
/* the end card and the after-round card focus their main button for Enter and screen readers; the ring shows only once Tab is used (html.tabbing, engine/game.js) */
:root:not(.tabbing) .end .btn:focus-visible, :root:not(.tabbing) .card .btn:focus-visible { outline: none; }
.stagewrap { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 1fr; place-items: center; padding: 6px 12px 12px; position: relative; }
.stage { position: relative; width: min(100%, 860px); height: 100%; max-height: 100%; border-radius: var(--g-radius); overflow: hidden; outline: none;
  background: var(--g-panel); box-shadow: var(--g-shadow); touch-action: none; user-select: none; -webkit-user-select: none; }
.stage.is-hug { height: auto; aspect-ratio: var(--stage-ar, .8); max-height: 100%; }
.stage .world { position: absolute; inset: 0; will-change: transform; }
.stage .g-canvas { display: block; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.stage .g-canvas.is-pixel { image-rendering: pixelated; image-rendering: crisp-edges; }
.hud { position: absolute; left: 12px; top: 10px; display: flex; gap: 10px; font-size: 13px; color: var(--g-ink-2); pointer-events: none; z-index: 2; }
.hud b { color: var(--g-ink); font-weight: 600; }
.hud .pill { background: color-mix(in srgb, var(--g-panel) 80%, transparent); border-radius: var(--r-btn, 4px); padding: 3px 10px; backdrop-filter: blur(4px); }
/* small-eyed faces read tiny at 13px: VT323 (pixel, terminal), Caveat (chalk), Patrick Hand (xkcd) */
[data-style="pixel"] .hud, [data-style="terminal"] .hud { font-size: 19px; line-height: 1; }
[data-style="chalk"] .hud, [data-style="xkcd"] .hud { font-size: 16px; }
.toast { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 14px; color: var(--g-ink); background: var(--g-panel);
  border-radius: var(--r-btn, 4px); padding: 6px 14px; box-shadow: var(--g-shadow); opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 2; }
.toast.on { opacity: 1; }
.toast.at-top { top: 46px; bottom: auto; } /* env.toast(msg, ms, {at: "top"}): under the HUD row, clear of a game's foot controls */
.toast.coach { max-width: calc(100% - 24px); text-align: center; white-space: normal; z-index: 3; }
/* HUD pills that carry a tip or a tap (hudSet [{tip, onTap}]) take the pointer; plain pills stay see-through */
.hud .pill.is-live { pointer-events: auto; }
.hud .pill.is-tap { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .hud .pill.is-tap:hover { color: var(--g-ink); background: var(--g-panel); } }
/* the page's undo on phones: a bottom slot within thumb reach (game-boot.js moves #undo here) */
.gfoot { flex: 0 0 auto; display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 0 10px max(8px, env(safe-area-inset-bottom)); }
.gfoot .icon-btn { width: auto; min-width: 44px; height: 44px; padding: 0 14px; gap: 6px; display: inline-flex; align-items: center;
  border: 1px solid var(--hair, var(--g-grid)); background: var(--g-panel); color: var(--g-ink); font-size: 14px; }
.gfoot .icon-btn .lbl { font-weight: 500; }
/* game.html could not start (boot-guard.js): one card over the stage */
.overlay.boot-fail { z-index: 20; }
.overlay.boot-fail .end { text-align: left; }

/* on-screen pad (phones) */
.pad { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 14px 14px; user-select: none; -webkit-user-select: none; touch-action: none; }
.pad[hidden] { display: none; }
.pad-dirs { display: grid; grid-template-columns: 48px 48px 48px; grid-template-rows: 48px 48px; grid-template-areas: ". up ." "left down right"; gap: 6px; }
.pad-dirs .pk:nth-child(1) { grid-area: up; } .pad-dirs .pk:nth-child(2) { grid-area: left; } .pad-dirs .pk:nth-child(3) { grid-area: down; } .pad-dirs .pk:nth-child(4) { grid-area: right; }
.pad-acts { display: flex; align-items: center; gap: 10px; }
.pk { width: 48px; height: 48px; border-radius: var(--r-card, 6px); border: 1px solid var(--g-grid); background: var(--g-panel); color: var(--g-ink); font-size: 18px; cursor: pointer; box-shadow: var(--g-shadow); transition: transform .08s; }
/* the action key is a ring, not a lit disc: the game's own light stays the brightest thing on screen; it fills only while pressed */
.pk.act { width: 64px; height: 64px; border-radius: 50%; background: color-mix(in srgb, var(--g-accent) 12%, var(--g-panel)); color: var(--g-accent); border: 2px solid color-mix(in srgb, var(--g-accent) 65%, transparent); font-size: 20px; box-shadow: none; }
.pk.sm { width: 40px; height: 40px; font-size: 16px; }
.pk.on, .pk:active { transform: scale(.92); filter: brightness(1.08); }
.pk.act.on, .pk.act:active { background: var(--g-accent); color: var(--g-halo); }
@media (max-width: 640px) {
  .gbar { padding: 8px 12px; }
  .gbar h1 { font-size: 17px; }
  .gbar .hint { display: none; }
  .gbar .pad-hint { display: inline; }
  .gbar .btn { padding: 5px 10px; font-size: 13px; }
  .stagewrap { padding: 4px 8px 8px; place-items: start center; } /* phones: the board starts under the bar, the spare room collects at the bottom */
}

/* end overlay + after-round card */
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 5;
  background: color-mix(in srgb, var(--g-bg) 60%, transparent); backdrop-filter: blur(6px); animation: ov-in .25s ease-out; }
@keyframes ov-in { from { opacity: 0; } to { opacity: 1; } }
/* round-done panel: sits low and clear, so the game's payoff (bloom, doodle, kiln…) stays readable above it */
.overlay.is-end { place-items: end center; padding-bottom: 14px; backdrop-filter: none;
  background: linear-gradient(to top, color-mix(in srgb, var(--g-bg) 72%, transparent) 0%, color-mix(in srgb, var(--g-bg) 30%, transparent) 38%, transparent 62%); }
.overlay.is-end.is-top { place-items: start center; padding: 54px 16px 0;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--g-bg) 72%, transparent) 0%, color-mix(in srgb, var(--g-bg) 30%, transparent) 38%, transparent 62%); }
.overlay.is-end.no-veil { background: none; }
.overlay.is-end.keep-input { pointer-events: none; } /* onEnd({keepInput}): the board under the card stays playable */
.overlay.is-end.keep-input .end { pointer-events: auto; }
.overlay.is-end.is-chosen .end .row .btn { pointer-events: none; opacity: .62; } /* a choice is made: the card or the next page is on its way */
.end .end-stars { display: flex; gap: 4px; font-size: 26px; margin: 2px 0 6px; } /* onEnd({veil:false}): a saturated scene (Glade at dusk) stays as it is around the card */
@media (max-width: 640px) { .overlay.is-end .end { padding: 14px 16px 12px; } .overlay.is-end .end h2 { font-size: 20px; }
  .overlay.is-end .end .score { font-size: 30px; margin: 4px 0 6px; } .overlay.is-end .end .row { margin-top: 6px; }
  /* compact on phone: title and number share the first row, so the finished picture keeps ~40px more */
  .overlay.is-end .end { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: baseline; }
  .overlay.is-end .end h2 { grid-column: 1; grid-row: 1; }
  .overlay.is-end .end .score { grid-column: 2; grid-row: 1; margin: 0; white-space: nowrap; }
  .overlay.is-end .end .line, .overlay.is-end .end .row, .overlay.is-end .end .end-stars { grid-column: 1 / -1; }
  .overlay.is-end .end .end-stars { font-size: 22px; margin: 4px 0 0; } }
.end, .card { width: min(100%, 460px); max-height: calc(100dvh - 32px); overflow: auto; -webkit-overflow-scrolling: touch; background: var(--g-panel); color: var(--g-ink); border-radius: var(--r-card, 6px); box-shadow: var(--g-shadow);
  padding: 22px 22px 18px; animation: card-in .35s cubic-bezier(.34,1.56,.64,1); }
@keyframes card-in { from { transform: translateY(14px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.end h2 { font-size: 24px; }
.end .line { margin: 6px 0 2px; color: var(--g-ink-2); }
.end .score { font: var(--g-font-display); font-size: 40px; margin: 8px 0 10px; letter-spacing: -.02em; }
.end .score .d { display: inline-block; animation: roll .4s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes roll { from { transform: translateY(.6em); opacity: 0; } to { transform: none; opacity: 1; } }
.end .row, .card .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.card .chip { display: inline-block; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--g-ink-2); margin-bottom: 6px; }
.card .chip b { color: var(--g-accent); font-weight: 600; }
.card h2 { font-size: 20px; line-height: 1.25; }
.card .why { margin: 8px 0 0; color: var(--g-ink-2); }
.card blockquote { margin: 10px 0 0; padding: 6px 12px; border-left: 3px solid var(--g-accent); color: var(--g-ink); font-style: italic; }
.card .next { margin: 10px 0 0; font-size: 14px; }
.card .next b { font-weight: 600; }
.card details { margin: 10px 0 0; font-size: 13px; color: var(--g-ink-2); }
.card details summary { cursor: pointer; }
.card details ul { margin: 6px 0 0; padding-left: 18px; }
.card .opts { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.card .opt { display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--g-grid); background: transparent; border-radius: var(--r-btn, 4px);
  padding: 8px 10px; cursor: pointer; transition: border-color .12s, background .12s, transform .12s cubic-bezier(.34,1.56,.64,1); }
.card .opt kbd { font: 12px var(--mono); border: 1px solid var(--g-grid); border-radius: 5px; padding: 1px 6px; color: var(--g-ink-2); }
.card .opt.on { border-color: var(--g-accent); background: color-mix(in srgb, var(--g-accent) 10%, transparent); transform: translateX(2px); }
.card .opt .d { font-size: 12.5px; color: var(--g-ink-2); }
.card details .opt-d { margin: 4px 0 0; padding-left: 0; list-style: none; }
.card details .opt-d li { margin: 2px 0; }
.card .comment { margin-top: 10px; width: 100%; border: 1px solid var(--g-grid); border-radius: var(--r-btn, 4px); padding: 9px 12px; font: inherit;
  background: transparent; color: var(--g-ink); }
.card .comment:focus { outline: 2px solid var(--g-accent); border-color: transparent; }
.card .keys { font-size: 12px; color: var(--g-ink-2); margin-left: auto; }
.card .keys kbd { font: 11px var(--mono); border: 1px solid var(--g-grid); border-radius: 4px; padding: 0 4px; }
.card .status { font-size: 12.5px; color: var(--g-ink-2); min-height: 1.2em; margin-top: 8px; }
.card .art { position: relative; margin: 8px -22px 0; background: #000; aspect-ratio: 4/5; max-height: 56vh; overflow: hidden; }
.card .art img, .card .art video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card .credit { font-size: 12px; color: var(--g-ink-2); margin-top: 10px; }
.card .credit a { color: inherit; text-decoration: none; border-bottom: 1px solid color-mix(in srgb, currentColor 30%, transparent); }
.card .credit a:hover { color: var(--g-ink); }
.card.is-art { width: min(560px, 94vw); }
.card .art.still { aspect-ratio: 4/5; max-height: 64vh; max-width: calc(100% + 44px); margin-inline: -22px; }
.card .art.still img.kb { object-fit: cover; opacity: 0; transform: scale(1.06); transition: opacity 600ms cubic-bezier(.2,.7,.2,1), transform 900ms cubic-bezier(.2,.7,.2,1); will-change: transform, opacity; }
.card .art.still.in img.kb { opacity: 1; transform: scale(1.02); animation: cg-kenburns 18s ease-in-out 900ms infinite alternate; }
.card .art.still.missing::after { content: "Image unavailable"; position: absolute; inset: 0; display: grid; place-items: center; color: #aaa; font-size: 13px; }
@keyframes cg-kenburns { from { transform: scale(1.02) translate3d(0, 0, 0); } to { transform: scale(1.12) translate3d(-2.5%, -2%, 0); } }
@media (prefers-reduced-motion: reduce) {
  .card .art.still img.kb { transition: opacity 300ms linear; transform: none; }
  .card .art.still.in img.kb { animation: none; transform: none; }
}
/* phone: the card takes the whole screen, above the touch pad, so the story is not squeezed into the game box */
@media (max-width: 760px) { .overlay.card-ov { position: fixed; z-index: 60; padding: 12px; } .card.is-item { max-height: calc(100dvh - 24px); } }
/* question card, narrative order: story → stakes → ask → options (each says what happens next) */
.card.is-item { width: min(100%, 520px); }
.card .story { margin: 4px 0 0; font-size: 15.5px; line-height: 1.55; color: var(--g-ink); max-width: 62ch; text-wrap: pretty; }
.card .stakes { margin: 12px 0 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--g-accent); font-size: 14.5px; line-height: 1.5; color: var(--g-ink-2); text-wrap: pretty; }
.card h2.ask { margin-top: 16px; font-size: 19px; line-height: 1.3; text-wrap: balance; }
.card .opt { align-items: flex-start; padding: 10px 12px; }
.card .opt kbd { margin-top: 1px; }
.card .opt .ol { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.card .opt .ol b { font-weight: 600; font-size: 15px; line-height: 1.3; }
.card .opt .ol small { font-size: 13px; line-height: 1.4; color: var(--g-ink-2); }
.card .opt .star { color: var(--g-accent); font-size: 14px; line-height: 1.3; }
.card details.proof { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--g-grid); }
.card details.proof p { margin: 6px 0 0; }
.card.is-item > * { animation: cg-rise .36s cubic-bezier(.2,.7,.2,1) both; }
.card.is-item > :nth-child(2) { animation-delay: 60ms; } .card.is-item > :nth-child(3) { animation-delay: 140ms; }
.card.is-item > :nth-child(4) { animation-delay: 220ms; } .card.is-item > :nth-child(n+5) { animation-delay: 300ms; }
@keyframes cg-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .card.is-item > * { animation: none; } }
.card a.open { font-size: 13px; color: var(--g-ink-2); }

/* ── styles gallery ────────────────────────────────────────────────── */
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 22px; padding: 10px 0 40px; }
.lab { border-radius: var(--r-card, 6px); overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.1), 0 10px 30px rgba(0,0,0,.08); background: var(--g-bg); color: var(--g-ink);
  background-image: var(--g-texture); font: var(--g-font); }
.lab .mini { padding: 14px 14px 12px; }
.lab .mini .topbar { padding: 0 0 6px; }
.lab .mini .brand { font-size: 18px; }
.lab .mini .grid { grid-template-columns: 1fr 1fr; gap: 10px; padding: 6px 0 0; }
.lab .mini .gcard { min-height: 92px; grid-template-columns: 1fr 78px; }
.lab .mini .gcard .meta { padding: 12px 12px 10px; }
.lab .mini .gcard h3 { font-size: 15px; }
.lab .mini .gcard .played { font-size: 11px; }
.lab .mini .gcard .played .dots i { width: 10px; height: 10px; }
.lab .foot-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 12px; border-top: 1px solid var(--g-grid); }
.lab .foot-row b { font: var(--g-font-display); font-size: 17px; }
.lab .foot-row small { color: var(--g-ink-2); display: block; font-size: 12.5px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}
