/* Hub: the front page of the workbook */
.hub { max-width: 1180px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 6px) calc(env(safe-area-inset-right, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 40px) calc(env(safe-area-inset-left, 0px) + 16px); }
.hub-top { height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hub-top .brand { gap: 10px; color: var(--graphite); text-decoration: none; }
.hub-top .wordmark { font-size: 22px; }
.search { position: relative; flex: 0 1 300px; min-width: 0; }
.search input { width: 100%; height: 40px; padding: 0 38px 0 38px; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); font-size: 15px; font-weight: 550; }
.search input::placeholder { color: var(--pencil); }
.search input:focus { outline: 2px solid var(--pen); outline-offset: 1px; border-color: transparent; }
.search .i { position: absolute; left: 11px; top: 10px; color: var(--pencil); }
.search kbd { position: absolute; right: 9px; top: 9px; }

.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: clamp(24px, 5vw, 72px); align-items: center; padding: clamp(18px, 4vw, 56px) 0 clamp(28px, 4vw, 52px); }
.hero h1 { margin: 0; font-size: clamp(40px, 6.4vw, 76px); line-height: .98; font-weight: 870; letter-spacing: -.03em; font-variation-settings: var(--casual); max-width: 12ch; text-wrap: balance; }
.hero-sub { margin: 18px 0 0; max-width: 46ch; color: var(--graphite-2); font-size: clamp(15px, 1.5vw, 17px); line-height: 1.55; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.hero-cta .btn { height: 50px; padding: 0 20px; }
.hero-cta .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }

.demo { justify-self: center; width: min(100%, 400px); }
.demo-board { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); aspect-ratio: 1; padding: 0; border: 3px solid var(--frame); border-radius: 12px; overflow: hidden; background: var(--sheet); container-type: inline-size; box-shadow: 0 24px 60px -32px rgba(20, 30, 50, .45); transform: rotate(-1.5deg); transition: opacity .5s; }
.demo-board.fade { opacity: .25; }
.demo-board .cell { box-shadow: inset -1px -1px 0 var(--rule); cursor: default; }
.demo-board .cell.br { box-shadow: inset -2.5px -1px 0 var(--frame); }
.demo-board .cell.bb { box-shadow: inset -1px -2.5px 0 var(--frame); }
.demo-board .cell.br.bb { box-shadow: inset -2.5px -2.5px 0 var(--frame); }
.demo-board .cell .v { font-size: 9.5cqi; }
.demo-board .cell.now { background: var(--hl); }
.demo-board .fx { background: var(--c-sudoku); }
.demo-cap { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; color: var(--graphite-2); font-size: 13.5px; }
.demo-cap a { font-weight: 700; text-decoration: none; white-space: nowrap; }
.demo-cap a:hover { text-decoration: underline; }

.recent { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 22px; }
.recent b { font-size: 13.5px; color: var(--graphite-2); font-weight: 650; margin-right: 4px; }
.recent a { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 99px; background: var(--sheet); border: 1px solid var(--rule); color: var(--graphite); font-size: 13.5px; font-weight: 650; text-decoration: none; }
.recent a::before { content: ""; width: 8px; height: 8px; margin-right: 7px; border-radius: 2px; background: var(--ch-deep); }
.recent a:hover { border-color: var(--ch-deep); }

.chips { position: sticky; top: 0; z-index: 10; display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 8px; padding: 10px 16px; background: var(--paper); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 99px; background: var(--sheet); color: var(--graphite); font-size: 14px; font-weight: 680; cursor: pointer; white-space: nowrap; }
.chip small { color: var(--pencil); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--graphite-2); }
.chip[aria-pressed="true"] { background: var(--ch); border-color: var(--ch-deep); color: var(--graphite); }
.chip[aria-pressed="true"] small { color: var(--graphite-2); }
.chip[data-c="all"][aria-pressed="true"] { background: var(--graphite); border-color: var(--graphite); color: var(--paper); }
.chip[data-c="all"][aria-pressed="true"] small { color: var(--paper); opacity: .7; }

.chapter { padding: 26px 0 8px; scroll-margin-top: 60px; }
.chapter-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 16px; }
.chapter-h h2 { margin: 0; font-size: clamp(26px, 3.2vw, 34px); line-height: 1.1; font-weight: 850; letter-spacing: -.015em; font-variation-settings: var(--casual);
  background: linear-gradient(transparent 58%, var(--ch) 58% 90%, transparent 90%); padding: 0 4px; margin-left: -4px; }
.chapter-h p { margin: 0; flex: 1 1 280px; color: var(--graphite-2); font-size: 14.5px; max-width: 62ch; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 232px), 1fr)); gap: 14px; }
.tile { position: relative; display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--rule); border-radius: 16px; background: var(--sheet); color: inherit; text-decoration: none; overflow: hidden; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--ch-deep); transform: translateY(-2px); }
.tile:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; }
.thumb { position: relative; aspect-ratio: 16 / 10; border-bottom: 1px solid var(--rule); background-color: var(--sheet-2);
  background-image: linear-gradient(var(--grid-major) 1px, transparent 1px), linear-gradient(90deg, var(--grid-major) 1px, transparent 1px); background-size: 16px 16px; }
