:root {
  --paper: #f6f0e1;
  --ink: #213f34;
  --line: #cfc7b3;
  --accent: #a64c3c;
  --muted: #526658;
  background: var(--paper);
  color: var(--ink);
  font:
    16px/1.45 "DM Sans",
    "PingFang SC",
    "Microsoft Yahei",
    system-ui,
    sans-serif;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  min-height: 100svh;
  background: radial-gradient(ellipse at 18% 4%, #fffbef, transparent 70%);
}
h1,
h2,
p {
  margin: 0;
}
h1,
h2,
.wordmark {
  font-family: "STSong", "Songti SC", Georgia, serif;
}
h1 {
  font-size: clamp(30px, 7vw, 50px);
  line-height: 1.08;
}
h2 {
  font-size: 24px;
}
main {
  width: min(100%, 890px);
  margin: auto;
  padding: max(12px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
}
button,
input {
  font: inherit;
  color: inherit;
}
button {
  min-height: 44px;
  min-width: 44px;
  background: #faf7ed;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover {
  background: #e9ead9;
}
button:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 3px solid #b97931;
  outline-offset: 2px;
}
.primary {
  background: var(--ink);
  color: #fff4d7;
  border-color: var(--ink);
  padding-inline: 22px;
}
.primary:hover {
  background: #38604e;
}
.icon,
.textButton {
  border: 0;
  background: transparent;
}
.icon {
  font-size: 20px;
}
.textButton {
  font-size: 13px;
}
.tools,
.brandbar,
.wordmark,
.levelHead,
.deskfoot,
.storyActions,
.resultButtons,
.dialogHead,
.score,
nav,
#levelButtons {
  display: flex;
  align-items: center;
}
.brandbar,
.levelHead,
.deskfoot,
.dialogHead {
  justify-content: space-between;
}
.brandbar {
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}
.wordmark {
  font-weight: 750;
  font-size: 22px;
  gap: 10px;
}
.brandmark {
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  background: var(--ink);
  border-radius: 8px;
  color: #f5d78d;
  font: 25px Georgia;
}
.chapter {
  font:
    700 12px/1.4 system-ui,
    sans-serif;
  letter-spacing: 0.13em;
  color: var(--accent);
  margin-bottom: 7px;
}
.book-story {
  margin: clamp(16px, 4.4vh, 44px) auto 0;
  max-width: 760px;
  border: 1px solid var(--line);
  background: #fcf8ed;
  box-shadow:
    0 6px 0 -3px #eee5d3,
    0 7px 0 -3px var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.plate {
  background: #254e3f;
}
.plate img {
  width: 100%;
  display: block;
  aspect-ratio: 3/2;
  height: auto;
  object-fit: cover;
}
.storyCopy {
  padding: clamp(21px, 5vw, 38px);
}
.storyCopy h1 {
  font-weight: 650;
}
.storyCopy p {
  color: #465b4c;
  margin: 14px 0 22px;
  max-width: 43ch;
  line-height: 1.55;
  font-size: clamp(16px, 2.7vw, 19px);
}
.storyActions {
  gap: 5px;
}
.storyActions .book-skip {
  margin-left: auto;
}
#play {
  margin: 15px auto 0;
  max-width: min(760px, max(590px, 87svh));
}
.levelHead {
  padding: 0 4px;
  gap: 8px;
}
.levelHead h1 {
  font-size: clamp(27px, 5.3vw, 37px);
}
.levelHead .chapter {
  font-size: 11px;
  margin-bottom: 4px;
}
.score {
  font: 20px Georgia;
  gap: 5px;
  white-space: nowrap;
}
.score > span:first-child {
  font-size: 24px;
  color: #a45742;
}
.score b {
  font-size: 28px;
}
.score i {
  color: #8f9c8c;
}
.objective {
  min-height: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  font-size: 13px;
  color: var(--muted);
}
.objective:has(#rule:empty) {
  min-height: 8px;
  padding: 0;
}
#bankCount {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
#table {
  width: 100%;
  height: auto;
  aspect-ratio: 10.65/7.17;
  display: block;
  touch-action: none;
  cursor: grab;
}
#table:active {
  cursor: grabbing;
}
.deskfoot {
  font-size: 13px;
  color: var(--muted);
  padding: 0 4px;
  min-height: 44px;
}
.deskfoot .textButton {
  white-space: nowrap;
}
.result {
  border-left: 3px solid #648157;
  background: #e6ecd9;
  padding: 10px 12px;
  margin: 4px 3px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.result[data-won="false"] {
  background: #efe4d4;
  border-color: #ad7550;
}
.result h2 {
  font-size: 21px;
}
.resultButtons {
  gap: 5px;
  flex-wrap: wrap;
}
.resultButtons button {
  font-size: 13px;
  padding-inline: 10px;
}
nav {
  border-top: 1px solid var(--line);
  gap: 10px;
  justify-content: space-between;
  padding-top: 8px;
}
nav > span {
  color: var(--muted);
  font-size: 13px;
}
#levelButtons {
  gap: 4px;
  flex-wrap: wrap;
}
#levelButtons button {
  font-family: Georgia, serif;
  font-size: 16px;
  min-width: 44px;
  padding: 6px 8px;
  background: transparent;
  border-color: transparent;
}
#levelButtons button[aria-current="true"] {
  background: var(--ink);
  color: #fff4d7;
}
#notice {
  font-size: 13px;
  line-height: 1.5;
  margin-top: 6px;
}
dialog {
  width: min(360px, 91vw);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop {
  background: #122b23b8;
}
.dialogHead {
  margin-bottom: 12px;
}
input {
  display: block;
  width: 100%;
  background: #fffaf0;
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 6px;
  margin: 6px 0;
}
#codeError {
  font-size: 13px;
  color: var(--accent);
  margin: 8px 0;
}
@media (max-width: 600px) {
  #play {
    margin-top: 15px;
  }
  .resultButtons {
    width: 100%;
  }
}
@media (min-width: 701px) {
  main {
    padding-top: 22px;
  }
  .book-story {
    display: grid;
    grid-template-columns: 1.08fr 1fr;
    align-items: stretch;
    max-width: none;
    margin-top: clamp(40px, 9vh, 105px);
  }
  .plate {
    display: grid;
    align-items: center;
    min-height: 300px;
    position: relative;
    overflow: hidden;
  }
  .plate img {
    position: absolute;
    inset: 0;
    height: 100%;
  }
  .storyCopy {
    align-self: center;
  }
  .storyCopy h1 {
    font-size: 42px;
  }
}
@media (max-width: 355px) {
  main {
    padding-inline: 9px;
  }
  #levelButtons {
    gap: 0;
  }
  .brandbar .tools {
    gap: 0;
  }
  .storyCopy {
    padding: 17px;
  }
  .storyActions {
    gap: 0;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  main {
    padding-top: 3px;
  }
  .brandbar {
    padding-bottom: 1px;
  }
  .book-story {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    margin-top: 7px;
  }
  .storyCopy {
    padding: 14px;
  }
  .storyCopy p {
    font-size: 14px;
    margin: 6px 0;
  }
  .storyCopy h1 {
    font-size: 24px;
  }
}

