:root {
  color-scheme: light;
  --paper: #f7eedc;
  --ink: #2b222b;
  --muted: #645551;
  --brick: #a64834;
  --teal: #345654;
  --saffron: #e3ae58;
  --line: #d7c9b4;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); }
body.loom-frame { padding: 0; }
button { font: inherit; }
a { color: inherit; text-underline-offset: .22em; }
a:hover { color: var(--brick); }
:focus-visible { outline: 3px solid #147676; outline-offset: 4px; }
.wrap { width: min(1080px, calc(100% - 56px)); margin-inline: auto; }
.skip { position: fixed; z-index: 5; top: 10px; left: 10px; padding: 8px 12px; background: #fff; transform: translateY(-150%); }
.skip:focus { transform: none; }
.masthead { height: 74px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font: 29px/1 var(--serif); white-space: nowrap; }
.wordmark em { margin-left: -3px; }
.woven-mark { display: inline-block; width: 25px; height: 25px; border-radius: 3px; background: conic-gradient(from 45deg, var(--brick) 25%, var(--saffron) 0 50%, var(--brick) 0 75%, var(--saffron) 0); }
.masthead nav, .footer nav { display: flex; align-items: center; flex-wrap: wrap; gap: 22px; }
.masthead nav a, .footer nav a { font-size: .875rem; text-decoration: none; }
.game-heading { text-align: center; padding: 35px 0 22px; }
h1, h2 { font: 400 3rem/.98 var(--serif); margin: 0; }
.game-heading h1 { font-size: clamp(4rem, 8.7vw, 7rem); }
.game-heading h1 em { color: var(--brick); }
.game-heading p { margin: .65rem 0 0; color: var(--muted); }
.stage { position: relative; overflow: hidden; isolation: isolate; height: clamp(465px, 58vh, 570px); background: var(--ink); border-radius: 12px; border: 1px solid #3e333c; color: var(--paper); }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage:fullscreen { border: 0; border-radius: 0; height: 100%; width: 100%; }
.cover { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1.03fr; align-items: center; gap: 30px; padding: clamp(25px, 5vw, 74px); background: radial-gradient(ellipse at 78% 53%, #4c3541, var(--ink) 65%); }
.cover[hidden] { display: none; }
.cover-content { position: relative; z-index: 1; }
.cover-content p { color: #ebbf78; font-size: .83rem; font-weight: 600; letter-spacing: .075em; margin: 0 0 15px; }
.cover h2 { font-size: clamp(2.8rem, 6vw, 5.8rem); line-height: .91; letter-spacing: -.025em; }
.primary { margin-top: 27px; padding: 12px 18px; min-height: 48px; border: 0; border-radius: 6px; background: #f3cc86; color: #30232b; font-weight: 700; cursor: pointer; }
.primary span { padding-left: 13px; }
.primary:hover { background: #ffe0a7; }
.art { display: grid; place-items: center; min-width: 0; }
.rug { position: relative; width: min(100%, 348px); aspect-ratio: 5 / 4; display: grid; grid-template-rows: 11% 1fr 11%; border: 5px solid #d29654; outline: 3px solid #7d4131; transform: rotate(-7deg); box-shadow: 9px 19px 32px #1c171d99; background: #a64834; }
.rug::before, .rug::after { position: absolute; content: ""; top: 5%; bottom: 5%; width: 11px; background: repeating-linear-gradient(to bottom, #dfbd87 0 2px, transparent 2px 5px); }
.rug::before { right: 100%; }
.rug::after { left: 100%; }
.rug-edge { background: repeating-linear-gradient(90deg, #d59b5c 0 8%, #f1d098 8% 12%, #2e4f4d 12% 19%, #2d242c 19% 24%); border-block: 4px solid #382b32; }
.rug-field { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); place-items: center; column-gap: 2px; overflow: hidden; background: repeating-linear-gradient(132deg, #8f4239 0 6px, #a64d39 6px 13px); padding: 13% 10%; }
.rug-field::after { position: absolute; content: ""; inset: 0; background: repeating-linear-gradient(to bottom, #2b222b52 0 1px, #ffe0a340 1px 2px, transparent 2px 4px); pointer-events: none; }
.rug-field i { display: block; width: 95%; aspect-ratio: 1; transform: rotate(45deg); border: 4px solid #e3ae58; box-shadow: 0 0 0 4px #342834; background: repeating-linear-gradient(135deg, #2f514f 0 7px, #ddbc85 7px 14px, #603a3d 14px 21px); }
.rug-field i:nth-child(4) { grid-column: 1; transform: translateX(55%) rotate(45deg); }
.rug-field i:nth-child(5) { grid-column: 3; transform: translateX(-55%) rotate(45deg); }
.loading { position: absolute; inset: 0; display: none; place-content: center; justify-items: center; gap: 14px; }
.stage[data-gf-state="loading"] .loading { display: grid; }
.loading span { width: 23px; height: 23px; border: 2px solid #9a796a; border-top-color: #ffe0a7; border-radius: 50%; animation: turn .8s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
.game-tools { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 13px 0; }
.source-link { color: var(--muted); font-size: .85rem; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.actions button { min-height: 40px; border: 1px solid var(--line); border-radius: 5px; padding: 5px 10px; color: var(--ink); background: transparent; font-size: .825rem; cursor: pointer; }
.actions button:hover, .actions [aria-pressed="true"] { border-color: var(--brick); color: #823d2e; }
.share-message:empty { display: none; }
.guide, .text-page article { max-width: 680px; }
.guide { margin: 45px auto 80px; scroll-margin-top: 20px; }
.guide h2, .text-page h2 { margin: 48px 0 14px; font-size: 2.8rem; }
.guide h3 { margin: 28px 0 3px; font-size: 1.08rem; }
.guide p, .text-page p { margin: 0 0 15px; }
.guide ol { padding-left: 22px; }
.guide li { padding-left: 4px; margin-bottom: 7px; }
.text-page { min-height: 60vh; margin-block: 60px 88px; }
.text-page h1 { font-size: clamp(2.7rem, 6vw, 4rem); margin-bottom: 25px; }
.footer { border-top: 1px solid var(--line); color: var(--muted); }
.footer-row { min-height: 82px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }

@media (max-width: 640px) {
  .wrap { width: calc(100% - 28px); }
  .masthead { height: 61px; }
  .masthead nav, .footer nav { gap: 13px; }
  .masthead nav a, .footer nav a { font-size: .8rem; }
  .game-heading { padding-top: 25px; }
  .game-heading h1 { font-size: 4rem; }
  .stage { height: min(540px, max(475px, 67svh)); }
  .cover { grid-template-columns: 1fr; grid-template-rows: 1fr .9fr; gap: 18px; padding: 25px 20px; text-align: center; }
  .cover-content p { margin-bottom: 10px; }
  .cover h2 { font-size: clamp(2.8rem, 9vw, 4rem); }
  .primary { margin-top: 19px; }
  .rug { max-width: 180px; }
  .game-tools, .footer-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .footer-row { padding-block: 20px; }
  .guide { margin: 30px auto 55px; }
}

@media (prefers-reduced-motion: reduce) {
  .loading span { animation: none; }
}
