:root {
  color-scheme: dark;
  --gold: #edc572;
  --ivory: #fff0ca;
  --green: #123e32;
  --accent: #edc572;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #081b14;
  color: var(--ivory);
  font:
    15px system-ui,
    sans-serif;
  min-height: 100dvh;
}
button,
select {
  font: inherit;
}
button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}
button,
select {
  min-height: 44px;
  color: var(--ivory);
  border: 1px solid #ad8648;
  background: linear-gradient(#453021, #241b15);
  border-radius: 9px;
  padding: 10px 16px;
}
button {
  cursor: pointer;
}
button:hover {
  filter: brightness(1.2);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
a {
  color: var(--gold);
  text-decoration: none;
}
button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
header {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 4vw;
  border-bottom: 1px solid #cba54b30;
  font-size: 12px;
  letter-spacing: 1px;
}
header span {
  opacity: 0.65;
}
header button {
  font-size: 12px;
  min-height: 36px;
  padding: 7px 12px;
}
main {
  position: relative;
  z-index: 2;
  max-width: 1250px;
  margin: auto;
  padding: 30px 24px;
}
#world {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 70% 10%, #abc56e70, transparent 42%),
    linear-gradient(110deg, #061b18, #174e39 50%, #061e1b);
}
.tree {
  position: absolute;
  top: -15%;
  left: calc(50% - 300px);
  width: 600px;
  height: 125%;
  border-radius: 48% 45% 5% 5%;
  background: repeating-linear-gradient(
    82deg,
    #211d10 0,
    #4e4226 10px,
    #302c1b 17px,
    #665733 22px,
    #302a19 25px
  );
  box-shadow:
    0 0 100px 40px #001b14 inset,
    0 0 160px #001710;
}
.rays {
  position: absolute;
  inset: -50%;
  background: conic-gradient(
    from 150deg at 70% 0%,
    transparent,
    #ffef9a15 10deg,
    transparent 15deg,
    #ffef9a20 25deg,
    transparent 30deg
  );
  animation: light 18s ease-in-out infinite alternate;
}
.mist {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 10% 80%, #bbffb21a, transparent 45%);
  animation: mist 12s ease-in-out infinite alternate;
}
#jungle {
  position: absolute;
  width: 100%;
  height: 100%;
  inset: 0;
}
.vine {
  transform-origin: top;
  animation: sway 8s ease-in-out infinite alternate;
}
.leaf {
  transform-box: fill-box;
  transform-origin: bottom;
  animation: sway 5s ease-in-out infinite alternate;
}
.royal-neck {
  animation: breathe 6s ease-in-out infinite;
  transform-origin: 650px 230px;
}
.snake-head {
  transform-box: fill-box;
  transform-origin: center;
  animation: head 7s ease-in-out infinite;
}
.eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 6s infinite;
}
.tongue {
  transform-box: fill-box;
  transform-origin: top;
  animation: tongue 4s infinite;
}
.jaw {
  transform-box: fill-box;
  transform-origin: 20% 20%;
  animation: jaw 8s infinite;
}
.small-snake {
  animation: breathe 5s ease-in-out infinite alternate;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--gold);
  font-weight: 700;
}
#menu {
  text-align: center;
  max-width: 550px;
  margin: 35px auto 0;
}
h1 {
  font:
    700 clamp(48px, 7vw, 86px) / 0.94 Georgia,
    serif;
  margin: 18px 0 12px;
  color: #ffe6a0;
  text-shadow:
    0 3px #6b3b10,
    0 6px 15px #000;
  letter-spacing: -3px;
}
h1 span {
  display: block;
}
h1 i {
  font-size: 0.65em;
}
h1:before {
  content: "♛";
  display: block;
  font-size: 44px;
  line-height: 1.2;
  color: #f5c354;
  letter-spacing: 0;
}
.subtitle {
  font: italic 18px Georgia;
  color: #e4dcb9;
  margin: 22px 0;
}
.menu-panel {
  background: linear-gradient(120deg, #34291cec, #171f16f5);
  border: 1px solid #b98a47;
  border-top: 3px solid #e0b66e;
  border-radius: 18px;
  padding: 25px;
  box-shadow:
    0 20px 70px #0009,
    inset 0 0 30px #9f712517;
  text-align: left;
}
.menu-panel label {
  display: block;
  color: #d6c5a1;
  font-size: 12px;
  letter-spacing: 1px;
}
select {
  display: block;
  width: 100%;
  margin-top: 9px;
  background: #18291f;
}
#colors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 18px 0;
}
#colors label {
  font-size: 11px;
}
#colors select {
  border-color: var(--pawn);
  color: var(--pawn);
}
.primary {
  background: linear-gradient(#21834b, #0a482e);
  border: 2px solid #e2bd67;
  box-shadow:
    0 3px 0 #6b471b,
    inset 0 0 15px #b1f36720;
  color: #fff3be;
  font: 700 22px Georgia;
  min-height: 56px;
  width: 100%;
}
.menu-links {
  display: flex;
  gap: 8px;
  margin-top: 19px;
}
.menu-links button {
  flex: 1;
  font-size: 12px;
  padding: 8px;
}
.footnote {
  font-size: 11px;
  color: #c2cab2;
}
.game-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
h2 {
  font: 700 30px Georgia;
  margin: 8px 0;
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 760px) 270px;
  gap: 26px;
  justify-content: center;
}
.board-frame {
  background: linear-gradient(
    135deg,
    #f5d48b,
    #81571c 15%,
    #ecbd56 40%,
    #705125 60%,
    #f6da88
  );
  padding: 10px;
  border-radius: 13px;
  box-shadow:
    0 15px 50px #000a,
    0 0 30px #f36a2920;
  border: 3px solid #5b3619;
  aspect-ratio: 1;
}
#board {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  overflow: visible;
  background: #11382b;
}
.square-number {
  font: 700 2.8px Georgia;
  paint-order: stroke;
  stroke-width: 0.5px;
  stroke: #143c30;
  fill: #fff0cd;
}
.square-number.light {
  stroke: #f5dfaf;
  fill: #302b1c;
}
.snake-body {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.board-eye {
  animation: blink 5s infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.board-tongue {
  animation: tongue 3.7s infinite;
  transform-box: fill-box;
  transform-origin: top;
}
.board-jaw {
  animation: jaw 6s infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.active-snake .board-jaw {
  transform: translateY(1px) scaleY(1.5);
}
.pawn {
  filter: drop-shadow(0 0.6px 0.4px #0009);
}
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #6e583c;
  background: #151b16d9;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 9px;
}
.player-row.current {
  border-color: var(--pawn);
  box-shadow: inset 3px 0 var(--pawn);
}
.player-row .dot {
  width: 13px;
  height: 13px;
  background: var(--pawn);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--pawn);
}
.player-row strong {
  flex: 1;
  font-size: 13px;
}
.player-row small {
  font-size: 11px;
  opacity: 0.8;
}
.dice-panel {
  padding: 17px;
  background: #181811d9;
  border: 1px solid #876238;
  border-radius: 12px;
  text-align: center;
  margin-top: 18px;
}
#dice {
  font: 70px Georgia;
  color: #fff2d8;
  line-height: 1.1;
}
.rolling {
  animation: roll 0.13s infinite;
}
#status {
  min-height: 42px;
  font-size: 13px;
  color: #e6d6b5;
}
.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 15px;
}
.toolbar button {
  font-size: 12px;
}
.hint {
  text-align: center;
  color: #c6ad85;
  font: italic 13px Georgia;
}
.playing #world {
  background:
    radial-gradient(ellipse at 50% 90%, #92320c 0, transparent 55%),
    repeating-conic-gradient(
      from 20deg at 70% 40%,
      #180f12 0 28deg,
      #352021 30deg 48deg,
      #100e12 50deg 70deg
    );
}
.playing .tree,
.playing #jungle,
.playing .rays,
.playing .mist {
  opacity: 0;
}
.playing .embers {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 95%, #ffcc42 0, #d6420a 2%, transparent 7%),
    radial-gradient(ellipse at 80% 85%, #ffcc42 0, #d6420a 1%, transparent 5%);
  background-size: 250px 240px;
  animation: lava 9s linear infinite alternate;
  opacity: 0.65;
}
.playing #world:after {
  content: "";
  position: absolute;
  inset: 75% -20% -20%;
  background: repeating-linear-gradient(
    155deg,
    transparent 0 70px,
    #f85b09 78px,
    #ffc35b 82px,
    #8d2308 89px,
    transparent 100px
  );
  filter: blur(6px);
  animation: lava 7s ease-in-out infinite alternate;
}
#intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: transparent;
}
#skip {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  pointer-events: auto;
}
.mouth-glow {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(ellipse, #280606, #080202 65%);
  animation: enter-glow 3.8s forwards;
}
.entering #jungle {
  animation: approach 3.8s cubic-bezier(0.6, 0, 0.8, 0.5) forwards;
  transform-origin: 65% 22%;
}
.entering .royal-neck,
.entering .snake-head {
  animation: none;
}
.entering #royal-upper {
  transform-box: fill-box;
  transform-origin: left bottom;
  animation: open-upper 3.8s forwards;
}
.entering #royal-lower {
  transform-box: fill-box;
  transform-origin: left top;
  animation: open-lower 3.8s forwards;
}
.entering #menu {
  transition: opacity 0.6s;
  opacity: 0;
}
.entering .tree {
  transition: transform 3.8s;
  transform: scale(1.8);
}
dialog {
  max-width: 540px;
  width: calc(100% - 32px);
  max-height: 85dvh;
  overflow: auto;
  background: #17281f;
  color: #fff0cc;
  border: 1px solid #d4a957;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 20px 90px #000;
}
dialog::backdrop {
  background: #000b;
  backdrop-filter: blur(5px);
}
.close {
  float: right;
  font-size: 24px;
  padding: 0 12px;
}
.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 17px 0;
  gap: 15px;
}
.setting select {
  width: 145px;
}
dialog p,
dialog li {
  line-height: 1.7;
  color: #dfd5bd;
}
#celebration {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #080c0def;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.result-card {
  position: relative;
  text-align: center;
  padding: 26px;
  max-width: 520px;
  width: 95%;
}
.result-card h2 {
  font-size: clamp(30px, 6vw, 55px);
  color: var(--accent);
  text-shadow: 0 0 25px var(--accent);
}
.crown {
  font-size: 80px;
  color: var(--accent);
  animation: breathe 3s infinite;
}
.result-card button {
  margin: 8px;
}
.result-card .primary {
  width: 85%;
}
.fireworks {
  position: absolute;
  inset: 0;
}
.spark {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: firework 2.8s ease-out infinite;
  animation-delay: var(--delay);
  --dx: 0px;
  --dy: 0px;
}
.standing {
  padding: 9px;
  border-bottom: 1px solid #ffffff20;
}
.defeat .fireworks,
.defeat .crown {
  display: none;
}
#defeat-snake svg {
  width: 240px;
  overflow: visible;
}
.defeat #defeat-snake {
  animation: defeat-loop 6s both;
}
.defeat #result-title {
  animation: swallow-text 6s both;
  color: #f3bb67;
}
.low .embers,
.low .rays,
.low .mist {
  display: none;
}
.low .leaf,
.low .vine,
.low .snake-head,
.low .royal-neck {
  animation: none;
}
.reduced *,
.reduced *:before,
.reduced *:after {
  animation: none !important;
  scroll-behavior: auto !important;
  transition: none !important;
}
@keyframes sway {
  to {
    transform: rotate(5deg);
  }
}
@keyframes breathe {
  50% {
    transform: translateY(-3px) scaleY(1.018);
  }
}
@keyframes head {
  50% {
    transform: rotate(3deg);
  }
}
@keyframes blink {
  0%,
  43%,
  47%,
  100% {
    transform: scaleY(1);
  }
  45% {
    transform: scaleY(0.08);
  }
}
@keyframes tongue {
  0%,
  70%,
  85%,
  100% {
    transform: scaleY(0.08);
    opacity: 0;
  }
  74%,
  81% {
    transform: scaleY(1);
    opacity: 1;
  }
}
@keyframes jaw {
  0%,
  75%,
  100% {
    transform: rotate(0);
  }
  85% {
    transform: rotate(8deg);
  }
}
@keyframes mist {
  to {
    transform: translateX(6%);
  }
}
@keyframes light {
  to {
    transform: rotate(4deg);
  }
}
@keyframes lava {
  to {
    transform: translate(15px, -12px);
    filter: brightness(1.25);
  }
}
@keyframes roll {
  to {
    transform: rotate(25deg) scale(0.9);
  }
}
@keyframes approach {
  0%,
  18% {
    transform: scale(1);
  }
  65% {
    transform: scale(3);
  }
  100% {
    transform: scale(15);
  }
}
@keyframes open-upper {
  30% {
    transform: rotate(0);
  }
  65%,
  100% {
    transform: rotate(-22deg);
  }
}
@keyframes open-lower {
  30% {
    transform: rotate(0);
  }
  65%,
  100% {
    transform: rotate(34deg);
  }
}
@keyframes enter-glow {
  0%,
  50% {
    opacity: 0;
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    background: #1b0805;
  }
}
@keyframes firework {
  0% {
    opacity: 0;
    transform: translate(0, 70px) scale(0.2);
  }
  20% {
    opacity: 1;
    transform: translate(0, 0);
  }
  80%,
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.2);
  }
}
@keyframes swallow-text {
  0%,
  22% {
    transform: scale(1);
    opacity: 1;
  }
  38%,
  65% {
    transform: translate(28px, -110px) scale(0.05);
    opacity: 0;
  }
  85%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes defeat-loop {
  0% {
    transform: translateX(-100vw);
  }
  25% {
    transform: translateX(0);
  }
  45%,
  65%,
  100% {
    transform: translateX(0);
  }
}
@media (max-width: 800px) {
  header span {
    display: none;
  }
  main {
    padding: 20px 12px;
  }
  .game-layout {
    grid-template-columns: minmax(0, 620px);
    gap: 15px;
  }
  aside {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  #players {
    align-self: center;
  }
  .dice-panel {
    margin: 0;
    padding: 12px;
  }
  .toolbar {
    grid-column: 1/-1;
    display: flex;
    margin: 0;
  }
  .toolbar button {
    flex: 1;
    padding: 8px;
  }
  .hint {
    grid-column: 1/-1;
    margin: 0;
  }
  .game-heading h2 {
    font-size: 23px;
  }
  .game-heading button {
    font-size: 12px;
    padding: 8px;
  }
  .board-frame {
    padding: 5px;
    border-width: 2px;
  }
  .player-row {
    padding: 9px;
    gap: 6px;
    margin-bottom: 5px;
  }
  .player-row strong {
    font-size: 11px;
  }
  .player-row small {
    font-size: 10px;
  }
  #dice {
    font-size: 45px;
  }
  #status {
    font-size: 11px;
    min-height: 28px;
    margin: 6px 0;
  }
  .dice-panel .primary {
    font-size: 19px;
    min-height: 47px;
  }
  .embers {
    opacity: 0.35 !important;
  }
  #menu {
    margin-top: 35px;
  }
  .menu-panel {
    padding: 18px;
  }
  .menu-links {
    gap: 5px;
  }
  .menu-links button {
    font-size: 11px;
    padding: 7px;
  }
  h1 {
    font-size: 63px;
  }
  .tree {
    left: calc(50% - 230px);
    width: 460px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}