.guardGlyph {
  width: 13px;
  height: 22px;
  border-radius: 3px 3px 2px 2px;
  background: linear-gradient(
    to bottom,
    #334c55 0 34%,
    #efc996 34% 53%,
    #ad5344 53% 78%,
    #edc78a 78% 83%,
    #364d53 83%
  );
  box-shadow: inset -2px 0 #24382b20;
}
/* Keep one physical playing surface at every viewport size. */
main {
  max-width: 1000px;
  width: 100%;
  padding-inline: clamp(12px, 3vw, 32px);
}
.brandbar {
  max-width: 900px;
  margin: auto;
}
#play {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 470px;
  margin: 10px auto 0;
  gap: 0;
}
.levelHead,
.objective,
.tableSide,
#levels {
  grid-column: auto;
  grid-row: auto;
}
.levelHead {
  align-self: auto;
  padding: 0 4px;
}
.levelHead h1 {
  font-size: clamp(25px, 6vw, 34px);
  font-weight: 650;
}
.levelHead .chapter {
  font-size: 10px;
  color: #965540;
  letter-spacing: 0.12em;
}
.objective {
  display: block;
  padding: 4px;
  margin: 0;
  min-height: 0;
  font-size: 13px;
}
.tableSide {
  min-width: 0;
  width: min(100%, max(202px, calc((100svh - 256px) * 0.7023)));
  margin: auto;
}
.boardWrap {
  position: relative;
  isolation: isolate;
}
#table {
  aspect-ratio: 7.55/10.75;
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 3px 3px #5039222c);
  outline-offset: -2px;
}
.deskfoot {
  min-height: 42px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 0 3px;
}
.tableHud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  margin: 0 5px;
}
.tableHud .score {
  font-size: 15px;
  gap: 4px;
}
.tableHud .score b {
  font-size: 21px;
}
.tableHud .guardGlyph {
  transform: scale(0.83);
}
#marbleStock {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #284535;
  font-weight: 700;
  font-size: 14px;
}
.marbleSlots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 5px 7px;
  border-radius: 24px;
  background: #294339;
  box-shadow: inset 0 1px 3px #14271f;
  border: 1px solid #b39766;
}
.marbleSlot {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-shadow: inset -1px -2px 2px #302b2640;
  transition:
    opacity 0.25s,
    box-shadow 0.25s;
}
.marbleSlot.gold {
  background: radial-gradient(
    circle at 33% 26%,
    #fffbe0,
    #edc574 35%,
    #b67e3a 72%,
    #f0d291
  );
}
.marbleSlot.silver {
  background: radial-gradient(
    circle at 33% 26%,
    white,
    #d2e0e3 35%,
    #7896a1 72%,
    #c8d8db
  );
}
.marbleSlot[data-state="current"] {
  outline: 1px solid #f9e8ae;
  outline-offset: 1px;
}
.marbleSlot[data-state="spent"] {
  opacity: 0.24;
  box-shadow: inset 0 1px 4px #19362a;
}
#notice:empty {
  display: none;
}
#levels {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border: 0;
  gap: 5px;
  padding: 9px 4px 0;
}
#chapterArt {
  display: none;
}
#chapterButtons,
#levelButtons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}
#chapterButtons button {
  font-size: 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 5px 2px;
  color: #526658;
}
#chapterButtons button[aria-current="true"] {
  color: var(--ink);
  border-bottom: 2px solid #9b7140;
}
#levelButtons button {
  font-family: inherit;
  font-size: 12px;
  padding: 5px;
  line-height: 1.35;
  border: 1px solid transparent;
}
#levelButtons button[aria-current="true"] {
  background: var(--ink);
}
#levelButtons button {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}
.stageIndex {
  font:
    italic 12px Georgia,
    serif;
  opacity: 0.72;
}
.stageName {
  text-wrap: balance;
}
#levelButtons button[data-cleared="true"] .stageIndex {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.result {
  position: absolute;
  bottom: 5%;
  left: 5%;
  right: 5%;
  margin: 0;
  display: block;
  padding: 13px 12px;
  background: #fcf5e4f7;
  border: 1px solid #c3a56e;
  border-radius: 6px;
  text-align: center;
  box-shadow: 0 4px 20px #1a342955;
}
.result[data-won="false"] {
  background: #f5e9d7f7;
}
.resultButtons {
  justify-content: center;
  margin-top: 7px;
  width: auto;
}
.resultButtons button {
  padding: 6px 9px;
  min-height: 44px;
}
#notice {
  overflow-wrap: anywhere;
}
@media (min-width: 700px) {
  main {
    padding-top: 18px;
  }
  #play {
    --board: min(48vw, max(250px, calc((100svh - 202px) * 0.7023)), 510px);
    display: grid;
    max-width: 870px;
    grid-template-columns: minmax(200px, 1fr) var(--board);
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 0 clamp(28px, 5vw, 76px);
    margin: 16px auto 0;
    align-items: start;
  }
  .levelHead {
    grid-area: 1/1;
    align-self: start;
    padding: clamp(14px, 5vh, 52px) 0 0;
  }
  .levelHead {
    container-type: inline-size;
    min-width: 0;
    display: block;
  }
  .levelHead h1 {
    font-size: clamp(24px, 10cqi, 44px);
    line-height: 1.15;
    text-wrap: balance;
  }
  #chapterButtons button {
    display: flex;
    flex-direction: column;
    gap: 1px;
    align-items: center;
    justify-content: center;
    line-height: 1.3;
  }
  .chapterIndex {
    font:
      italic 11px Georgia,
      serif;
    color: #946c44;
  }
  .chapterName {
    white-space: nowrap;
  }
  #levelButtons {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  #levelButtons button {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    gap: 12px;
    padding: 5px 14px;
    min-height: 38px;
  }
  #levelButtons button[data-cleared="true"] .stageIndex {
    text-decoration: none;
  }
  #levelButtons .stageName {
    white-space: nowrap;
  }

  .levelHead .chapter {
    font-size: 11px;
    margin-bottom: 10px;
  }
  .objective {
    grid-area: 2/1;
    padding: 10px 0 18px;
    font-size: 15px;
    line-height: 1.55;
  }
  .tableSide {
    grid-area: 1/2/4/3;
    width: 100%;
    margin: 0;
  }
  #levels {
    grid-area: 3/1;
    display: grid;
    gap: 10px;
    padding: 10px 0 20px;
  }
  #chapterArt {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2.35;
    object-fit: cover;
    object-position: 50% 46%;
    border-radius: 3px;
    outline: 1px solid #ab976c;
    outline-offset: -4px;
    margin: 0 0 10px;
  }
  #chapterButtons button,
  #levelButtons button {
    font-size: 13px;
  }
}
@media (max-height: 610px) and (min-width: 700px) {
  #chapterArt {
    display: none;
  }
}
@media (max-width: 355px) {
  main {
    padding-inline: 9px;
  }
  .brandbar {
    padding-bottom: 0;
  }
  #play {
    margin-top: 6px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .result:not([hidden]) {
    animation: reveal-result 0.25s ease-out both;
  }
  @keyframes reveal-result {
    from {
      opacity: 0;
      transform: translateY(4px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* A brass-edged parchment report rests on the lower part of the courtyard. */
#result {
  --award-green: #254b3d;
  width: min(354px, calc(100vw - 28px));
  left: 50%;
  right: auto;
  translate: -50% 0;
  bottom: 4%;
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid #a48652;
  border-radius: 12px;
  color: #274538;
  background: #faf4e7;
  box-shadow:
    0 10px 28px #12281f66,
    0 2px 5px #172e2459;
}
.awardTop {
  position: relative;
  padding: 11px 16px 13px;
  background:
    radial-gradient(ellipse at 50% -20%, #486b50, transparent 75%),
    var(--award-green);
  color: #fff3cd;
}
.awardTop::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid #c6ae794a;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  pointer-events: none;
}
.awardMeta {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 17px;
  color: #e8d5ae;
  font-size: 11px;
  letter-spacing: 0.09em;
}
#ratingHelp {
  position: absolute;
  right: 3px;
  top: 1px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  min-width: 44px;
  font:
    italic bold 16px Georgia,
    serif;
  background: transparent;
  border: 0;
  color: #f3dda9;
}
#ratingHelp::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid #c6ae798c;
  border-radius: 50%;
}
.medals {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 46px;
  margin: 3px auto 0;
}
.medals::before,
.medals::after {
  content: "";
  height: 1px;
  width: 32px;
  margin: 0 8px;
  background: linear-gradient(90deg, transparent, #c9ab73);
}
.medals::after {
  transform: rotate(180deg);
}
.medals canvas {
  display: block;
  width: 42px;
  height: 42px;
}
.medals canvas:nth-child(2) {
  width: 53px;
  height: 53px;
  margin-top: -5px;
}
#result h2 {
  font-size: clamp(21px, 3vw, 28px);
  line-height: 1.18;
  margin: 2px 0 3px;
  color: #fff3da;
}
#awardRecord {
  font-size: 12px;
  color: #e6cfa1;
  font-variant-numeric: tabular-nums;
}
.awardSlip {
  padding: 11px 13px 3px;
  border-top: 2px solid #c5a468;
}
#awardStats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 1px 0 6px;
}
#awardStats div + div {
  border-left: 1px solid #d9cdb3;
}
#awardStats dt {
  font-size: 11px;
  color: #66715f;
  line-height: 1.3;
}
#awardStats dd {
  font:
    600 18px/1.2 Georgia,
    serif;
  margin: 2px 0 0;
  font-variant-numeric: tabular-nums;
}
#awardHint {
  font-size: 12px;
  line-height: 1.4;
  color: #566457;
  margin: 5px auto 9px;
  text-wrap: balance;
}
.awardMain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.awardMain button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 0;
}
.awardMain svg {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.awardMain #retry { padding: 6px 12px; font-size: 14px; }
.awardMain #retry:not(.primary) { color: #405447; border-color: #a8b09e; background: transparent; }
.awardMain #primary { flex: 1; min-height: 48px; padding: 8px 12px; font-size: 16px; }
.awardMain #retry.primary { flex: 1; }
.awardMain button:focus-visible { outline: 2px solid #6e4626; outline-offset: 2px; }
#result .resultButtons {
  width: 100%;
  justify-content: center;
  gap: 4px;
  margin-top: 2px;
}
#result .resultButtons button {
  background: transparent;
  border: none;
  font-size: 12px;
  padding: 6px 8px;
}
#result .resultButtons button:hover,
#ratingHelp:hover {
  text-decoration: underline;
}
.ruleList {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 12px;
  margin: 16px 0;
  padding: 14px 0;
  border-block: 1px solid var(--line);
}
.ruleList dt {
  color: #825822;
  font-weight: 700;
}
.ruleList dd {
  margin: 0;
}
#ratingRules p {
  margin: 8px 0;
  color: #526357;
  font-size: 14px;
  line-height: 1.5;
}
@media (min-width: 700px) {
  #result {
    width: min(94%, 354px);
  }
  #levelButtons .stageBest {
    margin-left: auto;
  }
}
@media (max-width: 699px) {
  #levelButtons button {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 4px;
    row-gap: 2px;
    align-content: center;
  }
  .stageBest {
    grid-column: 1/-1;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .result:not([hidden]) .medals canvas:not([data-fill="0"]) {
    animation: stamp-star 0.34s cubic-bezier(0.15, 0.7, 0.25, 1.15) both;
  }
  .medals canvas:nth-child(2) {
    animation-delay: 0.09s !important;
  }
  .medals canvas:nth-child(3) {
    animation-delay: 0.18s !important;
  }
  @keyframes stamp-star {
    from {
      opacity: 0;
      transform: translateY(5px) scale(0.74);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

/* Chapter spreads use an independent demonstration table; the three doors
   correspond to the playable stages in the same chapter. */
.deskfoot {
  justify-content: flex-end;
}
.book-chapterGuide {
  max-width: 710px;
  margin: clamp(12px, 3.6vh, 38px) auto 12px;
  background: #faf5e8;
  border: 1px solid #d3c6ab;
  border-radius: 9px;
  overflow: hidden;
  box-shadow: 0 7px 25px #55412512;
}
.guideCover {
  position: relative;
  height: clamp(115px, 20vh, 189px);
  background: #173a30;
  color: #fff1cf;
  display: flex;
  align-items: flex-end;
  isolation: isolate;
}
.guideCover img {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 45%;
}
.guideCover::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, #112e26ed, #17342875 55%, #182e2426),
    linear-gradient(0deg, #172b2285, transparent 65%);
}
.guideHeading {
  padding: 18px clamp(15px, 4vw, 28px);
}
.guideHeading p {
  font-size: 12px;
  color: #ead5a4;
  letter-spacing: 0.12em;
  font-weight: 650;
  margin: 0 0 5px;
}
.guideHeading h1 {
  font-size: clamp(29px, 5vw, 45px);
  color: #fff3d6;
  line-height: 1.08;
}
.book-guideTabs {
  position: absolute;
  right: 10px;
  top: 9px;
  display: flex;
  gap: 1px;
  border-radius: 6px;
  background: #18352add;
}
.book-guideTabs button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #e0d1b1;
  font:
    600 15px Georgia,
    serif;
  padding: 0;
}
.book-guideTabs button[aria-current="true"] {
  color: #fff1c7;
  border-color: #d9ae62;
}
.guideInside {
  display: grid;
  grid-template-columns: minmax(170px, 0.84fr) minmax(205px, 1.16fr);
  grid-template-areas: "demo pitch" "demo route";
  grid-template-rows: auto 1fr;
  align-items: start;
  gap: 6px clamp(18px, 4vw, 35px);
  padding: clamp(15px, 3vw, 23px);
}
.guidePitch {
  grid-area: pitch;
  align-self: end;
  margin: 4px 0 7px;
}
.book-guideText {
  color: #355343;
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.55;
  text-wrap: pretty;
}
.guideFigure {
  grid-area: demo;
  display: flex;
  align-items: center;
  flex-direction: column;
  align-self: center;
  margin: 0;
  min-width: 0;
}
.book-guideBoard {
  display: block;
  width: min(100%, max(150px, calc((100svh - 360px) * 0.702)), 244px);
  height: auto;
  aspect-ratio: 7.55/10.75;
}
.book-guideReplay {
  font-size: 12px;
  font-weight: 500;
}
.guideRoute {
  grid-area: route;
  min-width: 0;
}
.book-guideLevels {
  border-top: 1px solid #d1c5a9;
}
.book-guideLevels button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #d9ceb5;
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 9px 2px;
  min-height: 51px;
}
.book-guideLevels button:hover,
.book-guideLevels button:focus-visible {
  background: #e6e9d9;
}
.routeIndex {
  font:
    italic 14px Georgia,
    serif;
  color: #88693f;
  white-space: nowrap;
}
.routeCopy {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.routeCopy strong {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
}
.routeCopy small {
  color: #687464;
  font-size: 12px;
  font-weight: 400;
}
.book-guideLevels .stageBest {
  margin-left: auto;
  flex: none;
}
.book-enterStage {
  margin: 13px 0 1px;
  width: 100%;
  font-weight: 650;
}
.stageBest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  --gold: #b27a2e;
  --empty: #c9c4b5;
}
.stageBest i {
  display: inline-block;
  width: 12px;
  height: 12px;
  clip-path: polygon(
    50% 0%,
    63% 33%,
    99% 37%,
    71% 61%,
    79% 98%,
    50% 79%,
    21% 98%,
    29% 61%,
    1% 37%,
    37% 33%
  );
  background: linear-gradient(
    90deg,
    var(--gold) var(--fill),
    var(--empty) var(--fill)
  );
}
button[aria-current="true"] .stageBest {
  --gold: #f5ce7a;
  --empty: #698475;
}
@media (max-width: 540px) {
  .book-chapterGuide {
    margin-top: 12px;
  }
  .guideCover {
    height: clamp(103px, 17svh, 142px);
  }
  .guideHeading {
    padding: 14px;
  }
  .guideInside {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    grid-template-rows: auto auto;
    grid-template-areas: "pitch pitch" "demo route";
    padding: 12px;
    gap: 8px 11px;
  }
  .guidePitch {
    margin: 0 0 5px;
  }
  .book-guideText {
    font-size: 14px;
    line-height: 1.4;
  }
  .book-guideLevels button {
    position: relative;
    flex-wrap: wrap;
    gap: 2px 6px;
    padding-block: 7px;
  }
  .book-guideLevels .routeIndex {
    font-size: 12px;
  }
  .book-guideLevels .routeCopy {
    flex: 1;
  }
  .book-guideLevels .routeCopy strong {
    font-size: 13px;
  }
  .book-guideLevels .routeCopy small {
    font-size: 10px;
  }
  .book-guideLevels .stageBest {
    width: 100%;
    justify-content: flex-start;
    padding-left: 24px;
  }
  .book-guideBoard {
    width: 100%;
  }
  .book-enterStage {
    margin-top: 9px;
    padding: 8px;
  }
}
@media (min-width: 541px) and (max-height: 610px) {
  .guideCover {
    height: 95px;
  }
  .guideInside {
    padding: 11px 20px;
  }
  .guideHeading {
    padding-block: 10px;
  }
}

#table[aria-disabled="true"] {
  cursor: default;
}


