:root {
  color-scheme: light dark;
  --paper: #f5f1fa;
  --ink: #2b2139;
  --muted: #655b72;
  --border: #cbbfd7;
  --surface: #fffafc;
  --button: #fff;
  --accent: #694495;
  --rule: #e3dae9;
  --tint: #e9e1f2;
  font-family: "DM Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100svh;
}
button,
select,
summary {
  font: inherit;
}
button,
summary,
select {
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled {
  cursor: default;
  opacity: 0.52;
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
summary:focus-visible,
canvas:focus-visible {
  outline: 3px solid #eb973e;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
a {
  color: inherit;
}
.shell {
  width: min(1040px, 100%);
  margin: auto;
  padding: 0 26px 32px;
}
.topline {
  display: flex;
  align-items: center;
  min-height: 55px;
  border-bottom: 1px solid var(--border);
}
.back-link {
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0;
}
h1,
h2,
p,
dl,
dd {
  margin: 0;
}
h1 {
  font-size: 42px;
  line-height: 1.16;
}
.stats {
  display: flex;
  align-items: center;
  gap: 20px;
}
.stats div {
  min-width: 44px;
}
.stats dt {
  font-size: 12px;
  color: var(--muted);
}
.stats dd {
  font:
    700 21px/1.2 ui-monospace,
    monospace;
  font-variant-numeric: tabular-nums;
}
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 258px;
  gap: 30px;
  align-items: start;
}
.stage {
  width: 100%;
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  padding: clamp(14px, 3%, 24px);
  border-radius: 10px;
  border: 1px solid #fff6;
  background: var(--table);
  box-shadow: inset 0 0 0 5px #ffffff15;
}
.snake {
  --table: #659878;
}
.tetris {
  --table: #564776;
}
.match3 {
  --table: #bb687d;
}
.mahjong {
  --table: #226853;
}
.divination {
  --table: #614060;
}
.board-wrap {
  min-width: 0;
  width: 100%;
  overflow: hidden;
  border-radius: 7px;
}
.snake-board {
  max-width: 470px;
  border: 3px solid #41634d;
  background: #d8ecc7;
}
.block-board {
  width: min(260px, 26svh);
  border: 3px solid #30263e;
  background: #221d35;
}
.board-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}
.snake canvas {
  touch-action: none;
}
.console {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.console > * {
  flex: 1 0 100%;
  min-width: 0;
}
.status-line {
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}
button:not(.tile8, .mahjong-tile),
select {
  border: 1px solid var(--border);
  background: var(--button);
  color: var(--ink);
  font-weight: 650;
  padding: 8px 12px;
  min-height: 42px;
  border-radius: 7px;
}
button:not(:disabled):active {
  translate: 0 1px;
}
button.primary,
button.primary:enabled {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.field,
.next {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}
.field select {
  font-size: 14px;
}
.buff,
.goal-text,
.combo-text {
  font-size: 14px;
  color: var(--muted);
}
.combo-text:empty {
  display: none;
}
.pad {
  display: grid;
  grid-template-areas: ". up ." "left down right";
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.pad button {
  font-size: 20px;
}
.pad [data-dir="up"] {
  grid-area: up;
}
.pad [data-dir="down"] {
  grid-area: down;
}
.pad [data-dir="left"] {
  grid-area: left;
}
.pad [data-dir="right"] {
  grid-area: right;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.actions button {
  flex: 1 1 auto;
}
.next canvas {
  width: 70px;
  height: 70px;
  background: #312840;
  border-radius: 6px;
}
.rules {
  margin-top: 6px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
}
.rules summary {
  font-weight: bold;
  width: fit-content;
}
.rules p {
  margin: 9px 0;
}
.board8 {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: 4px;
  max-width: 470px;
  aspect-ratio: 1;
  padding: 5px;
  background: #763f57;
}
.tile8 {
  position: relative;
  color: #4e2843;
  border: 0;
  border-radius: 5px;
  min-width: 0;
  padding: 0;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -3px 0 #48072a13;
  font-size: 29px;
  background: #f9e4e2;
}
.tile8[data-fruit="1"] {
  background: #f8edc7;
}
.tile8[data-fruit="2"] {
  background: #ebdbef;
}
.tile8[data-fruit="3"] {
  background: #fee0bd;
}
.tile8[data-fruit="4"] {
  background: #f9cfd1;
}
.tile8[data-fruit="5"] {
  background: #dbe6c6;
}
.tile8.selected,
.tile8.hinted {
  outline: 3px solid #543252;
  outline-offset: -4px;
}
.tile8.hinted {
  outline-style: dashed;
}
.special-mark {
  position: absolute;
  top: 0;
  right: 2px;
  font-size: 14px;
}
.fruit {
  line-height: 1;
}
progress {
  accent-color: #ae426a;
  width: 100%;
  height: 9px;
}
.mahjong .stage {
  background-color: var(--table);
  background-image: repeating-linear-gradient(
    45deg,
    transparent 0 4px,
    #ffffff04 4px 5px
  );
  padding-bottom: 18px;
}
.stacks {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 450px);
  padding: 4px 4px 7px;
  overflow: visible;
}
.mahjong-tile,
.slot:not(.empty) {
  position: relative;
  background: #fff8de;
  color: #233b34;
  border: 1px solid #eddcad;
  border-radius: 5px;
  box-shadow:
    0 3px 0 #c9b48a,
    0 5px 0 #41644f;
}
.mahjong-tile {
  aspect-ratio: 0.85;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 4px 6px;
}
.mahjong-tile[data-depth="2"],
.mahjong-tile[data-depth="3"] {
  box-shadow:
    0 3px 0 #c9b48a,
    0 5px 0 #357a63,
    0 8px 0 #ddcea9,
    0 10px 2px #1b5144;
}
.mahjong-tile.empty {
  visibility: hidden;
}
.mahjong-tile:disabled:not(.empty) {
  opacity: 0.78;
}
.face {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  container-type: size;
}
.face-wan {
  color: #b33e39;
}
.face-circle {
  color: #255d99;
}
.face-bamboo {
  color: #22835f;
}
.face-honor {
  color: #74428f;
}
.ideograph {
  font:
    800 min(73cqw, 69cqh) / 1 "Songti SC",
    "STSong",
    serif;
}
.face-wan .ideograph {
  font-size: min(53cqw, 45cqh);
  color: #31262a;
}
.face small {
  font:
    800 min(49cqw, 41cqh) / 1 "Songti SC",
    serif;
}
.pips {
  width: 94%;
  height: 94%;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  place-items: center;
  align-content: space-evenly;
  gap: 2px;
}
.pips i {
  display: block;
}
.pips.circle i {
  width: min(95%, 25cqh);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #fff7d8 0 12%,
    #a23b38 14% 28%,
    #ffecc5 30% 40%,
    #255d99 42% 100%
  );
}
.pips.circle i:only-child {
  width: 82%;
  background: repeating-radial-gradient(
    circle,
    #a33736 0 12%,
    #ffe3a3 14% 23%,
    #255d99 25% 38%
  );
}
.pips.bamboo i {
  width: min(53%, 12cqh);
  height: 21cqh;
  border-radius: 3px;
  background: linear-gradient(
    0deg,
    #26785e 0 22%,
    #b8d387 22% 36%,
    #277456 37% 71%,
    #afd292 72% 84%,
    #247257 85%
  );
}
.pips.bamboo i:only-child {
  height: 61cqh;
  width: 20cqw;
}
.tray-title {
  margin-top: 18px;
  font-size: 13px;
  font-weight: bold;
  color: #e3f7df;
}
.tray-title span {
  font-family: monospace;
}
.slots {
  display: grid;
  width: min(100%, 400px);
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  background: #164c40;
  padding: 8px;
  border-radius: 7px;
  margin-top: 7px;
}
.slot {
  display: grid;
  aspect-ratio: 0.83;
  padding: 3px;
  place-items: center;
}
.slot.empty {
  background: #ffffff12;
  border: 1px dashed #bbdfc44d;
  border-radius: 5px;
}
.divination .stage {
  background: repeating-linear-gradient(135deg, #684860 0 2px, #63455d 2px 6px);
  color: #ffedcc;
  padding: 30px 20px;
}
.cup-table {
  width: min(100%, 560px);
  text-align: center;
}
.cup-table canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #eadbbc;
  border-radius: 48%;
  box-shadow: 0 4px 0 #be9c7c;
}
.cup-table h2 {
  font:
    700 30px/1.25 "Songti SC",
    serif;
  margin-top: 24px;
}
.cup-table p {
  min-height: 30px;
  color: #f4e4d6;
  font-size: 15px;
  margin-top: 8px;
}
.home-header {
  margin: 18px 0 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 110px;
  padding: 12px 28px;
  color: #fff8ed;
  background: #593684;
  border-radius: 8px;
  overflow: hidden;
}
.home-header canvas {
  width: min(42%, 350px);
  height: auto;
}
.home-header h1 {
  white-space: nowrap;
}
.home-header h1 {
  font-size: 46px;
}
.game-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 18px;
}
.game-card {
  grid-column: span 2;
  display: grid;
  grid-template-rows: auto auto;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
}
.game-card:first-child,
.game-card:nth-child(2) {
  grid-column: span 3;
}
.game-card img {
  display: block;
  width: 100%;
  height: 170px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--tint);
  transition: filter 0.18s;
}
.game-card:first-child img,
.game-card:nth-child(2) img {
  height: 195px;
}
.caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 3px 0 10px;
}
.caption strong {
  font-size: 19px;
}
.caption i {
  font-style: normal;
  color: var(--accent);
}
.game-card:hover img {
  filter: brightness(1.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #211e28;
    --ink: #f7f1fa;
    --muted: #c8bbd4;
    --border: #584d61;
    --surface: #302939;
    --button: #382e40;
    --accent: #8655ac;
    --rule: #44364d;
    --tint: #43324e;
  }
}
@media (max-width: 720px) {
  .shell {
    padding: 0 14px 22px;
  }
  .topline {
    min-height: 40px;
  }
  .page-heading {
    margin: 13px 0;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  h1 {
    font-size: 27px;
  }
  .stats {
    gap: 10px;
  }
  .stats div {
    min-width: 27px;
  }
  .stats dd {
    font-size: 16px;
  }
  .stats dt {
    font-size: 11px;
  }
  .play-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .stage {
    padding: 10px;
  }
  .console {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
  }
  .console > * {
    grid-column: 1/-1;
  }
  .status-line,
  .console > #play,
  .snake .field,
  .snake .buff,
  .tetris .next,
  .tetris .move,
  .mahjong .field,
  .mahjong .actions {
    grid-column: auto;
  }
  .pad {
    display: flex;
  }
  .pad button {
    flex: 1;
  }
  .next {
    justify-content: flex-start;
  }
  .next canvas {
    width: 42px;
    height: 42px;
  }
  .move {
    flex-wrap: nowrap;
  }
  .move button {
    padding: 6px;
  }
  .block-board {
    width: min(235px, 21svh);
  }
  .snake-board,
  .board8 {
    max-width: min(100%, 49svh);
  }
  .tile8 {
    font-size: 23px;
  }
  .stacks {
    gap: 6px;
    width: min(100%, 48svh);
  }
  .mahjong-tile {
    padding: 3px 4px;
  }
  .slots {
    width: min(100%, 40svh);
  }
  .tile8.selected,
  .tile8.hinted {
    outline-width: 2px;
  }
  .tray-title {
    margin-top: 10px;
  }
  .rules {
    margin-top: 3px;
    padding-top: 8px;
  }
  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .game-card,
  .game-card:nth-child(2) {
    grid-column: span 1;
  }
  .game-card:first-child {
    grid-column: 1/-1;
  }
  .game-card img,
  .game-card:nth-child(2) img {
    height: 108px;
  }
  .game-card:first-child img {
    height: 155px;
  }
  .caption strong {
    font-size: 16px;
  }
  .home-header {
    min-height: 80px;
    padding: 8px 15px;
    margin: 12px 0 16px;
  }
  .home-header h1 {
    font-size: 31px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
