/* foldedline.com/play: the web trial. Loaded only on /play, on top of site.css (same tokens). */

/* The board is the hero: its size follows the viewport height so the board AND the tools fit in the first screen
   (compact header 60 + top 12 + stage bar 58 + message 44 + tools 56 + breathing 20 = 250 px of chrome). */
.play { --board-size: min(100%, 600px, max(320px, calc(100svh - 250px))); padding-block: 12px var(--section); }
.play-layout {
  display: grid; gap: 14px clamp(40px, 5vw, 72px);
  grid-template-areas: "intro" "stage" "modes" "panel" "note";
  align-items: start;
}
.play-intro { grid-area: intro; display: grid; gap: 2px; }
.play-intro h1 { font-size: clamp(1.5rem, 1.25rem + .9vw, 1.875rem); font-weight: 900; line-height: 1.1; letter-spacing: -.02em; text-wrap: balance; }
.play-intro p { font-size: var(--step--1); font-weight: 700; }
.modes { grid-area: modes; margin-top: 18px; }
.stage { grid-area: stage; width: var(--board-size); justify-self: center; scroll-margin-top: 8px; }
.chapter-panel { grid-area: panel; }
.storage-note { grid-area: note; max-width: 56ch; }

@media (min-width: 1000px) {
  .play-layout {
    --board-size: min(600px, calc(100vw - 21.5rem - 2 * var(--gutter) - 56px), max(360px, calc(100svh - 250px)));
    grid-template-columns: 21.5rem var(--board-size); justify-content: center;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas: "intro stage" "modes stage" "panel stage" "note stage";
  }
  .play-intro { padding-top: 6px; }
  .modes { margin-top: 4px; }
}

/* Compact header on /play: the puzzle gets the height. */
.site-header--compact .wrap { min-height: 60px; }
.site-header--compact .brand { font-size: 1.125rem; }
.site-header--compact .brand .mark { width: 32px; height: 32px; }
.site-header--compact .nav a { padding-block: 8px; }
.site-header--compact .icon-btn { width: 42px; min-height: 42px; }

/* ---------- Mode switch: two paper tiles on a tray ---------- */
.modes { display: inline-flex; gap: 4px; padding: 4px; border-radius: 20px; background: var(--band); justify-self: start; max-width: 100%; }
.mode {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 16px;
  color: var(--muted); font-weight: 800; text-decoration: none; white-space: nowrap;
}
.mode:hover { color: var(--ink); }
.mode[aria-current] { background: var(--tile); color: var(--ink); box-shadow: 0 3px 0 var(--tile-lip); }
:root[data-play-mode="tutorial"] .mode { color: var(--muted); }

/* ---------- Stage ---------- */
.stage-bar { display: flex; align-items: center; gap: 12px; min-height: 48px; margin-bottom: 10px; }
.stage-heading { flex: 1; min-width: 0; }
.stage-title { font-size: var(--step-2); font-weight: 900; letter-spacing: -.012em; line-height: 1.15; text-wrap: balance; }
.stage-heading .small { margin-top: 2px; }
.beat-tag { flex: none; padding: 4px 12px; border-radius: 99px; border: 2px solid color-mix(in srgb, var(--line) 60%, transparent); color: var(--link); font-size: var(--step--1); font-weight: 850; }
.btn--small { min-height: 44px; padding: 0 16px; font-size: .9375rem; border-radius: 14px; box-shadow: 0 3px 0 var(--lip); }

