/* Hana's square: a 5×5 map (258×258) beside a four-tool rail, inside the 520×268 encounter field. */
.square-field {
  display: flex; gap: 10px; align-items: center;
  width: 520px; height: 268px; box-sizing: border-box; padding: 5px 0;
  font-family: var(--font-read); color: var(--ink);
}

/* The map: grass, a path band on row 3, quiet trees top-left, a stage top-right, an entrance bottom-left. */
.square-map {
  position: relative; flex: none; width: 258px; height: 258px; box-sizing: border-box;
  border: 4px solid var(--grass-dark); background: var(--grass);
  outline: 1px solid var(--ink); outline-offset: -1px; box-shadow: inset 2px 2px 0 #b3e38a, inset -2px -2px 0 var(--grass-dark);
}
.square-map::before {
  content: ''; position: absolute; left: 110px; top: 12px; width: 4px; height: 2px; background: #b3e38a; pointer-events: none;
  box-shadow: 2px -2px 0 #b3e38a, 18px 26px 0 var(--grass-dark), 20px 24px 0 var(--grass-dark), 54px 58px 0 #b3e38a,
    56px 56px 0 #b3e38a, 22px 150px 0 var(--grass-dark), 24px 148px 0 var(--grass-dark), -28px 180px 0 #b3e38a,
    -26px 178px 0 #b3e38a, 104px 198px 0 var(--grass-dark), 106px 196px 0 var(--grass-dark), 62px 220px 0 #b3e38a;
}
.square-quiet {
  position: absolute; left: 0; top: 0; width: 100px; height: 100px; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 4px;
  background: var(--grass-dark); border-right: 3px solid var(--finish); border-bottom: 3px solid var(--finish);
  box-shadow: inset 2px 2px 0 var(--grass); outline: 1px solid var(--ink); outline-offset: -1px;
}
.square-quiet__trees { display: flex; gap: 6px; color: var(--ink); }
.square-quiet__word {
  font-size: var(--text-small); line-height: 1.05; text-align: center; color: var(--paper); background: var(--ink);
}
.square-path {
  position: absolute; left: 0; right: 0; top: 100px; height: 50px;
  background: var(--path); border-top: 3px solid #ffecc5; border-bottom: 3px solid #c9a776; box-sizing: border-box;
  outline: 1px solid var(--ink); outline-offset: -1px;
}
.square-path::before {
  content: ''; position: absolute; left: 12px; top: 8px; width: 12px; height: 2px; background: #ffecc5;
  box-shadow: 38px 26px 0 #c9a776, 80px 4px 0 #ffecc5, 130px 28px 0 #c9a776, 178px 6px 0 #ffecc5, 212px 24px 0 #c9a776;
}
.square-stage { position: absolute; right: 4px; top: 4px; width: 42px; height: 42px; }
.square-stage__roof {
  position: absolute; left: 0; right: 0; top: 0; height: 10px; background: var(--vermilion); border: 1px solid var(--ink);
  box-shadow: inset 2px 2px 0 #ff9c7c, inset -2px -2px 0 #a52e2b;
}
.square-stage__roof::after { content: ''; position: absolute; left: 8px; top: 2px; width: 3px; height: 6px; background: var(--paper); box-shadow: 10px 0 0 var(--paper), 20px 0 0 var(--paper); }
.square-stage__deck {
  position: absolute; left: 4px; right: 4px; top: 10px; bottom: 0;
  background: var(--wood); border: 1px solid var(--ink);
  box-shadow: inset 2px 2px 0 #dfa777, inset -2px -5px 0 #815035;
}
.square-stage__deck::before {
  content: ''; position: absolute; left: 4px; top: 2px; width: 2px; height: 22px; background: #815035;
  box-shadow: 10px 0 0 #815035, 20px 0 0 #815035, -4px 0 0 var(--ink), 26px 0 0 var(--ink);
}
.square-stage__deck::after {
  content: ''; position: absolute; left: 8px; right: 8px; bottom: 1px; height: 3px; background: #dfa777;
  border: 1px solid var(--ink);
}
.square-entrance { position: absolute; left: 0; bottom: 6px; width: 50px; height: 38px; }
.square-entrance span { position: absolute; top: 6px; bottom: 0; width: 6px; background: var(--vermilion); border: 1px solid var(--ink); box-shadow: inset 1px 0 0 #ff9c7c, inset -1px -2px 0 #a52e2b; }
.square-entrance span:nth-child(1) { left: 6px; }
.square-entrance span:nth-child(2) { left: 34px; }
.square-entrance span:nth-child(3) { left: 0; top: 0; bottom: auto; width: 46px; height: 6px; }

/* Neighbors trying the square walk the path; a blocked path stops them in red. */
.square-walkers {
  position: absolute; left: 6px; right: 6px; top: 118px; height: 14px;
  display: flex; justify-content: space-around; pointer-events: none;
}
.square-walkers[hidden] { display: none; }
.square-walkers span {
  --coat: var(--reading); --coat-light: var(--sky); --coat-shade: #367399;
  position: relative; width: 14px; height: 14px; box-sizing: border-box;
  clip-path: polygon(0 0, 14px 0, 14px 14px, 8px 14px, 8px 12px, 6px 12px, 6px 14px, 0 14px);
}
/* Tiny map pawns: a square head, a shaded coat and two ink feet, contained in the original 14px marker. */
.square-walkers span::before {
  content: ''; position: absolute; left: 4px; top: 0; width: 6px; height: 6px; background: var(--path); border: 1px solid var(--ink);
  box-shadow: inset 1px 1px 0 var(--paper), inset -1px -1px 0 #c9a776;
}
.square-walkers span::after {
  content: ''; position: absolute; left: 2px; top: 6px; width: 10px; height: 6px; background: var(--coat); border: 1px solid var(--ink);
  box-shadow: inset 2px 1px 0 var(--coat-light), inset -2px -1px 0 var(--coat-shade), -2px 4px 0 -2px var(--ink), 2px 4px 0 -2px var(--ink);
}
.square-walkers span:nth-child(2) { --coat: var(--writing); --coat-light: #d6c4ff; --coat-shade: #70578f; }
.square-walkers span:nth-child(3) { --coat: var(--lantern); --coat-light: #ffe59a; --coat-shade: #c28c32; }
.square-walkers--blocked span:nth-child(n) { --coat: var(--vermilion); --coat-light: #ff9c7c; --coat-shade: #a52e2b; }

.square-grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(5, 50px); grid-template-rows: repeat(5, 50px); }
.square-cell {
  display: grid; place-items: center; width: 50px; height: 50px; padding: 0; margin: 0;
  background: transparent; border: 1px solid var(--grass-dark); color: var(--ink); cursor: pointer;
  transition: background-color .12s;
}
.square-cell:hover { box-shadow: inset 0 0 0 2px var(--paper); }
.square-cell:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; box-shadow: inset 0 0 0 5px var(--paper); }
/* Grades 3–5 need a sign next to the stage: the three cells that count get a red frame. */
.square-field--stage-marked .square-cell[data-stage] {
  box-shadow: inset 0 0 0 1px var(--ink), inset 0 0 0 3px var(--vermilion), inset 0 0 0 4px #ff9c7c;
}
.square-field--stage-marked .square-cell[data-stage]:hover { box-shadow: inset 0 0 0 1px var(--ink), inset 0 0 0 3px var(--vermilion), inset 0 0 0 5px var(--paper); }
.square-item { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--ink); box-sizing: border-box; box-shadow: inset 2px 2px 0 var(--piece-light), inset -2px -3px 0 var(--piece-shade); }
.square-item--bench { background: var(--lantern); --piece-light: #ffe59a; --piece-shade: #c28c32; }
.square-item--sign { background: var(--sky); --piece-light: #d1efff; --piece-shade: var(--sea); }
.square-item--quiet { background: var(--grass); color: var(--grass-dark); --piece-light: #b3e38a; --piece-shade: var(--grass-dark); }
.square-item--quiet .icon { color: var(--ink); }

/* The tool rail: a radio group, one tool per row, each with a picture and a word. */
.square-rail { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-width: 0; height: 258px; }
.square-tool {
  display: flex; align-items: center; gap: 10px; flex: 1 1 0; min-height: 0; padding: 2px 12px; margin: 0;
  background: var(--paper); border: 1px solid var(--ink); color: var(--ink); cursor: pointer;
  font-family: var(--font-read); font-size: var(--text-field); line-height: 1; text-align: left;
  box-shadow: inset 2px 2px 0 var(--white), inset -3px -3px 0 var(--paper-shade);
  transition: transform .1s;
}
.square-tool__pic {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--ink); box-sizing: border-box;
  box-shadow: inset 2px 2px 0 var(--piece-light), inset -2px -3px 0 var(--piece-shade);
}
.square-tool--bench .square-tool__pic { background: var(--lantern); --piece-light: #ffe59a; --piece-shade: #c28c32; }
.square-tool--sign .square-tool__pic { background: var(--sky); --piece-light: #d1efff; --piece-shade: var(--sea); }
.square-tool--quiet .square-tool__pic { background: var(--grass); --piece-light: #b3e38a; --piece-shade: var(--grass-dark); }
.square-tool--remove .square-tool__pic { background: var(--paper-shade); --piece-light: var(--paper); --piece-shade: #d5bc88; }
.square-tool__word { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
.square-tool[aria-checked="true"] { background: var(--ink); color: var(--white); box-shadow: none; transform: translateX(-4px); }
.square-tool[aria-checked="true"] .square-tool__pic { color: var(--ink); border-color: var(--white); }
.square-tool[aria-checked="true"] .square-tool__word::after { content: ' ✓'; }
.square-tool:focus-visible { outline: 3px solid var(--lantern); outline-offset: 2px; }

/* Calm motion: nothing slides or fades. */
.calm .square-field *, .calm .square-field *::before, .calm .square-field *::after { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .square-field *, .square-field *::before, .square-field *::after { transition: none !important; animation: none !important; }
}