.courtMark { width:1.12em; height:1.12em; margin-inline-start:.32em; vertical-align:-.16em; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linejoin:round; color:#74552b; }
.courtMark[data-earned="true"] { fill:currentColor; }
[aria-current="true"] .courtMark { color:#efce86; }
#resultMedal:not([hidden]) { display:inline-block; line-height:1; margin-top:3px; }
#resultMedal .courtMark { margin:0; width:23px; height:23px; color:#f5ce7c; }

#walkthrough { width: min(370px, 92vw); max-height: 94dvh; }
#walkthrough form { display: grid; gap: 8px; }
#walkthrough .dialogHead { margin: 0; }
#walkBoard { display: block; width: 100%; height: min(54dvh, 425px); border-radius: 8px; background: #253e35; }
#walkCaption { margin: 0; min-height: 2.5em; font-size: 14px; line-height: 1.25; }


.questionMark {
  display: inline-grid; place-items: center; flex: none; width: 21px; height: 21px;
  border: 1.6px solid currentColor; border-radius: 50%; font: 700 15px/1 Georgia, serif;
}
#confirmSolution { width: min(350px, calc(100vw - 32px)); padding: 24px; color: var(--ink); }
#confirmSolution h2 { margin: 0 0 20px; text-align: center; }
.confirmActions, .guideActions { display: flex; align-items: stretch; gap: 8px; }
.confirmActions button { flex: 1; min-height: 48px; padding-inline: 8px; }
.guideActions .book-enterStage { flex: 1; width: auto; }
.guideActions .book-guideReplay, .guideActions .book-enterStage { margin: 0; }
.guideRoute { display: flex; flex-direction: column; gap: 10px; }

#chapterSave {
  margin: 9px 0 12px; padding: 10px 12px 4px; text-align: left;
  border-inline-start: 3px solid #9e793c; border-radius: 3px 8px 8px 3px;
  background: #eee4cd; color: #233c30;
}
#chapterSalute { margin: 0 0 3px; font-size: 16px; line-height: 1.35; }
#chapterSave p { margin: 0; color: #455646; font-size: 13px; line-height: 1.5; }
#joinToSave { display: inline-flex; align-items: center; min-height: 44px; color: #234d39;
  font-size: 14px; font-weight: 700; text-underline-offset: 3px; }

