#activity-root .gh-surface {
  --panel: #fff4d9;
  --ink: #173e54;
  --rim: #bf9057;
  width: min(100%, 1360px);
  display: grid;
  grid-template: "buno activity" "buno feedback" / minmax(0, 1fr) minmax(0, 3.45fr);
  align-content: center;
  align-items: center;
  column-gap: clamp(12px, 2vw, 32px);
}

#activity-root .gh-actor-header {
  grid-area: buno;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-height: none;
  gap: 0;
}

#activity-root .gh-hero {
  display: block;
  width: min(100%, 286px);
  height: auto;
  aspect-ratio: 1;
  filter: drop-shadow(0 9px 7px #3b2a244a);
}

#activity-root .gh-task,
#activity-root .gh-feedback:not(:empty) {
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--rim);
  border-radius: 14px;
  padding: 7px 12px;
}

#activity-root .gh-task {
  max-width: 23ch;
  text-align: center;
  font-size: clamp(17px, 2.15vw, 25px);
  line-height: 1.13;
  font-weight: 500;
}

#activity-root .gh-content { grid-area: activity; }
#activity-root .gh-feedback { grid-area: feedback; justify-self: center; }

.mat-model .model-label,
.tide-map h2,
.ribbon-goal {
  width: fit-content;
  padding: 2px 12px;
  border: 1px solid var(--rim);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: clamp(19px, 2.15vw, 30px);
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
}

/* The reference swatches use the same motifs as the playable strips. */
.mat-model {
  --sample: clamp(22px, 3.5vw, 50px);
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  gap: 5px;
}

.mat-target {
  gap: clamp(4px, 1vw, 11px);
  padding: 4px 6px;
  background: var(--panel);
  border: 1px solid var(--rim);
  box-shadow: 0 4px 10px #6144222b;
}

.mat-target .patch-row {
  gap: 2px;
  padding: 3px;
  border: 1px dashed #a97543;
  border-radius: 7px;
  background: #fffaf1;
}

