body:has(#roofs) { background: #f7efe7; }
body:has(#roofs) > header { padding-block: 14px; }
body:has(#roofs) > main { max-width: 1040px; margin-top: 4px; padding: 0 24px 28px; }
#roofs { --ink-roof: #392940; --mauve: #754961; --border-roof: #dec9c7; --roof-stage: clamp(300px, calc(100svh - 349px), 525px); color: var(--ink-roof); text-align: left; }
.roof-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 auto 16px; max-width: calc(var(--roof-stage) + 330px); }
.roof-heading h1 { font: 500 clamp(2.1rem, 5.3vw, 3.8rem)/.99 Georgia, serif; letter-spacing: -.055em; margin: 0; }
.roof-heading h1 span { color: #a35371; }
.roof-heading a { color: var(--mauve); font-weight: 700; font-size: .82rem; flex: none; text-underline-offset: 3px; }
#roofs .roof-kicker { color: #7c5368; font-size: .66rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; line-height: 1.1; margin: 0 0 4px; }
.roof-layout { display: grid; grid-template-columns: minmax(0, min(54%, var(--roof-stage))) minmax(230px, 310px); justify-content: center; gap: 20px; align-items: start; }
.roof-order { min-height: 79px; padding: 0 1px 7px; }
.roof-order h2, .roof-guide h2 { font: 500 clamp(1.34rem, 3vw, 1.85rem)/1.08 Georgia, serif; letter-spacing: -.02em; margin: 2px 0 4px; }
#roofs #roof-goal { color: #655264; font-size: .84rem; line-height: 1.3; margin: 0; }
.roof-board { position: relative; overflow: hidden; background: #352d47; border-radius: 18px; box-shadow: 0 13px 28px #492d4d29; }
.roof-hud { display: flex; align-items: center; gap: 20px; padding: 7px 14px; min-height: 56px; background: #3f3048; color: #fff2dd; }
.roof-hud > div { display: grid; gap: 3px; }
.roof-hud span { font-size: .68rem; font-weight: 700; color: #ebc9c5; line-height: 1.05; }
.roof-hud strong { font: 600 1.15rem Georgia, serif; }
.roof-hud .roof-pieces { display: flex; gap: 12px; margin-left: auto; }
.roof-pieces > div { display: grid; gap: 3px; justify-items: center; min-width: 40px; }
.roof-piece { position: relative; width: 37px; height: 25px; }
.roof-piece i { position: absolute; width: 11px; height: 10px; border-top: 2px solid var(--roof-edge); border-radius: 2px; background: var(--roof-fill); }
.roof-piece .roof-piece-demolition { left: 11px; bottom: 0; width: 17px; height: 17px; background: #543b50; border: 2px solid #efb770; border-radius: 4px; }
.roof-piece-demolition::after { content: ''; position: absolute; inset: 1px 3px; background: #ffe0a1; clip-path: polygon(60% 0, 0 58%, 42% 58%, 29% 100%, 100% 38%, 56% 38%); }
.roof-board canvas { display: block; width: 100%; height: auto; aspect-ratio: 640 / 636; touch-action: manipulation; cursor: crosshair; }
.roof-controls { display: grid; grid-template-columns: minmax(44px, 1fr) minmax(44px, 1fr) minmax(78px, 1.4fr) clamp(54px, 17%, 68px); gap: 6px; margin-top: 7px; }
#roofs button { min-height: 44px; padding: 6px 8px; border: 1px solid #cfafb6; border-radius: 10px; background: #fff8ee; color: var(--ink-roof); font-weight: 700; touch-action: manipulation; }
#roofs button[aria-disabled="true"] { opacity: .52; cursor: default; }
#roofs button:focus-visible, #roofs canvas:focus-visible { outline: 2px solid #a85f86; outline-offset: -3px; }
#roofs .roof-controls button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 54px; padding: 4px 5px; background: linear-gradient(#fff8ee, #f3e5e3); font-size: .9rem; touch-action: none; user-select: none; }
#roofs .roof-controls button:active { filter: brightness(.93); }
#roofs .roof-controls [data-roof="rotate"], #roofs .roof-end button { background: #54364f; color: #fff5df; border-color: #54364f; }
#roofs .roof-controls .roof-drop { gap: 2px; background: #eee3e7; font-size: .8rem; }
#roofs[data-demolition] .roof-controls .roof-drop { background: #8d473f; border-color: #8d473f; color: #fff5df; }
.roof-chevron { width: 12px; height: 12px; border-right: 2.5px solid; border-top: 2.5px solid; transform: rotate(45deg); }
[data-roof="left"] .roof-chevron { transform: rotate(-135deg); }
.roof-turn, .roof-down { position: relative; width: 14px; height: 14px; flex: 0 0 14px; }
.roof-turn { width: 16px; height: 16px; flex-basis: 16px; border: 1.5px solid; border-right-color: transparent; border-radius: 50%; }
.roof-turn::after { content: ''; position: absolute; right: -3px; top: 1px; width: 5px; height: 5px; border-right: 1.5px solid; border-bottom: 1.5px solid; }
.roof-down::before { content: ''; position: absolute; top: 1px; left: 6px; width: 1.5px; height: 9px; background: currentColor; }
.roof-down::after { content: ''; position: absolute; left: 4px; top: 5px; width: 6px; height: 6px; transform: rotate(45deg); border-right: 1.5px solid; border-bottom: 1.5px solid; }
#roofs #roof-note { margin: 7px 0 0; min-height: 37px; color: #684b61; font-size: .8rem; line-height: 1.35; }
.roof-guide { background: #fff8ee; border: 1px solid var(--border-roof); border-radius: 16px; padding: 19px; margin-top: 79px; }
.roof-guide ol { margin: 12px 0; padding-left: 20px; color: #5e4d62; font-size: .89rem; line-height: 1.55; }
.roof-guide li { padding-left: 4px; margin: 0 0 8px; }
#roofs .roof-keys { color: #75596a; font-size: .74rem; line-height: 1.4; }
#roofs .roof-help { color: #5e4d62; font-size: .83rem; line-height: 1.45; }
#roofs .roof-reset { font-size: .8rem; padding-inline: 12px; }
.roof-end { position: absolute; inset: 56px 0 0; display: grid; place-items: center; background: #30283bd9; padding: 20px; text-align: center; }
.roof-end[hidden] { display: none; }
.roof-end > div { border-radius: 14px; padding: 20px; width: min(100%, 300px); background: #fff1df; box-shadow: 0 12px 30px #24172a55; }
.roof-end h3 { font: 500 1.55rem Georgia, serif; margin: 0; }
.roof-end p { color: #654d63; font-size: .86rem; }
@media (max-width: 740px) {
  body:has(#roofs) > main { max-width: 540px; padding: 0 10px 25px; }
  body:has(#roofs) > header { padding: 12px 14px; }
  .roof-layout { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .roof-heading { margin-bottom: 8px; }
  .roof-order { min-height: 62px; }
  .roof-guide { margin-top: 0; padding: 14px; }
  .roof-board { border-radius: 12px; }
}
@media (max-width: 400px) {
  .roof-heading h1 { font-size: clamp(1.65rem, 7.2vw, 2rem); }
}
@media (max-width: 360px) {
  .roof-controls { gap: 4px; }
}
