:root {
  --ink: #123b3b;
  --cream: #fff5dc;
  --coral: #f0826e;
  --coral-text: #b8423b;
  --moss: #6e4da8;
  --neutral: #879092;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: linear-gradient(#f7e3b5, #fff5dc);
  color: var(--ink);
  font:
    16px/1.35 "Trebuchet MS",
    sans-serif;
}

button,
a {
  min-height: 44px;
  font: inherit;
}

button {
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff8e9;
  color: var(--ink);
  font-weight: 800;
}

.primary {
  min-height: 48px;
  background: var(--coral);
}

:focus-visible {
  outline: 4px solid #0f7376;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}

.game-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
}

.game-bar a {
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff8e9;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.panel {
  width: min(620px, calc(100% - 28px));
  margin: 5vh auto;
  padding: clamp(20px, 6vw, 46px);
  border: 3px solid var(--ink);
  border-radius: 25px;
  background: #fffdf4;
  box-shadow: 0 8px 0 var(--ink);
  text-align: center;
}

.eyebrow {
  color: var(--moss);
  font-weight: 800;
}
h1 {
  margin: 0.2em;
  font-size: clamp(2rem, 8vw, 4rem);
  line-height: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.opening-preview {
  position: relative;
  width: 176px;
  height: 176px;
  margin: 14px auto;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: #d8c2a1;
}

.preview-patch {
  position: absolute;
  width: 68px;
  height: 68px;
  border: 1px dashed #d6bb89;
  background: var(--cream);
}

.preview-patch.one {
  left: 18px;
  top: 18px;
}
.preview-patch.two {
  right: 18px;
  top: 18px;
}
.preview-patch.three {
  left: 18px;
  bottom: 18px;
}
.preview-patch.four {
  right: 18px;
  bottom: 18px;
}
.preview-ribbon {
  position: absolute;
  border-radius: 7px;
  background: repeating-linear-gradient(45deg, #879092 0 5px, #d9dedc 5px 10px);
}
.preview-ribbon.horizontal {
  left: 18px;
  top: 7px;
  width: 68px;
  height: 8px;
}
.preview-ribbon.vertical {
  right: 7px;
  bottom: 18px;
  width: 8px;
  height: 68px;
}

#play-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 10px;
  width: min(710px, 100%);
  margin: 0 auto;
  padding: 8px 14px 16px;
}

.game-copy {
  width: 100%;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: #fffdf4;
}

.game-copy p {
  margin: 3px 0;
}
.prompt {
  font-weight: 800;
}

.board-wrap {
  position: relative;
  width: 264px;
}

#board {
  position: relative;
  width: 264px;
  height: 264px;
  overflow: hidden;
  border-radius: 22px;
  background: #d8c2a1;
  box-shadow: inset 0 0 0 4px var(--ink);
}

.cell {
  position: absolute;
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border: 1px dashed #d6bb89;
  background: var(--cream);
  font-weight: 900;
}

.cell[data-cell="TL"] {
  left: 28px;
  top: 28px;
}
.cell[data-cell="TR"] {
  left: 132px;
  top: 28px;
}
.cell[data-cell="BL"] {
  left: 28px;
  top: 132px;
}
.cell[data-cell="BR"] {
  left: 132px;
  top: 132px;
}
.cell[data-owner="child"]::after {
  content: "★ You";
  color: #8b2b2f;
}
.cell[data-owner="moss"]::after {
  content: "♣ Moss";
  color: var(--moss);
}

.peg {
  position: absolute;
  z-index: 3;
  width: 16px;
  height: 16px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: #2d7672;
  box-shadow: 0 2px 0 #0d2829;
  pointer-events: none;
}

.p00 {
  left: 20px;
  top: 20px;
}
.p01 {
  left: 124px;
  top: 20px;
}
.p02 {
  left: 228px;
  top: 20px;
}
.p10 {
  left: 20px;
  top: 124px;
}
.p11 {
  left: 124px;
  top: 124px;
}
.p12 {
  left: 228px;
  top: 124px;
}
.p20 {
  left: 20px;
  top: 228px;
}
.p21 {
  left: 124px;
  top: 228px;
}
.p22 {
  left: 228px;
  top: 228px;
}

.edge {
  position: absolute;
  z-index: 2;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.edge::after {
  position: absolute;
  border-radius: 8px;
  background: var(--neutral);
  content: "";
}

.edge.h {
  width: 48px;
  height: 48px;
}
.edge.h::after {
  left: -28px;
  top: 20px;
  width: 104px;
  height: 8px;
}
.edge.v {
  width: 48px;
  height: 48px;
}
.edge.v::after {
  left: 20px;
  top: -28px;
  width: 8px;
  height: 104px;
}
.edge[data-owner="child"]::after {
  background: var(--coral);
}
.edge[data-owner="moss"]::after {
  background: var(--moss);
}
.edge[data-owner="neutral"]::after {
  background: repeating-linear-gradient(45deg, #879092 0 5px, #d9dedc 5px 10px);
}
.h0 {
  left: 56px;
  top: 4px;
}
.h1 {
  left: 160px;
  top: 4px;
}
.h2 {
  left: 56px;
  top: 108px;
}
.h3 {
  left: 160px;
  top: 108px;
}
.h4 {
  left: 56px;
  top: 212px;
}
.h5 {
  left: 160px;
  top: 212px;
}
.v6 {
  left: 4px;
  top: 56px;
}
.v7 {
  left: 108px;
  top: 56px;
}
.v8 {
  left: 212px;
  top: 56px;
}
.v9 {
  left: 4px;
  top: 160px;
}
.v10 {
  left: 108px;
  top: 160px;
}
.v11 {
  left: 212px;
  top: 160px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.actions button {
  flex: 1 1 132px;
}
.actions #next,
.actions #play-again {
  flex-basis: 100%;
}

#session-ribbons {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}

.completed-board {
  display: grid;
  grid-template-columns: repeat(2, 16px);
  gap: 2px;
  padding: 3px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: #d8c2a1;
}

.mini-patch {
  width: 16px;
  height: 16px;
  background: var(--cream);
}
.mini-patch.child {
  background: var(--coral);
}
.mini-patch.moss {
  background: var(--moss);
}

dialog {
  max-width: min(620px, calc(100% - 28px));
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: #fffdf4;
  color: var(--ink);
}

.examples {
  display: flex;
  gap: 8px;
}
.examples figure,
.shared-example {
  flex: 1;
  margin: 0;
  padding: 8px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--cream);
}

.examples figcaption {
  font-size: 0.9rem;
}
.examples b {
  color: var(--coral-text);
  font-size: 1.3rem;
}
.example-board,
.two-patch {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 5px;
  border: 3px dashed #d6bb89;
  background: #fffdf4;
}

.example-board i,
.two-patch i {
  position: absolute;
  display: block;
  border-radius: 4px;
  background: var(--moss);
}

.example-board i:nth-child(1) {
  left: 5px;
  top: 5px;
  width: 58px;
  height: 7px;
}
.example-board i:nth-child(2) {
  left: 5px;
  top: 5px;
  width: 7px;
  height: 58px;
}
.example-board i:nth-child(3) {
  bottom: 5px;
  left: 5px;
  width: 58px;
  height: 7px;
}
.example-board i:nth-child(4) {
  right: 5px;
  top: 5px;
  width: 7px;
  height: 58px;
  background: var(--coral);
}
.third-side i:nth-child(4) {
  display: none;
}
.kept-patch strong {
  position: absolute;
  inset: 17px;
  color: #8b2b2f;
  font-size: 2rem;
  text-align: center;
}

.shared-example {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.two-patch {
  flex: 0 0 126px;
  width: 126px;
  height: 60px;
  margin: 0;
}
.shared-example figcaption {
  min-width: 0;
}
.two-patch i:nth-child(1) {
  left: 4px;
  top: 4px;
  width: 116px;
  height: 7px;
}
.two-patch i:nth-child(2) {
  left: 4px;
  bottom: 4px;
  width: 116px;
  height: 7px;
}
.two-patch i:nth-child(3) {
  left: 4px;
  top: 4px;
  width: 7px;
  height: 48px;
}
.two-patch i:nth-child(4) {
  right: 4px;
  top: 4px;
  width: 7px;
  height: 48px;
}
.two-patch i:nth-child(5) {
  left: 57px;
  top: 4px;
  width: 7px;
  height: 48px;
  background: var(--moss);
}
.two-patch i:nth-child(6),
.two-patch i:nth-child(7) {
  display: none;
}

@media (min-width: 700px) {
  #play-area {
    grid-template-columns: 264px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
  }

  .game-copy {
    grid-column: 2;
  }
  .board-wrap {
    grid-column: 1;
    grid-row: 1 / span 2;
  }
  .actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .game-bar {
    padding: 6px;
  }
  .game-bar a,
  .game-bar button {
    padding: 7px;
  }
  .examples {
    flex-direction: column;
  }
  .examples figure {
    display: grid;
    grid-template-columns: 72px 1fr;
    align-items: center;
    gap: 8px;
  }
  .example-board {
    margin: 0;
  }
}

@media (max-height: 360px) and (min-width: 700px) {
  .game-bar {
    position: absolute;
    z-index: 4;
    top: 0;
    right: 0;
    width: calc(100% - 278px);
    min-height: 48px;
    padding: 3px 6px;
  }

  #play-area {
    max-width: 802px;
    min-height: 264px;
    padding: 0 4px;
  }

  .game-copy {
    min-height: 124px;
    padding: 54px 9px 4px;
  }

  .game-copy p {
    margin: 0 0 2px;
  }
  .actions {
    gap: 5px;
  }
  .actions button {
    flex-basis: 118px;
  }
  #session-ribbons {
    position: absolute;
    top: 157px;
    left: 274px;
    justify-content: flex-start;
    width: 300px;
    margin-top: 0;
  }
  .completed-board {
    grid-template-columns: repeat(2, 12px);
    padding: 2px;
  }
  .mini-patch {
    width: 12px;
    height: 12px;
  }
}

/* Long ribbon strokes are decorative; only the separated native targets receive input. */
.edge::after {
  pointer-events: none;
}
