@font-face { font-family: SG; src: url(/fonts/space-grotesk-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: SG; src: url(/fonts/space-grotesk-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }
* { box-sizing: border-box; margin: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { --paper: #ff84be; --ink: #1b1a2e; font: 700 16px/1.25 SG, system-ui, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; -webkit-text-size-adjust: 100%; background: var(--paper); }
.on-paper, body { --ink: #1b1a2e; }
@supports (color: oklch(from red l c h)) { .on-paper { --ink: oklch(from var(--paper) 0.25 0.1 h); } }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; border-radius: 0; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; height: 100svh; }
.screen { position: absolute; inset: 0; background: var(--paper); color: var(--ink); }
svg.px { height: calc(var(--h) * var(--u, 3px)); width: calc(var(--w) * var(--u, 3px)); display: block; flex: none; }
svg.ic { width: 27px; height: 27px; display: block; flex: none; }
.btn { background: var(--ink); color: #fff; min-height: 46px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; --u: 2px; position: relative; white-space: nowrap; flex: none;
  clip-path: polygon(0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)); }
.btn.soft { background: rgba(0, 0, 0, .16); color: var(--ink); }
.btn:active, .sq:active { transform: translateY(2px); }
.btn:disabled, .sq:disabled { opacity: .38; cursor: default; }
.sq { width: 46px; height: 46px; display: grid; place-items: center; flex: none; }
.text { min-height: 44px; padding: 0 12px; }

/* home: three fields of colour, three real heaps, one floor */
#home { display: grid; grid-template-rows: auto 1fr auto; background: var(--first); }
#mark { padding: calc(10px + env(safe-area-inset-top)) 14px 4px; --u: min(8px, calc((100vw - 28px) / 53)); }
#bands { display: grid; grid-template-rows: repeat(3, 1fr); min-height: 0; }
.band { position: relative; background: var(--paper); color: var(--ink); display: grid; grid-template: "name go" auto "chips chips" auto "heap heap" 1fr / 1fr auto; gap: 6px 12px; padding: 8px 14px 0; min-height: 0; overflow: hidden; }
.band h2 { grid-area: name; display: flex; align-items: center; gap: 12px; --u: 3px; }
.band h2 .n { opacity: .55; }
.band .btn { grid-area: go; }
.chips { grid-area: chips; display: flex; gap: 2px; font-size: 12px; line-height: 22px; text-align: center; }
.chips i { font-style: normal; flex: 0 1 46px; min-width: 0; }
.band .heap { grid-area: heap; width: calc(100% + 28px); height: 100%; margin: 0 -14px; min-height: 0; display: block; touch-action: none; cursor: grab; }
.band .made { grid-area: heap; min-height: 0; width: 100%; height: 100%; container-type: size; display: grid; place-items: center; }
.band .made canvas { width: min(92cqw, 100cqh - 16px); height: min(92cqw, 100cqh - 16px); image-rendering: pixelated; box-shadow: 0 0 0 3px var(--ink); cursor: pointer; }
#floor { background: #2a0f45; color: #fff; display: flex; align-items: center; padding: 0 6px env(safe-area-inset-bottom) 14px; min-height: 46px; font-size: 14px; }
#floor #next { flex: 1; }

/* build */
#play { --side: 8px; --sw: 1; --b: min(calc(100vw - 16px), calc(100svh - 46px - 52px - 48px - var(--swh) - 42px - env(safe-area-inset-top) - env(safe-area-inset-bottom))); --swh: 50px;
  display: grid; grid-template: "nav submit" 46px "board board" var(--b) "heap heap" minmax(42px, 1fr) "sw sw" var(--swh) "tools tools" 48px / 1fr auto; row-gap: 0; padding: calc(4px + env(safe-area-inset-top)) var(--side) calc(4px + env(safe-area-inset-bottom)); row-gap: 8px; overflow: hidden; }
#play.many { --swh: 94px; }
#nav { grid-area: nav; display: flex; }
#submit { grid-area: submit; }
#boardbox { grid-area: board; display: grid; justify-content: center; }
#board { width: var(--b); height: var(--b); display: block; touch-action: none; cursor: crosshair; outline: 3px solid var(--ink); background: var(--paper); }
#heapbox { grid-area: heap; position: relative; margin: 0 calc(var(--side) * -1); min-height: 0; overflow: hidden; }
#heap { position: absolute; inset: 0; width: 100%; height: 100%; }
#say { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--ink); color: #fff; padding: 6px 12px; font-size: 14px; white-space: nowrap; opacity: 0; transition: opacity .18s; pointer-events: none; }
#say.on { opacity: 1; }
#swatches { grid-area: sw; display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 4px; align-content: stretch; }
.sw { min-height: 44px; font-size: 15px; position: relative; font-variant-numeric: tabular-nums; background: var(--c); color: var(--t); }
.sw[aria-pressed=true] { box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 6px #fff; }
.sw.out { background: repeating-linear-gradient(135deg, var(--c) 0 5px, rgba(0, 0, 0, .12) 5px 10px), var(--paper); background-size: auto; }
#tools { grid-area: tools; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.tool { height: 48px; display: grid; place-items: center; min-width: 44px; }
.tool b, .tool kbd { display: none; }
.tool[aria-pressed=true] { background: var(--ink); color: #fff; }

/* the pictures */
#wall { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: env(safe-area-inset-top) 10px 24px; }
#wall * { touch-action: pan-y; }
.top { display: flex; align-items: center; gap: 12px; min-height: 58px; --u: 3px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 44vw), 1fr)); gap: 14px 10px; }
.card { min-width: 0; }
.card.mine { grid-column: span 2; grid-row: span 2; }
.card button { display: block; width: 100%; aspect-ratio: 1; outline-offset: 0; }
.card canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; box-shadow: 0 0 0 3px var(--ink); }
.card p { display: flex; justify-content: space-between; padding-top: 7px; font-size: 14px; }
.more { display: flex; justify-content: center; padding: 22px 0 8px; }