.sewn-mat {
  --strip-size: clamp(78px, 14svh, 148px);
  --motif: clamp(34px, 5.8vw, 82px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: clamp(8px, 1.45vw, 20px);
  gap: clamp(7px, 1.25vw, 18px);
  margin-top: 10px;
  background: repeating-linear-gradient(0deg, #0000 0 3px, #002d3818 3px 4px), #277e82;
  border: 2px solid #f9d49c;
  box-shadow: inset 0 0 0 3px #1d5e64, 0 5px 12px #61442246;
}

.sewn-block { min-width: 0; gap: clamp(5px, 1vw, 12px); }

.gh-content .strip-select {
  min-width: 0;
  min-height: var(--strip-size) !important;
  padding: 5px;
  border: 2px solid #925120 !important;
  background: repeating-linear-gradient(0deg, #0000 0 3px, #ad692510 3px 4px), #fff2ce !important;
  box-shadow: inset 0 0 0 4px #fffaf1, 0 3px 5px #143c4266;
}

.strip-select .patch-row { gap: clamp(3px, .7vw, 10px); }
.gh-content .mat-target .patch { width: var(--sample) !important; height: var(--sample) !important; }
.gh-content .strip-select .patch { width: var(--motif) !important; height: var(--motif) !important; }

.gh-content .strip-turn {
  width: clamp(48px, 6vw, 88px);
  height: clamp(48px, 9svh, 82px);
  min-width: 48px;
  min-height: 48px;
  border: 1px solid #925120;
  border-radius: 12px;
  color: #5a351e;
  background: linear-gradient(#ffe6a8, #e7ac55) !important;
  box-shadow: inset 0 1px 0 #fff8dc, 0 3px 5px #143c4266;
}

.gh-content .strip-select:focus-visible,
.gh-content .strip-turn:focus-visible { outline-color: #fff6cb; }
.sewn-block[data-mismatch="true"] { outline-color: #ffe19a; outline-offset: 2px; }

/* Two tide maps share the same horizontal scale and the same set of planks. */
.tide-maps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(8px, 1.1vw, 16px); }

.tide-map {
  --span-height: clamp(56px, 10svh, 100px);
  --island-height: clamp(15px, 3svh, 30px);
  --stone: clamp(13px, 1.85vw, 24px);
  --map-padding: clamp(6px, 1.25vw, 17px);
  padding: 0;
  background: none;
}

.tide-board {
  padding: var(--map-padding);
  color: #173e54;
  background: #a9e5df;
  border: 2px solid #357f82;
  border-radius: 16px;
  box-shadow: inset 0 0 0 3px #e2fff4a8, 0 4px 12px #27525a42;
}

.tide-map + .tide-map .tide-board { background: #a4d7e9; border-color: #407690; }
.tide-map h2 { margin: 0 auto 6px; }
.tide-map[data-result] { outline: none; }
.tide-map[data-result="gap"] .tide-board { border-color: #ae710f; }
.tide-map[data-result="connected"] .tide-board { border-color: #528943; }
.tide-result { min-height: 0; font-size: clamp(13px, 1.3vw, 17px); line-height: 1.2; }
.tide-result:not(:empty) { margin: 0 4px 4px; }

.tide-grid {
  grid-template-columns: var(--stone) repeat(var(--columns), minmax(0, 1fr) var(--stone));
  grid-template-rows: var(--span-height) var(--island-height) var(--span-height);
}

.gh-content .tide-edge { min-height: 48px !important; height: 100%; }
.gh-content .tide-edge.dry {
  background: linear-gradient(#f6d69e, #d7ae76) !important;
  box-shadow: inset 0 0 0 1px #95673c80;
}

.gh-content .tide-edge.water { border-color: #347582 !important; background-color: #21728c20 !important; }
.tide-node {
  width: var(--stone);
  height: var(--stone);
  background: radial-gradient(ellipse at 30% 22%, #fff1c4, #cead78 74%);
  border-color: #a07a4f;
  pointer-events: none;
}

.tide-node.reachable { background: #f5c340; box-shadow: 0 0 0 3px #fff4bb; }
.tide-start { background: #73a267; border-color: #41734f; }
.tide-finish { background: #d78950; }
.tide-finish::after { left: 42%; }
.island-link {
  width: var(--stone);
  height: calc(var(--island-height) + var(--span-height));
  background: linear-gradient(90deg, #a98458, #e5ca95 45%, #bea27a);
}
.plank-surface { inset: 18% -2px; }
.gh-content .wooden-plank { width: clamp(80px, 12vw, 166px); height: clamp(52px, 8svh, 75px); }

.shared-planks-label {
  width: fit-content;
  margin: 9px auto 3px;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: clamp(18px, 1.6vw, 22px);
}

/* Ribbon widths and offsets still come from the same 12-unit scale. */
.ribbon-stage {
  --lane: clamp(66px, 12svh, 128px);
  padding: clamp(8px, 1.4vw, 22px);
  gap: clamp(4px, 1.3svh, 15px);
  background: #fcf0d0;
  border: 2px solid #b5834d;
  box-shadow: inset 0 0 0 3px #fff9e9, 0 5px 14px #5b3b253b;
}

.ribbon-row { grid-template-columns: clamp(56px, 7.8vw, 96px) minmax(0, 1fr); min-height: var(--lane); }
.gh-content .start-marker {
  min-width: 0;
  min-height: var(--lane) !important;
  text-align: center;
  font-size: clamp(16px, 1.7vw, 24px) !important;
  padding-inline: 3px 7px !important;
  font-weight: 600;
  border-right-color: #b17923 !important;
  background: #f5dfab;
}

.start-marker > span { writing-mode: horizontal-tb; }
.ribbon-track { height: var(--lane); }
.gh-content .measuring-ribbon {
  --ribbon-height: min(46px, max(20px, calc(var(--lane) * .38)));
  --ribbon-notch: clamp(6px, 1.1vw, 15px);
  top: 0;
  height: 100%;
  min-height: 48px !important;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none;
  filter: drop-shadow(0 3px 2px #57342050);
}

.ribbon-row .blue { --silk-light: #79ddf5; --silk-mid: #2798cc; --silk-dark: #084b74; }
.ribbon-row .coral { --silk-light: #ffc5a8; --silk-mid: #e9786c; --silk-dark: #a53d39; }
.ribbon-row .gold { --silk-light: #ffecaa; --silk-mid: #f2b63f; --silk-dark: #a06512; }

/* Keep the cut edge at x=0 and both tail points at x=100% while the fabric dips in between. */
.measuring-ribbon::before {
  content: '';
  position: absolute;
  inset: 50% 0 auto;
  height: calc(var(--ribbon-height) * 1.37);
  transform: translateY(-50%);
  clip-path: polygon(
    0 15%, 8% 14%, 16% 10%, 24% 5%, 32% 3%, 40% 6%, 48% 11%,
    56% 18%, 64% 24%, 72% 27%, 80% 26%, 88% 22%, 95% 17%, 100% 15%,
    calc(100% - var(--ribbon-notch)) 50%,
    100% 85%, 95% 87%, 88% 92%, 80% 96%, 72% 97%, 64% 94%, 56% 88%,
    48% 81%, 40% 76%, 32% 73%, 24% 75%, 16% 80%, 8% 84%, 0 85%
  );
  background:
    linear-gradient(90deg, var(--silk-dark) 1px, #fff0 1px),
    repeating-linear-gradient(0deg, #fff0 0 2px, #fff1 2px 3px),
    radial-gradient(ellipse 34% 59% at 29% 12%, #fff9, #fff0),
    radial-gradient(ellipse 38% 60% at 73% 78%, #fff8, #fff0),
    linear-gradient(180deg, var(--silk-mid) 5%, var(--silk-light) 23%, var(--silk-mid) 43%,
      var(--silk-dark) 67%, var(--silk-mid) 84%, var(--silk-dark));
}

.gh-content .measuring-ribbon[aria-pressed="true"]:not(:focus-visible) {
  outline: 0;
  filter: drop-shadow(0 0 2px #fffcdf) drop-shadow(0 0 3px #865419);
}

.measuring-ribbon::after {
  display: none;
}

.ribbon-stage[data-checked="ends"] .measuring-ribbon::after {
  display: block;
  inset: 50% 0 auto auto;
  height: calc(var(--ribbon-height) + 16px);
  transform: translateY(-50%);
  border: 0;
  border-right: 2px dashed #744a24;
}

.gh-content .ribbon-choice.blue { --thread-light: #2a7e9e; --thread: #155775; }
.gh-content .ribbon-choice.coral { --thread-light: #b65b4c; --thread: #873429; }
.gh-content .ribbon-choice.gold { --thread-light: #f9d774; --thread: #d6a337; }
.gh-content .ribbon-choice {
  background: linear-gradient(155deg, var(--thread-light), var(--thread)) !important;
}

.ribbon-goal {
  margin: 10px auto 8px;
  font-size: clamp(21px, 2.15vw, 30px);
}

.gh-content .ribbon-choices button {
  flex: 1 1 0;
  min-width: 48px;
  min-height: clamp(48px, 8svh, 78px);
  max-width: 176px;
  padding: 4px 5px;
  font-size: clamp(17px, 2.1vw, 26px);
  font-weight: 600;
  border: 1px solid #815326;
  box-shadow: inset 0 1px 2px #fff7, 0 3px 6px #785c3944;
}

.gh-content .ribbon-choices button[aria-pressed="true"] { outline-color: #7b4928; outline-offset: 1px; }

@media (orientation: portrait) {
  #activity-root .gh-surface {
    width: min(100%, 660px);
    grid-template: "buno" "activity" "feedback" / minmax(0, 1fr);
    row-gap: 4px;
  }

  #activity-root .gh-actor-header { flex-direction: row; gap: 9px; }
  #activity-root .gh-hero { width: clamp(103px, 30vw, 198px); }
  #activity-root .gh-task { text-align: left; }
  .tide-maps { grid-template-columns: minmax(0, 1fr); }
  .tide-map { --span-height: clamp(48px, 6.1svh, 74px); --stone: clamp(13px, 3.4vw, 22px); }
  .mat-model { --sample: clamp(17px, (100vw - 104px) / 10, 42px); }
  .sewn-mat { --motif: clamp(41px, 8vw, 65px); }
  .ribbon-stage { --lane: clamp(57px, 10svh, 112px); }
}

@media (orientation: portrait) and (max-width: 560px) {
  .sewn-mat { --strip-size: clamp(58px, 8.8svh, 100px); --motif: clamp(36px, 12vw, 60px); grid-template-columns: 1fr; }
  .mat-target { gap: 4px; }
  .tide-map { --island-height: 14px; --map-padding: 5px 8px; }
  .ribbon-choices { gap: 7px; }
}

@media (orientation: portrait) and (min-width: 620px) and (max-height: 1000px) {
  .tide-maps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tide-map { --stone: 15px; --span-height: clamp(48px, 9svh, 88px); }
}

@media (orientation: portrait) and (max-height: 900px) {
  #activity-root[data-adventure="tide-paths"] .gh-surface { row-gap: 2px; }
  #activity-root[data-adventure="tide-paths"] .gh-content { padding-block: 2px; }
  #activity-root[data-adventure="tide-paths"] .gh-feedback { margin-top: 3px; }
  .tide-map { --span-height: 48px; --island-height: 8px; --map-padding: 3px 8px; }
  .tide-map h2 { margin-bottom: 5px; }
  .tide-result:not(:empty) { margin-bottom: 2px; }
}

@media (orientation: portrait) and (max-height: 800px) {
  #activity-root .gh-hero { width: 89px; }
  #activity-root .gh-feedback:not(:empty) { padding-block: 4px; }
  .sewn-mat { --strip-size: 55px; }
  .gh-content .strip-turn { height: 55px; }
  .tide-maps { gap: 5px; }
  .shared-planks-label { display: none; }
  .plank-tray { margin-top: 3px; }
  .gh-content .wooden-plank { height: 48px; min-height: 48px !important; }
}

@media (orientation: landscape) and (max-height: 600px) {
  .tide-map { --span-height: clamp(48px, 10svh, 62px); --island-height: 12px; }
  .ribbon-stage { --lane: clamp(48px, 11svh, 66px); }
}

@media (orientation: landscape) and (max-height: 450px) {
  #activity-root .gh-surface { grid-template-columns: clamp(88px, 13vw, 132px) minmax(0, 1fr); column-gap: 7px; }
  #activity-root .gh-task,
  #activity-root .gh-feedback:not(:empty) { font-size: 14px; padding: 4px 6px; }
  #activity-root .gh-hero { width: min(100%, 100px); }
  .sewn-mat { --strip-size: 49px; --motif: 34px; padding: 6px; margin-top: 5px; gap: 5px; }
  .mat-model { --sample: 22px; flex-direction: row; }
  .tide-map { --stone: 11px; --span-height: 48px; --island-height: 8px; --map-padding: 3px 4px; }
  .tide-maps { gap: 5px; }
  .shared-planks-label { display: none; }
  .plank-tray { margin-top: 4px; }
  .gh-content .wooden-plank { height: 48px; min-height: 48px !important; }
  .ribbon-stage { --lane: 48px; padding: 0 4px; gap: 1px; }
  .ribbon-goal { margin: 2px auto; padding-block: 1px; font-size: 19px; }
}