/* Layered environmental art remains separate from the interactive SVG rigs. */
.entering #jungle {
  transform-origin: 73% 26%;
}
.reveal {
  animation: reveal-out 0.5s forwards;
  background: #160604 !important;
}
.reveal .mouth-glow {
  animation: none;
  opacity: 0;
}
.reveal #skip {
  display: none;
}
.board-frame {
  position: relative;
}
.board-frame:before,
.board-frame:after {
  content: "◆";
  position: absolute;
  z-index: 2;
  color: #ffe9a3;
  text-shadow: 0 2px 3px #432408;
  pointer-events: none;
  top: -9px;
  font-size: 25px;
}
.board-frame:before {
  left: -5px;
}
.board-frame:after {
  right: -5px;
}
.tree {
  background-image:
    radial-gradient(ellipse at 40% 20%, #bd93612b, transparent 30%),
    repeating-linear-gradient(
      82deg,
      #211d10 0,
      #4e4226 10px,
      #302c1b 17px,
      #665733 22px,
      #302a19 25px
    );
}
.menu-panel {
  backdrop-filter: blur(9px);
}
.playing #world {
  background: #170d0d url("assets/cavern.webp") center/cover no-repeat;
}
.playing #world:after {
  opacity: 0.6;
}
.playing .game-heading {
  border-bottom: 1px solid #a3754430;
  padding-bottom: 12px;
}
.playing .board-frame {
  box-shadow:
    0 20px 60px #000c,
    0 0 2px 2px #f7d88e,
    0 0 38px #ea5d1733;
}
@keyframes reveal-out {
  to {
    opacity: 0;
  }
}
.roster-summary {
  font-size: 11px;
  letter-spacing: 0.5px;
  color: #d4bc94;
  margin: 0 0 10px;
}
.playing #jungle *,
.playing .rays,
.playing .mist {
  animation-play-state: paused !important;
}
.low .board-eye,
.low .board-jaw,
.low .board-tongue {
  animation-duration: 12s;
}
/* Painted volcanic realm: independent artwork behind a data-driven board. */
.playing #world {
  background: #150503 url("assets/cavern.webp") center top / 100% 100% no-repeat;
}
.playing #world:after {
  inset: 78% 0 0;
  opacity: 0.2;
  mix-blend-mode: screen;
  background: radial-gradient(ellipse at 50% 90%, #ffb516a0, transparent 75%);
  filter: blur(14px);
}
.playing .embers {
  background:
    radial-gradient(circle at 15% 75%, #ffc26c 0 1px, transparent 3px),
    radial-gradient(circle at 80% 65%, #ff8b2d 0 1px, transparent 3px);
  background-size: 140px 170px;
  opacity: 0.6;
}
.playing main {
  max-width: 930px;
  padding: 10px 32px 32px;
}
.playing header {
  background: linear-gradient(#130806b0, transparent);
  border: 0;
  padding: 12px 4vw;
}
.playing .game-heading {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 0 auto 8px;
  padding: 0;
  border: 0;
  text-align: center;
  min-height: 128px;
}
.playing .game-heading .eyebrow {
  font-size: 9px;
  letter-spacing: 4px;
  margin-bottom: -12px;
  position: relative;
  z-index: 1;
  color: #ffdda4;
  text-shadow: 0 1px 4px #000;
}
.painted-title {
  margin: 0;
  line-height: 0;
}
.painted-title img {
  display: block;
  width: min(470px, 65vw);
  height: 128px;
  object-fit: contain;
  filter: drop-shadow(0 5px 6px #000b);
}
.playing #menu-button {
  position: absolute;
  right: -40px;
  top: 45px;
  font-size: 11px;
  padding: 8px;
  min-height: 40px;
  background: #20100ac9;
  border-color: #9b6536;
}
.playing .game-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 740px;
  margin: auto;
}
.playing .board-frame {
  padding: 12px;
  border: 3px solid #a65b10;
  border-radius: 17px;
  background: repeating-linear-gradient(
    115deg,
    #d79523 0,
    #fff0ac 3px,
    #a4520d 7px,
    #e0a637 10px,
    #714011 14px
  );
  box-shadow:
    0 0 0 2px #ffe08a,
    inset 0 0 0 2px #ffe4a1,
    0 12px 0 #4c230e,
    0 16px 0 2px #ae7229,
    0 19px 25px #000c,
    0 0 38px #ff6c172b;
}
.playing .board-frame:before,
.playing .board-frame:after {
  display: none;
}
.gold-corner {
  position: absolute;
  z-index: 2;
  color: #ffdd71;
  font: 36px Georgia;
  line-height: 1;
  text-shadow:
    0 1px #6c2e05,
    1px 0 #7b3808,
    0 0 4px #ffeb97;
  pointer-events: none;
}
.top-left {
  top: -5px;
  left: -5px;
  transform: rotate(-45deg);
}
.top-right {
  top: -5px;
  right: -5px;
  transform: rotate(45deg);
}
.bottom-left {
  bottom: -5px;
  left: -5px;
  transform: rotate(-135deg);
}
.bottom-right {
  bottom: -5px;
  right: -5px;
  transform: rotate(135deg);
}
.playing #board {
  border: 1px solid #ffc962;
  border-radius: 5px;
  box-shadow: 0 0 0 2px #5e2d0e;
}
.square-number {
  font:
    700 2.95px Georgia,
    "Times New Roman",
    serif;
  stroke: #132319;
  stroke-width: 0.35px;
  fill: #fff5d6;
  text-shadow: 0 0.12px 0.12px #0008;
}
.square-number.light {
  fill: #201407;
  stroke: #fff3cb;
  stroke-width: 0.22px;
}
.painted-head {
  filter: drop-shadow(0.12px 0.3px 0.18px #140800c9);
}
.painted-head image {
  filter: hue-rotate(var(--head-hue));
  image-rendering: auto;
}
.painted-head .board-jaw {
  transform-origin: 0 0;
  animation: painted-jaw 7s ease-in-out infinite;
}
.active-snake .painted-head .board-jaw {
  transform: translate(0.1px, 0.28px) rotate(3deg);
}
@keyframes painted-jaw {
  0%,
  65%,
  100% {
    transform: translateY(0);
  }
  80% {
    transform: translateY(0.08px) rotate(1.5deg);
  }
}
.playing aside {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  background: linear-gradient(110deg, #1e100de8, #4a2114df, #180b09e8);
  border: 1px solid #9f5d24;
  border-radius: 14px;
  padding: 12px 15px;
  box-shadow:
    0 6px 20px #0009,
    inset 0 1px #f3bc5b66;
  margin-top: 3px;
}
.playing #players {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}
.playing .roster-summary {
  grid-column: 1/-1;
  text-align: center;
  margin: 0;
  color: #dfbe88;
  line-height: 1;
}
.playing .player-row {
  margin: 0;
  padding: 8px;
  gap: 6px;
  border-color: #95632d66;
  background: #0b0806b0;
}
.playing .player-row.current {
  border-color: var(--pawn);
  box-shadow:
    inset 0 -2px var(--pawn),
    0 0 12px color-mix(in srgb, var(--pawn) 15%, transparent);
}
.playing .player-row strong {
  font-size: 11px;
}
.playing .player-row small {
  font-size: 9px;
}
.playing .player-row .dot {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
}
.playing .dice-panel {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 230px;
  gap: 10px;
  align-items: center;
  margin: 0;
  border: 0;
  background: transparent;
  padding: 0;
}
.playing #dice {
  font-size: 0;
  line-height: 0;
  filter: drop-shadow(0 6px 4px #0008);
  width: 76px;
  height: 75px;
}
.playing #dice svg {
  width: 100%;
  height: 100%;
}
.playing #status {
  margin: 0;
  min-height: 0;
  font-size: 13px;
  color: #fce4b7;
  text-align: left;
}
.playing #roll {
  font-size: 27px;
  min-height: 62px;
  border-radius: 35px;
  border: 3px solid #f8d475;
  background: linear-gradient(
    #81ac32 0,
    #146b22 15%,
    #064a19 50%,
    #052c0d 80%,
    #377624 100%
  );
  box-shadow:
    0 0 0 2px #7c3e09,
    inset 0 0 0 2px #eac15c,
    inset 0 5px 8px #c9f08788,
    0 4px 9px #0009;
  text-shadow: 0 2px 2px #032d0c;
}
.playing .toolbar {
  display: flex;
  justify-content: center;
  gap: 8px;
  grid-column: 1/-1;
  margin: 0;
}
.playing .toolbar button {
  flex: 1;
  max-width: 150px;
  border: 1px solid #c48c3c;
  border-radius: 25px;
  background: linear-gradient(#5c3c1a, #1a1009);
  box-shadow: inset 0 1px #ffeab580;
  font-size: 11px;
  min-height: 40px;
  padding: 8px;
}
.playing .hint {
  display: none;
}
@media (min-width: 1100px) and (min-height: 900px) {
  .playing .game-layout {
    max-width: 700px;
  }
  .playing main {
    padding-top: 0;
  }
  .playing .game-heading {
    min-height: 110px;
  }
  .painted-title img {
    height: 110px;
  }
}
@media (max-width: 800px) {
  .playing main {
    padding: 4px 12px 24px;
  }
  .playing .game-heading {
    min-height: 105px;
    margin-bottom: 5px;
  }
  .painted-title img {
    height: 100px;
    width: min(440px, 78vw);
  }
  .playing .game-heading .eyebrow {
    font-size: 8px;
    letter-spacing: 2px;
    margin-bottom: -8px;
  }
  .playing #menu-button {
    right: 0;
    top: 76px;
    font-size: 9px;
    min-height: 30px;
    padding: 5px 8px;
    z-index: 3;
  }
  .playing .board-frame {
    padding: 7px;
    border-width: 2px;
    border-radius: 11px;
    box-shadow:
      0 0 0 1px #ffe08a,
      inset 0 0 0 1px #ffe4a1,
      0 7px 0 #4c230e,
      0 9px 0 1px #ae7229,
      0 15px 20px #000b,
      0 0 24px #ff6c1730;
  }
  .gold-corner {
    font-size: 24px;
  }
  .playing .game-layout {
    gap: 12px;
  }
  .playing aside {
    padding: 10px;
    gap: 10px;
    border-radius: 10px;
  }
  .playing .dice-panel {
    grid-template-columns: 55px minmax(0, 1fr) 42%;
    gap: 7px;
  }
  .playing #dice {
    width: 55px;
    height: 55px;
  }
  .playing #roll {
    font-size: 21px;
    min-height: 54px;
    border-width: 2px;
  }
  .playing #status {
    font-size: 11px;
    line-height: 1.4;
  }
  .playing #players {
    gap: 5px;
  }
  .playing .player-row {
    padding: 6px;
    gap: 4px;
    flex-wrap: wrap;
  }
  .playing .player-row strong {
    font-size: 10px;
  }
  .playing .player-row small {
    font-size: 8px;
  }
  .playing .player-row > span:last-child {
    font-size: 10px;
  }
  .playing .roster-summary {
    font-size: 9px;
  }
  .playing .toolbar {
    gap: 5px;
  }
  .playing .toolbar button {
    font-size: 10px;
    min-height: 44px;
    padding: 7px;
  }
  .playing #world {
    background-size: auto 100%;
    background-position: center top;
  }
  .playing header {
    padding: 9px 12px;
  }
  .playing header a {
    font-size: 10px;
  }
  .playing header button {
    font-size: 10px;
    padding: 5px 9px;
    min-height: 30px;
  }
}
@media (max-width: 359px) {
  .playing main {
    padding-left: 8px;
    padding-right: 8px;
  }
  .playing .board-frame {
    padding: 5px;
  }
  .playing .player-row .dot {
    display: none;
  }
  .playing #roll {
    font-size: 19px;
  }
  .playing .game-heading {
    min-height: 90px;
  }
  .painted-title img {
    height: 87px;
  }
  .playing #menu-button {
    top: 66px;
  }
  .playing aside {
    padding: 8px;
  }
}
.playing .board-frame {
  background: linear-gradient(
    135deg,
    #fff4bb 0,
    #b36716 8%,
    #ffe6a0 16%,
    #9e5211 23%,
    #eab845 30%,
    #f9d981 60%,
    #995013 80%,
    #ffe4a1 100%
  );
  border-color: #b77c27;
}
.playing [data-snake] {
  filter: drop-shadow(0.15px 0.35px 0.2px #100801aa);
}
.painted-head image {
  filter: hue-rotate(var(--head-hue)) saturate(1.25) brightness(1.15);
}
.playing .painted-title img {
  width: 440px;
  height: 150px;
}
.playing .game-heading {
  min-height: 150px;
  margin-top: -8px;
  margin-bottom: 4px;
}
.playing .game-heading .eyebrow {
  margin-bottom: -7px;
}
.playing .game-layout {
  max-width: 680px;
}
.playing #menu-button {
  top: 70px;
}
@media (max-width: 800px) {
  .playing .painted-title img {
    width: min(380px, 85vw);
    height: 125px;
  }
  .playing .game-heading {
    min-height: 125px;
    margin-top: -3px;
    margin-bottom: 5px;
  }
  .playing #menu-button {
    top: 100px;
  }
  .playing .game-layout {
    max-width: 680px;
  }
}
@media (max-width: 359px) {
  .playing .painted-title img {
    height: 108px;
  }
  .playing .game-heading {
    min-height: 108px;
  }
  .playing #menu-button {
    top: 86px;
  }
}
.painted-head image {
  filter: none;
}
.playing #roll {
  min-width: 0;
  padding: 10px 7px;
  white-space: nowrap;
}
.playing .player-row {
  min-width: 0;
}
.playing .player-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}
.playing #players {
  min-width: 0;
}
.playing #players {
  grid-template-columns: repeat(var(--player-count, 4), minmax(0, 1fr));
}
.top-left,
.bottom-left {
  left: 0;
}
.top-right,
.bottom-right {
  right: 0;
}
@media (max-width: 800px) {
  .playing #world {
    background-image: url("assets/cavern-mobile.webp");
    background-size: 100% 100%;
  }
  .gold-corner {
    font-size: 20px;
  }
}
body.playing {
  background: #170603;
}
@media (max-width: 800px) {
  .playing header button,
  .playing header > a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .playing #menu-button {
    min-height: 44px;
    top: 86px;
  }
}
@media (max-width: 359px) {
  .playing #menu-button {
    top: 72px;
  }
}
/* A complete match fits the visual viewport; each player owns a real six-face die. */
body.playing {
  height: 100dvh;
  min-height: 0;
  margin: 0;
  --board-size: 500px;
}
.playing header {
  height: 44px;
  min-height: 44px;
  padding: 0 20px;
  align-items: center;
}
.playing header button,
.playing header > a {
  height: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.playing main {
  height: calc(100dvh - 44px);
  max-width: none;
  padding: 4px 20px 10px;
  width: 100%;
  margin: 0;
}
.playing #play {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.playing .game-heading {
  height: 84px;
  min-height: 84px;
  width: 100%;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}
