:root {
  --paper: #fffaf0;
  --paper-deep: #f7e7c6;
  --panel: #fffdfa;
  --shelf: #fff4d9;
  --ink: #2b251d;
  --muted: #736651;
  --line: #dfc895;
  --green: #4f8f63;
  --green-deep: #2f6844;
  --green-dark: #183b29;
  --gold: #e7bb52;
  --gold-deep: #bd8628;
  --danger: #a8493d;
  --white: #ffffff;
  --radius: 8px;
  --shadow: 0 12px 30px rgba(45, 51, 35, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(47, 104, 68, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 28px;
  color: var(--ink);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  line-height: 1.7;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--green-deep);
}

[hidden] {
  display: none !important;
}

.loom-skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: 4px;
  background: var(--green-dark);
  color: var(--white);
  transform: translateY(-160%);
}

.loom-skip-link:focus {
  transform: translateY(0);
}

.site-header {
  border-bottom: 1px solid rgba(223, 200, 149, 0.9);
  background: rgba(255, 253, 250, 0.96);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  width: min(1320px, calc(100% - 32px));
  min-height: 58px;
  margin: 0 auto;
}

.site-logo {
  flex: 0 0 auto;
  color: var(--green-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex: 1 1 auto;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.site-nav a {
  flex: 0 0 auto;
  padding: 7px 9px;
  border-radius: 5px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover {
  background: var(--shelf);
  color: var(--green-deep);
}

.site-logo:focus-visible,
.site-nav a:focus-visible,
.site-footer a:focus-visible,
.loom-related a:focus-visible,
.loom-button:focus-visible,
.loom-form input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.page-shell {
  display: grid;
  grid-template-columns: 110px minmax(0, 1100px) 110px;
  gap: 20px;
  justify-content: center;
  width: min(1360px, calc(100% - 32px));
  margin: 18px auto 42px;
}

.main-content {
  min-width: 0;
}

.main-content:focus {
  outline: none;
}

.ad-rail {
  align-self: stretch;
}

.ad-placeholder {
  position: sticky;
  top: 18px;
  display: grid;
  min-height: 300px;
  place-content: center;
  gap: 6px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.ad-placeholder span {
  color: var(--gold-deep);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.ad-placeholder strong {
  font-size: 11px;
  font-weight: 700;
  writing-mode: vertical-rl;
}

.loom-hero {
  margin: 0 0 14px;
  padding: 12px 4px 4px;
}

.loom-kicker,
.loom-eyebrow {
  margin: 0 0 4px;
  color: var(--green-deep);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.17em;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 1000px;
  margin: 0;
  color: var(--green-dark);
  font-family: Georgia, "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(30px, 4.1vw, 46px);
  line-height: 1.16;
  letter-spacing: 0.015em;
}

h2,
h3 {
  margin: 0;
  color: var(--green-dark);
  line-height: 1.35;
}

h2 {
  font-size: clamp(21px, 2.8vw, 28px);
}

h3 {
  font-size: 20px;
}

.loom-hero__rule {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.loom-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, 0.97);
  box-shadow: var(--shadow);
}

.loom-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  margin-bottom: 18px;
  padding: 20px 22px;
}

.loom-intro p:not(.loom-eyebrow, .loom-start-failure) {
  margin: 7px 0 0;
  color: var(--muted);
}

.loom-intro__action {
  min-width: 170px;
  text-align: center;
}

.loom-button {
  min-height: 44px;
  padding: 9px 18px;
  border: 1px solid var(--green-deep);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 900;
}

.loom-button--primary {
  background: var(--green-deep);
  color: var(--white);
  box-shadow: 0 4px 0 var(--green-dark);
}

.loom-button--primary:hover {
  background: var(--green-dark);
}

.loom-button:active {
  box-shadow: none;
  transform: translateY(2px);
}

.loom-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.loom-start-failure {
  max-width: 320px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.loom-game {
  margin-bottom: 18px;
  padding: 16px 18px 18px;
}

.loom-game__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.loom-phase-status {
  flex: 0 0 auto;
  margin: 0;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--shelf);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
}

.loom-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 8px;
}

.loom-metrics div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
}

.loom-metrics span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.loom-metrics strong {
  color: var(--green-dark);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.loom-progress {
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--paper-deep);
}

.loom-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green-deep), var(--gold));
  transition: width 180ms ease-out;
}