/* over the game */
#sheet { z-index: 5; text-align: center; position: absolute; inset: 0; background: var(--paper); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom)); --u: 3px; overflow-y: auto; }
#sheet .pic { width: min(calc(100vw - 28px), calc(100svh - 230px), 760px); aspect-ratio: 1; image-rendering: pixelated; box-shadow: 0 0 0 3px var(--ink); cursor: pointer; flex: none; }
#sheet .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
#sheet dl { text-align: left; width: min(560px, 100%); display: grid; gap: 12px; font-weight: 500; }
#sheet dt { font-weight: 700; } #sheet dd { margin: 0; }
#toast { z-index: 8; position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0; background: #1b1a2e; color: #fff; padding: 12px 18px; transition: .2s; pointer-events: none; text-align: center; width: max-content; max-width: calc(100vw - 28px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#tweaks { position: absolute; right: 8px; top: 60px; background: #fff; color: #1b1a2e; padding: 10px; display: grid; gap: 6px; font-size: 13px; z-index: 9; box-shadow: 0 0 0 3px #1b1a2e; }
#tweaks button { padding: 6px 8px; background: #e4dcff; } #tweaks button.on { background: #1b1a2e; color: #fff; }

/* on its side: the canvas takes the full height, the pile and tools stand beside it */
@media (min-aspect-ratio: 1/1) {
  #bands { grid-template: 1fr / repeat(3, 1fr); }
  #home { background: none; position: absolute; }
  #home #mark { position: absolute; z-index: 1; top: 0; left: 0; right: 0; display: grid; justify-content: center; padding-top: 2.4vh; --u: min(calc(100vw / 74), 2.5vh); pointer-events: none; }
  #bands { grid-row: 1 / 3; }
  .band { padding-top: calc(5vh + 7 * min(100vw / 74, 2.5vh) + 10px); grid-template: "name" auto "chips" auto "go" auto "heap" 1fr / 1fr; gap: 1.6vh; padding-inline: 2vw; justify-items: start; }
  .band h2 { --u: min(6px, .34vw, 1vh); gap: 1.4vw; }
  .band .heap { width: calc(100% + 4vw); margin: 0 -2vw; }
  .band .btn { min-height: clamp(46px, 8.5vh, 76px); padding: 0 clamp(16px, 2vw, 34px); --u: clamp(2px, .3vw, 4px); }
  .chips { width: 100%; font-size: clamp(11px, 1.05vw, 17px); line-height: clamp(20px, 3.6vh, 36px); }
  .chips i { flex-basis: 64px; }
  #play, #play.many { --gap: clamp(8px, 2.2vh, 24px); --b: min(calc(100svh - 2 * var(--gap)), calc(100vw - 2 * 172px)); --side: 10px;
    grid-template: "nav board sw" auto "tools board sw" auto "heap board sw" 1fr "heap board submit" auto / 1fr var(--b) 1fr; gap: 10px var(--gap); padding: var(--gap) 12px; align-items: start; }
  #boardbox { align-self: center; } #nav { flex-wrap: nowrap; justify-content: space-between; max-width: 220px; }
  #heapbox { align-self: stretch; margin: 0 calc(var(--gap) * -1 + 6px) calc(var(--gap) * -1) -12px; }
  #tools { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); }
  .tool { height: 44px; }
  #swatches, #play.many #swatches { grid-template-columns: repeat(2, 1fr); gap: 5px; }
  .sw { height: clamp(44px, 9vh, 84px); font-size: clamp(15px, 2.4vh, 24px); }
  #submit { justify-self: stretch; }
  #say { top: auto; bottom: 10px; white-space: normal; width: max-content; max-width: calc(100% - 12px); text-align: center; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(clamp(130px, 15vw, 250px), 1fr)); gap: 22px 18px; }
  #wall { padding-inline: 2.4vw; }
}
@media (min-aspect-ratio: 1/1) and (min-height: 600px) and (min-width: 1200px) {
  #play { --b: min(calc(100svh - 2 * var(--gap)), calc(100vw - 2 * 250px)); }
  #nav { max-width: none; justify-content: flex-start; gap: 6px; }
  #tools { grid-template-columns: 1fr; max-width: 260px; }
  .tool { grid-template-columns: 27px 1fr auto; gap: 14px; padding: 0 12px; justify-items: start; }
  .tool b { display: block; font-size: 17px; }
  #submit { min-height: 64px; --u: 3px; }
  #swatches, #play.many #swatches { align-self: stretch; grid-auto-rows: minmax(44px, 124px); gap: 6px; }
  #play:not(.many) #swatches { grid-template-columns: 1fr; }
  .sw { height: auto; }
  #sheet { --u: 4px; }
  .top { min-height: 84px; --u: 5px; }
}
@media (hover: hover) and (pointer: fine) {
  .tool kbd { display: block; font: 700 13px/22px SG, sans-serif; min-width: 22px; text-align: center; box-shadow: 0 0 0 2px currentColor; }
  .btn:hover:not(:disabled) { filter: brightness(1.35); } .tool:hover:not([aria-pressed=true]), .sq:hover:not(:disabled) { background: rgba(0, 0, 0, .12); }
}
@media (max-width: 1199px), (max-height: 599px) { .tool kbd { display: none; } }