.playing .game-heading .eyebrow {
  font-size: 8px;
  letter-spacing: 3px;
  margin: 0;
  line-height: 10px;
}
.playing .painted-title img {
  width: 300px;
  height: 72px;
  max-width: 55vw;
  object-fit: contain;
}
.playing #menu-button {
  top: 17px;
  right: 0;
  min-height: 44px;
  height: 44px;
  padding: 9px 14px;
  font-size: 12px;
}
.playing .game-layout {
  display: grid;
  grid-template-columns: var(--board-size) 250px;
  gap: 20px;
  align-items: center;
  max-width: none;
  width: max-content;
  margin: 0 auto;
  flex: none;
}
.playing .board-frame {
  width: var(--board-size);
  height: var(--board-size);
  aspect-ratio: 1;
  min-width: 0;
  padding: 9px;
  margin: 0;
  align-self: start;
  flex-shrink: 0;
  box-shadow:
    0 0 0 2px #ffe08a,
    inset 0 0 0 2px #ffe4a1,
    0 5px 0 #4c230e,
    0 8px 0 1px #ae7229,
    0 12px 22px #000a;
}
.playing aside {
  width: 250px;
  min-width: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  margin: 0;
  align-self: center;
  border: 1px solid #ad7834;
  border-radius: 14px;
  background: linear-gradient(140deg, #160b08ee, #4a2519e8, #110806ed);
}
.playing #players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  width: 100%;
}
.playing .player-row {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  margin: 0;
  border-radius: 10px;
  min-width: 0;
  background: radial-gradient(
    ellipse at 50% 80%,
    color-mix(in srgb, var(--pawn) 12%, transparent),
    #120b08
  );
  border: 1px solid #83603a;
  box-shadow: inset 0 1px #ffe2a42a;
}
.playing .player-row strong {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: none;
  font-size: 11px;
  line-height: 14px;
  text-align: center;
  min-height: 14px;
  white-space: nowrap;
  overflow-wrap: normal;
}
.playing .player-row .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  background: var(--pawn);
  border-radius: 50%;
  box-shadow: 0 0 7px var(--pawn);
}
.playing .player-position {
  font-size: 10px;
  line-height: 13px;
  color: #f3dcae;
  text-align: center;
  white-space: nowrap;
}
.playing .player-row.current {
  border-color: var(--pawn);
  box-shadow:
    inset 0 0 15px color-mix(in srgb, var(--pawn) 15%, transparent),
    0 0 14px color-mix(in srgb, var(--pawn) 20%, transparent);
}
.playing .player-row.finished {
  opacity: 0.65;
}
.player-die {
  --die-size: 46px;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 70px;
  min-height: 44px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent !important;
  box-shadow: none;
  cursor: pointer;
  perspective: 250px;
  touch-action: manipulation;
}
.player-die:disabled {
  cursor: default;
  opacity: 0.45;
}
.player-die:enabled {
  filter: drop-shadow(0 0 7px var(--pawn));
}
.player-die:hover {
  filter: brightness(1.12);
}
.player-die.rolling {
  animation: none;
  opacity: 1;
}
.cube-stage {
  display: block;
  width: var(--die-size);
  height: var(--die-size);
  perspective: 250px;
  transform: rotateX(-16deg) rotateY(22deg);
  transform-style: preserve-3d;
}
.die-cube {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  will-change: transform;
}
.die-face {
  display: block;
  position: absolute;
  inset: 0;
  border: 1px solid #c39e64;
  border-radius: 6px;
  background: radial-gradient(
    ellipse at 25% 15%,
    #fffef3,
    #efe0bb 65%,
    #b99159
  );
  box-shadow:
    inset 0 0 4px #fff4bf,
    0 0 0.5px #594026;
  backface-visibility: hidden;
}
.face-1 {
  transform: translateZ(calc(var(--die-size) / 2));
}
.face-6 {
  transform: rotateY(180deg) translateZ(calc(var(--die-size) / 2));
}
.face-2 {
  transform: rotateY(90deg) translateZ(calc(var(--die-size) / 2));
}
.face-5 {
  transform: rotateY(-90deg) translateZ(calc(var(--die-size) / 2));
}
.face-3 {
  transform: rotateX(90deg) translateZ(calc(var(--die-size) / 2));
}
.face-4 {
  transform: rotateX(-90deg) translateZ(calc(var(--die-size) / 2));
}
.pip {
  position: absolute;
  width: 16%;
  height: 16%;
  border-radius: 50%;
  left: calc(13% + var(--px) * 29%);
  top: calc(13% + var(--py) * 29%);
  background: radial-gradient(ellipse at 35% 30%, #635343, #160f09 70%);
  box-shadow:
    inset 0 1px 2px #000,
    0 0.5px #fff3d4;
}
.playing #status {
  min-height: 32px;
  margin: 0;
  font-size: 12px;
  text-align: center;
  line-height: 1.45;
  color: #f5dfb6;
}
.playing .toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  width: 100%;
}
.playing .toolbar button {
  min-width: 0;
  max-width: none;
  min-height: 44px;
  font-size: 10px;
  padding: 6px 4px;
  border-radius: 10px;
}
.portrait-game header {
  height: 40px;
  min-height: 40px;
  padding: 0 10px;
}
.portrait-game header button,
.portrait-game header > a {
  height: 40px;
  min-height: 40px;
  font-size: 10px;
}
.portrait-game main {
  height: calc(100dvh - 40px);
  padding: 0 9px 7px;
}
.portrait-game .game-heading {
  height: 62px;
  min-height: 62px;
}
.portrait-game .game-heading .eyebrow {
  font-size: 7px;
  letter-spacing: 1.5px;
  line-height: 8px;
}
.portrait-game .painted-title img {
  height: 54px;
  width: 230px;
  max-width: 69vw;
}
.portrait-game #menu-button {
  top: 12px;
  right: 0;
  min-height: 40px;
  height: 40px;
  font-size: 9px;
  padding: 5px 8px;
  max-width: 64px;
  white-space: normal;
  line-height: 12px;
}
.portrait-game .game-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 550px;
  align-items: center;
}
.portrait-game .board-frame {
  align-self: center;
  padding: 6px;
  border-width: 2px;
  border-radius: 10px;
  box-shadow:
    0 0 0 1px #ffe08a,
    inset 0 0 0 1px #ffe4a1,
    0 4px 0 #4c230e,
    0 6px 0 1px #ae7229,
    0 9px 15px #000b;
}
.portrait-game aside {
  width: 100%;
  max-width: 550px;
  padding: 7px 8px;
  gap: 5px;
  border-radius: 10px;
}
.portrait-game #players {
  grid-template-columns: repeat(var(--player-count, 4), minmax(0, 1fr));
  gap: 5px;
}
.portrait-game .player-row {
  gap: 0;
  padding: 4px 2px;
  border-radius: 7px;
}
.portrait-game .player-row strong {
  font-size: 9px;
  line-height: 12px;
  min-height: 12px;
  gap: 3px;
}
.portrait-game .player-row .dot {
  width: 6px;
  height: 6px;
}
.portrait-game .player-position {
  font-size: 8px;
  line-height: 11px;
}
.portrait-game .player-die {
  --die-size: 35px;
  height: 50px;
  min-height: 50px;
  padding: 7px 3px;
}
.portrait-game #status {
  min-height: 23px;
  font-size: 10px;
  line-height: 1.3;
  display: grid;
  place-items: center;
}
.portrait-game .toolbar {
  gap: 5px;
}
.portrait-game .toolbar button {
  min-height: 44px;
  font-size: 10px;
  border-radius: 9px;
}
@media (max-height: 500px) and (orientation: landscape) {
  .playing header {
    height: 34px;
    min-height: 34px;
  }
  .playing header button,
  .playing header > a {
    height: 34px;
    min-height: 34px;
  }
  .playing main {
    height: calc(100dvh - 34px);
    padding: 0 10px 5px;
  }
  .playing .game-heading {
    height: 38px;
    min-height: 38px;
  }
  .playing .game-heading .eyebrow {
    display: none;
  }
  .playing .painted-title img {
    height: 38px;
  }
  .playing #menu-button {
    top: 0;
    height: 36px;
    min-height: 36px;
  }
  .playing aside {
    padding: 8px;
    gap: 6px;
  }
  .playing .player-row {
    padding: 3px;
    gap: 0;
  }
  .playing .player-row strong {
    font-size: 9px;
    line-height: 12px;
    min-height: 12px;
  }
  .playing .player-position {
    font-size: 8px;
    line-height: 10px;
  }
  .playing .player-die {
    --die-size: 30px;
    height: 44px;
    padding: 7px;
  }
  .playing #status {
    min-height: 24px;
    font-size: 10px;
  }
  .playing .toolbar button {
    min-height: 40px;
  }
}
.pin-outline {
  fill: #f7fbff;
  stroke: #52677b;
  stroke-width: 2.5;
}
.pin-color {
  fill: #f5f9fc;
  stroke: #c8d6e4;
  stroke-width: 1;
}
.pin-face {
  fill: var(--pawn);
  stroke: #24374c;
  stroke-width: 2;
}
.pin-gloss {
  fill: #fff;
  opacity: 0.78;
}
.pin-pawn {
  filter: drop-shadow(0 0.2px 0.15px #0009);
}
.pin-avatar {
  width: 30px;
  height: 36px;
  flex-shrink: 0;
  display: block;
}
.playing .player-row strong .pin-avatar {
  width: 15px;
  height: 19px;
}
.setup-color {
  min-width: 0;
}
.setup-color > button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 65px;
  background: linear-gradient(#223d2c, #132218);
  border-color: #a47e42;
}
.setup-color span {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  text-align: left;
}
.setup-color small {
  color: #e8c575;
  margin-top: 3px;
}
.color-palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.color-palette button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 68px;
}
.color-palette button[aria-pressed="true"] {
  outline: 2px solid #f1cf7b;
  outline-offset: 2px;
}
.sculpted-ladder {
  filter: drop-shadow(0.22px 0.38px 0.2px #1a0a06c0);
}
.painted-head .board-jaw {
  animation: living-jaw 6s ease-in-out infinite;
}
.active-snake .painted-head .board-jaw {
  animation: none;
  transform: translate(0.1px, 0.4px) rotate(4deg);
}
@keyframes living-jaw {
  0%,
  58%,
  100% {
    transform: translateY(0) rotate(0);
  }
  75% {
    transform: translateY(0.22px) rotate(2deg);
  }
}
.playing .player-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 2px 3px;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #fff0cb;
}
.playing .player-head .pin-avatar {
  width: 20px;
  height: 25px;
}
.playing .player-head:disabled {
  opacity: 1;
  cursor: default;
  filter: none;
}
.playing .player-head strong {
  font-size: 11px;
  line-height: 13px;
}
.portrait-game .player-head {
  height: 34px;
  min-height: 34px;
  gap: 3px;
}
.portrait-game .player-head .pin-avatar {
  width: 17px;
  height: 22px;
}
.portrait-game .player-head strong {
  font-size: 9px;
}
.color-palette {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.color-palette button {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 78px;
  padding: 7px 4px;
  font-size: 11px;
  background: #14271c;
}
.color-swatch {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #fff1c9;
  background:
    radial-gradient(circle at 30% 24%, #ffffffb0, transparent 48%),
    var(--swatch);
  box-shadow:
    inset -3px -3px 5px #0005,
    0 3px 7px #0007;
}
.color-palette button[aria-pressed="true"] .color-swatch {
  outline: 2px solid #f1ce73;
  outline-offset: 3px;
}
@media (max-height: 500px) and (orientation: landscape) {
  .playing .player-head {
    height: 24px;
    min-height: 24px;
  }
  .playing .player-head .pin-avatar {
    width: 14px;
    height: 18px;
  }
  .playing .player-head strong {
    font-size: 9px;
  }
}
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
dialog.color-dialog {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 7px 8px;
  width: max-content;
  max-width: calc(100vw - 16px);
  height: auto;
  overflow: visible;
  background: linear-gradient(#75401b, #351b0b);
  border: 1px solid #e6b756;
  border-radius: 13px;
  box-shadow:
    inset 0 1px #ffe7ab,
    0 7px 16px #0009;
  color: #fff;
}
.color-dialog::backdrop {
  background: #0002;
  backdrop-filter: none;
}
.color-dialog > .close {
  display: none;
}
.color-dialog .color-palette {
  display: flex;
  gap: 5px;
  align-items: center;
}
.color-dialog .color-palette button {
  width: clamp(23px, calc((100vw - 78px) / 9), 36px);
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  outline: 0;
  flex: none;
}
.color-dialog .color-palette button > span:last-child {
  display: none;
}
.color-dialog .color-swatch {
  width: clamp(23px, calc((100vw - 78px) / 9), 34px);
  height: clamp(23px, calc((100vw - 78px) / 9), 34px);
  border: 1.5px solid #fff3dd;
  border-radius: 50%;
  box-shadow:
    inset -2px -2px 3px #0004,
    0 1px 2px #0009;
}
.color-dialog .color-palette button[aria-pressed="true"] .color-swatch {
  outline: 2px solid #ffdb71;
  outline-offset: 2px;
  box-shadow:
    0 0 0 4px #15221d,
    inset -2px -2px 3px #0004;
}
.color-dialog .color-palette button:focus-visible .color-swatch {
  outline: 2px solid white;
  outline-offset: 3px;
}
.playing .player-row.current .player-die:disabled {
  opacity: 1;
}
@media (max-height: 700px) {
  .result-card {
    padding: 12px;
  }
  .result-card .crown {
    font-size: 48px;
    line-height: 1.1;
  }
  .result-card h2 {
    font-size: 28px;
    margin: 8px 0;
  }
  .result-card p {
    font-size: 12px;
    margin: 8px 0;
  }
  .result-card .standing {
    font-size: 12px;
    padding: 6px;
  }
  .result-card button {
    min-height: 44px;
    font-size: 13px;
    margin: 5px;
  }
  .result-card .primary {
    font-size: 18px;
    min-height: 44px;
  }
}
@media (max-height: 450px) {
  .result-card {
    padding: 8px;
  }
  .result-card .crown {
    font-size: 30px;
  }
  .result-card h2 {
    font-size: 24px;
    margin: 5px 0;
  }
  .result-card p {
    font-size: 11px;
    margin: 5px 0;
  }
  .result-card .standing {
    font-size: 10px;
    padding: 4px;
  }
  .result-card button {
    font-size: 11px;
    margin: 4px;
    min-height: 40px;
  }
  .result-card #defeat-snake svg {
    width: 120px;
    height: 92px;
  }
}
/* Compact gold icon controls and a board-first player dock. */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  gap: 8px;
  border: 0;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
}
.icon-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 8px !important;
  border: 2px solid #e2b75e !important;
  border-radius: 50% !important;
  background: radial-gradient(
    ellipse at 40% 15%,
    #85572a,
    #341b0e 60%,
    #140b06
  ) !important;
  color: #ffe6a0;
  box-shadow:
    inset 0 1px 2px #fff0b7,
    0 0 0 1px #5b2a09,
    0 3px 7px #0009;
  text-decoration: none;
}
.icon-control svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1px #1b0906);
}
.icon-control:hover {
  filter: brightness(1.15);
}
#menu-button {
  display: none;
}
.playing #games-link {
  display: none;
}
.playing #menu-button {
  display: inline-flex;
  position: static;
  right: auto;
  top: auto;
  max-width: none;
  font-size: inherit;
}
.playing header {
  height: 48px;
  min-height: 48px;
  padding: 2px 18px;
}
.playing header .icon-control {
  height: 44px;
  min-height: 44px;
}
.playing main {
  height: calc(100dvh - 48px);
  padding: 0 16px 9px;
}
.playing .game-heading {
  height: 62px;
  min-height: 62px;
}
.playing .game-heading .eyebrow {
  font-size: 7px;
  line-height: 8px;
  letter-spacing: 2px;
}
.playing .painted-title img {
  height: 54px;
  width: 250px;
  max-width: 60vw;
}
.playing .game-layout {
  grid-template-columns: var(--board-size) 200px;
  gap: 14px;
}
.playing aside {
  width: 200px;
  padding: 8px;
  gap: 5px;
  border-radius: 11px;
  background: linear-gradient(125deg, #33190ce8, #150b07e8);
  box-shadow:
    inset 0 1px #edc87b55,
    0 4px 12px #0007;
}
.playing #players {
  grid-template-columns: 1fr;
  gap: 6px;
}
.playing .player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  grid-template-rows: 28px 18px;
  grid-template-areas: "head die" "position die";
  column-gap: 3px;
  row-gap: 0;
  padding: 5px 7px;
  min-height: 58px;
  border-radius: 8px;
}
.playing .player-head {
  grid-area: head;
  height: 28px;
  min-height: 28px;
  padding: 0;
  justify-content: flex-start;
  gap: 5px;
}
.playing .player-head .pin-avatar {
  width: 18px;
  height: 23px;
}
.playing .player-head strong {
  font-size: 10px;
  line-height: 12px;
  min-height: 0;
}
.playing .player-position {
  grid-area: position;
  font-size: 9px;
  line-height: 15px;
  text-align: left;
  align-self: start;
  padding-left: 23px;
}
.playing .player-die {
  grid-area: die;
  --die-size: 34px;
  width: 58px;
  height: 48px;
  min-height: 48px;
  padding: 7px;
}
.playing #status {
  font-size: 10px;
  min-height: 25px;
  line-height: 1.3;
  margin: 0;
}
.portrait-game header {
  height: 44px;
  min-height: 44px;
  padding: 0 9px;
}
.portrait-game header .icon-control {
  height: 40px;
  width: 40px;
  min-height: 40px;
  padding: 8px !important;
}
.portrait-game .header-actions {
  gap: 7px;
}
.portrait-game main {
  height: calc(100dvh - 44px);
  padding: 0 8px 7px;
}
.portrait-game .game-heading {
  height: 52px;
  min-height: 52px;
}
.portrait-game .game-heading .eyebrow {
  font-size: 6px;
  line-height: 7px;
}
.portrait-game .painted-title img {
  height: 45px;
  width: 220px;
  max-width: 65vw;
}
.portrait-game .game-layout {
  display: flex;
  gap: 10px;
}
.portrait-game aside {
  width: 100%;
  padding: 6px;
  gap: 3px;
}
.portrait-game #players {
  grid-template-columns: repeat(var(--player-count, 4), minmax(0, 1fr));
  gap: 5px;
}
.portrait-game .player-row {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 3px 2px;
  gap: 0;
  border-radius: 7px;
}
.portrait-game .player-head {
  height: 23px;
  min-height: 23px;
  justify-content: center;
  gap: 3px;
}
.portrait-game .player-head .pin-avatar {
  width: 14px;
  height: 18px;
}
.portrait-game .player-head strong {
  font-size: 9px;
}
.portrait-game .player-position {
  padding: 0;
  font-size: 8px;
  line-height: 11px;
  text-align: center;
  align-self: center;
}
.portrait-game .player-die {
  --die-size: 30px;
  width: 100%;
  height: 42px;
  min-height: 44px;
  padding: 6px;
}
.portrait-game #status {
  font-size: 9px;
  min-height: 18px;
  line-height: 1.25;
}
.portrait-game #players[data-count="2"] .player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  grid-template-rows: 25px 17px;
  grid-template-areas: "head die" "position die";
  padding: 4px 6px;
}
.portrait-game #players[data-count="2"] .player-head {
  justify-content: flex-start;
}
.portrait-game #players[data-count="2"] .player-head .pin-avatar {
  width: 17px;
  height: 21px;
}
.portrait-game #players[data-count="2"] .player-position {
  text-align: left;
  align-self: start;
  justify-self: start;
  padding-left: 20px;
}
.portrait-game #players[data-count="2"] .player-die {
  width: 48px;
  height: 44px;
  min-height: 44px;
}
@media (max-height: 500px) and (orientation: landscape) {
  .playing header {
    height: 40px;
    min-height: 40px;
    padding: 0 10px;
  }
  .playing header .icon-control {
    height: 36px;
    min-height: 36px;
    width: 36px;
  }
  .playing main {
    height: calc(100dvh - 40px);
  }
  .playing .game-heading {
    height: 34px;
    min-height: 34px;
  }
  .playing .game-heading .eyebrow {
    display: none;
  }
  .playing .painted-title img {
    height: 34px;
  }
  .playing aside {
    padding: 6px;
    gap: 4px;
  }
  .playing .player-row {
    grid-template-rows: 23px 15px;
    min-height: 46px;
    padding: 3px 5px;
  }
  .playing .player-head {
    height: 23px;
    min-height: 23px;
  }
  .playing .player-head .pin-avatar {
    width: 14px;
    height: 18px;
  }
  .playing .player-head strong {
    font-size: 9px;
  }
  .playing .player-position {
    font-size: 8px;
    line-height: 12px;
    padding-left: 19px;
  }
  .playing .player-die {
    --die-size: 28px;
    height: 40px;
    min-height: 40px;
  }
  .playing #status {
    font-size: 9px;
    min-height: 22px;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .playing .player-die {
    height: 44px;
    min-height: 44px;
  }
}
.natural-eyelid {
  opacity: 0;
  transform: none;
  animation: natural-blink 6s infinite;
}
@keyframes natural-blink {
  0%,
  43%,
  47%,
  100% {
    opacity: 0;
  }
  45% {
    opacity: 1;
  }
}
/* Inactive dice remain legible while only the current player can tap. */
.player-die:disabled {
  opacity: 0.72;
}
.finish-crown {
  filter: drop-shadow(0 0.2px 0.15px #4b1c07aa);
}
.finish-crown {
  filter: none;
}
#live-lava {
  display: none;
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 28%;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.8;
}
.playing #live-lava {
  display: block;
}
#players[data-mode="bot"] [data-player-card="1"] {
  order: 0;
}
#players[data-mode="bot"] [data-player-card="0"] {
  order: 1;
}
.playing:not(.portrait-game) #players[data-mode="bot"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.playing:not(.portrait-game) #players[data-mode="bot"] .player-row {
  display: flex;
  flex-direction: column;
  padding: 5px 2px;
  gap: 0;
}
.playing:not(.portrait-game) #players[data-mode="bot"] .player-head {
  justify-content: center;
  gap: 3px;
}
.playing:not(.portrait-game) #players[data-mode="bot"] .player-head strong {
  font-size: 9px;
}
.playing:not(.portrait-game) #players[data-mode="bot"] .player-position {
  padding: 0;
  text-align: center;
  align-self: center;
  font-size: 8px;
}

