@font-face {
  font-family: "Bakudai";
  src: url("assets/fonts/bakudai-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Fondamento";
  src: url("assets/fonts/fondamento-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink-edge: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20120%2076%22%3E%3Cdefs%3E%3Cfilter%20id%3D%22bleed%22%20x%3D%22-10%25%22%20y%3D%22-15%25%22%20width%3D%22120%25%22%20height%3D%22130%25%22%3E%3CfeGaussianBlur%20stdDeviation%3D%222.4%22%2F%3E%3C%2Ffilter%3E%3ClinearGradient%20id%3D%22wash%22%20x2%3D%22.35%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23d3c7bb%22%20stop-opacity%3D%22.38%22%2F%3E%3Cstop%20offset%3D%22.5%22%20stop-color%3D%22%23f5eee7%22%20stop-opacity%3D%22.2%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23c9bbae%22%20stop-opacity%3D%22.4%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Cpath%20d%3D%22M8%206%2024%205%2041%207%2057%205%2070%206%2090%204%20107%206q8%200%208%209l-2%2013%202%2017-1%2017q0%207-8%207l-18-1-14%202-15-1-17%202-15-2-16%201q-7-1-7-8L5%2048l1-17-2-15q-1-8%204-10Z%22%20fill%3D%22url(%23wash)%22%20stroke%3D%22%23000%22%20stroke-width%3D%225%22%20stroke-opacity%3D%22.22%22%20filter%3D%22url(%23bleed)%22%2F%3E%3Cpath%20d%3D%22M7%206%2024%205%2038%206%2057%205%2072%206%2088%205%20107%206q7%200%208%208l-1%2016%201%2016-1%2017q0%206-7%206l-19-1-14%202-16-1-16%201-16-1-15%201q-7-1-7-7l1-15-1-17V16q-1-7%203-10Z%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%2F%3E%3Cpath%20d%3D%22M7%209%206%2022%207%2031M15%206l11%201m32-2%2016%201m34%201%206%205m1%2038-1%2013M86%2069l14-1M35%2070l-10-1M6%2054l1%209%203%204%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-opacity%3D%22.5%22%20stroke-width%3D%221.9%22%20stroke-linecap%3D%22round%22%2F%3E%3C%2Fsvg%3E");
  --ink-arrow: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2040%2024'%3E%3Cpath%20fill%3D'%23000'%20d%3D'M1%2012C8%2011.65%2015%2011.2%2021%2010.96C25.1%2010.79%2028%2010.62%2030%2010.45C28.1%208.4%2026.5%206.45%2024.1%204.1C29.5%206.1%2034.6%209.15%2038.8%2012C34.4%2015.18%2029.7%2018.06%2024.05%2020.1C26.15%2017.78%2028.15%2015.51%2030%2013.48C26.5%2013.38%2024.4%2013.29%2021%2013.13C14.2%2012.82%207.3%2012.48%201%2012Z'%2F%3E%3C%2Fsvg%3E");
  --ink-counter-edge: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20104%2068%22%3E%3Cpath%20d%3D%22M5%208%208%204l10%201%208-2%2011%201%209-1%208%201%2012-1%2011%201%2010-1%2010%202%203%205-1%208%202%207-2%209%202%2010-1%2012-2%206-6%203-12-1-12%201-9-1-13%201-8-1-13%201-10-2-8%201-4-5%201-11-2-9%201-10-1-10%201-8Z%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%224.8%22%20stroke-linejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22m5%208%2012-1%208%201%2016-2%2013%201%209-2%2011%202%2011-1%2013%202M4%2025l2-8-1-8m-1%2034%202%208-1%209%209%201%2010%202m63-1%209-1%204-9m-2-39%201%209-1%2015%201%207%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-opacity%3D%22.65%22%20stroke-width%3D%221.5%22%20stroke-linecap%3D%22round%22%2F%3E%3Cpath%20d%3D%22M8%203l13%201%2012-1m25%201%2014-1%2013%201M9%2066l12-1%2010%201m19%200%2011-2%2013%201m14%201%209-2%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%22.8%22%20stroke-linecap%3D%22round%22%2F%3E%3C%2Fsvg%3E");
  --paper: #e7e7e7;
  --card: #f3f3f3;
  --ink: #272727;
  --muted: #5c5c5c;
  --hairline: #cdcdcd;
  --forest: #2d2d2d;
  --forest-dark: #1e1e1e;
  --jade: #cecece;
  --red: #505050;
  --serif: "Bakudai", "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Bakudai", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 12% 0%, #f4f4f4 0%, transparent 45%), var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
}
button { color: inherit; font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, summary:focus-visible { outline: 2px solid #606060; outline-offset: 3px; }
button, summary { touch-action: manipulation; }
h1, h2, p, ul { margin: 0; }

.shell { width: min(1150px, calc(100% - 64px)); margin-inline: auto; }
.masthead {
  position: relative;
  isolation: isolate;
  display: flex;
  justify-content: space-between;
  align-items: end;
  min-height: 226px;
  margin-top: 27px;
  padding: 23px 33px 28px;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: #e0e0e0;
}
.masthead::before, .masthead::after { position: absolute; z-index: -1; inset: 0; content: ""; }
.masthead::before {
  left: 21%;
  background: url("assets/ink-mountain-pass.webp") 57% 72% / cover no-repeat;
  opacity: .94;
}
.masthead::after {
  background: linear-gradient(90deg, #eeeeee 0%, #eeeeee 18%, #eeeeeef5 30%, #eeeeee7a 47%, #e4e4e41c 68%);
}
.byline { display: flex; align-items: center; gap: 10px; color: #545454; font-size: 13px; letter-spacing: .16em; }
.seal {
  display: grid;
  width: 27px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 4px;
  background: var(--red);
  color: #f3f3f3;
  font-family: var(--serif);
  letter-spacing: 0;
}
.masthead h1 { margin-block: 9px 3px; font: 700 clamp(2.5rem, 5.4vw, 4.6rem)/1.12 var(--serif); letter-spacing: .1em; }
.masthead-copy > p { color: #4b4b4b; letter-spacing: .07em; }
.journey {
  flex: 0 0 auto;
  display: grid;
  gap: 0;
  min-width: 106px;
  padding: 9px 13px;
  border: 1px solid #ecececbf;
  border-radius: 8px;
  background: #f3f3f3eb;
}
.journey span { color: var(--muted); font-size: 12px; }
.journey strong { font: 650 20px/1.4 var(--sans); font-variant-numeric: tabular-nums; }
.chapters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-block: 15px; }
.chapter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #f1f1f1;
  text-align: left;
  font-family: var(--serif);
  font-weight: 700;
}
.chapter:hover { border-color: #8e8e8e; }
.chapter[data-chapter="6"]:not([aria-current="true"]) { border-color: #acacac; background: #e6e6e6; color: #525252; }
.chapter[aria-current="true"] { border-color: var(--forest); background: var(--forest); color: #f5f5f5; }
.chapter-mark {
  flex: 0 0 25px;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid #a0a0a0;
  border-radius: 50%;
  font-weight: 400;
  font-size: 12px;
}
.chapter[aria-current="true"] .chapter-mark { border-color: #9e9e9e; color: #d2d2d2; }
.layout { display: grid; grid-template-columns: minmax(0, 2.05fr) minmax(264px, 1fr); gap: 15px; align-items: start; }

.game-panel {
  display: grid;
  gap: 15px;
  min-width: 0;
  padding: clamp(15px, 3vw, 31px);
  border: 1px solid #3f3f3f;
  border-radius: 14px;
  background: radial-gradient(ellipse at 48% 26%, #3b3b3b 0, transparent 70%), var(--forest);
  color: #f1f1f1;
  box-shadow: 0 9px 23px #2a2a2a16;
}
.game-panel button:focus-visible { outline-color: #cbcbcb; }
.level-header { display: flex; align-items: end; justify-content: space-between; gap: 9px; }
.eyebrow { color: #c7c7c7; font-size: 12px; letter-spacing: .14em; }
.level-header h2 { margin-top: 2px; font: 700 clamp(1.62rem, 3.5vw, 2.45rem)/1.25 var(--serif); }
.enemies-count { flex-shrink: 0; color: #dedede; font-size: 13px; font-variant-numeric: tabular-nums; }
.beat { display: grid; gap: 5px; }
.beat-label { display: flex; justify-content: space-between; gap: 10px; color: #dddddd; font-size: 13px; font-variant-numeric: tabular-nums; }
.beads { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; }
.beads i { height: 5px; border-radius: 9px; background: #5c5c5c; }
.beads i:last-child { background: #676767; }
.beads i.is-spent { background: #c7c7c7; }
.beads i:last-child.is-spent { background: #b9b9b9; }
.board-stage { position: relative; display: grid; justify-items: center; padding: 12px; border-radius: 10px; background: #1d1d1d80; }
.board {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  --tile-gap: clamp(2px, .6vw, 5px);
  gap: var(--tile-gap);
  width: min(100%, var(--board-width, 420px));
  touch-action: manipulation;
  user-select: none;
}
.tile {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  place-items: center;
  padding: 0;
  border: 1px solid #8c8c8c31;
  border-radius: 5px;
  background: #434343;
  color: #f1f1f1;
}
.tile.is-alt { background: #494949; }
.tile[data-terrain="#"] {
  border-color: #414141;
  background: repeating-linear-gradient(135deg, #292929, #292929 5px, #2e2e2e 5px, #2e2e2e 7px);
}
.tile[data-terrain="I"] { border-color: #b9b9b9aa; background: #5f5f5f; color: #eeeeee; }
.tile[data-terrain="M"] { border-color: #9c9c9c; background: #565656; color: #e9e9e9; }
[data-patrol="A"] { --patrol-color: #c5c5c5; }
[data-patrol="B"] { --patrol-color: #d1d1d1; }
[data-patrol="C"] { --patrol-color: #cacaca; }
[data-patrol="D"] { --patrol-color: #bdbdbd; }
[data-patrol="E"] { --patrol-color: #dbdbdb; }
[data-gate="1"] { --gate-color: #cfcfcf; }
[data-gate="2"] { --gate-color: #cccccc; }
[data-gate="3"] { --gate-color: #c4c4c4; }
[data-gate="4"] { --gate-color: #cfcfcf; }
[data-gate="5"] { --gate-color: #bdbdbd; }
[data-gate="6"] { --gate-color: #d7d7d7; }
[data-gate="7"] { --gate-color: #d3d3d3; }
[data-gate="8"] { --gate-color: #c1c1c1; }
[data-gate="9"] { --gate-color: #d1d1d1; }
.tile[data-portal] {
  border-color: var(--gate-color, #a1a1a1);
  background: color-mix(in srgb, var(--gate-color, #a1a1a1) 28%, #303030);
  color: var(--gate-color, #e6e6e6);
}
.gate-layer {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.portal-connection, .portal-endpoint, .portal-direction {
  fill: none;
  stroke: var(--gate-color, #cfcfcf);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 1.5px #222222);
}
.portal-connection {
  stroke-width: 2.5;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.portal-direction { stroke-linecap: round; stroke-linejoin: round; }
.portal-endpoint { fill: #37373770; }
.tile.is-patrol-next::after {
  position: absolute;
  inset: auto auto 4px 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--patrol-color);
  content: "";
  pointer-events: none;
}
.patrol-link {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: calc(100% + var(--tile-gap) + 2px);
  height: 0;
  border-top: 1px solid var(--patrol-color);
  transform: rotate(var(--bearing, 0deg)) translateY(var(--lane, 0px));
  transform-origin: 0 0;
  pointer-events: none;
}
.patrol-link::after {
  position: absolute;
  top: -1px;
  left: 50%;
  width: 6px;
  height: 6px;
  border: solid var(--patrol-color);
  border-width: 1.5px 1.5px 0 0;
  transform: translate(-50%, -50%) rotate(45deg);
  content: "";
}
.patrol-link[data-dir="D"] { --bearing: 90deg; }
.patrol-link[data-dir="L"] { --bearing: 180deg; }
.patrol-link[data-dir="U"] { --bearing: 270deg; }
.patrol-jump, .patrol-trace {
  position: absolute;
  z-index: 2;
  top: 3px;
  left: calc(3px + var(--mark-offset, 0) * 8px);
  width: 7px;
  height: 7px;
  border: 1px dashed var(--patrol-color, #e0e0e0);
  border-radius: 50%;
  pointer-events: none;
}
.patrol-jump { box-shadow: 0 0 0 1px #222222a0; }
.patrol-trace { border-style: solid; background: var(--patrol-color, #e0e0e0); }
.tile.is-adjacent { cursor: pointer; }
.tile.is-preview { background: #757575; }
.tile.is-destination { z-index: 1; outline: 2px solid #d4d4d4; outline-offset: 1px; }
.tile.is-focus { z-index: 2; }
.piece {
  position: relative;
  z-index: 1;
  display: grid;
  width: 74%;
  max-width: 46px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #d9d9d980;
  border-radius: 50%;
  background: #525252;
  color: #f3f3f3;
  font: 700 clamp(.75rem, 3.4vw, 1.29rem)/1 var(--serif);
  box-shadow: 0 2px 5px #15151568;
  pointer-events: none;
}
.piece.player { border-color: #e8e8e8; background: var(--jade); color: #2f2f2f; }
.piece.mounted { border: 2px solid #b9b9b9; background: #dadada; color: #313131; }
.tile-glyph { font: 700 clamp(.7rem, 2.6vw, 1.12rem)/1 var(--serif); pointer-events: none; }
.patrol-arrow { position: absolute; right: 2px; bottom: 0; z-index: 2; color: var(--patrol-color); font: 700 .7rem/1.2 var(--sans); }
.clear-banner {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 11px;
  border-radius: 10px;
  background: #202020ec;
  color: #ececec;
}
.clear-banner > span { font: 700 clamp(1.45rem, 4vw, 2.1rem)/1.3 var(--serif); letter-spacing: .12em; }
.primary-button { min-height: 42px; padding-inline: 15px; border: 1px solid #e4e4e4; border-radius: 7px; background: var(--jade); color: #313131; font-weight: 700; }
.primary-button:hover { background: #dfdfdf; }
.status { min-height: 2.85em; align-content: center; padding: 5px 10px; border-radius: 6px; background: #1e1e1e92; color: #e5e5e5; font-size: 13px; }
.status[data-tone="error"] { background: #3b3b3b; color: #ebebeb; }
.status[data-tone="success"] { background: #4f4f4f; color: #f5f5f5; }
.controls, .directions, .actions { display: flex; align-items: center; gap: 6px; }
.controls { justify-content: space-between; flex-wrap: wrap; gap: 9px; }
.directions button, .actions button {
  min-width: 41px;
  min-height: 41px;
  padding: 5px 8px;
  border: 1px solid #848484;
  border-radius: 7px;
  background: #414141;
  color: #f2f2f2;
}
.directions button { font-size: 20px; line-height: 1; }
.actions button { font-size: 13px; white-space: nowrap; }
.directions button:hover:not(:disabled), .actions button:hover:not(:disabled) { background: #5a5a5a; }
.actions button:disabled, .directions button:disabled { opacity: .55; }
kbd { margin-left: 3px; color: #d9d9d9; font: 11px/1 monospace; }

.sidebar { display: grid; gap: 11px; }
.paper-card { min-width: 0; padding: 15px 17px; border: 1px solid var(--hairline); border-radius: 11px; background: var(--card); }
.paper-card h2, .rules summary { font: 700 18px/1.35 var(--serif); }
.level-list { display: grid; gap: 5px; margin-top: 9px; }
.level-option {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}
.level-option:hover { background: #e7e7e7; }
.level-option[aria-current="true"] { border-color: #c4c4c4; background: #e9e9e9; font-weight: 700; }
.level-id, .level-complete { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.level-complete { color: #4e4e4e; }
.kill-order { display: grid; grid-template-columns: repeat(var(--targets), minmax(0, 1fr)); gap: 4px; padding: 0; list-style: none; }
.kill-order li { display: grid; justify-items: center; gap: 1px; padding-block: 4px; border-top: 1px solid #d0d0d0; color: #5c5c5c; }
.kill-order small { font-size: 11px; }
.kill-order b { color: #494949; font: 700 14px/1.2 var(--serif); }
.field-notes p { margin-top: 7px; color: #4e4e4e; font-size: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 11px; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.legend-icon { display: grid; place-items: center; min-width: 20px; height: 20px; border-radius: 4px; background: #e5e5e5; color: #323232; font: 700 12px/1 var(--serif); }
.legend-icon[data-icon="enemy"] { background: #dcdcdc; color: #424242; }
.legend-icon[data-icon="portal"] { background: #dedede; color: #454545; }
.legend-icon[data-icon="ice"] { background: #e6e6e6; color: #494949; }
.legend-icon[data-icon="horse"] { background: #e2e2e2; color: #4c4c4c; }
.rules summary { cursor: pointer; }
.rules ul { display: grid; gap: 5px; margin-top: 8px; padding-inline-start: 1.15rem; font-size: 13px; color: #4f4f4f; }
.rules > p:not(:empty) { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--hairline); color: #4f4f4f; font-size: 13px; }
footer { display: flex; justify-content: space-between; gap: 12px; padding-block: 14px 20px; color: var(--muted); font-size: 12px; }

@media (max-width: 820px) {
  .shell { width: calc(100% - 36px); }
  .masthead { min-height: 182px; margin-top: 15px; }
  .chapter { padding-inline: 7px; gap: 5px; font-size: 13px; }
  .chapter-mark { flex-basis: 21px; }
  .layout { grid-template-columns: minmax(0, 1.8fr) minmax(225px, 1fr); gap: 10px; }
}
@media (max-width: 620px) {
  .shell { width: calc(100% - 22px); }
  .masthead { min-height: 151px; margin-top: 10px; padding: 15px 13px; }
  .masthead::before { left: 1%; background-position: 63% 62%; }
  .masthead::after { background: linear-gradient(90deg, #eeeeeef9, #eeeeeee0 34%, #eeeeee1c 100%); }
  .masthead h1 { font-size: clamp(1.82rem, 8vw, 3rem); letter-spacing: .03em; }
  .masthead-copy > p, .byline { font-size: 12px; }
  .journey { position: absolute; top: 11px; right: 11px; min-width: auto; padding: 4px 7px; }
  .journey span { font-size: 10px; }
  .journey strong { font-size: 15px; }
  .chapters { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-block: 8px; }
  .chapter { justify-content: center; gap: 4px; min-height: 44px; padding: 5px 2px; font-size: clamp(.68rem, 2.9vw, .8rem); text-align: center; }
  .chapter-mark { width: 19px; font-size: 10px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .game-panel { gap: 9px; padding: 12px; }
  .board-stage { padding: 7px; }
  .status { min-height: 2.7em; }
  .controls { gap: 5px; }
  .directions, .actions { gap: 4px; }
  .directions button { min-width: 40px; min-height: 44px; }
  .actions button { min-width: 43px; }
  .actions kbd { display: none; }
}

/* Solvekoban's compact shell, with game-specific information and board art. */
.game-page {
  --ui-dialog-title: 24px;
  --ui-section-title: 19px;
  --ui-control: 19px;
  --ui-main-title: 22px;
  --ui-alias-title: 18px;
  --surface: #fcfcfc;
  --panel-paper: #dce4e8;
  --ink-panel-edge: url('assets/ink-panel-frame.svg');
  --ink-dialog-edge: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='76' viewBox='0 0 120 76'%3E%3Cpath d='M7 6 24 5 38 6 57 5 72 6 88 5 107 6q7 0 8 8l-1 16 1 16-1 17q0 6-7 6l-19-1-14 2-16-1-16 1-16-1-15 1q-7-1-7-7l1-15-1-17V16q-1-7 3-10Z' fill='%23f8f8f8' stroke='%23000' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M7 9 6 22 7 31M15 6l11 1m32-2 16 1m34 1 6 5m1 38-1 13M86 69l14-1M35 70l-10-1M6 54l1 9 3 4' fill='none' stroke='%23000' stroke-opacity='.5' stroke-width='1.9' stroke-linecap='round'/%3E%3C/svg%3E");
  --line: #d3d3d3;
  --paper: #f8f8f8;
  --ink: #3c3c3c;
  --muted: #6b6b6b;
  --control-paper: radial-gradient(ellipse at 27% 26%, #f5eee7, #eee5dc 68%, #e3d8ce);
  --control-hover: radial-gradient(ellipse at 27% 26%, #f0e7de, #e6dacf 68%, #dccfc2);
  --control-current: radial-gradient(ellipse at 27% 26%, #e7dcd0, #d9c9ba 72%, #d2c1b1);
  min-width: 280px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  font-synthesis: none;
}
.game-page button:not(.tile) {
  position: relative;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid #000;
  border-radius: 6px 8px 7px 5px;
  overflow: hidden; /* Clip the ink border image to the button's rounded edge. */
  background: var(--control-paper);
  color: #000;
  transition: background .14s, transform .14s;
  -webkit-tap-highlight-color: transparent;
}
.game-page button:not(.tile)::before {
  position: absolute;
  inset: -1px;
  border-image: var(--ink-edge) 15 fill / 6px;
  content: "";
  pointer-events: none;
}
.game-page button:not(.tile):hover:not(:disabled) { background: var(--control-hover); }
.game-page button:not(.tile):active:not(:disabled) { transform: translateY(1px); }
.game-page button:not(.tile):disabled { border-style: dashed; background: #f6f1ec; opacity: 1; }
.game-page button:not(.tile):disabled::before { border-image: none; }
.game-page :is(button, .board):focus-visible { outline: 3px solid #000; outline-offset: 3px; }
.game-page svg { display: block; }
.game-page button svg { pointer-events: none; }
.game-page output { font-variant-numeric: tabular-nums; }
.game-page .shell {
  width: min(1180px, 100%);
  margin: auto;
  padding: 28px 32px max(24px, env(safe-area-inset-bottom));
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 30px;
  margin-bottom: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-seal {
  display: block;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.brand-seal img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-name { min-width: 0; }
.brand-name h1 { margin: 0 0 3px; font-size: 32px; line-height: 1.08; letter-spacing: -.045em; font-weight: 750; white-space: nowrap; }
.brand-name p { color: #6c6c6c; font-size: 14px; font-weight: 500; letter-spacing: .04em; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.game-page .header-actions .header-icon {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
}
.header-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ink-arrow {
  display: inline-block;
  flex: none;
  width: 22px;
  height: 16px;
  background: var(--ink-arrow) center / contain no-repeat;
  vertical-align: middle;
}
.arrow-left .ink-arrow { transform: rotate(180deg); }
.arrow-up .ink-arrow { transform: rotate(-90deg); }
.arrow-down .ink-arrow { transform: rotate(90deg); }
.dpad .ink-arrow { width: 26px; height: 18px; }

.play-area { display: grid; grid-template-columns: minmax(0, 1fr) 278px; gap: 22px; align-items: start; }
.game-page .game-panel {
  position: relative;
  display: block;
  min-width: 0;
  padding: 20px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--panel-paper);
  color: var(--ink);
  box-shadow: none;
}
.board-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 17px; }
.level-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 9px; min-width: 0; }
.game-page .eyebrow { color: var(--ink); font-size: 17px; line-height: 1.5; letter-spacing: .04em; text-wrap: balance; }
.level-heading h2 { margin: 0; font-size: var(--ui-main-title); font-weight: 650; line-height: 1.35; letter-spacing: -.025em; overflow-wrap: anywhere; }
.level-arrows { display: flex; gap: 6px; flex: none; }
.game-page .level-arrows button { width: 44px; padding: 5px; }
.game-page .board-stage { display: grid; place-items: center; width: 100%; min-width: 0; padding: 0; background: transparent; }
.board-frame {
  position: relative;
  width: 100%;
  max-width: 740px;
  margin: auto;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  box-shadow: none;
}
.game-page .board {
  position: relative;
  isolation: isolate;
  width: 100%;
  box-shadow: none;
  --tile-gap: 2px;
  border-radius: 5px;
  touch-action: none;
  -webkit-user-select: none;
}
.game-page .tile { border-radius: 4px; }
.game-page .tile .piece, .game-page .tile .tile-glyph { position: relative; z-index: 3; }
.game-page .tile .patrol-arrow, .game-page .tile.is-destination { z-index: 4; }
.game-page .tile.is-destination { outline-offset: -2px; }

.result-overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  border-radius: inherit;
  background: #f6f6f66e;
}
.result-card {
  display: grid;
  justify-items: center;
  gap: 5px;
  width: min(290px, 100%);
  padding: clamp(9px, 2vw, 20px);
  border: 7px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
}
.result-title { font: 750 clamp(1.13rem, 4vw, 1.8rem)/1.2 var(--serif); }
.result-card p { max-width: 26ch; color: #454545; font-size: 16px; line-height: 1.5; }
.result-card p:empty, .result-actions:not(:has(button:not([hidden]))) { display: none; }
.result-actions { display: flex; justify-content: center; gap: 7px; margin-top: 2px; }
.game-page .result-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 74px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 700;
}
.result-actions .ink-arrow { width: 16px; }

.side-panel { display: grid; min-width: 0; gap: 16px; }
.side-card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel-paper); }
.side-card h2 { margin: 0; font-size: var(--ui-alias-title); font-weight: 650; line-height: 1.6; }
.step-counter {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  justify-items: center;
  gap: 7px 4px;
  margin: 12px 0 0;
  padding: 12px 8px;
  border-radius: 6px 8px 7px 5px;
  background: var(--control-paper);
  list-style: none;
}
.step-counter::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  border: 1px solid transparent;
  border-image: var(--ink-counter-edge) 10 / 6px;
  pointer-events: none;
  content: "";
}
.step-counter li {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: min(100%, 34px);
  aspect-ratio: 1;
  color: #000;
  font: 750 25px/1 var(--serif);
}
.step-counter li:is(.is-current, [aria-current="step"])::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  border: 1px solid #000;
  border-radius: 3px 5px 4px 3px;
  background: var(--control-current);
  content: "";
  transform: rotate(-7deg);
}
.game-page .controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.dpad {
  display: grid;
  grid-template: repeat(3, 46px) / repeat(3, 46px);
  gap: 4px;
  justify-content: center;
}
.game-page .dpad button:not(.tile) {
  min-width: 0;
  min-height: 46px;
  padding: 0;
}
.dpad .up { grid-area: 1 / 2; }
.dpad .left { grid-area: 2 / 1; }
.dpad .right { grid-area: 2 / 3; }
.dpad .down { grid-area: 3 / 2; }
.game-page .actions { display: block; min-width: 0; }
.secondary-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.game-page .secondary-actions button:not(.tile) { display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; height: 48px; min-height: 48px; padding: 8px 2px; font-size: var(--ui-control); white-space: nowrap; }
.game-page kbd { margin: 0; padding: 1px 3px; border: 1px solid currentColor; border-radius: 3px; color: inherit; font: 11px/1.3 ui-monospace, monospace; }

.game-page :is(.levels-dialog, .settings-dialog, .help-dialog) {
  width: min(860px, calc(100% - 40px));
  max-height: min(88dvh, 940px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 7px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}
.game-page :is(.levels-dialog, .settings-dialog, .help-dialog)::backdrop { background: #3c3c3c6b; backdrop-filter: blur(3px); }
.game-page .settings-dialog { width: min(720px, calc(100% - 24px)); }
.game-page .help-dialog { width: min(840px, calc(100% - 32px)); }
.dialog-head {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 25px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.dialog-head h2 { margin: 7px 0; font-size: var(--ui-dialog-title); line-height: 1.35; font-weight: 650; letter-spacing: -.025em; }
.dialog-head p { color: var(--muted); font-size: 14px; }
.game-page .dialog-close { width: 44px; height: 44px; padding: 0; font: 25px/1 sans-serif; }
.level-catalog { display: grid; gap: 19px; padding: 20px 28px 30px; }
.game-page .chapters { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 7px; margin: 0; }
.game-page .chapter { justify-content: center; min-width: 0; padding: 6px 4px; font-size: 16px; font-weight: 650; line-height: 1.3; }
.game-page .chapter[data-chapter="6"]:not([aria-current="true"]) { border-color: #000; background: var(--control-paper); color: #000; }
.game-page .chapter-mark { display: none; }
.game-page .chapter[aria-current="true"] { background: var(--control-current); box-shadow: inset 0 0 0 2px #000; }
.catalog-book > h3, .catalog-chapter > h3 {
  margin: 0 0 12px;
  padding: 11px 13px;
  border-radius: 8px;
  background: #e1e1e1;
  font-size: var(--ui-section-title);
  font-weight: 650;
  line-height: 1.6;
  text-wrap: balance;
}
.catalog-chapter + .catalog-chapter { margin-top: 16px; }
.game-page .catalog-levels { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 7px; margin-top: 0; }
.game-page .catalog-levels .level-option { position: relative; display: block; min-height: 50px; padding: 7px 3px; border-radius: 8px; text-align: center; font-size: var(--ui-control); font-variant-numeric: tabular-nums; line-height: 1.35; }
.game-page .catalog-levels .level-option:has(.level-complete) { background: var(--control-hover); }
.game-page .catalog-levels .level-option[aria-current="true"] { background: var(--control-current); box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px #000; }
.catalog-levels .level-id { color: inherit; font-size: inherit; }
.catalog-levels .level-complete { position: absolute; top: 3px; right: 4px; color: inherit; font-size: 9px; }
.help-body, .settings-body { padding: 20px 28px 24px; }
.game-rules { display: grid; gap: 8px; padding-inline-start: 1.35rem; color: #5a5a5a; font-size: 16px; }
.help-body section { margin-top: 17px; padding-top: 13px; border-top: 1px solid var(--line); }
.help-body h3, .settings-body h3 { margin: 0 0 9px; font-size: var(--ui-section-title); font-weight: 650; }
.help-body #mechanic-rule { margin-top: 5px; color: #5a5a5a; font-size: 16px; }
.game-page .legend li { font-size: 14px; }
.controls-options { display: flex; gap: 8px; }
.game-page .controls-options button { min-width: 88px; }
.game-page .controls-options button[aria-pressed="true"] { background: var(--control-current); box-shadow: inset 0 0 0 2px #000; font-weight: 650; }

html[data-controls-side="left"] .play-area { grid-template-columns: 278px minmax(0, 1fr); }
html[data-controls-side="left"] .play-area .game-panel { grid-area: 1 / 2; }
html[data-controls-side="left"] #side-panel { grid-area: 1 / 1; }
@media (min-width: 1350px) {
  .game-page .shell { padding-top: 38px; }
  .page-header { margin-bottom: 32px; }
}
@media (max-width: 960px) {
  .game-page .shell { padding: 22px; }
  .page-header { gap: 20px; margin-bottom: 22px; }
  .play-area { grid-template-columns: minmax(0, 1fr) 248px; gap: 16px; }
  .game-page .game-panel { padding: 16px; }
  .side-card { padding: 17px; }
  .level-arrows { gap: 4px; }
  html[data-controls-side="left"] .play-area { grid-template-columns: 248px minmax(0, 1fr); }
}
@media (max-width: 760px), (max-height: 560px) and (max-width: 1100px) {
  .game-page {
    --ui-dialog-title: 20px;
    --ui-control: 17px;
    --ui-main-title: 18px;
    --ui-alias-title: 15px;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .game-page .shell {
    display: grid;
    grid-template-rows: 44px minmax(0, 1fr);
    gap: 6px;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    overflow: hidden;
  }
  .page-header { gap: 6px; min-width: 0; margin: 0; }
  .brand { gap: 5px; }
  .brand-seal { width: 30px; height: 30px; }
  .brand-name h1 { margin: 0; font-size: 22px; line-height: 1.15; }
  .brand-name p { margin-top: 2px; font-size: 11px; line-height: 1.2; }
  .header-actions { gap: 4px; }
  .header-icon svg { width: 17px; height: 17px; }
  .play-area, html[data-controls-side="left"] .play-area {
    min-width: 0;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 152px;
    gap: 6px;
    align-items: stretch;
    overflow: hidden;
  }
  html[data-controls-side="left"] .play-area .game-panel, html[data-controls-side="left"] #side-panel { grid-area: auto; }
  .game-page .game-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 4px;
    min-height: 0;
    padding: 6px;
    border-radius: 6px;
    overflow: hidden;
  }
  .board-toolbar { min-height: 44px; gap: 8px; margin: 0; }
  .level-heading { gap: 3px 7px; }
  .game-page .level-heading .eyebrow { font-size: 14px; letter-spacing: 0; }
  .level-arrows { gap: 3px; }
  .game-page .level-arrows button { height: 44px; padding: 0; font-size: 17px; }
  .game-page .board-stage { min-height: 0; height: 100%; overflow: hidden; container-type: size; }
  .board-frame {
    --frame-insets: 10px;
    width: min(100%, calc((100cqh - var(--frame-insets)) * var(--board-ratio, 1.25) + var(--frame-insets)));
    max-width: 100%;
    margin: 0;
    padding: 4px;
    border-radius: 5px;
  }
  .game-page .board { --tile-gap: 1.5px; }
  .game-page .tile { border-radius: 3px; }
  .side-panel {
    min-width: 0;
    min-height: 0;
    grid-template-columns: 64px minmax(0, 1fr) 138px;
    grid-template-rows: 138px;
    gap: 8px;
    padding: 6px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
  }
  .game-page .control-card, .game-page .controls { display: contents; }
  .dpad { grid-area: 1 / 3; place-self: center; width: 138px; height: 138px; grid-template: repeat(3, 44px) / repeat(3, 44px); gap: 3px; }
  .game-page .dpad button:not(.tile) { width: 44px; height: 44px; min-height: 44px; border-radius: 9px; font-size: 21px; }
  .game-page .actions { grid-area: 1 / 1; align-self: center; width: 64px; height: 138px; }
  .secondary-actions { height: 138px; grid-template: repeat(3, 44px) / 64px; gap: 3px; }
  .game-page .secondary-actions button:not(.tile) { width: 64px; height: 44px; min-height: 44px; padding: 0 2px; font-size: var(--ui-control); }
  .game-page .secondary-actions kbd { display: none; }
  .counter-panel {
    grid-area: 1 / 2;
    align-self: center;
    display: grid;
    justify-items: center;
    align-content: center;
    min-width: 0;
    container: step-panel / inline-size;
    height: 138px;
    padding: 4px;
    border: 0;
    border-inline: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
  }
  .step-counter { width: min(100%, 126px); gap: 4px 2px; margin-top: 7px; padding: 8px 6px; }
  .step-counter::before { border-image-width: 4px; }
  .step-counter li { font-size: 18px; }
  .game-page :is(.levels-dialog, .settings-dialog, .help-dialog) { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
  .dialog-head { padding: 15px; }
  .level-catalog, .help-body, .settings-body { padding: 15px; }
  .game-page .catalog-levels { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  html[data-controls-side="left"] #side-panel { grid-template-columns: 138px minmax(0, 1fr) 64px; }
  html[data-controls-side="left"] .dpad { grid-column: 1; }
  html[data-controls-side="left"] .game-page .actions { grid-column: 3; }
}
@media (orientation: landscape) and (max-height: 560px) and (max-width: 1100px) {
  .play-area, html[data-controls-side="left"] .play-area { grid-template-columns: minmax(0, 1fr) minmax(300px, 52%); grid-template-rows: minmax(0, 1fr); }
  .side-panel { align-content: center; }
}
@media (max-width: 340px) {
  .brand-name h1 { font-size: 20px; }
  .header-actions { gap: 3px; }
  .side-panel { gap: 5px; }
}
@container step-panel (max-width: 170px) {
  .step-counter { width: min(100%, 84px); grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 4px; margin-top: 5px; padding: 5px 7px; }
  .step-counter li { width: 100%; height: 18px; aspect-ratio: auto; font-size: 17px; }
}

.game-page :is(.result-card, .levels-dialog, .help-dialog, .settings-dialog) {
  /* The same SVG draws both paper and edge: no rounded background corners
     beneath a square border-image, and no filtered glow outside the frame. */
  border: 7px solid transparent;
  border-radius: 0;
  border-image: var(--ink-dialog-edge) 16 fill / 7px stretch;
  background: transparent;
  box-shadow: none;
}
.game-page :is(.game-panel, .control-card, .counter-panel) {
  border-color: transparent;
  border-image: var(--ink-panel-edge) 16 / 7px round;
}
.game-page :is(.game-panel, .board-frame)::before {
  content: none;
}
.game-page .counter-panel { border-color: transparent; }
@media (max-width: 760px), (max-height: 560px) and (max-width: 1100px) {
  .game-page .side-panel {
    border-color: transparent;
    border-image: var(--ink-panel-edge) 16 / 6px round;
    background: var(--panel-paper);
  }
  .game-page .counter-panel { border-image: none; border-inline-color: var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  .game-page *, .game-page *::before, .game-page *::after { transition: none; }
}