.thumb svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tile-b { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; flex: 1; }
.tile-n { font-size: 17px; line-height: 1.2; font-weight: 800; font-variation-settings: var(--casual); }
.tile-d { color: var(--graphite-2); font-size: 13.5px; line-height: 1.4; flex: 1; }
.tile-s { margin-top: 6px; font-size: 12.5px; font-weight: 700; color: var(--pencil); font-variant-numeric: tabular-nums; }
.tile-s.has { color: var(--graphite); }
.tile-s.has::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--ch-deep); vertical-align: 1px; }
.empty { padding: 40px 0; color: var(--graphite-2); font-size: 15px; }
.hub-foot { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--rule); color: var(--graphite-2); font-size: 13px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; }
.hub-foot p { margin: 0; max-width: 70ch; }

/* thumbnails */
.t-thin { fill: none; stroke: var(--rule); stroke-width: 1; }
.t-ink { fill: none; stroke: var(--graphite); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.t-mid { fill: none; stroke: var(--graphite-2); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.t-dash { fill: none; stroke: var(--graphite-2); stroke-width: 1.1; stroke-dasharray: 3 2; }
.t-hl { fill: var(--ch); }
.t-deep { fill: none; stroke: var(--ch-deep); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.t-fill { fill: var(--graphite); }
.t-sheet { fill: var(--sheet); }
.t-gray { fill: var(--graphite); opacity: .14; }
.t-red { fill: var(--red); }
.t-pen { fill: var(--pen); font-family: var(--font); font-weight: 640; font-variation-settings: var(--casual); }
.t-txt { fill: var(--graphite); font-family: var(--font); font-weight: 600; }
.t-small { fill: var(--graphite); font-family: var(--font); font-weight: 760; }
.tile:hover .t-hl { animation: thumb-glow 1.2s ease-in-out infinite alternate; }
@keyframes thumb-glow { to { fill: var(--ch-deep); opacity: .55; } }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .demo { width: min(100%, 300px); order: -1; }
  .hub-top .wordmark { font-size: 20px; }
  .search kbd { display: none; }
}
@media (max-width: 420px) { .hub-top .mark { display: none; } .search { flex-basis: 170px; } }

/* ==========================================================================
   One-page launcher: sidebar with every game, games open in place
   ========================================================================== */
.shell { min-height: 100vh; min-height: var(--vh); }
.side { display: none; }
.stage-frame { position: fixed; inset: 0; z-index: 40; background: var(--paper); }
.frames, .frames iframe { position: absolute; inset: 0; width: 100%; height: 100%; }
.frames iframe { display: block; border: 0; background: var(--paper); }
.frames iframe[hidden] { display: none; }
.frame-busy { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; justify-items: center; gap: 12px; background: var(--paper); }
body.in-game { overflow: hidden; }
.side-empty { margin: 16px 12px; color: var(--graphite-2); font-size: 13.5px; }
@media (min-width: 1100px) {
  .shell { display: grid; grid-template-columns: 284px minmax(0, 1fr); }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: var(--vh); border-right: 1px solid var(--rule); background: color-mix(in srgb, var(--sheet) 72%, transparent); }
  .side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 8px 18px; }
  .side-top .brand { gap: 10px; color: var(--graphite); text-decoration: none; }
  .side-top .wordmark { font-size: 20px; }
  .side .search { flex: none; margin: 4px 14px 10px; }
  .side-list { flex: 1; overflow-y: auto; padding: 0 8px 18px; overscroll-behavior: contain; scrollbar-width: thin; }
  .side-h { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; margin: 0; padding: 12px 10px 5px; background: color-mix(in srgb, var(--sheet) 92%, var(--paper)); font-size: 12.5px; font-weight: 800; color: var(--graphite-2); }
  .side-h::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--ch-deep); }
  .side-h small { margin-left: auto; color: var(--pencil); font-weight: 700; }
  .side-g { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 6px 10px; border-radius: 9px; color: var(--graphite); text-decoration: none; font-size: 14px; font-weight: 640; }
  .side-g span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-g:hover { background: var(--tint); }
  .side-g[aria-current="page"] { background: var(--ch); font-weight: 780; }
  .side-g small { margin-left: auto; flex: none; font-size: 11.5px; color: var(--pencil); font-weight: 650; font-variant-numeric: tabular-nums; }
  .side-g[aria-current="page"] small { color: var(--graphite-2); }
  .side-foot { display: flex; gap: 8px; padding: 10px 14px 16px; border-top: 1px solid var(--rule); }
  .side-foot .btn { flex: 1; }
  .pane { position: relative; min-width: 0; }
  .pane .hub-top { display: none; }
  .pane .hub { padding-top: 10px; }
  .stage-frame { position: sticky; top: 0; height: 100vh; height: var(--vh); z-index: 1; }
  body.in-game { overflow: auto; }
  .in-game .lib { display: none; }
}