/* Reference jungle menu: independently rigged title snakes over a living waterfall. */
body:not(.playing) {
  height: 100dvh;
  overflow: hidden;
  background: #071b0e;
}
body:not(.playing) main {
  height: 100dvh;
  max-width: none;
  padding: 0;
  margin: 0;
}
body:not(.playing) header {
  position: fixed;
  inset: 12px 20px auto;
  z-index: 8;
  padding: 0;
  max-width: none;
  pointer-events: none;
}
body:not(.playing) header button,
body:not(.playing) header a {
  pointer-events: auto;
}
body:not(.playing) #settings-button {
  display: none;
}
#menu-info {
  display: none;
}
body:not(.playing) #menu-info {
  display: grid;
}
body:not(.playing) #games-link {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(#172719, #060d08);
  border: 2px solid #f2c55d;
  box-shadow:
    inset 0 0 0 3px #72511c,
    0 3px 10px #0009;
  color: #ffdb74;
  padding: 10px;
}
body:not(.playing) #games-link svg {
  width: 30px;
  height: 30px;
}
body:not(.playing) .header-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
}
body:not(.playing) .icon-control {
  width: 56px;
  height: 56px;
  border-radius: 16px;
}
#menu {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  margin: 0;
  overflow: hidden;
  isolation: isolate;
  text-align: center;
}
#menu[hidden] {
  display: none;
}
.menu-scenery,
#jungle-water {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.menu-scenery {
  background: #0b2517 url("assets/jungle-menu.webp") 60% center/cover no-repeat;
  z-index: -3;
}
#jungle-water {
  z-index: -2;
}
.menu-hero {
  position: absolute;
  left: 1.5%;
  top: 5%;
  width: 65%;
  height: 64%;
  filter: drop-shadow(0 8px 8px #0007);
}
#menu #jungle {
  position: static;
  width: 100%;
  height: 100%;
  overflow: visible;
  animation: none;
  transform: none;
}
#menu .menu-panel {
  position: absolute;
  right: 3.5%;
  top: 52%;
  transform: translateY(-50%);
  width: 30%;
  max-width: 470px;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.7vh, 18px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