.loom-game__body {
  display: grid;
  grid-template-columns: minmax(250px, 0.78fr) minmax(0, 1.22fr);
  gap: 16px;
  margin-top: 14px;
}

.loom-stage {
  min-width: 0;
  margin: 0;
  padding: 10px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 10%, rgba(231, 187, 82, 0.2), transparent 45%),
    var(--paper);
}

.loom-stage figcaption {
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 900;
}

.loom-frame {
  position: relative;
  width: min(100%, 390px);
  margin: 2px auto 0;
}

.loom-frame__svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 247px;
}

.loom-svg__wood {
  fill: #9a6b3c;
  stroke: #664627;
  stroke-width: 3;
}

.loom-svg__threads line {
  stroke: #cbb481;
  stroke-width: 2;
}

.loom-svg__fabric rect {
  fill: var(--green);
  stroke: var(--green-deep);
  stroke-width: 1.5;
  opacity: 0.05;
  transition: opacity 140ms ease-out;
}

.loom-svg__fabric rect:nth-child(even) {
  fill: var(--gold);
  stroke: var(--gold-deep);
}

.loom-svg__fabric rect.is-woven {
  opacity: 0.96;
}

.loom-shuttle {
  --loom-row-index: 0;
  position: absolute;
  top: calc(77% - (var(--loom-row-index) * 8.55%));
  left: 17%;
  display: none;
  width: 54px;
  height: 12px;
  border: 2px solid var(--green-dark);
  border-radius: 70% 15% 70% 15%;
  background: var(--gold);
  box-shadow: 0 2px 0 rgba(24, 59, 41, 0.18);
}

.loom-shuttle::after {
  position: absolute;
  top: 3px;
  right: 9px;
  width: 20px;
  height: 2px;
  background: var(--green-dark);
  content: "";
}

.loom-shuttle.is-running {
  display: block;
}

.loom-shuttle.is-running.is-left-to-right {
  animation: loom-shuttle-right 280ms ease-in-out both;
}

.loom-shuttle.is-running.is-right-to-left {
  animation: loom-shuttle-left 280ms ease-in-out both;
}

@keyframes loom-shuttle-right {
  from { left: 17%; }
  to { left: 70%; }
}

@keyframes loom-shuttle-left {
  from { left: 70%; }
  to { left: 17%; }
}

#loom-weave-summary {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.loom-controls {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.loom-pattern {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.loom-pattern__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.loom-pattern__badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--green-dark);
  color: var(--white);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.09em;
}

.loom-pattern__help {
  margin: 5px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.loom-pattern__groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.loom-pattern__group {
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
}

.loom-pattern__group > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.loom-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 29px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.loom-chips li {
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--green);
  border-radius: 4px;
  background: var(--white);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.loom-chips li.loom-chip--blank {
  min-width: 31px;
  border: 2px dashed var(--gold-deep);
  background: #fff8dc;
  color: var(--gold-deep);
  text-align: center;
}

.loom-form {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--shelf);
}

.loom-form > label {
  display: block;
  margin-bottom: 5px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 900;
}

.loom-form__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.loom-form input {
  min-width: 0;
  width: 100%;
  min-height: 44px;
  padding: 8px 11px;
  border: 2px solid var(--green-deep);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

.loom-form input:disabled {
  background: var(--paper-deep);
  color: var(--muted);
}

.loom-input-hint {
  min-height: 21px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.loom-input-hint.is-error {
  color: var(--danger);
}

.loom-result {
  margin-top: 14px;
  padding: 15px;
  border: 2px solid var(--green-deep);
  border-radius: 6px;
  background: var(--shelf);
}

.loom-result__numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.loom-result__numbers p {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--white);
}

.loom-result__numbers span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.loom-result__numbers strong {
  color: var(--green-dark);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

#loom-result-message {
  margin: 8px 0 13px;
  font-weight: 800;
}

.loom-section,
.loom-related {
  margin-bottom: 18px;
  padding: 18px 20px;
}

.loom-steps {
  margin: 10px 0 0;
  padding-left: 1.4em;
}

.loom-steps li + li {
  margin-top: 5px;
}

.loom-related__links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.loom-related a {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  font-weight: 800;
  text-decoration: none;
}

.is-playing #loom-intro,
.is-playing #loom-howto,
.is-playing #loom-related {
  display: none;
}