/* Shared reading order for the menu and the short in-game guide. */
dialog.courtSheet {
  width: min(420px, calc(100% - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; overflow: hidden; border-radius: 19px; color: #213f34;
  box-shadow: 0 18px 65px #081c2355;
}
.courtSheet form { display: flex; flex-direction: column; max-height: calc(100dvh - 36px); }
.sheetHead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex: none;
  padding: 19px 20px 14px; border-bottom: 1px solid #d8d1bd; }
.sheetHead small { display: block; font-size: 12px; line-height: 1.5; color: #5d6857; }
.sheetHead h2 { font-size: 24px; line-height: 1.3; margin: 2px 0 0; }
.sheetClose { flex: none; min-width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 23px; }
.sheetBody { padding: 14px 20px 4px; overflow: auto; overscroll-behavior: contain; }
.menuShortcuts { display: grid; grid-template-columns: repeat(auto-fit,minmax(70px,1fr)); gap: 6px; margin-bottom: 11px; }
.menuShortcuts button { display: grid; justify-items: center; align-content: center; gap: 5px; padding: 9px 3px;
  font-size: 13px; line-height: 1.25; background: #e7ecdf; color: #214435; border: 1px solid #c9d2c1; min-height: 64px; border-radius: 9px; }
.menuShortcuts svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.menuFold { border-bottom: 1px solid #d8d1bd; }
.menuFold summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 46px;
  font-size: 15px; font-weight: 650; cursor: pointer; list-style: none; }
.menuFold summary::-webkit-details-marker { display: none; }
.menuFold summary::after { content: ""; width: 8px; height: 8px; margin-right: 6px; border-right: 1.5px solid; border-bottom: 1.5px solid; transform: rotate(45deg); }
.menuFold[open] summary::after { transform: rotate(225deg); }
.menuItems, .menuLinks { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; padding: 0 0 9px; }
.menuItems button, .menuLinks :is(button,a) { text-align: start; font-size: 14px; min-height: 44px; line-height: 1.35; border-radius: 7px; }
.menuLinks { padding-block: 6px 0; }
.menuLinks :is(button,a) { display:flex; align-items:center; color:#395b47; padding: 4px 0; border:0; background:transparent; text-decoration:none; font-weight:600; }
.menuLinks :last-child { justify-content: flex-end; text-align: end; }
.sheetFoot { flex: none; padding: 10px 20px 16px; }
.sheetPrimary { width: 100%; min-height: 46px; border: 1px solid #194135; background: #214a38; color: #fff6db; border-radius: 10px; font-weight: 700; }
.courtSheet :is(button,a,summary):focus-visible { outline: 2px solid #9e6625; outline-offset: -3px; }
.quickRules { margin: 0 0 12px; }
.quickRules dt { font-size: 12px; color: #5d6857; font-weight: 650; margin: 0 0 3px; }
.quickRules dd { margin: 0 0 13px; font-size: 16px; line-height: 1.55; }
.quickRules dd:first-of-type { font-size: 19px; font-weight: 650; }
.infoGuide { display:flex; min-height:44px; align-items:center; justify-content:space-between; gap:8px;
  padding: 8px 12px; border: 1px solid #c9d2c1; border-radius: 8px; color: #214435; background: #e7ecdf; text-decoration:none; font-weight:600; }
.infoGuide::after { content:'↗'; }
.courtSheet .menuFold p { margin: 5px 0 10px; line-height: 1.65; font-size: 14px; }