#menu .menu-pill {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: clamp(48px, 8.5vh, 82px);
  margin: 0;
  padding: 9px 18px;
  border: 3px solid #e5b542;
  border-radius: 999px;
  background: linear-gradient(105deg, #151d17, #0a0d0b 50%, #25241a);
  box-shadow:
    inset 0 0 0 2px #70430d,
    inset 0 4px 6px #fff5,
    inset 0 -5px 8px #000,
    0 4px 6px #0009,
    0 0 12px #efb63255;
  color: #fff2ba;
  font:
    italic 700 clamp(20px, 2.7vw, 41px) / 1.05 Georgia,
    serif;
  text-shadow: 0 2px 2px #000;
  letter-spacing: -0.5px;
}
#menu .menu-pill:after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid #fff2b459;
  border-radius: inherit;
  pointer-events: none;
}
#menu .menu-pill.primary,
#menu .menu-pill.selected {
  background: linear-gradient(105deg, #063e1d, #07592b 45%, #002712);
}
#menu .menu-pill:hover {
  filter: brightness(1.13);
}
#menu .menu-pill:focus-visible {
  outline: 3px solid ivory;
  outline-offset: 4px;
}
#menu .menu-symbol {
  display: inline-grid;
  place-items: center;
  width: 18%;
  flex-shrink: 0;
  color: #ffd65c;
  filter: drop-shadow(0 2px 1px #754109);
}
#menu .menu-symbol svg {
  width: clamp(26px, 3.8vw, 55px);
  height: clamp(26px, 3.8vw, 55px);
  fill: currentColor;
  stroke: #a27518;
  stroke-width: 0.5;
}
#menu .menu-pill > span:last-child {
  flex: 1;
}
#menu .menu-pill small {
  display: block;
  font-size: 0.65em;
  line-height: 1.2;
}
#menu .local-picker {
  position: relative;
}
#local-options {
  position: absolute;
  inset: calc(100% + 5px) 6px auto;
  z-index: 5;
  display: flex;
  gap: 4px;
  padding: 8px;
  border: 2px solid #e5b542;
  border-radius: 14px;
  background: #12271b;
  box-shadow: 0 8px 22px #000b;
}
#local-options[hidden] {
  display: none;
}
#local-options button {
  flex: 1;
  min-height: 44px;
  padding: 6px;
  font-size: 13px;
}
#menu #colors {
  display: flex;
  gap: 7px;
  margin: 0;
}
#menu .setup-color {
  flex: 1;
  min-width: 0;
}
#menu .setup-color button {
  width: 100%;
  min-height: 42px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid #b98b3f;
  border-radius: 12px;
  background: #0c2017de;
  font: 600 11px/1.1 system-ui;
  color: #f6e5b9;
}
#menu .setup-color button small {
  display: none;
}
#menu .pin-avatar {
  width: 22px;
  height: 27px;
  flex-shrink: 0;
}
.menu-foliage {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}
.menu-foliage .vine {
  position: absolute;
  left: -20px;
  top: 24%;
  display: block;
  transform-origin: top;
  animation: sway 7s ease-in-out infinite alternate;
  color: #567d2699;
}
.menu-foliage .vine:nth-child(2) {
  left: auto;
  right: -20px;
  top: 68%;
  animation-delay: -3s;
}
.menu-foliage .leaf {
  display: block;
  font: 130px/1 Georgia;
  animation: sway 5s ease-in-out infinite alternate;
}
#menu .menu-neck {
  transform-box: view-box;
  animation: menu-breathe 6.5s ease-in-out infinite;
}
#menu .menu-head {
  transform-box: view-box;
  animation: menu-head 8s ease-in-out infinite;
}
#menu .menu-jaw {
  transform-box: view-box;
  animation: menu-jaw 7.3s ease-in-out infinite;
}
#menu .menu-tongue {
  transform-box: view-box;
  animation: menu-tongue 4s ease-in-out infinite;
}
#menu .menu-eyelid {
  transform-box: fill-box;
  transform-origin: center;
  animation: menu-blink 6s infinite;
}
@keyframes menu-breathe {
  50% {
    transform: translateY(-3px) scaleX(1.008);
  }
}
@keyframes menu-head {
  0%,
  100% {
    transform: rotate(-0.5deg);
  }
  50% {
    transform: rotate(1.2deg);
  }
}
@keyframes menu-jaw {
  0%,
  65%,
  100% {
    transform: rotate(0);
  }
  78% {
    transform: rotate(4deg);
  }
}
@keyframes menu-tongue {
  0%,
  60%,
  86%,
  100% {
    transform: scale(0.25);
    opacity: 0;
  }
  65%,
  78% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes menu-blink {
  0%,
  44%,
  49%,
  100% {
    opacity: 0;
    transform: scaleY(0.05);
  }
  46%,
  47% {
    opacity: 1;
    transform: scaleY(1);
  }
}
.entering #menu {
  opacity: 1;
  transition: none;
}
.entering #menu .menu-panel,
.entering .menu-foliage {
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.entering .menu-hero {
  animation: menu-camera 3.8s cubic-bezier(0.5, 0, 0.7, 0.5) forwards;
  transform-origin: 17% 18%;
}
.entering #menu .royal-neck,
.entering #menu .menu-head {
  animation: none;
}
.entering #menu #royal-upper {
  transform-box: view-box;
  transform-origin: 260px 152px;
  animation: menu-open-upper 3.8s forwards;
}
.entering #menu #royal-lower {
  transform-box: view-box;
  transform-origin: 278px 153px;
  animation: menu-open-lower 3.8s forwards;
}
@keyframes menu-camera {
  0%,
  12% {
    transform: scale(1);
  }
  55% {
    transform: scale(3);
  }
  100% {
    transform: scale(24);
  }
}
@keyframes menu-open-upper {
  0%,
  23% {
    transform: rotate(0);
  }
  55%,
  100% {
    transform: rotate(-3deg);
  }
}
@keyframes menu-open-lower {
  0%,
  23% {
    transform: rotate(0);
  }
  55%,
  100% {
    transform: rotate(9deg);
  }
}
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  body:not(.playing) header {
    inset: 7px 12px auto;
  }
  body:not(.playing) .icon-control,
  body:not(.playing) #games-link {
    width: 40px;
    height: 40px;
    padding: 7px;
    border-radius: 12px;
  }
  #menu .menu-hero {
    top: 10%;
    left: 2%;
    width: 62%;
    height: 77%;
  }
  #menu .menu-panel {
    top: 55%;
    gap: 5px;
    width: 31%;
    right: 3%;
  }
  #menu .menu-pill {
    min-height: 40px;
    padding: 5px 12px;
    font-size: 20px;
    border-width: 2px;
  }
  #menu .menu-symbol svg {
    width: 26px;
    height: 26px;
  }
  #menu .setup-color button {
    min-height: 32px;
    font-size: 9px;
  }
  #menu .pin-avatar {
    width: 17px;
    height: 22px;
  }
}
@media (max-aspect-ratio: 4/5) {
  body:not(.playing) header {
    inset: 10px 12px auto;
  }
  body:not(.playing) .icon-control,
  body:not(.playing) #games-link {
    width: 44px;
    height: 44px;
    padding: 8px;
    border-radius: 12px;
  }
  #menu .menu-hero {
    top: 55px;
    left: 3%;
    width: 94%;
    height: min(34vh, 63vw);
  }
  #menu .menu-panel {
    top: calc(62px + min(34vh, 63vw));
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 10%;
    right: 10%;
    width: 80%;
    max-width: none;
    transform: none;
    gap: clamp(5px, 1.2vh, 12px);
    justify-content: center;
  }
  #menu .menu-pill {
    min-height: 44px;
    flex: 1;
    max-height: 72px;
    padding: 6px 14px;
    font-size: clamp(23px, 4.8vh, 35px);
    border-width: 2px;
  }
  #menu .local-picker {
    display: flex;
    flex: 1;
    max-height: 72px;
    min-height: 44px;
  }
  #menu .menu-symbol svg {
    width: 32px;
    height: 32px;
  }
  #menu .setup-color button {
    min-height: 36px;
    font-size: 10px;
  }
  #menu #colors {
    gap: 4px;
    flex-shrink: 0;
  }
  #menu .pin-avatar {
    width: 19px;
    height: 25px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #menu *,
  #menu *:before,
  #menu *:after {
    animation: none !important;
    transition: none !important;
  }
}
.reduced #menu *,
.low #menu .menu-head {
  animation: none !important;
}

#menu .menu-panel {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
#menu #bot-mode > span:last-child {
  font-size: 0.85em;
}
@media (max-height: 650px) and (max-aspect-ratio: 4/5) {
  #menu #bot-mode small {
    display: inline;
  }
}
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  #menu .menu-pill {
    min-height: 44px;
  }
  #menu #bot-mode small {
    display: inline;
  }
}

body:not(.playing) #sound {
  order: 1;
}
body:not(.playing) #menu-info {
  order: 2;
}
@media (max-width: 850px) and (max-height: 480px) and (min-aspect-ratio: 1/1) {
  #menu .setup-color button > span {
    display: none;
  }
  #menu .setup-color button:after {
    content: attr(data-short-name);
    font-size: 9px;
  }
  #menu .setup-color button {
    gap: 2px;
  }
}

