:root {
  --paper: #f4ead8;
  --ink: #3a3129;
  --muted: #8f8474;
  --card: #fffaf0;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", SimSun, serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* 与游戏一致的竖屏单列，桌面宽屏居中显示。 */
.hub {
  max-width: 440px;
  min-height: 100%;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 44px) 18px calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hub[hidden] { display: none; }

.hub-head { text-align: center; margin-bottom: 10px; }

.kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: .32em;
  color: var(--muted);
}

.hub-head h1 {
  margin: 10px 0 6px;
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: .2em;
  text-indent: .2em;
}

.sub {
  margin: 0;
  font-size: 13px;
  letter-spacing: .12em;
  color: #a1705f;
}

.game-card {
  display: grid;
  grid-template-columns: 124px 1fr;
  gap: 14px 16px;
  align-items: center;
  padding: 16px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid rgba(116, 87, 64, .14);
  box-shadow: 0 3px 0 rgba(91, 65, 43, .06), 0 12px 24px -16px rgba(91, 65, 43, .45);
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease;
}

.game-card:active { transform: scale(.98); }

.info h2 { margin: 0; font-size: 21px; }

.tagline { margin: 6px 0 12px; font-size: 12px; }

.modes {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.modes li {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
}

.play {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .08em;
}

/* 五子棋：取自其大厅的豆沙棋盘与黄绿按钮。 */
.gomoku .info h2 { font-weight: 800; letter-spacing: .04em; }
.gomoku .tagline { color: #b0786a; }
.gomoku .modes li { background: #eaf0dc; color: #62794f; }
.gomoku .play { background: #e0b565; color: #4b3a22; box-shadow: inset 0 -2px 0 rgba(120, 80, 30, .18); }

.preview {
  position: relative;
  width: 124px;
  height: 124px;
  border-radius: 16px;
  display: grid;
  place-items: center;
}

.gomoku-board {
  --cell: 24px;
  background: #d2a69b;
  box-shadow: inset 0 -3px 0 rgba(119, 80, 68, .18), inset 0 0 0 5px #deb9ad;
}

.gomoku-board .grid,
.xiangqi-board .grid {
  position: relative;
  width: calc(var(--cols) * var(--cell) + 1.5px);
  height: calc(var(--rows) * var(--cell) + 1.5px);
  background:
    repeating-linear-gradient(to right, var(--line) 0 1.5px, transparent 1.5px var(--cell)),
    repeating-linear-gradient(to bottom, var(--line) 0 1.5px, transparent 1.5px var(--cell));
}

.gomoku-board .grid { --cols: 4; --rows: 4; --line: #84605566; }

.stone,
.piece {
  position: absolute;
  left: calc(var(--c) * var(--cell) + .75px);
  top: calc(var(--r) * var(--cell) + .75px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.stone {
  width: 20px;
  height: 20px;
  box-shadow: 1px 2px 2px rgba(61, 43, 34, .35);
}

.stone.b { background: radial-gradient(circle at 34% 30%, #5d625e, #1c1f1e 68%); }
.stone.w { background: radial-gradient(circle at 34% 30%, #fffef7, #dcdad0 60%, #b6b2a4); }

/* 象棋：取自其大厅的宣纸、木纹棋盘与朱红主按钮。 */
.xiangqi { background: #fcf8ef; }
.xiangqi .info h2 { font-family: var(--serif); font-weight: 700; letter-spacing: .14em; }
.xiangqi .tagline { color: var(--muted); letter-spacing: .06em; }
.xiangqi .modes li { background: #e8ede6; color: #3f5a48; }
.xiangqi .play { background: #a33f35; color: #fffaf0; box-shadow: inset 0 -2px 0 rgba(60, 20, 15, .22); }

.xiangqi-board {
  --cell: 17px;
  background: #e8c890;
  box-shadow: inset 0 0 0 2px #c49a60, inset 0 0 0 5px #e8c890, inset 0 0 0 6px #b98c55;
}

.xiangqi-board .grid { --cols: 4; --rows: 5; --line: #8a6a3e; }

.river {
  position: absolute;
  left: 1.5px;
  right: 1.5px;
  top: calc(2 * var(--cell) + 1.5px);
  height: calc(var(--cell) - 1.5px);
  display: grid;
  place-items: center;
  background: #e8c890;
  font-family: var(--serif);
  font-size: 9px;
  color: #8a6a3e;
  white-space: nowrap;
}

.piece {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  font: 700 10px/1 var(--serif);
  font-style: normal;
  background: radial-gradient(circle at 40% 35%, #fdf5e2, #ead6aa);
  box-shadow: inset 0 0 0 1px currentColor, inset 0 0 0 2.5px #f8ecd0, 0 1px 2px rgba(80, 50, 20, .35);
}

.piece.red { color: #a33f35; }
.piece.black { color: #303c33; }

.hub-foot {
  margin-top: auto;
  padding-top: 18px;
  text-align: center;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: .3em;
  color: #a49886;
}

/* 游戏页：全屏交给 Cocos 自身适配，只保留一个返回按钮。 */
.player {
  position: fixed;
  inset: 0;
  background: var(--paper);
}

.player[hidden] { display: none; }

.player iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.back {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 10px;
  width: 34px;
  height: 34px;
  padding: 0 0 3px;
  border: 1px solid rgba(116, 87, 64, .18);
  border-radius: 50%;
  background: rgba(255, 250, 240, .88);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(91, 65, 43, .18);
}

@media (hover: hover) {
  .game-card:hover { transform: translateY(-2px); }
}