.board-wrap { position: relative; border-radius: calc(3400% / (var(--n, 6) * 100 + 32)); box-shadow: 0 18px 36px -16px rgba(60, 38, 16, .38); }
:root[data-theme="dark"] .board-wrap { box-shadow: 0 24px 44px -18px rgba(0, 0, 0, .7); }
.play-board {
  display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: calc(3400% / (var(--n, 6) * 100 + 32));
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.play-board:focus-visible { outline: 3px solid var(--line); outline-offset: 5px; }
.noscript { padding: 24px; text-align: center; }

/* Board pieces (base classes come from site.css: .b-frame .b-cell .b-lip .b-line .pip) */
.play-board .b-cell { transition: fill .18s ease; }
.play-board .b-cell.is-on { fill: color-mix(in srgb, var(--tile) 86%, var(--line)); }
.play-board .b-cell.is-hover { fill: color-mix(in srgb, var(--tile) 84%, var(--line)); }
.play-board .b-cell.is-flash { fill: color-mix(in srgb, var(--tile) 62%, var(--glow)); }
.play-board .b-cell.is-pulse { animation: cell-pulse 1.4s ease-in-out infinite; }
@keyframes cell-pulse { 0%, 100% { fill: var(--tile); } 50% { fill: color-mix(in srgb, var(--tile) 70%, var(--copper)); } }
.play-board .b-glow { filter: url(#ember-play); opacity: 0; transition: opacity .9s ease .1s; }
.play-board.is-won .b-glow { opacity: var(--glow-max); }
.play-board .b-reach { stroke: var(--line); stroke-width: 34; stroke-linecap: round; opacity: .38; }
.play-board .b-cursor { fill: var(--line); opacity: .2; }
.play-board.is-drawing .b-cursor { opacity: .3; }
.play-board .pip .pip-ring { opacity: 0; transition: opacity .2s ease; }
.play-board .pip.is-next .pip-ring { opacity: 1; }
/* Solved: like the app's Daily, the line turns amber and glows; the discs stay as they are. */
.play-board .b-line { transition: stroke .6s ease; }
.play-board.is-won .b-line { stroke: var(--line-lit); }
.play-board.is-won .pip .pip-ring { opacity: 0; }
.play-board .pip text { pointer-events: none; }

.msg { min-height: 1.6em; margin: 10px 0 8px; text-align: center; font-weight: 750; color: var(--muted); text-wrap: balance; }

/* ---------- Tools ---------- */
.tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tool { min-height: 50px; padding: 0 14px; gap: 7px; font-size: 1rem; }
.tool .t-icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.tool .snd-off { display: none; }
.tool.is-off .snd-on { display: none; }
.tool.is-off .snd-off { display: block; }
.tool.is-off { color: var(--muted); }
.tool:disabled { opacity: .42; cursor: default; box-shadow: 0 4px 0 var(--lip); transform: none; filter: none; }
.tool.is-nudge { box-shadow: 0 4px 0 var(--lip), 0 0 0 3px color-mix(in srgb, var(--line) 55%, transparent); }
.tool--wide { flex-basis: 100%; max-width: 280px; }
@media (max-width: 520px) {
  .tray { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .tool { flex-direction: column; gap: 3px; min-height: 64px; padding: 6px 4px; font-size: .8125rem; border-radius: 16px; }
  .tool--wide { grid-column: 1 / -1; max-width: none; flex-direction: row; min-height: 52px; font-size: .9375rem; }
}

/* ---------- Results ---------- */
.result { margin-top: 18px; padding: 22px 24px 24px; border-left: 4px solid var(--line); background: var(--raised); border-radius: 0 24px 24px 0; }
.result-title { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.75rem); font-weight: 900; letter-spacing: -.025em; line-height: 1; margin-bottom: 10px; }
.result-title:focus { outline: none; }
.result-line { font-size: var(--step-1); font-weight: 800; }
.result p + p { margin-top: 6px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px 14px; margin-top: 20px; }
.share-preview { margin-top: 14px !important; overflow-wrap: anywhere; }
.install-line { margin-top: 18px !important; padding-top: 16px; border-top: 2px solid var(--rule); font-weight: 750; max-width: 52ch; }

/* ---------- Chapter lit card ---------- */
.lit-card { position: relative; margin-top: 18px; padding: clamp(24px, 4vw, 36px); background: var(--raised); border-radius: 28px; box-shadow: var(--shadow); overflow: hidden; }
.lit-card::before { content: ""; position: absolute; inset: -40% -10% auto auto; width: 60%; height: 90%; background: radial-gradient(closest-side, color-mix(in srgb, var(--glow) 38%, transparent), transparent); opacity: var(--glow-max); pointer-events: none; }
.lit-body { position: relative; display: grid; gap: 24px; }
.lit-title { font-size: clamp(2rem, 1.5rem + 2vw, 2.875rem); font-weight: 900; letter-spacing: -.025em; line-height: 1.02; padding-right: 48px; }
.lit-title:focus { outline: none; }
.lit-next { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 18px; align-items: center; margin-top: 18px; }
.lit-next .lead { max-width: 30ch; }
.lit-board { width: 96px; }
.lit-copy .store-slot { margin-top: 24px; }
.lit-close { position: absolute; top: 16px; right: 16px; z-index: 2; }
.lit-close svg { width: 20px; height: 20px; }
.lit-side { display: none; }
.lit-qr { width: 152px; margin: 0; }
.lit-qr .qr { width: 152px; height: 152px; border-radius: 14px; box-shadow: 0 0 0 1px var(--rule); }
.lit-qr .qr-plate { fill: #FFF8EC; }
.lit-qr .qr-ink { fill: #2A211C; }
.lit-qr figcaption { margin-top: 10px; font-size: .8125rem; }
.lit-foot { position: relative; margin-top: 22px; font-weight: 800; }
@media (min-width: 760px) and (pointer: fine) {
  .lit-body { grid-template-columns: minmax(0, 1fr) 152px; align-items: end; }
  .lit-side { display: block; }
}

/* ---------- Chapter panel: the level strip ---------- */
.chapter-panel { padding: 18px 20px 20px; background: var(--band); border-radius: 24px; }
.chapter-panel .meta { font-size: var(--step--1); font-weight: 800; color: var(--muted); }
.chapter-panel h2 { margin: 0 0 12px; }
.strip-wrap { position: relative; }
.strip-line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.strip-track { fill: none; stroke: var(--rule); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.strip-lit { fill: none; stroke: var(--line); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.strip { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 6px; justify-items: center; }
.node {
  position: relative; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  font-weight: 900; font-size: .9375rem; font-variant-numeric: tabular-nums; text-decoration: none;
  color: var(--muted); background: var(--band); box-shadow: inset 0 0 0 3px var(--rule);
}
.node.is-open { color: var(--ink); background: var(--tile); box-shadow: 0 3px 0 var(--tile-lip); }
.node.is-lit { color: var(--pip-lit-num); background: var(--pip-lit); box-shadow: 0 3px 0 color-mix(in srgb, var(--pip-lit) 60%, #000); }
.node.is-locked { cursor: not-allowed; }
.node[aria-current] { outline: 3px solid var(--line); outline-offset: 3px; }
.node.is-tag::after { content: ""; position: absolute; top: -2px; right: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--copper); box-shadow: 0 0 0 3px var(--band); }
.node:not(.is-locked):hover { filter: brightness(1.05); }
#ch-count { margin-top: 12px; }
.app-node {
  display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 12px; padding: 8px 14px; min-height: 54px;
  border: 2px dashed color-mix(in srgb, var(--muted) 55%, transparent); border-radius: 20px; background: transparent;
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.app-node:hover { background: var(--raised); }
.app-node strong { display: block; font-weight: 850; }
.app-node .small { display: block; }
.app-node-pips { display: inline-flex; gap: 5px; flex: none; }
.app-node-pips i { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 2.5px var(--copper); }
.panel-links { margin-top: 10px; }

@media (prefers-reduced-motion: reduce) {
  .play-board .b-cell, .play-board .b-glow, .play-board .b-line, .play-board .pip .pip-ring { transition: none; }
  .play-board .b-cell.is-pulse { animation: none; fill: color-mix(in srgb, var(--tile) 70%, var(--copper)); }
}

/* Level nodes are 38 px to keep the strip compact; the hit area stays 44 px. */
.node::before { content: ""; position: absolute; inset: -3px; border-radius: 50%; }
.stage-heading .small, .app-node .small, .storage-note { text-wrap: balance; }

/* ---------- Tutorial win screen (design B) and the anonymous-stats card ---------- */
/* The win screen replaces the board: one centred column (480 px on desktop), no overlay. */
.play-layout.is-win { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "stage"; justify-content: stretch; }
.play-layout.is-win > :not(.stage) { display: none; }
.play-layout.is-win .stage { width: min(100%, 480px); }
.play-layout.is-win :is(.stage-bar, .board-wrap, .msg, .tray) { display: none; }
.result--win { margin-top: 0; padding: 0; border: 0; background: none; border-radius: 0; }
.win { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 4px; }
@media (min-width: 700px) { .win { padding-top: clamp(8px, 4vh, 36px); } }
.win-tag { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; margin-bottom: 26px; padding: 5px 12px 5px 8px; border-radius: 14px;
  background: color-mix(in srgb, var(--line-lit) 20%, var(--bg)); color: var(--link); font-size: .9375rem; font-weight: 800; line-height: 1.3; }
.win-tag-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; background: radial-gradient(circle, currentColor 0 3px, transparent 3.5px); }
@media (min-width: 700px) { .win-tag { display: none; } }
.win-mark { width: 104px; height: 104px; transition: width .22s ease, height .22s ease; }
.win-mark .mark { width: 100%; height: 100%; border-radius: 23%; box-shadow: 0 0 0 1px var(--rule), var(--shadow); }
.win.is-open .win-mark { width: 64px; height: 64px; }
.result .win-title { margin: 14px 0 0; font-size: 1.9375rem; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; }
.win-line { margin-top: 8px !important; color: var(--muted); font-size: 1.03rem; font-weight: 600; line-height: 1.45; text-wrap: balance; }
.consent-slot { width: 100%; }
.win .consent-slot { margin-top: 26px; }
.win .consent-slot:empty { margin-top: 0; }
.win-go { width: 100%; min-height: 56px; margin-top: 26px; font-size: 1.1875rem; }
.win.has-consent .win-go { margin-top: 22px; }
.result:not(.result--win) .consent-slot:not(:empty) { margin-top: 18px; }

.consent { text-align: left; }
.consent-card { display: grid; gap: 12px; padding: 18px 18px 16px; background: var(--raised); border-radius: 24px; box-shadow: var(--shadow); }
.result:not(.result--win) .consent-card { background: var(--bg); }
.consent-title { margin: 0; font-size: 1.25rem; font-weight: 800; line-height: 1.25; }
.consent-body { margin: 0 !important; font-size: 1rem; font-weight: 600; line-height: 1.42; }
.consent-more { justify-self: start; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin: -8px 0 -10px; padding: 0 2px; border: 0; background: none;
  color: var(--ink); font: 800 .96875rem/1.2 var(--font); cursor: pointer; }
.consent-more span { text-decoration: underline 2px var(--rule); text-underline-offset: 7px; }
.consent-chev { width: 18px; height: 18px; flex: none; transition: transform .22s ease; }
.consent-more[aria-expanded="true"] .consent-chev { transform: rotate(180deg); }
.consent-panel { display: grid; grid-template-rows: 0fr; margin-top: -12px; visibility: hidden;
  transition: grid-template-rows .22s cubic-bezier(.2, .8, .2, 1), margin-top .22s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .22s; }
.consent.is-open .consent-panel { grid-template-rows: 1fr; margin-top: 0; visibility: visible;
  transition: grid-template-rows .22s cubic-bezier(.2, .8, .2, 1), margin-top .22s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
.consent-panel-in { min-height: 0; overflow: hidden; }
.consent-box { padding: 12px 14px; border-radius: 16px; background: color-mix(in srgb, var(--btn2) 55%, var(--raised)); }
.result:not(.result--win) .consent-box { background: var(--raised); }
.consent-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.consent-list li { position: relative; padding-left: 20px; font-size: .9375rem; font-weight: 700; line-height: 1.3; }
.consent-list li::before { content: ""; position: absolute; left: 4px; top: .5em; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.consent-never { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 0 !important; padding-top: 10px; border-top: 1.5px solid var(--rule);
  color: var(--muted); font-size: .9375rem; font-weight: 700; line-height: 1.3; }
.consent-never svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.consent-policy { margin: 8px 0 0 !important; font-size: .875rem; font-weight: 700; }
.consent-policy a { color: var(--link); }
/* Two identical buttons: one component, one grid, equal columns and height. No amber, nothing pre-selected. */
.consent-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; margin-top: 2px; margin-bottom: 4px; scroll-margin-bottom: 24px; }
.consent-btn { width: 100%; min-height: 56px; padding: 8px 12px; font-size: 1.125rem; line-height: 1.15; white-space: normal; text-align: center; }
/* Toast in the card's spot after either answer (same treatment for both). */
.consent-toast.is-on { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 18px; background: var(--ink); color: var(--bg);
  font-size: .9375rem; font-weight: 700; line-height: 1.35; box-shadow: var(--shadow); animation: toast-in .24s ease both; transition: opacity .3s ease; }
.consent-toast.is-fading { opacity: 0; }
.toast-disc { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--bg); color: var(--ink); }
.toast-disc svg { width: 18px; height: 18px; }
@keyframes toast-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- Settings · Privacy ---------- */
.trial-settings { margin-top: 16px; padding-top: 14px; border-top: 2px solid var(--rule); }
.trial-settings .meta { margin: 0 0 6px; }
.privacy-label { margin: 0 0 8px; font-size: .8125rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.privacy-card { padding: 14px 16px; background: var(--raised); border-radius: 20px; box-shadow: var(--shadow); }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; cursor: pointer; }
.switch-text { display: grid; gap: 3px; }
.switch-title { font-size: 1.0625rem; font-weight: 800; line-height: 1.3; }
.switch-help { color: var(--muted); font-size: .90625rem; font-weight: 700; line-height: 1.35; }
.switch-row input { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 32px; margin: 0; border-radius: 16px; background: var(--rule); position: relative; cursor: pointer; transition: background .2s; }
.switch-row input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 2px 0 rgba(0, 0, 0, .18); transition: transform .2s; }
.switch-row input:checked { background: var(--btn); }
.switch-row input:checked::after { transform: translateX(20px); }
.switch-row input:disabled { opacity: .5; cursor: not-allowed; }
.switch-row input:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.stats-note { margin-top: 8px; }
.privacy-id { margin-top: 12px; }
.id-box { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; margin: 0; padding: 8px 12px; border-radius: 14px; background: var(--btn2); }
.id-label { grid-column: 1; color: var(--muted); font-size: .8125rem; font-weight: 700; line-height: 1.3; }
.id-box code { grid-column: 1; font: 800 1.0625rem/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.id-new { grid-column: 2; grid-row: 1 / span 2; padding: 3px 10px; border-radius: 10px; background: var(--btn); color: var(--btn-ink); font-size: .8125rem; font-weight: 800; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; margin-top: 12px; }
.pair-btn { width: 100%; min-height: 48px; padding: 6px 10px; font-size: 1rem; gap: 8px; white-space: normal; text-align: center; }
.pair-btn .t-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.stats-status { margin: 0; font-size: .875rem; font-weight: 700; color: var(--muted); }
.stats-status:not(:empty) { margin-top: 10px; }
.privacy-link { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-top: 6px; padding: 0 4px; color: var(--ink); font-weight: 800; text-decoration: none; }
.privacy-link svg { width: 20px; height: 20px; }
.reset-dialog { width: min(92vw, 360px); padding: 22px 20px 20px; border: 0; border-radius: 24px; background: var(--raised); color: var(--ink); box-shadow: var(--shadow); }
.reset-dialog::backdrop { background: rgba(20, 14, 10, .45); }
.reset-title { margin: 0 0 8px; font-size: 1.25rem; font-weight: 800; line-height: 1.25; }
.reset-dialog p { font-weight: 600; line-height: 1.45; }
.link-btn { font: inherit; color: var(--link); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .switch-row input, .switch-row input::after, .win-mark, .consent-chev { transition: none; }
  /* Reduce Motion: a cross-fade instead of the height spring. */
  .consent-panel, .consent.is-open .consent-panel { transition: opacity .2s linear, visibility 0s; }
  .consent-panel { opacity: 0; }
  .consent.is-open .consent-panel { opacity: 1; }
  .consent-toast.is-on { animation: none; }
}