.is-playing .loom-hero {
  margin-bottom: 8px;
  padding-top: 4px;
}

.is-playing h1 {
  font-size: clamp(28px, 3.5vw, 40px);
}

.is-playing .loom-hero__rule {
  margin-top: 4px;
  font-size: 13px;
}

.loom-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.site-footer {
  padding: 24px 16px 28px;
  border-top: 1px solid var(--line);
  background: var(--green-dark);
  color: var(--white);
  text-align: center;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
}

.site-footer a {
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
}

.site-footer p {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

@media (max-width: 1280px) {
  .page-shell {
    grid-template-columns: minmax(0, 1100px);
    width: min(1100px, calc(100% - 32px));
  }

  .ad-rail {
    display: none;
  }
}

@media (max-width: 760px) {
  .header-inner {
    display: block;
    width: min(100% - 24px, 720px);
    padding: 8px 0 6px;
  }

  .site-logo {
    display: inline-block;
    margin-bottom: 4px;
  }

  .site-nav {
    width: 100%;
  }

  .site-nav a {
    padding: 6px 8px;
    font-size: 12px;
  }

  .page-shell {
    width: min(100% - 24px, 720px);
    margin-top: 10px;
  }

  .loom-hero {
    padding-top: 5px;
  }

  h1 {
    font-size: clamp(27px, 8.2vw, 38px);
  }

  .loom-intro {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .loom-intro__action {
    min-width: 0;
    text-align: left;
  }

  .loom-game {
    padding: 13px 12px 15px;
  }

  .loom-game__body {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .loom-frame {
    max-width: 330px;
  }

  .loom-frame__svg {
    max-height: 218px;
  }

  .loom-related__links {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .page-shell {
    width: min(100% - 20px, 390px);
  }

  .loom-hero__rule {
    font-size: 13px;
  }

  .is-playing h1 {
    font-size: 24px;
    line-height: 1.12;
  }

  .is-playing .loom-kicker {
    font-size: 9px;
  }

  .loom-game__header {
    align-items: flex-start;
  }

  .loom-game__header h2 {
    font-size: 20px;
  }

  .loom-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .loom-stage {
    padding: 7px 9px 5px;
  }

  .loom-frame {
    max-width: 250px;
  }

  .loom-frame__svg {
    max-height: 170px;
  }

  .loom-form__row {
    grid-template-columns: minmax(0, 1fr) 74px;
  }

  .loom-form__row .loom-button {
    padding-inline: 10px;
  }

  .loom-result__numbers {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

.page-shell{grid-template-columns:minmax(0,1100px)}h1{font-size:clamp(30px,4.1vw,42px)}h1 span{font-size:.5em;display:inline-block}h2{margin:0 0 8px;font-size:21px}p{margin:0 0 10px}.loom-panel{padding:20px}#intro{display:flex;align-items:center;gap:24px;justify-content:space-between}#intro p{margin:0}#intro button{flex-shrink:0}.game-top{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-bottom:12px}.game-top p{margin:0;font-weight:800}.small{font-size:12px;padding:6px 10px}.lab-body{display:grid;grid-template-columns:minmax(0,.95fr) minmax(0,1fr);gap:22px}.vessel{position:relative;background:#183b29;color:#fffaf0;border-radius:8px;padding:12px 20px;text-align:center}.stage-label{font-size:11px;font-weight:800;letter-spacing:.12em;color:#e7bb52;margin:0 0 9px}.mixing{display:flex;align-items:center;justify-content:center;gap:12px}.ingredient{min-width:90px;padding:5px 10px;background:#ffffff10;border:1px solid #a9b8a2;border-radius:5px;font-weight:800;font-size:18px;line-height:1.4}.ingredient.chosen{background:#e7bb52;color:#183b29;border-color:#e7bb52}.flask{position:relative;height:118px}.flask svg{height:100%;width:220px;max-width:100%}.glass{stroke:#e8f3dd;stroke-width:4;fill:#ffffff0b;stroke-linecap:round}.liquid{fill:#76cdb2}.bubble{fill:#d9f9d9}.mixing-now .bubble{animation:rise .3s ease-in-out}.discovered .liquid{fill:#e7bb52}.smoke .liquid{fill:#93aaa0}#discovery-mark{position:absolute;left:50%;top:43%;transform:translate(-50%,-50%);font-size:24px;color:#fffaf0;text-shadow:0 2px 6px #183b29}#reaction{font-size:13px;margin:0;min-height:23px;font-weight:700}.notebook{margin-top:12px}.notebook h2{font-size:14px}.notebook h2 span{font-size:11px;font-weight:400;color:#736651;margin-left:8px}#book{list-style:none;padding:0;margin:0;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}#book li{border:1px solid #dfc895;border-radius:4px;text-align:center;font-size:13px;padding:5px 2px;background:#fff4d9;color:#736651}#book li.found{background:#e4f0dc;color:#183b29;font-weight:800}.controls{min-width:0}.shelf h2{font-size:17px}#inventory{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;margin:0;padding:0;list-style:none}#inventory li{border:1px solid #dfc895;background:#fff4d9;border-radius:5px;text-align:center;font-weight:800;padding:5px 2px;font-size:16px}#inventory li.new{background:#e4f0dc;border-color:#4f8f63}.shelf>p{font-size:11px;margin:6px 0 12px}.form-heading{display:flex;justify-content:space-between;align-items:center;gap:8px;min-height:26px}.form-heading label{font-weight:800;font-size:14px}.text-button{border:0;background:none;color:#2f6844;text-decoration:underline;font-size:11px;padding:4px;cursor:pointer}.text-button:disabled{opacity:.45;cursor:default}.input-row{display:flex;gap:7px}.input-row input{min-width:0;width:100%;border:2px solid #bba773;border-radius:6px;padding:8px;font-size:20px;color:#2b251d;background:#fffdfa}.input-row button{flex-shrink:0}#input-hint{font-size:11px;margin:4px 0}#status{font-size:13px;font-weight:700;min-height:44px;margin:8px 0}.clue{border-left:3px solid #bd8628;background:#fff4d9;padding:8px 10px;font-size:13px;color:#51422b;margin:0}.fiction-note{color:#736651;font-size:13px}#result h2{font-size:21px}#result-copy{font-size:14px}.is-playing #howto,.is-playing #related{display:none}.is-playing .loom-hero{padding-top:0;margin-bottom:10px}.is-playing .loom-hero__rule{margin:5px 0}.is-playing .page-shell{margin-top:12px}.is-playing #game{padding:14px}input:focus-visible,button:focus-visible{outline:3px solid #bd8628;outline-offset:3px}@keyframes rise{50%{transform:translateY(-10px);opacity:.3}}@media(max-width:650px){#intro{display:block}#intro button{margin-top:12px}.lab-body{grid-template-columns:1fr;gap:9px}.workbench{display:grid;grid-template-columns:1fr}.vessel{padding:8px 12px}.stage-label{display:none}.ingredient{font-size:15px;min-width:90px;padding:3px 9px}.flask{height:70px}.flask svg{width:155px}#discovery-mark{font-size:18px}#reaction{font-size:11px;min-height:19px}.notebook{margin-top:7px}.notebook h2{margin:0 0 4px;font-size:12px}#book{grid-template-columns:repeat(5,minmax(0,1fr));gap:4px}#book li{font-size:11px;padding:2px 0}.game-top{margin-bottom:7px}.game-top p{font-size:13px}#inventory{grid-template-columns:repeat(5,minmax(0,1fr));gap:4px}#inventory li{font-size:13px;padding:3px 0}.shelf h2{font-size:14px;margin-bottom:4px}.shelf>p{font-size:10px;margin:4px 0}.input-row input{font-size:18px;padding:6px}.input-row button{padding:7px 12px}#status{min-height:20px;font-size:12px;margin:5px 0}.clue{font-size:11px;padding:5px 8px}.is-playing .loom-kicker{display:none}.is-playing h1{font-size:27px}.is-playing .loom-hero__rule{font-size:11px}.is-playing #game{padding:11px}.is-playing .page-shell{margin-top:8px}.loom-panel{padding:14px}#result h2{font-size:18px}#result-copy{font-size:12px}#result button{padding:7px 12px}}
.is-ready #intro{padding:9px 14px;margin-bottom:10px}.is-ready #intro h2,.is-ready #intro p,.is-ready #form,.is-ready #status,.is-ready #restart{display:none}.is-ready #intro button{padding:7px 14px;margin:0}
.is-ready #howto,.is-ready #related{display:block}