.menu-mouth-cavity {
  opacity: 0;
  transform-box: view-box;
  transform-origin: 365px 170px;
}
.entering #menu .menu-mouth-cavity {
  animation: menu-cavity 3.8s forwards;
}
.entering .menu-hero {
  transform-origin: var(--mouth-x) var(--mouth-y);
}
@keyframes menu-camera {
  0%,
  12% {
    transform: translate(0, 0) scale(1);
  }
  55% {
    transform: translate(var(--camera-x), var(--camera-y)) scale(3);
  }
  100% {
    transform: translate(var(--camera-x), var(--camera-y)) scale(24);
  }
}
@keyframes menu-cavity {
  0%,
  23% {
    opacity: 0;
    transform: scaleY(0.5);
  }
  45%,
  100% {
    opacity: 1;
    transform: scaleY(1.1);
  }
}
body:not(.playing) .icon-control {
  border-radius: 16px !important;
  background: linear-gradient(#20271b, #050a05) !important;
}
@media (max-aspect-ratio: 4/5), (max-height: 480px) {
  body:not(.playing) .icon-control {
    border-radius: 12px !important;
  }
}

/* One photographic cobra is used for entering and leaving the volcanic realm. */
.entering .menu-hero {
  animation: none !important;
  will-change: transform, opacity;
}
#entrance-scene,
.cinematic-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  perspective: 1100px;
}
.cinematic-jungle,
.cinematic-aura,
.cinematic-dark {
  position: absolute;
  inset: 0;
}
.cinematic-jungle {
  background: #07160d url("assets/jungle-menu.webp") 60% center/cover no-repeat;
}
.cinematic-aura {
  background: radial-gradient(
    ellipse at 50% 47%,
    #ff531524,
    transparent 36%,
    #0005 85%
  );
}
.cinematic-face {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(112vw, 110vh);
  aspect-ratio: 3/4;
  transform-origin: 50% 47%;
  transform-style: preserve-3d;
  will-change: transform;
  filter: drop-shadow(0 15px 24px #0008);
}
.cinematic-face svg {
  display: block;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
}
.cinematic-closed,
.cinematic-open {
  will-change: opacity;
}
.cinematic-upper {
  transform: translateY(calc(var(--gape, 1) * -4px));
}
.cinematic-lower {
  transform: translateY(calc(var(--gape, 1) * 8px));
}
.cinematic-dark {
  background: radial-gradient(ellipse, #210301, #030000 70%);
  opacity: 0;
}
#defeat-snake {
  position: fixed;
  inset: 0;
  animation: none !important;
  z-index: 0;
  pointer-events: none;
  display: none;
}
.defeat #defeat-snake {
  display: block;
}
.defeat #defeat-snake .cinematic-face {
  top: 40%;
}
#celebration .result-card {
  z-index: 2;
  perspective: 850px;
  transform-style: preserve-3d;
}
#result-title {
  position: relative;
  isolation: isolate;
  transform-style: preserve-3d;
  animation: result-3d 4s ease-in-out infinite !important;
  transform-origin: center;
  color: var(--accent);
  -webkit-text-stroke: 0.6px #fff0b7;
  font-family: Georgia, serif;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow:
    0 1px #8b591c,
    0 2px #765019,
    0 3px #684215,
    0 4px #573611,
    0 5px #482b0e,
    0 6px #3c200b,
    0 7px #301809,
    0 9px 3px #000b,
    0 0 28px var(--accent);
}
#result-title:before {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  z-index: -1;
  color: #8d581c;
  -webkit-text-stroke: 1px #d9a53c;
  transform: translate3d(0, 5px, -8px);
  text-shadow: 0 5px 12px #000;
}
.bot-victory #result-title {
  font-size: clamp(40px, 9vw, 88px);
}
.bot-victory .crown {
  font-size: clamp(65px, 15vw, 125px);
}
.bot-victory .result-card {
  max-width: 700px;
  background: radial-gradient(ellipse, #1d251eaa, transparent 70%);
}
.bot-victory .spark {
  width: 6px;
  height: 6px;
  box-shadow:
    0 0 8px var(--accent),
    0 0 18px var(--accent);
}
.defeat #result-title {
  animation: result-3d 4s ease-in-out infinite !important;
  font-size: clamp(40px, 9vw, 84px);
  color: #ffc473;
}
.defeat .result-card {
  align-self: end;
  margin-bottom: max(14px, 3vh);
  background: linear-gradient(transparent, #080402c9 28%);
  max-width: 650px;
}
.defeat .standing {
  background: #09060366;
}
.defeat #result-name {
  text-shadow: 0 1px 3px #000;
}
@keyframes result-3d {
  0%,
  100% {
    transform: scale(var(--result-scale, 1)) rotateX(8deg) rotateY(-7deg)
      translateZ(14px);
  }
  50% {
    transform: scale(var(--result-scale, 1)) rotateX(-3deg) rotateY(7deg)
      translateZ(26px);
  }
}
.playing .game-heading {
  height: 84px;
  min-height: 84px;
}
.playing .game-heading .eyebrow {
  display: none;
}
.playing .painted-title img {
  width: 180px;
  height: 80px;
  object-fit: contain;
}
.portrait-game .game-heading {
  height: 72px;
  min-height: 72px;
}
.portrait-game .painted-title img {
  width: 170px;
  height: 68px;
}
@media (max-height: 480px) {
  .playing .game-heading {
    height: 44px;
    min-height: 44px;
  }
  .playing .painted-title img {
    height: 42px;
    width: 105px;
  }
  .defeat .result-card {
    padding: 10px;
    margin-bottom: 2px;
  }
  .defeat #result-title {
    font-size: 38px;
    margin: 6px 0;
  }
  .defeat #result-name {
    font-size: 11px;
    margin: 5px 0;
  }
  .defeat .standing {
    padding: 3px;
    font-size: 11px;
  }
}
.reduced #result-title {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  #result-title {
    animation: none !important;
    transform: none !important;
  }
}
#result-title:before {
  content: none;
}
#result-fireworks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}
.defeat #result-fireworks {
  display: none;
}
#celebration .crown {
  width: clamp(90px, 19vw, 150px);
  height: auto;
  margin: 0 auto;
  line-height: 0;
  filter: drop-shadow(0 0 14px var(--accent));
}
#celebration .crown svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: hidden;
}
/* Colors are chosen on player heads after Play Now, before the first die click. */
#menu #colors {
  display: none !important;
}
#cavern-eyes {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.playing #cavern-eyes {
  display: block;
}
#live-lava {
  opacity: 1;
}
/* Premium player-count chooser: real colored pins, no plain browser-style list. */
@font-face {
  font-family: SerpentRoyal;
  src: url("../2048/cormorant-700.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}
#local-options {
  position: fixed;
  inset: 0;
  margin: auto;
  display: block;
  width: min(620px, 94vw);
  max-height: 88dvh;
  padding: 22px;
  border: 4px double #f9d77e;
  border-radius: 28px;
  background: radial-gradient(at 50% 0, #345c36, #102e21 48%, #08190f);
  box-shadow:
    inset 0 0 0 3px #3d2910,
    inset 0 0 35px #0009,
    0 15px 70px #000b;
  text-align: center;
  color: #fff0be;
}
#local-options::backdrop {
  background: #021008b8;
  backdrop-filter: blur(7px);
}
#local-options #close-local {
  position: absolute;
  right: 12px;
  top: 9px;
  min-height: 35px;
  width: 35px;
  padding: 0;
  border-radius: 50%;
  font-size: 25px;
  background: #102719;
  border: 1px solid #b58d42;
}
.chooser-crown {
  font:
    56px SerpentRoyal,
    Georgia,
    serif;
  color: #ffda73;
  text-shadow:
    0 3px #81500d,
    0 0 15px #d9a43477;
  line-height: 1;
}
#local-title {
  font:
    700 clamp(27px, 4vw, 40px) SerpentRoyal,
    Georgia,
    serif;
  color: #ffe69b;
  margin: 7px 0;
}
#local-options > p {
  color: #c8d5b7;
  font:
    14px Georgia,
    serif;
  margin: 0 0 20px;
}
.player-count-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
#local-options [data-local-mode] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  min-height: 160px;
  padding: 16px 7px;
  background: radial-gradient(at 50% 25%, #2b6541, #102e22 70%);
  border: 2px solid #dbb768;
  border-radius: 20px;
  box-shadow:
    inset 0 0 0 2px #684b1f,
    inset 0 2px 6px #fff0a155,
    0 5px 12px #0005;
}
#local-options [data-local-mode][aria-pressed="true"] {
  background: radial-gradient(at top, #517b40, #173a25);
  border-color: #ffefb3;
  box-shadow:
    0 0 15px #ffc95766,
    inset 0 0 0 2px #bb8736;
}
.seat-preview {
  display: flex;
  justify-content: center;
  align-items: end;
  width: 100%;
  height: 56px;
  gap: 0;
}
.seat-preview .pin-avatar {
  width: 32px;
  height: 46px;
  filter: drop-shadow(0 3px 2px #0009);
  margin: 0 -3px;
}
#local-options strong {
  font:
    700 clamp(18px, 3vw, 27px) SerpentRoyal,
    Georgia,
    serif;
  color: #ffe494;
  white-space: nowrap;
  text-shadow: 0 2px #4b310c;
}
#local-options small {
  font:
    11px Georgia,
    serif;
  color: #cfdfc2;
}
@media (max-width: 430px) {
  #local-options {
    padding: 18px 12px;
  }
  .player-count-grid {
    gap: 7px;
  }
  #local-options [data-local-mode] {
    min-height: 145px;
    padding: 12px 3px;
    border-radius: 16px;
  }
  .seat-preview .pin-avatar {
    width: 25px;
    height: 38px;
    margin: 0 -4px;
  }
  #local-options small {
    font-size: 10px;
  }
}
/* Celebration stays on the actual board; completed players never block the next turn. */
#celebration:not(.defeat) {
  inset: auto;
  left: var(--result-left);
  top: var(--result-top);
  width: var(--result-width);
  height: var(--result-height);
  border-radius: 22px;
  background: radial-gradient(ellipse, #06120bdd, #06120b88 55%, #06120b28);
  backdrop-filter: blur(1px);
}
#celebration .result-card {
  max-width: 96%;
  max-height: 100%;
  overflow: auto;
  padding: 18px 12px;
  perspective: none;
}
#celebration #result-title {
  font:
    700 clamp(30px, 8vw, 68px) SerpentRoyal,
    Georgia,
    serif;
  line-height: 1.05;
  margin: 12px 0;
  color: var(--accent);
  letter-spacing: 0;
  text-shadow:
    0 2px #66401b,
    0 4px 6px #000b,
    0 0 16px color-mix(in srgb, var(--accent) 60%, transparent);
  -webkit-text-stroke: 0.35px #ffe7a3;
  animation: royal-title-glow 2.2s ease-in-out infinite alternate !important;
}
#celebration.bot-victory #result-title {
  color: #ffdf7a;
  background: linear-gradient(#fff8cd, #ffdc6c 40%, #b97c1d 66%, #fff0a6);
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 0.3px #fff1bb;
  text-shadow: none;
  filter: drop-shadow(0 2px 1px #70410a) drop-shadow(0 0 12px #ffba3355);
  font-size: clamp(40px, 10vw, 84px);
}
#celebration .crown {
  width: clamp(78px, 18vw, 135px);
  margin: auto;
  animation: crown-arrival 0.9s ease-out both;
  filter: drop-shadow(0 0 12px var(--medal-color, #ffd66b));
}
#celebration .crown[data-medal="silver"] svg,
.medal-icon[data-medal="silver"] svg {
  filter: grayscale(1) brightness(1.55) contrast(0.8);
}
#celebration .crown[data-medal="bronze"] svg,
.medal-icon[data-medal="bronze"] svg {
  filter: sepia(1) saturate(1.6) hue-rotate(-18deg) brightness(0.8);
}
.finish-crown[data-medal="silver"] image {
  filter: grayscale(1) brightness(1.55) contrast(0.8);
}
.finish-crown[data-medal="bronze"] image {
  filter: sepia(1) saturate(1.6) hue-rotate(-18deg) brightness(0.8);
}
#celebration #result-name {
  font:
    15px Georgia,
    serif;
  color: #f4dfad;
  line-height: 1.5;
  margin: 8px auto 14px;
}
#celebration.placement-celebration #result-title {
  font-size: clamp(26px, 6vw, 48px);
  max-width: 100%;
  text-wrap: balance;
}
#celebration .result-card button {
  font:
    700 clamp(16px, 3vw, 22px) SerpentRoyal,
    Georgia,
    serif;
  border: 2px solid #e6c57b;
  border-radius: 24px;
  background: linear-gradient(#365d31, #123c27 50%, #0c2316);
  color: #ffedb4;
  box-shadow: inset 0 1px 3px #fff5ab44;
  padding: 10px 20px;
  margin: 7px;
  min-height: 44px;
}
#celebration #try-again {
  width: auto;
}
#celebration.final-summary .crown {
  display: none;
}
#celebration.final-summary #result-title {
  color: #ffe49c;
  font-size: clamp(28px, 6vw, 45px);
}
#celebration.final-summary #result-name {
  font-size: 12px;
  margin: 4px 0 12px;
}
#standings .standing {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 9px;
  align-items: center;
  padding: 7px 9px;
  background: linear-gradient(90deg, #163324bb, #0c211988);
  border: 1px solid #dfb65c55;
  border-radius: 12px;
  margin: 5px 0;
  text-align: left;
  font:
    12px Georgia,
    serif;
  color: #ebdfc4;
}
.standing strong {
  color: var(--pawn);
  font-size: 16px;
  text-shadow: 0 1px 2px #000;
}
.medal-icon {
  display: block;
  width: 42px;
  height: 28px;
}
.medal-icon svg {
  width: 100%;
  height: 100%;
}
.last-place-mark {
  font-size: 24px;
  color: #ab9872;
  text-align: center;
}
#celebration.defeat .result-card {
  overflow: visible;
  max-width: 650px;
}
#celebration.defeat #result-title {
  color: #ffd397;
  font-size: clamp(40px, 9vw, 80px);
}
#celebration .fireworks {
  display: none;
}
@keyframes royal-title-glow {
  to {
    filter: brightness(1.12);
  }
}
@keyframes crown-arrival {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.7);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@media (max-width: 430px) {
  #celebration .result-card {
    padding: 12px 8px;
  }
  #celebration .result-card button {
    padding: 8px 13px;
    margin: 5px;
    font-size: 16px;
  }
  #standings .standing {
    grid-template-columns: 34px 1fr auto;
    gap: 5px;
    padding: 5px 7px;
    font-size: 10px;
  }
  .medal-icon {
    width: 32px;
    height: 24px;
  }
  .standing strong {
    font-size: 14px;
  }
  #celebration.final-summary #result-name {
    margin: 3px 0 8px;
  }
  #celebration.final-summary #result-title {
    margin: 5px 0;
  }
}
/* Entrance retains the exact menu snake and its original photo-textured jaw. */
#entrance-scene[data-mode="enter"] .cinematic-face,
#entrance-scene[data-mode="enter"] .cinematic-jungle,
#entrance-scene[data-mode="enter"] .cinematic-aura {
  display: none;
}
.entering #jungle,
.entering #royal-upper,
.entering #royal-lower,
.entering .menu-mouth-cavity {
  animation: none !important;
}
.entering #menu {
  opacity: 1 !important;
  transition: none !important;
}
.entering .menu-hero {
  opacity: 1 !important;
  transform-origin: var(--mouth-x) var(--mouth-y);
}
.entering #royal-upper {
  transform-origin: 260px 152px;
  transform-box: view-box;
}
.entering #royal-lower {
  transform-origin: 278px 153px;
  transform-box: view-box;
}
.entering .menu-mouth-cavity {
  transform-origin: 365px 178px;
  transform-box: view-box;
}
.arriving #play {
  filter: blur(var(--arrival-blur, 24px));
  opacity: var(--arrival-opacity, 0.12);
  will-change: filter, opacity;
}
.arriving #play .board-frame {
  transform: scale(var(--arrival-scale, 0.72));
  transform-origin: center;
  will-change: transform;
}
.cinematic-dark {
  background: radial-gradient(ellipse at 50% 50%, #140402, #020000 75%);
}
#intro {
  pointer-events: auto;
}
#intro[hidden] {
  pointer-events: none;
}
.reduced #celebration #result-title {
  animation: none !important;
  filter: none;
}
#local-options .chooser-crown {
  width: 85px;
  height: 62px;
  margin: auto;
  line-height: 0;
}
#local-options .chooser-crown svg {
  width: 100%;
  height: 100%;
  display: block;
}
#local-options .seat-preview .pin-avatar {
  width: 36px;
  height: 52px;
  margin: 0 -3px;
  flex-shrink: 0;
}
#local-options strong {
  font-size: 26px;
}
@media (max-width: 430px) {
  #local-options .seat-preview .pin-avatar {
    width: 28px;
    height: 43px;
    margin: 0 -4px;
  }
  #local-options strong {
    font-size: 21px;
  }
}
#celebration.final-summary #result-name {
  display: none;
}
#celebration.final-summary .result-card {
  padding: 10px;
}
#celebration.final-summary #result-title {
  font-size: clamp(25px, 5.5vw, 40px);
  margin: 3px 0 7px;
}
#celebration.final-summary .standing {
  padding: 4px 7px;
  margin: 4px 0;
}

