/* v30: identical ordered cascade, flattened from mountain-v29.css, mountain-v28.css, mountain-v27.css, mountain-v25.css, mountain-v24.css, mountain-v23.css, mountain-v22.css, mountain-v21.css, mountain-v20.css */
:root {
  color-scheme: dark;
  --gold: #d9bf7f;
  --jade: #173c38;
  --ink: #f1e8cf;
  font-family: "Noto Serif TC", "PMingLiU", serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--ink);
  background: #0a1717;
}
body:before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(#081a1be0, #081a1bdd),
    url("assets/wilderness-landscape-v28.webp") center/cover;
  z-index: -1;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid #d8bd7950;
  background: #153530;
  border-radius: 10px;
  padding: 10px;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #f6d481;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.42;
  cursor: default;
}
[hidden] {
  display: none !important;
}
a {
  color: var(--gold);
}
.app {
  width: min(100%, 620px);
  height: 100svh;
  min-height: 550px;
  margin: auto;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 12px;
  position: relative;
  background: radial-gradient(ellipse at 50% 40%, #2a514d77, transparent 75%);
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 43px;
  flex-shrink: 0;
}
.top h1 {
  font-size: 18px;
  letter-spacing: 0.14em;
  margin: 0;
}
.top small {
  font: 11px system-ui;
  color: #c0c9b9;
}
.top button {
  font: 14px system-ui;
  padding: 8px 12px;
}
.hud {
  display: flex;
  justify-content: space-between;
  font: 12px system-ui;
  color: #c3d0bc;
  margin: 6px 5px;
}
.tray {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 218px;
  height: 65px;
  align-self: center;
  border: 2px solid #a58b58;
  border-radius: 12px;
  background: linear-gradient(120deg, #0a211f, #224038);
  box-shadow:
    inset 0 3px 10px #0008,
    0 3px 0 #5b6046;
  padding: 5px;
  flex-shrink: 0;
}
.slot {
  width: 45px;
  height: 52px;
  border: 1px solid #bfa96f22;
  border-radius: 5px;
  position: relative;
  background: #081e1c55;
}
.slot:empty:before {
  content: "◇";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: #dbc89725;
}
.arena {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
  isolation: isolate;
}
.arena:before {
  content: "";
  position: absolute;
  inset: 2%;
  border: 1px solid #d3bb7233;
  border-radius: 45% 45% 22% 22%;
  background: repeating-radial-gradient(
    ellipse at center,
    transparent 0 30px,
    #c8b87508 31px 32px,
    transparent 33px 65px
  );
  box-shadow: inset 0 0 80px #001c1880;
  z-index: -1;
}
.board {
  position: relative;
  flex: none;
}
.piece {
  position: absolute;
  padding: 0;
  overflow: visible;
  border: 1px solid #fff9df;
  border-radius: 8%;
  background: linear-gradient(125deg, #fffdf0 0%, #f6f0dc 55%, #e9dfc3 100%);
  box-shadow:
    1px 3px 0 #c5c29f,
    2px 6px 0 #587b60,
    3px 8px 0 #254b3b,
    4px 10px 7px #0009;
  color: #263e36;
  touch-action: manipulation;
  transition: filter 0.12s;
  isolation: isolate;
}
.piece:before {
  content: "";
  position: absolute;
  inset: 3%;
  border: 1px solid #aa976a55;
  border-radius: 6%;
  pointer-events: none;
}
.piece:hover {
  filter: brightness(1.06);
}
.piece:active {
  filter: brightness(1.12);
}
.piece.blocked {
  filter: brightness(0.94);
}
.piece.hint {
  outline: 3px solid #f7d786;
  outline-offset: 1px;
  filter: brightness(1.08);
}
.totem {
  position: absolute;
  inset: 3% 3% 17%;
  background: url("assets/totems-v34.webp") no-repeat;
  background-size: 400% 200%;
  mix-blend-mode: multiply;
  pointer-events: none;
}
.piece b {
  position: absolute;
  bottom: 5%;
  left: 0;
  width: 100%;
  font-size: clamp(8px, 1.7vh, 13px);
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}
.slot .piece {
  inset: 0;
  width: 100%;
  height: 100%;
  box-shadow: 0 2px 0 #788d64;
  position: absolute;
}
.slot .piece b {
  font-size: 8px;
}
.status {
  height: 28px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 12px/1.3 system-ui;
  color: #d7cfad;
  flex-shrink: 0;
}
.tools {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
}
.tools button {
  min-width: 78px;
  padding: 8px 12px;
  background: linear-gradient(#3c5041, #1c3027);
  box-shadow: 0 3px 0 #0b2019;
  border-color: #a8946066;
  font-size: 14px;
}
.gods {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 10px 0 0;
  flex-shrink: 0;
}
.god {
  padding: 0;
  background: none;
  border: 0;
  position: relative;
  width: 58px;
  text-align: center;
}
.medal {
  display: block;
  width: 39px;
  height: 39px;
  margin: 0 auto 3px;
  border-radius: 50%;
  border: 1px solid #ceb373;
  background-image: url("assets/guardians-v34.webp");
  background-size: 200% 200%;
  box-shadow: 0 2px 8px #0008;
}
.god small {
  display: block;
  font: 10px system-ui;
  white-space: nowrap;
  color: #e3d8b7;
}
.god .energy {
  position: absolute;
  right: 1px;
  top: 25px;
  border-radius: 8px;
  background: #143a33;
  border: 1px solid #b69e65;
  font: 10px system-ui;
  padding: 1px 4px;
}
.primary {
  background: linear-gradient(#e3ca8b, #b6985c);
  color: #243b31;
  font-weight: bold;
  border-color: #e7d195;
  padding: 12px 25px;
}
.sheet {
  position: fixed;
  inset: 0;
  background: #061412a8;
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.paper {
  width: min(100%, 470px);
  max-height: 90svh;
  overflow: auto;
  background: linear-gradient(140deg, #223b34, #102820);
  border: 1px solid #bda56b;
  border-radius: 18px;
  padding: 26px;
  text-align: center;
  box-shadow: 0 16px 80px #0009;
}
.paper h2 {
  letter-spacing: 0.15em;
  font-size: 28px;
  margin: 10px 0 15px;
}
.paper p {
  font: 14px/1.8 system-ui;
  color: #d2d8c8;
}
.paper .buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 17px;
}
.paper .mark {
  font-size: 11px;
  letter-spacing: 0.25em;
  color: var(--gold);
}
.level-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.level-list button {
  min-height: 65px;
}
.lesson {
  border-bottom: 1px solid #d1b97555;
  padding: 6px 4px;
  font: 12px/1.5 system-ui;
  text-align: center;
  color: #ffe4a1;
  flex-shrink: 0;
}
.flight {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  margin: 0;
}
.echo {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 1px solid #d8c08055;
  border-radius: 50%;
  pointer-events: none;
  animation: echo 700ms ease-out forwards;
}
.guardian-cast {
  pointer-events: none;
  z-index: 70;
}
.arena .cast-avatar {
  opacity: 0.8;
  transform: scale(0.65);
}
.arena .cast-banner {
  top: 5%;
  font-size: 12px;
}
.arena .cast-wash,
.arena .cast-aura {
  opacity: 0.12;
}
.footnote {
  font: 10px system-ui;
  color: #9cae9b;
  text-align: center;
  margin: 6px 0 0;
}
.won-seal {
  display: block;
  font-size: 48px;
  color: #d9c48d;
  margin: 10px;
}
.journey-scenes {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 15px 0;
}
.journey-scenes span {
  border: 1px solid #ad956555;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #cfbd87;
  font-size: 13px;
}
@keyframes echo {
  to {
    transform: scale(2.8);
    opacity: 0;
  }
}
@media (max-width: 420px) {
  .app {
    padding: 8px 9px;
  }
  .top h1 {
    font-size: 16px;
  }
  .gods {
    gap: 9px;
  }
  .tray {
    height: 60px;
  }
  .slot {
    height: 48px;
  }
  .god {
    width: 54px;
  }
  .status {
    font-size: 11px;
  }
  .paper {
    padding: 22px 17px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition: none !important;
  }
}

/* Keep summoned art outside the reading plane; effect paths never paint opaque SVG fills. */
.arena .cast-drawing {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  stroke: var(--cast-color);
  fill: none;
  stroke-linecap: round;
  opacity: 0.65;
  overflow: visible;
}
.arena .guardian-cast {
  z-index: 2;
}
.board {
  z-index: 3;
}
.arena .guardian-cast .cast-avatar {
  left: auto;
  right: -5px;
  top: 5%;
  width: 110px;
  min-width: 0;
  opacity: 0.75;
  animation: edge-summon 1.25s both;
  transform: none;
}
.arena .cast-banner {
  left: 50%;
  top: -5px;
  padding: 4px 15px;
}
.arena .cast-banner b {
  font-size: 16px;
}
.arena .cast-banner small {
  font-size: 8px;
}
.arena .cast-wash {
  opacity: 0.1;
}
.arena .cast-tile {
  display: none;
}
@keyframes edge-summon {
  0% {
    opacity: 0;
    translate: 18px 0;
  }
  25% {
    opacity: 0.8;
    translate: 0 0;
  }
  75% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    translate: 0 -10px;
  }
}
@media (max-width: 420px) {
  .arena .guardian-cast .cast-avatar {
    width: 76px;
    right: -8px;
    top: 0;
  }
}

body[data-realm="1"] .app {
  background: radial-gradient(ellipse at center, #67543942, transparent 80%);
}
body[data-realm="2"] .app {
  background: radial-gradient(ellipse at center, #713e363b, transparent 80%);
}
body[data-realm="3"] .app {
  background: radial-gradient(ellipse at center, #234d694d, transparent 80%);
}
body[data-realm="4"] .app {
  background: radial-gradient(ellipse at center, #485f4947, transparent 80%);
}
body[data-realm="5"] .app {
  background: radial-gradient(ellipse at center, #47426447, transparent 80%);
}

/* A luminous jade table: broad quiet fields behind the ivory tiles. */
body {
  background: #66897f;
  --table: #467d70;
  --mist: #b8cbb4;
}
body:before {
  background:
    linear-gradient(90deg, #c6cfb188, #739b8acc 40%, #527e70cc 70%, #b5b99588),
    url("assets/wilderness-landscape-v28.webp") center/cover;
  filter: saturate(0.55);
  opacity: 1;
}
body:after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse at 48% 25%, #e1e5bc66, transparent 65%),
    linear-gradient(0deg, #254b4655, transparent 60%);
}
body[data-realm="1"] {
  --table: #7c7956;
  --mist: #d9cfa7;
}
body[data-realm="2"] {
  --table: #966f62;
  --mist: #e7c7a8;
}
body[data-realm="3"] {
  --table: #4c8088;
  --mist: #b9d8d4;
}
body[data-realm="4"] {
  --table: #628269;
  --mist: #cbd6b6;
}
body[data-realm="5"] {
  --table: #6c768f;
  --mist: #c9cce1;
}
body .app {
  background: none;
  width: min(100%, 1220px);
  padding: 14px 20px;
  gap: 0;
}
.arena {
  background: radial-gradient(
    ellipse at 50% 35%,
    color-mix(in srgb, var(--mist) 38%, var(--table)),
    var(--table) 80%
  );
  border: 1px solid #e9dba780;
  border-radius: 28px;
  box-shadow:
    inset 0 0 50px #253f2825,
    0 12px 40px #183e3b25;
}
.arena:before {
  inset: 10px;
  border: 1px solid #ede4bc48;
  border-radius: 20px;
  background: repeating-radial-gradient(
    ellipse at 50% 120%,
    transparent 0 39px,
    #e9e4b608 40px 41px,
    transparent 42px 85px
  );
  box-shadow: none;
}
.arena:after {
  content: "山 海";
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  letter-spacing: 1.4em;
  font-size: 12px;
  color: #f5e9bd44;
  pointer-events: none;
  z-index: -1;
}
.piece {
  box-shadow:
    0 2px 0 #dfd5ae,
    1px 5px 0 #96aa79,
    2px 8px 0 #38664c,
    3px 10px 0 #244c3a,
    4px 13px 7px #102b3055;
}
.piece.blocked {
  filter: brightness(0.93) saturate(0.9);
}
.piece b {
  font-size: clamp(10px, 1.9vh, 16px);
}
.top h1 {
  text-shadow: 0 2px 4px #183c35;
  letter-spacing: 0.1em;
  font-size: 21px;
}
.hud,
.status,
.footnote {
  color: #fff2d6;
  text-shadow: 0 1px 3px #173c35;
}
.tray {
  background: linear-gradient(130deg, #33594a, #284d43);
  border-color: #dfc890;
}
.tools button {
  background: linear-gradient(#58755b, #345347);
  border-color: #dbc58b;
}
.god small {
  color: #fff2d8;
  text-shadow: 0 1px 3px #173c35;
}
.medal {
  box-shadow:
    0 2px 0 #566348,
    0 3px 10px #25453766;
}
@media (min-width: 760px) {
  .app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 236px;
    grid-template-rows: 54px 34px 86px minmax(0, 1fr) 66px 42px 29px;
    column-gap: 22px;
    min-height: 480px;
  }
  .top {
    grid-column: 1/-1;
    grid-row: 1;
    height: auto;
    border-bottom: 1px solid #f1dfaa55;
    padding-bottom: 10px;
  }
  .arena {
    grid-column: 1;
    grid-row: 2/8;
    margin: 12px 0 0;
  }
  .hud {
    grid-column: 2;
    grid-row: 2;
    margin: 8px 0 0;
    font-size: 13px;
  }
  .tray {
    grid-column: 2;
    grid-row: 3;
    justify-self: center;
    align-self: center;
    width: 236px;
    height: 76px;
  }
  .slot {
    width: 49px;
    height: 60px;
  }
  .gods {
    grid-column: 2;
    grid-row: 4;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-content: center;
    gap: 26px 8px;
    margin: 0;
  }
  .god {
    width: 100%;
    padding: 10px 0;
    border: 1px solid #f0dda64d;
    background: #234b4238;
    border-radius: 16px;
  }
  .medal {
    width: 58px;
    height: 58px;
  }
  .god small {
    font-size: 12px;
  }
  .god .energy {
    right: 20px;
    top: 50px;
    font-size: 12px;
  }
  .status {
    grid-column: 2;
    grid-row: 5;
    height: auto;
    font-size: 13px;
    line-height: 1.65;
    padding: 5px;
  }
  .tools {
    grid-column: 2;
    grid-row: 6;
    gap: 5px;
    align-items: center;
  }
  .tools button {
    min-width: 0;
    flex: 1;
    padding: 9px 2px;
    font-size: 13px;
  }
  .footnote {
    grid-column: 2;
    grid-row: 7;
    font-size: 10px;
    align-self: end;
  }
  .lesson {
    grid-column: 2;
    grid-row: 4;
    align-self: center;
    font-size: 16px;
    line-height: 2;
    padding: 16px;
    background: #234b4266;
    border-radius: 12px;
    border: 1px solid #f1dfa777;
  }
}
@media (max-width: 759px) {
  body .app {
    width: 100%;
    padding: 6px 7px max(6px, env(safe-area-inset-bottom));
    min-height: 560px;
  }
  .top {
    height: 36px;
  }
  .top h1 {
    font-size: 18px;
  }
  .top button {
    padding: 6px 10px;
  }
  .hud {
    margin: 4px 5px;
  }
  .tray {
    height: 55px;
    width: 218px;
  }
  .slot {
    height: 43px;
  }
  .arena {
    margin: 6px 0 2px;
    border-radius: 20px;
  }
  .arena:before {
    inset: 6px;
    border-radius: 15px;
  }
  .status {
    height: 25px;
    font-size: 11px;
  }
  .tools {
    gap: 8px;
  }
  .tools button {
    padding: 6px 12px;
  }
  .gods {
    margin-top: 6px;
    gap: 16px;
  }
  .god {
    width: 60px;
  }
  .medal {
    width: 33px;
    height: 33px;
    margin-bottom: 2px;
  }
  .god .energy {
    top: 20px;
    right: 6px;
  }
  .god small {
    font-size: 10px;
  }
  .footnote {
    margin-top: 3px;
    font-size: 9px;
  }
  .lesson {
    padding: 5px;
    font-size: 12px;
    background: #2a524b88;
    border-radius: 8px;
  }
  .board .totem {
    bottom: auto;
    top: 5%;
    aspect-ratio: 1/1.15;
  }
}

/* Fit the table to a portrait mountain, rather than stretching it across the viewport. */
body {
  background: #183c37;
  --table: #285747;
  --mist: #90b588;
}
body:before {
  background:
    linear-gradient(90deg, #0f302934, #173e3012 45%, #0e2b2545),
    url("assets/wilderness-landscape-v28.webp") center/cover;
  filter: saturate(0.95) contrast(1.12);
  opacity: 1;
}
body:after {
  background:
    radial-gradient(ellipse at 48% 0%, #f2cf7733, transparent 53%),
    linear-gradient(0deg, #092b3bcc, transparent 65%);
}
body[data-realm="1"] {
  --table: #605238;
  --mist: #c6aa64;
}
body[data-realm="2"] {
  --table: #70443a;
  --mist: #ce9870;
}
body[data-realm="3"] {
  --table: #24505c;
  --mist: #7cb4af;
}
body[data-realm="4"] {
  --table: #34543b;
  --mist: #9eae75;
}
body[data-realm="5"] {
  --table: #34465e;
  --mist: #899bb7;
}
.arena {
  background: radial-gradient(
    ellipse at 45% 30%,
    color-mix(in srgb, var(--mist) 19%, var(--table)),
    var(--table) 85%
  );
  border: 1px solid #c6a46b;
  border-radius: 18px;
  box-shadow:
    inset 0 2px 1px #fff0b333,
    inset 0 0 40px #0e241b44,
    0 4px 0 #283e30,
    0 7px 0 #a48b58,
    0 18px 35px #071a1970;
}
.arena:before {
  inset: 7px;
  border: 1px solid #d9bd7640;
  border-radius: 12px;
  background: repeating-radial-gradient(
    ellipse at 50% 120%,
    transparent 0 39px,
    #dbc7850a 40px 41px,
    transparent 42px 85px
  );
}
.piece {
  background: linear-gradient(125deg, #fffef2 0%, #f8f1dc 55%, #e9d9b7 100%);
  border-color: #fff8df;
  box-shadow:
    0 2px 0 #dfd4ad,
    1px 5px 0 #91a573,
    2px 8px 0 #326348,
    3px 10px 0 #163d2b,
    4px 13px 8px #061c2470;
}
.piece:before {
  border-color: #a38a505e;
  box-shadow: inset 1px 1px 1px #fffef4;
}
.piece.blocked {
  filter: brightness(0.94);
}
.top {
  background: linear-gradient(90deg, #153b35c9, #173930b3);
  border: 1px solid #c0a66c70;
  border-radius: 12px;
  padding: 8px 10px;
}
.hud,
.status,
.footnote {
  color: #fff3d6;
  text-shadow:
    0 1px 3px #071c17,
    0 0 8px #071c17;
}
.god {
  background: linear-gradient(140deg, #2a4d3de8, #173c34e8);
  border-color: #cdb77766;
  box-shadow:
    inset 0 1px 0 #e2d49a22,
    0 3px 8px #051f2844;
}
.tray {
  box-shadow:
    inset 0 3px 10px #051c1899,
    0 3px 0 #b39a60,
    0 7px 12px #082b3155;
}
@media (min-width: 760px) {
  body .app {
    width: min(100%, calc(100svh + 200px), 1120px);
    padding: 10px 14px 14px;
    column-gap: 14px;
    grid-template-rows: 50px 34px 86px minmax(0, 1fr) 66px 42px 29px;
  }
  .top {
    padding: 6px 10px;
    border-bottom: 1px solid #c0a66c70;
  }
  .arena {
    margin-top: 10px;
  }
  .gods {
    gap: 18px 8px;
  }
  .status {
    background: #13382bbf;
    border: 1px solid #d5bb6e33;
    border-radius: 10px;
    margin: 3px 0;
  }
}
@media (max-width: 759px) {
  body .app {
    padding-top: 5px;
  }
  .top {
    height: 38px;
    padding: 3px 5px;
  }
  .top button {
    padding: 4px 8px;
  }
  .gods .god {
    border: 1px solid #cdb77755;
    border-radius: 10px;
    padding: 3px 0;
  }
  .gods {
    gap: 12px;
    margin-top: 7px;
  }
  .god .energy {
    top: 23px;
  }
  .arena {
    margin-bottom: 6px;
  }
  .status {
    background: #153c30b8;
    border-radius: 8px;
    margin: 2px 0;
  }
}

/* Status lives on the rim; creature art retains the same colour and contrast. */
.board .piece.blocked {
  filter: none;
}
.board .piece.ready:before {
  border: 1px solid #567c60;
  box-shadow: inset 0 1px 0 #fffdf3;
}
.board .piece.covered:before {
  border: 1px dashed #a79878;
  box-shadow: none;
}
.board .piece.wedged:before {
  border-left: 3px solid #a38b60;
  border-right: 3px solid #a38b60;
  box-shadow: none;
}
.board .piece.covered,
.board .piece.wedged {
  box-shadow:
    0 2px 0 #d8cdab,
    1px 5px 0 #81946a,
    2px 8px 0 #31543f,
    3px 10px 0 #163d2b,
    3px 11px 5px #061c2455;
}
.availability {
  position: absolute;
  right: 5%;
  top: 3%;
  width: 12px;
  height: 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f8f0db;
  color: #315f47;
  font: bold 16px/12px system-ui;
  pointer-events: none;
}
.covered .availability {
  display: none;
}
.wedged .availability {
  color: #765b30;
  font-size: 11px;
  border-radius: 2px;
  width: 14px;
}
.piece.revealed .totem,
.piece.revealed b {
  animation: ivory-settle 240ms cubic-bezier(0.2, 0.65, 0.3, 1) both;
}
.piece.revealed:before {
  animation: rim-settle 240ms ease-out both;
}
@keyframes ivory-settle {
  0% {
    translate: 0 2px;
  }
  55% {
    translate: 0 -1px;
  }
  100% {
    translate: 0 0;
  }
}
@keyframes rim-settle {
  0% {
    box-shadow: inset 0 5px 8px #69572e25;
  }
  100% {
    box-shadow: inset 0 1px 0 #fffdf3;
  }
}
@media (prefers-reduced-motion: reduce) {
  .piece.revealed .totem,
  .piece.revealed b,
  .piece.revealed:before {
    animation: none;
  }
}

.jade-flight {
  pointer-events: none !important;
  will-change: transform, opacity;
  box-shadow:
    0 2px 0 #d6c7a3,
    1px 4px 0 #608265,
    2px 7px 12px #0c281e66;
}
.jade-flight .totem {
  bottom: 17%;
  top: 3%;
  aspect-ratio: auto;
}
.jade-flight b {
  font-size: clamp(9px, 1.7vh, 14px);
}

.layout-note {
  display: block;
  margin-top: 5px;
  color: #c7b787;
  font-size: 11px;
}

/* Full-bleed painted victory. All controls work from the first frame. */
.sheet.victory {
  padding: 0;
  background: #092f30;
  backdrop-filter: none;
  overflow: auto;
  overscroll-behavior: contain;
  align-items: stretch;
}
.victory .paper {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 100svh;
  height: max-content;
  flex-shrink: 0;
  max-height: none;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  padding: clamp(25px, 5vh, 60px) 24px max(24px, env(safe-area-inset-bottom));
  background: #092f30;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
}
.victory-art {
  position: absolute;
  inset: 0;
  z-index: -3;
  background: url("assets/victory-landscape-v27.webp") center top/cover
    no-repeat;
  animation: victory-arrive 0.55s ease-out both;
  pointer-events: none;
}
.victory-shade {
  position: absolute;
  inset: 0;
  z-index: -2;
  background: linear-gradient(
    180deg,
    #031d26a6 0%,
    transparent 25%,
    transparent 45%,
    #0523269c 67%,
    #052023f5 100%
  );
  pointer-events: none;
}
.victory-heading {
  position: relative;
  text-shadow:
    0 2px 14px #09262e,
    0 1px 3px #09262e;
  flex-shrink: 0;
}
.victory .mark {
  font-size: 12px;
  letter-spacing: 0.36em;
  color: #f7dfaa;
}
.victory .paper h2 {
  font-size: clamp(30px, 4.3vw, 58px);
  font-weight: 600;
  letter-spacing: 0.2em;
  margin: 10px 0 0;
  color: #fff2d4;
  line-height: 1.35;
}
.victory-rule {
  display: block;
  color: #f0d19b;
  line-height: 1;
  margin-top: 12px;
  font-size: 14px;
}
.victory-rule:before,
.victory-rule:after {
  content: "";
  display: inline-block;
  width: 55px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #c6a86d);
  vertical-align: middle;
  margin: 0 15px;
}
.victory-rule:after {
  transform: rotate(180deg);
}
.victory-content {
  width: min(100%, 650px);
  margin-top: 170px;
  text-shadow: 0 1px 5px #041c1e;
  animation: victory-content 0.32s ease-out both;
}
.victory-guardians {
  display: flex;
  justify-content: center;
  gap: 22px;
}
.guardian-seal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: #d9d8bc;
}
.guardian-seal .medal {
  width: 46px;
  height: 46px;
  border-color: #ac9660;
  box-shadow: 0 3px 10px #061d21;
  margin: 0;
}
.guardian-seal.invoked .medal {
  border: 2px solid #f4d89b;
  box-shadow:
    0 0 0 3px #c6a66c38,
    0 3px 10px #061d21;
}
.guardian-seal small {
  font: 11px system-ui;
}
.victory .paper .victory-score {
  font-size: 17px;
  letter-spacing: 0.13em;
  color: #ffedce;
  margin: 13px 0 0;
}
.victory-score span {
  font-size: 13px;
  color: #b89e6c;
  margin: 0 9px;
}
.victory .paper .victory-line {
  font-size: 13px;
  color: #d9e1d8;
  margin: 7px 0 0;
}
.victory .paper .victory-boons {
  font-size: 12px;
  color: #edce93;
  margin: 6px 0 0;
}
.victory .buttons {
  margin-top: 17px;
  gap: 12px;
}
.victory .buttons button {
  min-height: 46px;
  min-width: 145px;
  background: #0b3036e8;
  border-color: #aa996c;
  color: #efe8d5;
  border-radius: 6px;
  padding: 11px 25px;
  text-shadow: none;
}
.victory .buttons .primary {
  background: linear-gradient(135deg, #fae3ac, #d0ae6c);
  color: #173b3d;
  border-color: #fcebc5;
  box-shadow:
    0 3px 0 #6f603a,
    0 7px 20px #061d2170;
}
.victory .journey-scenes {
  margin: 10px 0 0;
  gap: 7px;
}
.victory .journey-scenes span {
  width: auto;
  height: auto;
  padding: 4px 10px;
  border-radius: 3px;
  background: #123636ba;
  font-size: 12px;
  color: #e6cf9e;
}
@keyframes victory-arrive {
  from {
    opacity: 0.65;
    transform: scale(1.018);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes victory-content {
  from {
    opacity: 0.5;
    translate: 0 6px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@media (min-width: 901px) {
  .victory-content {
    width: 410px;
    align-self: flex-end;
    margin-right: clamp(0px, 3vw, 65px);
  }
}
@media (max-width: 600px) {
  .victory .paper {
    padding: max(26px, env(safe-area-inset-top)) 16px
      max(22px, env(safe-area-inset-bottom));
    gap: 18px;
  }
  .victory-art {
    background-image: url("assets/victory-portrait-v27.webp");
    background-position: center top;
    background-size: 100% auto;
    mask-image: linear-gradient(
      #000 0%,
      #000 calc(100vw * 1.1),
      transparent calc(100vw * 1.5)
    );
  }
  .victory-shade {
    background: linear-gradient(
      180deg,
      #07272a99,
      transparent 24%,
      transparent 43%,
      #062a2e99 63%,
      #062329fc 100%
    );
  }
  .victory .paper h2 {
    font-size: clamp(26px, 7.5vw, 38px);
    letter-spacing: 0.12em;
  }
  .victory .mark {
    font-size: 10px;
    letter-spacing: 0.25em;
  }
  .victory-content {
    margin-top: clamp(105px, calc(100svh - 500px), 230px);
  }
  .victory-guardians {
    gap: 17px;
  }
  .guardian-seal .medal {
    width: 40px;
    height: 40px;
  }
  .guardian-seal small {
    font-size: 10px;
  }
  .victory .paper .victory-score {
    font-size: 15px;
    margin-top: 10px;
  }
  .victory .buttons {
    flex-wrap: nowrap;
    gap: 10px;
  }
  .victory .buttons button {
    min-width: 0;
    flex: 1;
    padding: 11px 10px;
    font-size: 15px;
  }
  .victory .journey-scenes {
    gap: 5px;
  }
  .victory .journey-scenes span {
    font-size: 11px;
    padding: 3px 7px;
  }
}
@media (max-height: 740px) and (min-width: 601px) {
  .victory .paper {
    padding: 16px 24px;
    gap: 10px;
  }
  .victory .paper h2 {
    font-size: 32px;
  }
  .victory-content {
    margin-top: 70px;
  }
  .guardian-seal .medal {
    width: 32px;
    height: 32px;
  }
  .victory .buttons {
    margin-top: 9px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .victory-art,
  .victory-content {
    animation: none;
  }
}

/* Mineral jade and natural light: a quiet reading plane within a vast landscape. */
body {
  background: #132d2b;
  --table: #24483f;
  --mist: #b5bba0;
}
body:before {
  background:
    linear-gradient(90deg, #0c202225, transparent 48%, #0c202225),
    url("assets/wilderness-landscape-v28.webp") center 48% / cover no-repeat;
  filter: none;
  opacity: 1;
}
body:after {
  background: linear-gradient(180deg, #132e2920, transparent 35%, #112b2d50);
}
body[data-realm="1"] {
  --table: #424a41;
  --mist: #c2b69a;
}
body[data-realm="2"] {
  --table: #51483d;
  --mist: #c3ad8c;
}
body[data-realm="3"] {
  --table: #24474e;
  --mist: #b0c3bc;
}
body[data-realm="4"] {
  --table: #314c3c;
  --mist: #adbd98;
}
body[data-realm="5"] {
  --table: #35474e;
  --mist: #b9bdc7;
}
.arena {
  background: radial-gradient(
    ellipse at 30% 12%,
    color-mix(in srgb, var(--mist) 15%, var(--table)),
    var(--table) 78%
  );
  border-color: #a7a184;
  box-shadow:
    inset 0 1px 1px #f5f4cf45,
    inset 0 -24px 45px #10291f45,
    0 4px 0 #2c3d33,
    0 6px 0 #767e65,
    0 16px 32px #071b2359;
}
.arena:before {
  border-color: #c3c1a72b;
  background: repeating-radial-gradient(
    ellipse at 25% 140%,
    transparent 0 59px,
    #ccd1b708 60px 61px,
    transparent 62px 100px
  );
  box-shadow: inset 0 0 35px #0c21131a;
}
.top {
  background: linear-gradient(115deg, #132e2ded, #23433be8);
  border-color: #bbb79b70;
  box-shadow: inset 0 1px 0 #f5f3cb19;
}
.tray {
  background: linear-gradient(125deg, #1e3c33, #132d29);
  border-color: #b9b295;
  box-shadow:
    inset 0 3px 9px #071c1e99,
    0 3px 0 #798469,
    0 6px 10px #081e2044;
}
.god {
  background: linear-gradient(140deg, #29463bee, #18352fee);
  border-color: #aaa88b60;
}
.tools button {
  background: linear-gradient(#4b6251, #2e493d);
  border-color: #b5af8c99;
}
.status {
  background: #1b352cc9;
  border-color: #bdb29730;
}
.hud {
  background: #17332cde;
  border: 1px solid #b5af8c45;
  border-radius: 7px;
  padding: 4px 6px;
  align-items: center;
}
.sheet:not(.victory) {
  background: #0c23256b;
  backdrop-filter: blur(3px);
}
.sheet:not(.victory) .paper {
  background: linear-gradient(145deg, #2c493fee, #17332df7);
  border-color: #bab293;
  box-shadow:
    0 18px 65px #041c2266,
    inset 0 1px 0 #ededd22b;
}
.victory-art {
  background-image: url("assets/wilderness-landscape-v28.webp");
  background-position: center top;
}
.victory-shade {
  background: linear-gradient(
    180deg,
    #061c23a6 0%,
    transparent 27%,
    transparent 51%,
    #0b252b80 72%,
    #0b242bf2 100%
  );
}
.victory .paper,
.sheet.victory {
  background: #142d2f;
}
.victory .buttons button {
  border-color: #bdb79a;
  background: #193c3ce8;
}
.victory .buttons .primary {
  background: linear-gradient(135deg, #efdfb3, #c5b483);
  border-color: #f3e6c5;
  color: #173b3d;
  box-shadow:
    0 3px 0 #70785a,
    0 7px 20px #061d2170;
}
@media (max-width: 600px) {
  body:before {
    background-image:
      linear-gradient(#142e291a, #0c242a44),
      url("assets/wilderness-portrait-v28.webp");
    background-position: center 42%;
  }
  .victory-art {
    background-image: url("assets/wilderness-portrait-v28.webp");
  }
  .victory-shade {
    background: linear-gradient(
      180deg,
      #0a252b99,
      transparent 25%,
      transparent 49%,
      #142d2f88 72%,
      #142d2ffc 100%
    );
  }
}

.hud #counter {
  padding: 0 2px;
  border: 0;
  border-bottom: 1px dotted #d8c49888;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  white-space: nowrap;
  text-underline-offset: 3px;
}
.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1px 6px;
  font-size: 11px;
  padding: 3px 6px;
}
.hud #counter {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}
.hud #score {
  grid-column: 1;
  grid-row: 2;
  font-size: 10px;
  text-align: left;
}
.hud #sound {
  grid-column: 2;
  grid-row: 1/3;
}
.land-seal {
  position: absolute;
  left: 4%;
  top: 3%;
  font: 700 10px/1.2 serif;
  color: #f7e8be;
  background: #665336;
  border: 1px solid #d6bd81;
  border-radius: 3px;
  padding: 1px 2px;
  pointer-events: none;
  box-shadow: 0 1px 2px #193c3566;
}
.land-seal.tide {
  background: #254c59;
  border-color: #95bfca;
  color: #e6f1e7;
}
.route-cards {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.route-cards button {
  text-align: left;
  padding: 15px;
  border-color: #ada97e;
  background: #163b33;
}
.route-cards strong,
.route-cards small,
.route-cards span {
  display: block;
}
.route-cards small {
  color: #e5cf99;
  margin: 7px 0;
  font-size: 12px;
}
.route-cards span {
  font: 13px/1.7 system-ui;
  color: #d7dfcf;
}
.boon-choice {
  padding-bottom: 12px;
  border-bottom: 1px solid #cfc59422;
}
.god.relay {
  animation: relay-rim 0.65s ease-out both;
}
@keyframes relay-rim {
  0%,
  100% {
    border-color: #aaa88b60;
  }
  40% {
    border-color: #f1d499;
    box-shadow: 0 0 0 2px #c5c69845;
  }
}
@media (min-width: 760px) {
  body .app {
    grid-template-rows: 50px 40px 86px minmax(0, 1fr) 66px 42px 29px;
  }
  .hud {
    margin-top: 4px;
  }
}
@media (max-width: 759px) {
  .hud {
    padding: 3px 5px;
    min-height: 33px;
    font-size: 11px;
  }
  .land-seal {
    font-size: 9px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .god.relay {
    animation: none;
  }
}

/* v31: quiet terrain echoes stay below the unchanged jade tiles. */
.land-seal.path {
  background: #344c36;
  border-color: #b7c7a1;
  color: #eef0d3;
}
.advanced-boons,
.advanced-mode {
  margin-top: 16px;
  padding: 12px 0;
  border-top: 1px solid #c5b98b45;
  text-align: left;
}
.advanced-boons summary,
.advanced-mode summary {
  cursor: pointer;
  color: #e4cc92;
  font-size: 13px;
  padding: 6px 0;
  line-height: 1.6;
}
.advanced-boons summary:focus-visible,
.advanced-mode summary:focus-visible {
  outline: 2px solid #f6d481;
  outline-offset: 3px;
}
.advanced-mode p,
.advanced-boons > p {
  font-size: 12px;
  line-height: 1.8;
}
.grace-progress:empty {
  display: none;
}
.grace-progress {
  font-size: 12px;
  color: #e4d299;
}
.journey-scenes span:has(small) {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.journey-scenes small {
  font: 9px/1.2 system-ui;
  color: #d7d4b9;
}
body[data-terrain="1"] .arena:before {
  background: repeating-linear-gradient(
    140deg,
    transparent 0 73px,
    #e6cba907 74px 75px,
    transparent 76px 125px
  );
}
body[data-terrain="2"] .arena:before {
  background: repeating-radial-gradient(
    ellipse at 45% 120%,
    transparent 0 63px,
    #edc6a608 64px 65px,
    transparent 66px 106px
  );
}
body[data-terrain="3"] .arena:before {
  background: repeating-radial-gradient(
    ellipse at 10% 125%,
    transparent 0 54px,
    #abcddc0b 55px 56px,
    transparent 57px 90px
  );
}
body[data-terrain="4"] .arena:before {
  background:
    radial-gradient(ellipse at 10% 45%, #d2c0980b, transparent 55%),
    radial-gradient(ellipse at 90% 55%, #d2c0980b, transparent 55%);
}
body[data-terrain="5"] .arena:before {
  background: radial-gradient(circle, #d6dfc40e 1px, transparent 2px);
  background-size: 67px 71px;
}

.status > span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
@media (max-width: 759px) {
  .status {
    height: 34px;
    font-size: 11px;
    line-height: 1.35;
  }
}

/* The explanation stays outside the pile, in the existing fixed-height row. */
.status { font-size: 12px; line-height: 1.3; }
.status > span { min-width: 0; flex: 1; }
.status .response-info {
  flex: 0 0 auto; min-height: 32px; padding: 3px 6px; margin-left: 4px;
  border: 0; border-left: 1px solid #bcc8a844; border-radius: 0;
  background: transparent; color: #e8d6a6; font: inherit; white-space: nowrap;
}
.status .response-info[hidden] { display: none; }
.response-history { border-top: 1px solid #c4c1a640; padding-top: 10px; }
.response-history summary { cursor: pointer; color: #e3d8b3; }
.response-history small { color: #bdd1c7; }

/* Stable space on the existing footer: no veil, tooltip, input target or jump. */
.footnote {
  flex-shrink: 0; height: 32px; min-height: 32px; margin-top: 3px;
  display: flex; align-items: center; justify-content: center;
  font: 11.5px/1.3 system-ui; padding: 1px 4px;
}
.footnote.learning-note {
  color: #f1e1b7; background: #183a32e8; border-left: 2px solid #c7b788;
  border-radius: 4px; text-align: left; justify-content: flex-start;
}
[data-coach-anchor] { outline: 1px dashed #e1d2a188; outline-offset: 2px; }
@media(min-width:760px) {
  body .app { grid-template-rows: 50px 34px 86px minmax(0, 1fr) 66px 42px 35px; }
}

/* v34: clear input targets, ordered guidance, and explicit image fallback. */
#boot { position:fixed; inset:0; z-index:3000; display:grid; place-content:center; text-align:center; background:#17352e; color:#f4e8c6; font:16px/2 system-ui; padding:28px; }
#boot-note:not(:empty) { position:fixed; bottom:0; left:0; right:0; z-index:4000; padding:7px; text-align:center; background:#17352ef5; font:13px/1.5 system-ui; }
#retry-art { position:fixed; bottom:54px; right:10px; z-index:4001; }
.hint-order { position:absolute; right:4%; top:4%; width:24px; height:24px; border-radius:50%; background:#334e43; color:#fff3c9; border:2px solid #ecce86; font:700 15px/20px system-ui; z-index:3; }
.art-fallback .totem { background-image:none; display:grid; place-items:center; }
.art-fallback .totem:after { content:attr(data-seal); font:700 clamp(26px,4vw,54px)/1 serif; color:var(--seal-color,#264c42); border:2px solid currentColor; padding:6px; border-radius:10px; }
.tray .piece b { font-size:12px; line-height:1.3; }
.god small { font-size:12px; }
#counter, #sound, #menu, #help, .tools button { min-height:44px; }
#sound { min-width:52px; }
.hud { font-size:12px; }
.hud #score { font-size:12px; }
.hud #counter { min-height:44px; }
.top { min-height:44px; }
.lesson { flex-shrink:0; }
.lesson button { margin-left:6px; min-height:36px; padding:5px 8px; font:12px system-ui; }
.performance-line { font:14px/1.6 system-ui; color:#f1dfb1; }
.codex-list p { border-bottom:1px solid #c9b88344; padding-bottom:12px; }
.arena[data-cast] { outline:2px solid #e4c47a88; outline-offset:-4px; }
@media(min-width:760px) { body .app { grid-template-rows:50px 62px 86px minmax(0,1fr) 66px 44px 35px; } .lesson { position:absolute; top:50px; left:12px; width:calc(100% - 265px); z-index:900; } }
@media(max-width:759px) {
  .top { height:44px; }
  .hud { min-height:64px; margin:0 4px; }
  .hud #counter { font-size:12px; }
  .tray { height:64px; width:240px; } .slot { height:52px; width:50px; }
  .tools button { padding:7px 10px; font-size:13px; }
  .gods { gap:8px; margin-top:3px; } .god { width:76px; min-height:58px; padding:3px; } .god small { font-size:11px; }
  .footnote { font-size:11px; } .status { font-size:12px; }
}

@media(min-width:760px) {
 .side-learning { grid-column:2; grid-row:4; min-height:0; display:flex; flex-direction:column; justify-content:center; gap:8px; }
 .side-learning .lesson { position:static; width:auto; max-width:none; margin:0; padding:9px; font-size:13px; line-height:1.7; align-self:stretch; }
 .side-learning .gods { gap:12px 8px; }
 .side-learning:has(.lesson:not([hidden])) .medal { width:40px; height:40px; }
 .side-learning:has(.lesson:not([hidden])) .god { padding:5px 0; }
 .side-learning:has(.lesson:not([hidden])) .energy { top:24px; }
}
@media(max-width:759px) {
 .side-learning {display:contents;} .top{order:0}.hud{order:1}.lesson{order:2}.tray{order:3}.arena{order:4}.status{order:5}.tools{order:6}.gods{order:7}.footnote{order:8}
}
#boot-note { margin:0; } #boot-note:empty { display:none; } #menu,#help { min-width:44px; }

.lesson button {min-height:44px;}
@media(max-width:759px) and (max-height:700px) { body .app { min-height:760px; } }

@media(min-width:760px) {
 .side-learning:has(.lesson:not([hidden])) .gods {grid-template-columns:repeat(4,minmax(0,1fr));gap:3px;}
 .side-learning:has(.lesson:not([hidden])) .god small {font-size:11px;line-height:1.5;display:block;}
 .side-learning:has(.lesson:not([hidden])) .energy {right:2px;}
}

/* Same full-resolution Shanhai originals, smaller AVIF; faces and totems untouched. */
@supports(background-image:image-set(url("assets/wilderness-landscape-v41.avif") type("image/avif"),url("assets/wilderness-landscape-v28.webp") type("image/webp"))) {
body:before{background-image:linear-gradient(90deg,#0c202225,transparent 48%,#0c202225),image-set(url("assets/wilderness-landscape-v41.avif") type("image/avif"),url("assets/wilderness-landscape-v28.webp") type("image/webp"))}
.victory-art{background-image:image-set(url("assets/wilderness-landscape-v41.avif") type("image/avif"),url("assets/wilderness-landscape-v28.webp") type("image/webp"))}
@media(max-width:600px){body:before{background-image:linear-gradient(#142e291a,#0c242a44),image-set(url("assets/wilderness-portrait-v41.avif") type("image/avif"),url("assets/wilderness-portrait-v28.webp") type("image/webp"))}.victory-art{background-image:image-set(url("assets/wilderness-portrait-v41.avif") type("image/avif"),url("assets/wilderness-portrait-v28.webp") type("image/webp"))}}
}

/* Keep both HUD rows inside the desktop panel, including long challenge names. */
@media(min-width:760px){
 body .app{grid-template-rows:50px minmax(76px,auto) 86px minmax(0,1fr) 66px 44px 35px}
 .hud{min-height:76px;grid-template-rows:minmax(44px,auto) auto;align-content:center;padding:4px 8px;row-gap:2px}
 .hud #score{white-space:normal;line-height:1.4;min-width:0;overflow-wrap:anywhere}
 .hud #counter{white-space:normal;line-height:1.35;text-align:left}
}