#celebration button:focus-visible {
  outline: 2px solid #ffe39b;
  outline-offset: 3px;
}
.standing > span:last-child {
  justify-self: end;
  color: #d9c99f;
}
@media (max-height: 500px) {
  #local-options {
    padding: 12px 20px;
  }
  #local-options .chooser-crown {
    width: 60px;
    height: 40px;
  }
  #local-options h2 {
    font-size: 27px;
    margin: 3px 0;
  }
  #local-options > p {
    font-size: 12px;
    margin: 0 0 10px;
  }
  #local-options [data-local-mode] {
    min-height: 112px;
    padding: 7px;
  }
  #local-options .seat-preview {
    height: 42px;
  }
  #local-options .seat-preview .pin-avatar {
    width: 28px;
    height: 40px;
  }
  #local-options strong {
    font-size: 22px;
  }
}
/* Entry keeps the existing menu snake node and artwork for the entire camera move. */
.entering #menu #royal-upper,
.entering #menu #royal-lower,
.entering #menu .menu-mouth-cavity {
  animation: none !important;
}
.entering #menu .menu-tongue {
  animation: none !important;
  opacity: 0;
}
.original-snake-entry {
  background: none;
}
.original-snake-entry .cinematic-dark {
  background: radial-gradient(ellipse, #260507, #040001 75%);
}
.bot-victory #standings,
.defeat #standings {
  display: none;
}
/* Always-visible player count and explicit match type replace the dropdown. */
#player-count-choice {
  display: flex;
  gap: 9px;
  min-height: 44px;
}
#player-count-choice button {
  flex: 1;
  border: 2px solid #dcaf4b;
  border-radius: 18px;
  padding: 7px 4px;
  background: linear-gradient(#17251b, #050c08);
  color: #ffe7a0;
  font: 700 clamp(20px, 2.4vw, 30px) / 1 Georgia;
  box-shadow:
    inset 0 1px 3px #fff7,
    0 3px 7px #0009;
}
#player-count-choice small {
  display: inline;
  font-size: 0.53em;
}
#player-count-choice button.selected {
  background: linear-gradient(#16783a, #053b20);
  border-color: #ffe99a;
  box-shadow:
    inset 0 0 0 2px #bf913b,
    0 0 12px #d7b45466;
}
#menu #friends-mode {
  font-size: clamp(19px, 2.3vw, 34px);
}
#menu .menu-panel {
  gap: clamp(7px, 1.25vh, 14px);
}
#menu #bot-mode > span:last-child {
  font-size: 0.85em;
}
#jungle-life {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}
@media (max-aspect-ratio: 4/5) {
  #menu .menu-panel {
    gap: clamp(5px, 0.9vh, 9px);
  }
  #menu #friends-mode {
    font-size: clamp(20px, 3.8vh, 28px);
  }
  #player-count-choice {
    flex: 0 0 44px;
    gap: 7px;
  }
  #player-count-choice button {
    font-size: 23px;
    padding: 6px;
    border-radius: 14px;
  }
  #menu #bot-mode small {
    display: inline;
  }
}
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  #player-count-choice {
    min-height: 34px;
  }
  #player-count-choice button {
    font-size: 17px;
    padding: 4px;
  }
  #menu .menu-panel {
    gap: 4px;
  }
  #menu #friends-mode {
    font-size: 17px;
  }
  #menu #bot-mode {
    font-size: 17px;
  }
  #menu #bot-mode small {
    display: inline;
  }
}
/* Desktop seats surround the board; compact phone seats remain below/beside it. */
.desktop-game header {
  height: 148px;
  min-height: 148px;
  align-items: flex-start;
  padding: 8px 20px;
}
.desktop-game main {
  height: calc(100dvh - 148px);
  padding: 0 18px 28px;
}
.desktop-game .game-heading {
  position: fixed;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  height: 144px;
  min-height: 0;
  width: 290px;
  z-index: 4;
  pointer-events: none;
}
.desktop-game .painted-title img {
  width: 290px;
  height: 144px;
  max-width: none;
}
.desktop-game .game-layout {
  position: relative;
  display: block;
  margin-top: 8px;
}
.desktop-game .board-frame {
  margin: 0 auto;
}
.desktop-game #play aside {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  display: block;
  pointer-events: none;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.desktop-game #players {
  position: absolute;
  inset: 0;
  display: block;
}
.desktop-game #play #players .player-row {
  position: absolute;
  width: 154px;
  height: 136px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 30px 70px 18px;
  grid-template-areas: "head" "die" "position";
  align-content: center;
  justify-items: center;
  gap: 3px;
  padding: 7px;
  margin: 0;
  border-radius: 18px;
  pointer-events: auto;
  background: linear-gradient(135deg, #25140eef, #080f0bef);
  box-shadow:
    0 5px 18px #0008,
    inset 0 0 14px #b8802222;
}
.desktop-game #play #players .player-head {
  justify-content: center;
  min-height: 30px;
}
.desktop-game #play #players .player-head strong {
  font-size: 12px;
}
.desktop-game #play #players .pin-avatar {
  width: 23px;
  height: 28px;
}
.desktop-game #play #players .player-die {
  --die-size: 52px;
  width: 80px;
  height: 70px;
  min-height: 70px;
  padding: 8px;
}
.desktop-game #play #players .player-position {
  font-size: 11px;
  text-align: center;
  padding: 0;
}
.desktop-game #players [data-player-card="0"],
.desktop-game #players [data-player-card="2"] {
  left: calc(50% + var(--board-size) / 2 + 20px);
  right: auto;
}
.desktop-game #players [data-player-card="1"],
.desktop-game #players [data-player-card="3"] {
  right: calc(50% + var(--board-size) / 2 + 20px);
  left: auto;
}
.desktop-game #players [data-player-card="0"],
.desktop-game #players [data-player-card="1"] {
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}
.desktop-game #players[data-count="3"] [data-player-card="0"],
.desktop-game #players[data-count="4"] [data-player-card="0"],
.desktop-game #players [data-player-card="3"] {
  top: auto;
  bottom: 0;
  transform: none;
}
.desktop-game #players[data-count="3"] [data-player-card="1"],
.desktop-game #players[data-count="4"] [data-player-card="1"],
.desktop-game #players [data-player-card="2"] {
  top: 0;
  bottom: auto;
  transform: none;
}
.desktop-game #status {
  position: absolute;
  left: 50%;
  bottom: -25px;
  transform: translateX(-50%);
  width: var(--board-size);
  max-width: none;
  min-height: 18px;
  text-align: center;
  font-size: 12px;
  pointer-events: none;
}
/* Bevelled victory artwork, animated reflected light and pawn-color celebrations. */
#celebration.bot-victory {
  background: radial-gradient(ellipse at 50% 42%, #173c27ed, #010704f5 76%);
}
#celebration.bot-victory:before {
  content: "";
  position: absolute;
  inset: -25%;
  background: repeating-conic-gradient(
    from 0deg,
    transparent 0deg 10deg,
    #e0ba6e15 10deg 13deg,
    transparent 13deg 30deg
  );
  mask-image: radial-gradient(ellipse, #000, transparent 65%);
  animation: royal-rays 45s linear infinite;
}
#celebration.bot-victory .result-card {
  max-width: 800px;
  width: 96%;
  padding: 16px;
  background: none;
}
#celebration.bot-victory .crown {
  display: none;
}
#celebration.bot-victory #result-title {
  height: clamp(190px, 45vh, 390px);
  width: 100%;
  margin: 0;
  color: transparent;
  font-size: 0;
  line-height: 0;
  -webkit-text-stroke: 0;
  text-shadow: none;
  background: url("assets/victory-emblem.webp") center/contain no-repeat;
  filter: drop-shadow(0 0 16px var(--accent));
}
#celebration.bot-victory #result-title:after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 35%,
    #fff6 48%,
    transparent 60%
  );
  mask: url("assets/victory-emblem.webp") center/contain no-repeat;
  mix-blend-mode: screen;
  animation: victory-gleam 4s ease-in-out infinite;
  pointer-events: none;
}
.victory-caption {
  display: none;
}
.bot-victory .victory-caption {
  display: block;
  margin: 2px 0 14px;
  font: 700 12px/1.2 Georgia;
  color: #e5c982;
  letter-spacing: 3px;
  text-transform: uppercase;
}
.bot-victory #result-name {
  font-size: 14px;
  color: #ffe8af;
}
.result-card #try-again,
.result-card #result-menu,
.result-card #continue {
  min-height: 48px;
  border: 2px solid #e2b65a;
  border-radius: 999px;
  box-shadow:
    inset 0 0 0 2px #624016,
    inset 0 2px 4px #fff3,
    0 4px 10px #0008;
  padding: 10px 20px;
  font: 700 15px Georgia;
}
.bot-victory #try-again {
  background: linear-gradient(#146a36, #03341b);
  color: #fff2b7;
}
@keyframes royal-rays {
  to {
    transform: rotate(360deg);
  }
}
@keyframes victory-gleam {
  0%,
  20% {
    opacity: 0;
    transform: translateX(-15%);
  }
  40% {
    opacity: 0.8;
  }
  65%,
  100% {
    opacity: 0;
    transform: translateX(20%);
  }
}
@media (max-height: 480px) {
  #celebration.bot-victory #result-title {
    height: 165px;
  }
  .bot-victory .victory-caption {
    margin: 0 0 5px;
    font-size: 10px;
  }
  .bot-victory #result-name {
    margin: 4px 0;
  }
  .result-card #try-again,
  .result-card #result-menu {
    min-height: 42px;
    padding: 8px 15px;
  }
}
.low #celebration.bot-victory:before {
  display: none;
}
.reduced #celebration:before,
.reduced #result-title:after {
  animation: none !important;
}
#menu #bot-mode small {
  display: block !important;
  font-size: max(11px, 0.6em);
  line-height: 1.05;
  white-space: nowrap;
}
@media (max-height: 650px) and (max-aspect-ratio: 4/5) {
  #menu #bot-mode {
    font-size: 21px;
    padding: 4px 10px;
  }
}
.desktop-game #status {
  background: #130c08e8;
  border: 1px solid #ad833f;
  border-radius: 20px;
  padding: 3px 8px;
}
#celebration.bot-victory #result-title {
  height: auto;
  aspect-ratio: 1.7;
  min-height: 0;
  max-height: 45vh;
}
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  #player-count-choice {
    min-height: 44px;
  }
  #player-count-choice button {
    min-height: 44px;
  }
}

#celebration.bot-victory #result-title {
  animation: result-3d 4s ease-in-out infinite !important;
  transform: rotateY(0deg);
}
#celebration.bot-victory .result-card {
  perspective: 850px;
}
.reduced #celebration.bot-victory #result-title {
  animation: none !important;
}
/* The bot victory has its own full-viewport stage, including short landscape screens. */
#celebration.bot-victory {
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
}
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  #celebration.bot-victory .result-card {
    padding: 6px;
  }
  #celebration.bot-victory #result-title {
    max-height: 42vh;
    width: min(100%, 400px);
    margin: 0 auto;
  }
  #celebration.bot-victory .victory-caption {
    margin: 3px 0;
  }
  #celebration.bot-victory #result-name {
    margin: 4px 0;
  }
  #celebration.bot-victory button {
    margin-top: 5px;
    margin-bottom: 0;
  }
}
/* One photographic menu animal frames a real, interactive board through its mouth. */
html,
body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
.cube-stage {
  transform: none;
}
.mouth-crossing #menu {
  z-index: 20;
  pointer-events: none;
}
.mouth-crossing header {
  visibility: hidden;
}
.mouth-crossing #menu .menu-panel {
  opacity: 0;
  pointer-events: none;
  transition: none;
}
.mouth-crossing #menu .menu-hero {
  animation: none !important;
  filter: none;
  will-change: transform;
}
.mouth-crossing #menu #jungle {
  width: 100%;
  height: 100%;
  position: static;
}
.mouth-crossing #menu .menu-neck,
.mouth-crossing #menu .menu-head {
  animation: none !important;
}
#intro {
  z-index: 50;
  overflow: hidden;
}
.mouth-journey {
  perspective: none;
}
.throat-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.arriving #play {
  filter: blur(var(--arrival-blur, 0px))
    brightness(var(--arrival-brightness, 1));
  opacity: var(--arrival-opacity, 1);
}
.arriving #play .board-frame {
  transform: translate(var(--arrival-x, 0px), var(--arrival-y, 0px))
    scale(var(--arrival-scale, 1));
}
.return-play,
.return-lose {
  position: fixed;
  left: 50%;
  top: 50%;
  opacity: 0;
  pointer-events: none;
  transform-origin: center;
}
.return-play {
  border: 3px double #ffe099;
  border-radius: 50px;
  padding: 12px 22px;
  color: #fff0b2;
  background: linear-gradient(#08713d, #012d19);
  box-shadow:
    0 0 15px #e9b94c,
    inset 0 0 0 2px #744e15;
  font:
    italic 700 clamp(22px, 3vw, 36px) Georgia,
    serif;
  text-align: center;
  white-space: nowrap;
}
.return-lose {
  font:
    900 clamp(38px, 8vw, 100px) Georgia,
    serif;
  color: #ffc66c;
  text-shadow:
    0 1px #9f5219,
    0 3px #75340d,
    0 5px #432306,
    0 8px 3px #000;
}
.returning #menu .menu-panel {
  opacity: var(--return-options, 0);
}
.defeat-camera #menu .menu-panel {
  opacity: 0;
}
#celebration.defeat {
  background: transparent;
  backdrop-filter: none;
  z-index: 40;
}
#celebration.defeat #defeat-snake {
  display: block;
}
#celebration.defeat #result-title {
  animation: result-3d 3s ease-in-out infinite !important;
  font-weight: 900;
  text-shadow:
    0 1px #b7742a,
    0 3px #88531b,
    0 5px #6b3610,
    0 7px #4d2207,
    0 10px 3px #000;
}
#celebration,
#celebration .result-card {
  overflow: hidden;
}
#celebration .result-card {
  min-width: 0;
  flex-shrink: 1;
  padding: 12px;
}
#celebration #result-title {
  max-width: 100%;
  overflow-wrap: anywhere;
}
#celebration.bot-victory #result-title {
  width: min(100%, 720px);
  height: min(45dvh, 390px);
  aspect-ratio: auto;
  margin: 0 auto;
}
#celebration.bot-victory .result-card {
  width: min(800px, 94vw);
  max-width: 94vw;
  max-height: 96dvh;
}
#celebration.bot-victory #result-name {
  display: none;
}
#celebration:not(.defeat) {
  overflow: hidden;
  contain: paint;
}
#celebration .result-card button {
  max-width: 48%;
}
#celebration.defeat .result-card {
  position: relative;
  top: 16dvh;
}
#celebration.defeat #result-name {
  display: none;
}
@media (max-height: 480px) {
  #celebration .result-card {
    padding: 6px;
  }
  #celebration.bot-victory #result-title {
    height: 42dvh;
  }
  #celebration .result-card button {
    min-height: 40px;
    margin: 3px;
    padding: 6px 14px;
  }
  #celebration.defeat .result-card {
    top: 12dvh;
  }
  #celebration.defeat #result-title {
    font-size: clamp(30px, 8vh, 52px);
    margin: 6px 0;
  }
}
.mouth-crossing #play aside,
.mouth-crossing .game-heading {
  visibility: hidden;
}
/* Narrowing a photographed eyelid supplies the final hostile gaze, without a second head. */
.defeat-camera #menu .menu-scenery {
  filter: brightness(0.64);
}
.return-play {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
}
.return-play svg {
  width: 36px;
  height: 36px;
  fill: #ffd85a;
  flex: none;
}
#celebration.defeat .result-card {
  position: absolute;
  top: auto;
  bottom: max(16px, 6dvh);
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, 94vw);
  max-width: 94vw;
}
#celebration.defeat #result-title,
.return-lose {
  font-size: 0;
  line-height: 0;
  text-shadow: none;
  -webkit-text-stroke: 0;
  background: url("assets/defeat-title.webp") center/contain no-repeat;
  height: clamp(70px, 18dvh, 150px);
  width: 100%;
  margin: 4px auto 10px;
  filter: drop-shadow(0 6px 10px #000b);
}
.return-lose {
  width: min(720px, 90vw);
}
#celebration.defeat #result-title:before {
  display: none;
}
@media (max-height: 480px) {
  #celebration.defeat .result-card {
    bottom: 10px;
  }
  #celebration.defeat #result-title {
    height: 20dvh;
    margin: 0 auto 6px;
  }
  #celebration.final-summary #result-title {
    font-size: 22px;
  }
  #celebration.final-summary .standing {
    font-size: 10px;
    margin: 2px 0;
    padding: 2px 6px;
  }
  #celebration.final-summary .medal-icon {
    height: 20px;
    width: 28px;
  }
  #celebration.final-summary .standing strong {
    font-size: 13px;
  }
}
@media (max-height: 480px) {
  #celebration.two-player-result .crown,
  #celebration.placement-celebration .crown {
    width: 84px;
  }
  #celebration.two-player-result #result-title {
    font-size: 28px;
    margin: 5px 0;
  }
  #celebration:not(.bot-victory):not(.defeat) .result-card button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: calc(50% - 8px);
    max-width: none;
    margin: 3px;
    min-height: 40px;
    font-size: 12px;
    padding: 6px;
    white-space: nowrap;
  }
}
#celebration.defeat .result-card {
  background: none;
  box-shadow: none;
}
#celebration.defeat .result-card {
  overflow: hidden;
}

/* Bound mobile work and fit the actually visible browser viewport. */
body,
body:not(.playing),
body:not(.playing) main,
#menu {
  height: var(--app-height, 100dvh);
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
#world .tree,
#world .rays,
#world .mist {
  display: none !important;
}
.low #world .embers {
  display: none !important;
}
.mobile-menu-art {
  animation: none !important;
}
#start[aria-busy="true"] {
  cursor: progress;
}
@media (max-width: 800px), (pointer: coarse) {
  .menu-scenery,
  .cinematic-jungle {
    background-image: url("assets/jungle-menu-small.webp");
  }
  .menu-hero {
    filter: none;
  }
  .low #menu .menu-neck,
  .low #menu .menu-head,
  .low #menu .menu-jaw {
    animation: none !important;
  }
  .mouth-crossing #play {
    filter: brightness(var(--arrival-brightness, 1));
  }
}
@media (max-aspect-ratio: 4/5) {
  #menu {
    display: grid;
    grid-template-rows: 48px minmax(70px, 1fr) minmax(284px, 48%);
    padding: 8px 0 max(14px, env(safe-area-inset-bottom));
  }
  #menu .menu-hero {
    position: relative;
    grid-row: 2;
    top: auto;
    left: auto;
    width: 94%;
    height: 100%;
    margin: auto;
  }
  #menu .menu-panel {
    position: relative;
    grid-row: 3;
    inset: auto;
    transform: none;
    width: 80%;
    height: 100%;
    max-height: 430px;
    margin: auto;
    gap: clamp(4px, 1vh, 8px);
  }
}
/* Keep the static board out of the animated Canvas repaint boundary (also avoids
   mobile WebKit/Chromium foreignObject compositing failures). Numbers and pawns
   remain vector elements above the living snakes. */
.board-base,
.board-frame > .living-serpents {
  position: absolute;
  left: var(--board-pad, 9px);
  top: var(--board-pad, 9px);
  width: calc(100% - 2 * var(--board-pad, 9px));
  height: calc(100% - 2 * var(--board-pad, 9px));
  pointer-events: none;
  border-radius: 4px;
}
.board-base {
  z-index: 0;
  background: #11382b;
  contain: layout paint;
}
.board-frame > .living-serpents {
  z-index: 1;
  contain: strict;
  transform: translateZ(0);
}
#board {
  position: relative;
  z-index: 2;
  background: transparent;
}
/* The small lava Canvas already supplies the glow and embers. Do not also blur
   and blend an animated viewport-sized CSS layer behind the whole board. */
#world::after,
#world .embers {
  display: none !important;
}
.menu-hero {
  filter: none;
}

.page-hidden * {
  animation-play-state: paused !important;
}
body,
body:not(.playing),
body:not(.playing) main,
#menu {
  height: min(var(--app-height, 100dvh), 100dvh);
}
.playing [data-snake] {
  filter: none;
}
#board {
  pointer-events: none;
}

/* Both match choices share one line, one type size and an explicit icon column. */
#menu :is(#friends-mode, #bot-mode) {
  display: grid;
  grid-template-columns: 1.5em minmax(0, 1fr);
  column-gap: 8px;
  padding: 6px 14px;
  font-size: clamp(18px, 2.3vw, 34px);
  line-height: 1.1;
}
#menu :is(#friends-mode, #bot-mode) .menu-symbol {
  width: 1.5em;
  height: 1.5em;
}
#menu :is(#friends-mode, #bot-mode) .menu-symbol svg {
  width: 100%;
  height: 100%;
}
#menu :is(#friends-mode, #bot-mode) > span.mode-label {
  min-width: 0;
  font: inherit;
  line-height: 1.1;
  white-space: nowrap;
  text-align: center;
}
@media (max-aspect-ratio: 4/5) {
  #menu :is(#friends-mode, #bot-mode) {
    font-size: clamp(18px, 5.5vw, 26px);
    padding: 6px 12px;
  }
}
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  #menu :is(#friends-mode, #bot-mode) {
    font-size: clamp(14px, 2.4vw, 20px);
    padding: 6px 10px;
    column-gap: 6px;
  }
}
