/* ============================================================
 * XIANGQI KNIGHT — styles
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:root {
  --wood-1: #f0d5a3;
  --wood-2: #dfb678;
  --line: #7a4b23;
  --red: #c0392b;
  --red-dark: #922b21;
  --black: #33302c;
  --cream: #faf0d7;
  --bg: #f5efe2;
  --panel: #ffffff;
  --ink: #3b3229;
  --muted: #8a7c6b;
  --accent: #b03a2e;
  --shadow: 0 4px 18px rgba(60, 40, 20, .18);
}

html, body { height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  /* Ink-wash landscape with a more visible distant palace and mountains. */
  background:
    linear-gradient(rgba(245, 239, 226, 0.48), rgba(245, 239, 226, 0.48)),
    url('../bg-landscape-clear.png') center / cover no-repeat fixed;
}

#app { max-width: 640px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
#app:has(#screen-game.active) { max-width: none; }
.screen { display: none; flex-direction: column; min-height: 100vh; padding: 10px 14px calc(16px + env(safe-area-inset-bottom)); }
.screen.active { display: flex; }

/* ---------------- HOME ---------------- */
.home-hero { text-align: center; padding: 34px 0 18px; }
.logo-piece {
  width: 118px; height: 118px; margin: 0 auto 18px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff8e6, #f3dfae 60%, #e6c684);
  border: 3px solid #d8b264; box-shadow: var(--shadow), inset 0 -3px 8px rgba(120, 80, 20, .28);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; position: relative;
}
.logo-piece::after {
  content: ""; position: absolute; left: 17%; top: 13%;
  width: 36%; height: 24%; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,.9), rgba(255,255,255,0) 70%);
  z-index: 3; pointer-events: none;
}
/* Realistic marching-army photo behind the wordmark. */
.logo-piece .lp-scene {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%; z-index: 0; pointer-events: none;
}
/* soft light veil so the red wordmark stays readable over the photo */
.logo-piece .lp-veil {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, rgba(255,246,224,.30), rgba(255,246,224,.14) 45%, rgba(60,30,10,.06) 100%);
}
.logo-piece .lp-mark {
  font-family: "KaiTi", "STKaiti", "BiauKai", "Noto Serif SC", "SimSun", serif;
  font-size: 46px; font-weight: 700; line-height: 1; color: var(--red);
  text-shadow: 0 0 3px #fff6e0, 0 0 8px rgba(255, 246, 224, .98), 0 0 14px rgba(255, 246, 224, .9), 0 1px 1px rgba(120, 30, 20, .3);
  position: relative; z-index: 2;
}
.logo-piece .lp-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px; font-weight: 700; letter-spacing: 3.5px; text-indent: 3.5px;
  line-height: 1; color: #fff3d6;
  text-shadow: 0 0 3px rgba(60, 30, 10, .9), 0 0 7px rgba(60, 30, 10, .8), 0 1px 3px rgba(60, 30, 10, .8);
  position: relative; z-index: 2;
}
.home-hero h1 {
  font-size: 32px; letter-spacing: 1.5px; color: var(--red-dark);
  font-family: Georgia, "Times New Roman", "Segoe UI", serif;
}
.tagline { color: var(--muted); margin-top: 6px; font-size: 15px; }

/* Decorative slogan shown on every main screen. */
.slogan {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; text-align: center;
  font-family: Georgia, "Times New Roman", "Noto Serif", serif;
  font-size: 13px; font-style: italic; line-height: 1.45;
  color: #6b4a2a;
  letter-spacing: .25px;
  padding: 10px 14px;
  margin: 6px 12px 2px;
  border-top: 1px dashed rgba(107, 74, 42, .28);
  border-bottom: 1px dashed rgba(107, 74, 42, .28);
}
.slogan em { font-style: italic; }
.slogan .s-mark {
  font-family: "KaiTi", "STKaiti", "BiauKai", "Noto Serif SC", serif;
  font-style: normal; font-weight: 700; font-size: 17px;
  flex: none;
}
.slogan .s-mark.red { color: var(--red); }
.slogan .s-mark.black { color: var(--black); }
.slogan .s-quote {
  font-family: "KaiTi", "STKaiti", serif;
  font-style: normal; font-size: 18px;
  color: var(--red-dark);
  flex: none;
}
.slogan.compact {
  font-size: 11.5px;
  padding: 7px 10px;
  margin: 4px 8px 0;
  border-style: solid;
  border-color: rgba(107, 74, 42, .16);
  border-width: 1px 0;
  background: rgba(255, 252, 245, .6);
}
@media (min-aspect-ratio: 5/4) and (min-width: 760px) {
  /* In landscape the slogan sits below the playing area without crowding panels. */
  #screen-game .slogan.compact { margin-top: 6px; }
}

.home-menu { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
.menu-btn {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--panel); border: 1px solid #e5d9c2; border-radius: 16px;
  padding: 14px 18px; cursor: pointer; box-shadow: 0 2px 8px rgba(60,40,20,.08);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s;
  font: inherit; color: inherit;
}
.menu-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d3bfa0; }
.menu-btn:active { transform: translateY(0); }
.menu-btn.primary { background: linear-gradient(135deg, #c0392b, #a33025); border-color: #9c2f24; color: #fff; }
.menu-btn.primary:hover { box-shadow: 0 6px 22px rgba(160, 50, 35, .4); }
.menu-btn.subtle { background: #fbf6ea; }
.menu-ico { width: 40px; display: flex; align-items: center; justify-content: center; color: #8f2b21; flex: none; }
.menu-ico svg { width: 34px; height: 34px; display: block; }
.menu-btn.primary .menu-ico { color: #fff; }
.menu-txt { display: flex; flex-direction: column; gap: 2px; }
.menu-txt small { color: var(--muted); font-size: 12.5px; }
.menu-btn.primary .menu-txt small { color: #f5d8d3; }
.install-hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 14px; }
.home-footer { margin-top: auto; padding-top: 18px; text-align: center; }
.foot-links { margin-bottom: 8px; font-size: 12.5px; }
.foot-links a { color: #6f5a35; text-decoration: none; padding: 2px 4px; }
.foot-links a:hover { color: var(--red-dark); text-decoration: underline; }
.foot-sep { color: #c9ba88; margin: 0 2px; }
.copyright { margin: 4px 0 0; font-size: 12px; color: #a08a63; letter-spacing: .3px; }

/* ---------------- GAME LAYOUT ---------------- */
.game-layout {
  display: flex; flex-direction: column; flex: 1; gap: 6px; min-height: 0;
}
.game-panel {
  display: flex; flex-direction: column; gap: 6px; min-height: 0;
  background: rgba(255, 252, 245, 0.94);
  border-radius: 14px;
  padding: 8px;
  backdrop-filter: blur(2px);
}
.panel-title {
  font-size: 17px; font-weight: 700; color: var(--red-dark);
  padding: 2px 0 0; letter-spacing: .3px;
  /* Full "A vs B" stays readable: JS shrinks the font until the longest word
   * fits its line, then the title wraps to a second line instead of clipping. */
  white-space: normal; overflow-wrap: anywhere; overflow: hidden; line-height: 1.15;
}
.panel-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-start; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid #e0d3ba;
  background: #fff; font-size: 17px; cursor: pointer; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.icon-btn:hover { background: #f6eedb; }
.icon-btn:disabled { opacity: .35; cursor: default; }
#btn-back { font-size: 24px; font-weight: 700; padding-bottom: 3px; }

.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid #e8dcc4; border-radius: 10px;
  padding: 6px 12px; margin-bottom: 0; box-shadow: 0 1px 4px rgba(60,40,20,.05);
}
#status-text { font-weight: 600; font-size: 14px; min-width: 0;
               overflow-wrap: anywhere; }  /* long names wrap, never clip */
#move-count { flex: none; }
#status-text.alert { color: var(--red); }
#move-count { color: var(--muted); font-size: 12.5px; }

/* ---------------- PVP TIMER ---------------- */
.timer-bar {
  display: flex; align-items: stretch; justify-content: space-between; gap: 4px;
  background: #fff; border: 1px solid #e8dcc4; border-radius: 10px;
  padding: 4px 5px; box-shadow: 0 1px 4px rgba(60,40,20,.05);
  font-variant-numeric: tabular-nums;
}
.tm { display: flex; flex-direction: column; align-items: center; line-height: 1.2;
      flex: 1 1 auto; min-width: 0; }   /* min-width:0 → long names may shrink the box */
.tm-side {
  font-size: 9.5px; letter-spacing: .2px; color: var(--muted); font-weight: 600;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tm-clock { font-size: 15px; font-weight: 700; color: var(--muted); }
.tm-red.active .tm-clock { color: var(--red); }
.tm-black.active .tm-clock { color: var(--black); }
.tm.active { background: #fdf6e4; border-radius: 8px; }
.tm.low .tm-clock { color: var(--red); animation: tm-blink 1s steps(2, start) infinite; }
.tm-step {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.2; border-left: 1px dashed #e0d3ba; border-right: 1px dashed #e0d3ba;
  padding: 0 5px; min-width: 44px; flex: 0 0 auto;
}
.tm-step-label { font-size: 8.5px; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.tm-step-clock { font-size: 13px; font-weight: 700; color: var(--ink); }
.tm-step.low .tm-step-clock { color: var(--red); animation: tm-blink 1s steps(2, start) infinite; }
@keyframes tm-blink { 50% { opacity: .45; } }

/* ---------------- BOARD ---------------- */
.board-wrap { display: flex; justify-content: center; align-items: center; flex: 1; min-height: 0; }
#board {
  position: relative;
  width: 100%;
  max-width: min(96vw, 80vh, 660px);
  aspect-ratio: 540 / 600;
  border-radius: 8px;
  box-shadow: var(--shadow);
  container-type: inline-size;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
#board > svg { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 10px; }

/* Wooden drum-shaped pieces (木质鼓形棋子): a boxwood top face inside a heavy
 * turned-brass rim, with the solid side wall drawn by a hard offset shadow. */
.piece {
  position: absolute; width: 10.2%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: .58cqw solid transparent;
  background:
    radial-gradient(circle at 32% 26%, #fbf2d8, #efd9a8 55%, #ddc084 88%, #d0ae6e) padding-box,
    conic-gradient(from 205deg,
      #5c4517 0deg, #b3923f 28deg, #f6e5ab 56deg, #b8923c 84deg,
      #63491a 120deg, #a1843a 150deg, #6f531f 188deg,
      #cdb066 212deg, #f6e5ab 238deg, #a8862f 266deg,
      #63491a 305deg, #c0a257 336deg, #5c4517 360deg) border-box;
  box-shadow:
    0 .55cqw 0 #7d5f24,                     /* brass rim side wall */
    0 1cqw 0 #4d3a12,                       /* second step of the rim */
    0 2.2cqw 2cqw rgba(35, 22, 4, .5),      /* cast shadow on the board */
    0 0 0 .1cqw rgba(48, 32, 6, .55),       /* dark outer hairline */
    inset 0 -.6cqw 1.1cqw rgba(120, 82, 24, .38),
    inset 0 .45cqw .8cqw rgba(255, 251, 232, .7);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-bottom: 1cqw;    /* optical centre: nudge the two-line legend up a touch */
  cursor: pointer; z-index: 5;
  transition: left .16s ease, top .16s ease;
}
/* Two-line legend: the Chinese glyph sits on top, the English name lies flat
 * underneath it — both centred as one group inside the face. The English size
 * is uniform for every piece; it is bounded by the longest name (ELEPHANT),
 * which must clear the curved rim at the depth where the second line sits. */
.piece .ch {
  font-family: "KaiTi", "STKaiti", "BiauKai", "Noto Serif SC", "SimSun", serif;
  font-size: 4.5cqw; font-weight: 700; line-height: 1;
  text-shadow: 0 .12cqw .2cqw rgba(255, 250, 235, .55);
}
.piece .lb {
  font-family: "Times New Roman", Georgia, "Noto Serif", serif;
  font-size: 1.2cqw; font-weight: 700; line-height: 1;
  white-space: nowrap; text-transform: uppercase; letter-spacing: .01em;
  margin-top: .3cqw;
  text-shadow: 0 .12cqw .2cqw rgba(255, 250, 235, .55);
}
.piece.red .ch, .piece.red .lb { color: var(--red); }
.piece.black .ch, .piece.black .lb { color: var(--black); }
.piece.hide-lb .lb { display: none; }
.piece.big-lb .ch { display: none; }
.piece.big-lb .lb { font-size: 2cqw; margin-top: 0; }
.piece.selected { z-index: 8; }
.piece.selected::after {
  content: ""; position: absolute; inset: -8%; border-radius: 50%;
  border: .5cqw solid #2e86c1; box-shadow: 0 0 1.2cqw rgba(46, 134, 193, .7);
}
/* Last move: the piece that just landed breathes with a golden halo ring,
 * clearly visible on both the wooden board and either side's pieces. */
.piece.last-move::after {
  content: ""; position: absolute; inset: -13%; border-radius: 50%;
  border: .6cqw solid #f5b71a;
  animation: lastglow 1.7s ease-in-out infinite;
}
@keyframes lastglow {
  0%, 100% { box-shadow: 0 0 1cqw rgba(245, 183, 26, .70), 0 0 2.4cqw rgba(245, 183, 26, .45), 0 0 4cqw rgba(245, 183, 26, .25); }
  50%      { box-shadow: 0 0 1.6cqw rgba(245, 183, 26, 1), 0 0 3.6cqw rgba(245, 183, 26, .70), 0 0 6cqw rgba(245, 183, 26, .40); }
}
.piece.in-check { animation: checkpulse 0.9s ease infinite; }
@keyframes checkpulse {
  0%, 100% {
    box-shadow: 0 .55cqw 0 #7d5f24, 0 1cqw 0 #4d3a12, 0 2.2cqw 2cqw rgba(35,22,4,.5),
      0 0 0 .1cqw rgba(48,32,6,.55), 0 0 0 0 rgba(192,57,43,.65);
  }
  50% {
    box-shadow: 0 .55cqw 0 #7d5f24, 0 1cqw 0 #4d3a12, 0 2.2cqw 2cqw rgba(35,22,4,.5),
      0 0 0 .1cqw rgba(48,32,6,.55), 0 0 0 1.2cqw rgba(192,57,43,.35);
  }
}
/* Hint: the suggested piece pulses with a bright blue glow, and the landing
 * point flashes in sync — position is read at a glance, no text needed.
 * Blue stands out clearly against the warm wooden board. */
.piece.hinting { z-index: 8; animation: hintpulse .7s ease 4; }
@keyframes hintpulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.15); }
}
.piece.hinting::after {
  content: ""; position: absolute; inset: -9%; border-radius: 50%;
  border: .5cqw solid #1e90ff;
  box-shadow: 0 0 1.2cqw rgba(30, 144, 255, .95), 0 0 2.4cqw rgba(30, 144, 255, .6);
  animation: hintglow .7s ease 4;
}
@keyframes hintglow { 50% { opacity: .3; } }
.hint-dot {
  position: absolute; width: 11.5%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%);
  border: .5cqw solid #1e90ff;
  box-shadow: 0 0 1.4cqw rgba(30, 144, 255, .95), 0 0 2.6cqw rgba(30, 144, 255, .6), inset 0 0 .9cqw rgba(30, 144, 255, .5);
  z-index: 7; pointer-events: none;
  animation: hintdot .7s ease 4;
}
@keyframes hintdot {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50%      { transform: translate(-50%, -50%) scale(1.28); opacity: .4; }
}
.piece.fade-out { opacity: 0; transition: opacity .22s ease; pointer-events: none; }

.dot {
  position: absolute; width: 4.2%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%); background: rgba(46, 134, 193, .5);
  z-index: 4; pointer-events: none;
}
.dot.capture {
  width: 10.6%; background: transparent;
  border: .55cqw solid rgba(192, 57, 43, .65);
}

/* ---------------- captured / movelist / puzzle bar ---------------- */
.cap-row {
  display: flex; flex-wrap: wrap; gap: 3px; min-height: 22px;
  padding: 2px 4px; align-items: center;
}
.cap-row .mini {
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, #fbf2d8, #efd9a8 55%, #ddc084);
  border: 1px solid #b99a4e; font-size: 12px; font-weight: 700;
  box-shadow: 0 2px 0 #8a6a2a, 0 3px 3px rgba(35, 22, 4, .4), inset 0 -1px 2px rgba(120, 82, 24, .35);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: "KaiTi", "STKaiti", "Noto Serif SC", serif;
}
.cap-row .mini.red { color: var(--red); }
.cap-row .mini.black { color: var(--black); }

.movelist-wrap {
  margin-top: 0; background: #fff; border: 1px solid #e8dcc4; border-radius: 10px;
  overflow: hidden; display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.movelist-label { font-size: 10.5px; font-weight: 700; letter-spacing: 1px; color: var(--muted); padding: 4px 10px 1px; text-transform: uppercase; flex: none; }
.movelist {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 3px 10px;
  overflow-y: auto; min-height: 0; max-height: 96px;
  padding: 1px 10px 8px; font-size: 13px; font-family: Consolas, Menlo, monospace;
  scrollbar-width: thin; scrollbar-color: #c9b58b transparent;
}
.movelist::-webkit-scrollbar { width: 6px; }
.movelist::-webkit-scrollbar-thumb { background: #c9b58b; border-radius: 3px; }
.movelist .mv-no { color: var(--muted); }
.movelist .mv-r { color: var(--red); font-weight: 600; }
.movelist .mv-b { color: var(--black); font-weight: 600; }

.puzzle-bar {
  margin-top: 4px; display: flex; align-items: center; gap: 10px;
  background: #fff8e9; border: 1px solid #ecd9ae; border-radius: 10px; padding: 7px 11px;
}
#puzzle-hint-text { flex: 1; font-size: 12.5px; color: #7d6533; font-style: italic; }
.pill-btn {
  border: none; background: linear-gradient(135deg, #d4a017, #b8860b); color: #fff;
  border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 12.5px; cursor: pointer;
  box-shadow: 0 2px 6px rgba(184, 134, 11, .4);
}
.pill-btn:active { transform: scale(.97); }

/* ---------------- puzzles ---------------- */
.puzzle-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.puzzle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pz-card {
  background: var(--panel); border: 1px solid #e5d9c2; border-radius: 14px;
  padding: 12px 14px; cursor: pointer; position: relative;
  transition: transform .12s, box-shadow .12s; font: inherit; text-align: left; color: inherit;
}
.pz-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.pz-card .pz-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px; margin-bottom: 7px;
  background: #f3e7cd; color: var(--red-dark); font-weight: 800; font-size: 15px;
}
.pz-card.solved .pz-no { background: #27ae60; color: #fff; }
.pz-card h3 { font-size: 14.5px; margin-bottom: 2px; }
.pz-card .pz-sub { font-size: 11.5px; color: var(--muted); }
.pz-card .pz-state { position: absolute; top: 10px; right: 12px; font-size: 15px; }
.pz-card .pz-side-b {
  position: absolute; top: 8px; left: 42px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #2c2c2c; color: #ffd98a; border: 1.5px solid #ffd98a;
  font-size: 10.5px; line-height: 15px; text-align: center;
}
.pz-card.locked { opacity: .55; cursor: not-allowed; }
.pz-card.locked:hover { transform: none; box-shadow: none; }

/* ---------------- help ---------------- */
.help-body { background: #fff; border: 1px solid #e8dcc4; border-radius: 14px; padding: 18px 20px; line-height: 1.55; font-size: 14.5px; }
.help-body h2 { color: var(--red-dark); margin: 18px 0 8px; font-size: 17px; }
.help-body h2:first-child { margin-top: 0; }
.help-body table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13.5px; }
.help-body th, .help-body td { border: 1px solid #e5d9c2; padding: 6px 9px; text-align: left; vertical-align: top; }
.help-body th { background: #f8f1df; }
.help-body .pc { font-family: "KaiTi", "STKaiti", serif; font-size: 17px; }
.help-body .r { color: var(--red); font-weight: 700; }
.help-body .b { color: var(--black); font-weight: 700; }
.help-body ul { padding-left: 20px; }

/* ---------------- toast ---------------- */
#toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 90;
  transform: translateX(-50%) translateY(10px);
  background: #4a2f14; color: #fff;
  padding: 10px 18px; border-radius: 12px;
  font-size: 14px; line-height: 1.45; text-align: center;
  max-width: min(86vw, 460px);
  box-shadow: 0 8px 22px rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.14);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
#toast[hidden] { display: none !important; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.warn { background: #a4342a; border-color: rgba(255,255,255,.22); font-weight: 600; }

/* ---------------- modal ---------------- */
#modal-root {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(43, 30, 15, .55); backdrop-filter: blur(3px); padding: 20px;
}
#modal-root[hidden] { display: none !important; }
.modal {
  background: #fff; border-radius: 18px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden;
  animation: modalin .18s ease;
}
@keyframes modalin { from { transform: scale(.94); opacity: 0; } }
.modal-head { padding: 18px 20px 0; text-align: center; }
.modal-head h2 { color: var(--red-dark); font-size: 20px; }
.modal-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.modal-body { padding: 14px 20px 4px; }
.modal-body p { text-align: center; font-size: 14.5px; line-height: 1.5; }
.modal-foot { display: flex; gap: 10px; padding: 16px 20px 20px; }
.modal-foot button {
  flex: 1; border: none; border-radius: 12px; padding: 12px; font-size: 15px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: transform .1s;
}
.modal-foot button:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, #c0392b, #a33025); color: #fff; box-shadow: 0 3px 10px rgba(160,50,35,.35); }
.btn-secondary { background: #f1ead9; color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); }

/* difficulty chooser */
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.diff-opt {
  border: 2px solid #e5d9c2; border-radius: 12px; padding: 10px 8px; text-align: center;
  cursor: pointer; transition: border-color .12s, background .12s;
}
.diff-opt .d-name { font-weight: 800; font-size: 14px; }
.diff-opt .d-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.diff-opt.sel { border-color: var(--accent); background: #fdf1ef; }
.side-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.side-opt {
  border: 2px solid #e5d9c2; border-radius: 12px; padding: 9px 4px; text-align: center; cursor: pointer;
}
.side-opt .pc { font-family: "KaiTi", serif; font-size: 22px; font-weight: 700; }
.side-opt .pc.r { color: var(--red); } .side-opt .pc.b { color: var(--black); }
.side-opt.sel { border-color: var(--accent); background: #fdf1ef; }
.side-opt small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.modal-label { font-size: 11px; font-weight: 800; letter-spacing: 1.2px; color: var(--muted); text-transform: uppercase; margin: 14px 0 6px; }

/* settings rows */
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid #f0e8d6; font-size: 14.5px; }
.set-row:last-child { border-bottom: none; }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; cursor: pointer; z-index: 2; margin: 0; }
.switch .track { position: absolute; inset: 0; background: #d8cdb8; border-radius: 999px; transition: background .15s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); transition: left .15s; }
.switch input:checked ~ .track { background: #27ae60; }
.switch input:checked ~ .knob { left: 23px; }
/* music controls */
.icon-btn.muted { opacity: .35; text-decoration: line-through; }
.set-row.dimmed { opacity: .45; }
.vol-slider {
  -webkit-appearance: none; appearance: none; flex: none;
  width: 116px; height: 22px; background: transparent; cursor: pointer; margin: 0;
}
.vol-slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, #d4a017, #e8cf94);
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -6px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  border: 2px solid #b8860b; box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.vol-slider::-moz-range-track { height: 6px; border-radius: 999px; background: linear-gradient(90deg, #d4a017, #e8cf94); }
.vol-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  border: 2px solid #b8860b; box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.vol-slider:disabled { cursor: default; }

/* thinking spinner */
.thinking-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-left: 8px; vertical-align: middle; animation: think 1s ease infinite; }
@keyframes think { 50% { opacity: .25; transform: translateY(-3px); } }

/* stars on level complete */
.stars { font-size: 34px; letter-spacing: 6px; text-align: center; margin: 4px 0 2px; }

/* ---------------- horizontal / desktop layout ---------------- */
@media (min-aspect-ratio: 5/4) and (min-width: 760px) {
  #screen-game { padding: 4px 4px calc(8px + env(safe-area-inset-bottom)); }
  .game-layout {
    flex-direction: row; align-items: stretch; justify-content: center;
    gap: 0; height: calc(100vh - 8px - env(safe-area-inset-bottom));
    min-height: 0; overflow: hidden;
  }
  .game-panel {
    /* Narrow symmetric rails: no move list any more, so both panels stay
     * slim (status + timers left, action buttons right) and the board gets
     * the room — better fit for smaller / phone-wide screens. */
    width: auto; flex: 1 1 112px; min-width: 0; max-width: 178px;
    justify-content: flex-start;
    padding: 8px; min-height: 0; overflow: hidden; gap: 3px;
    background: rgba(255, 252, 245, 0.94); border-radius: 12px;
    backdrop-filter: blur(2px);
  }
  .game-panel-right { align-items: flex-end; }
  .panel-title { font-size: 15px; padding: 0; }
  .panel-actions { flex-direction: column; align-items: flex-end; gap: 4px; }
  /* Side panels are narrow here: stack the clock rows vertically so each
   * player name gets the full panel width on its own line. */
  .timer-bar { flex-direction: column; align-items: stretch; gap: 3px; padding: 6px 8px; }
  .tm { flex-direction: row; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 4px; }
  .tm-side { flex: 1 1 auto; min-width: 0; white-space: normal; overflow-wrap: anywhere;
             text-align: left; line-height: 1.15; }
  .tm-clock { flex: none; }
  .tm-step { order: 3; flex-direction: row; align-items: center; justify-content: space-between;
             border-left: 0; border-right: 0; border-top: 1px dashed #e0d3ba;
             padding: 4px 2px 0; min-width: 0; }
  /* Keep the board at its natural size and let side panels sit symmetrically. */
  .board-wrap {
    flex: 0 0 auto;
    width: fit-content;
    min-width: 0;
    padding: 0 8px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  #board {
    /* Keep the original board sizing so pieces align with the grid again. */
    width: min(96vw, 80vh, 660px);
    aspect-ratio: 540 / 600;
  }
  .movelist-wrap { max-height: none; min-height: 0; flex: 1; overflow: hidden; }
  .movelist { flex: 1 1 0; min-height: 0; max-height: 100%; overflow-y: auto; }
  .cap-row { min-height: 22px; flex-shrink: 0; }
  .cap-row .mini { width: 20px; height: 20px; font-size: 12px; }
  .puzzle-bar { margin-top: 1px; }
  .status-bar { padding: 4px 9px; }
  .movelist-label { padding: 3px 9px 1px; }
  .movelist { padding: 1px 9px 7px; }
}

@media (max-width: 380px) {
  .panel-actions .icon-btn { width: 34px; height: 34px; font-size: 16px; }
  .home-hero h1 { font-size: 28px; }
}

/* ---------------- home member button (prominent bar above the menu) ---------------- */
.member-chip {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; margin: 20px 0 0;
  background: linear-gradient(135deg, #c0392b, #a33025); border: 1.5px solid #9c2f24; border-radius: 16px;
  padding: 13px 20px; cursor: pointer; font: inherit; color: #fff;
  box-shadow: 0 4px 16px rgba(160, 50, 35, .35); transition: box-shadow .12s, transform .12s;
  white-space: nowrap;
}
.member-chip:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(160, 50, 35, .45); }
.member-chip .knight-ico { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .25)); }
.member-chip .chip-ava {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #c0392b, #922b21); color: #fff;
  font-weight: 800; font-size: 19px; display: inline-flex; align-items: center; justify-content: center;
  font-family: "KaiTi", "STKaiti", serif;
}
.member-chip .chip-ava.off { background: rgba(255, 255, 255, .22); color: #fff; font-size: 20px; }
.member-chip .chip-mid { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; min-width: 0; }
.member-chip .chip-name { font-weight: 800; font-size: 17px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-chip .chip-cty { font-size: 12px; color: #f5d8d3; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-chip .chip-pts { color: #a33025; font-weight: 800; font-size: 14px; background: #fbeae5; padding: 3px 11px; border-radius: 999px; flex: none; }
/* signed-in look: light card that stands out against the warm background */
.member-chip:not(.guest) {
  background: rgba(255, 255, 255, .95); border-color: #d8b264; color: var(--ink);
  box-shadow: 0 4px 16px rgba(60, 40, 20, .18);
}
.member-chip:not(.guest):hover { box-shadow: 0 8px 24px rgba(60, 40, 20, .26); }
.member-chip:not(.guest) .chip-ava { background: linear-gradient(135deg, #c0392b, #922b21); }
.member-chip:not(.guest) .chip-cty { color: var(--muted); }
.mm-form .btn-link-sm { display: block; margin: 10px auto 0; padding: 2px 4px; border: none; background: none; color: #8a5a2b; font: inherit; font-size: 12.5px; text-decoration: underline; cursor: pointer; }
.mm-form .btn-link-sm:hover { color: var(--red-dark); }

/* ---------------- member modal ---------------- */
.member-modal { max-width: 420px; position: relative; }
.member-modal.wide { max-width: 480px; }
.member-modal.xwide { max-width: 580px; }   /* admin console needs table room */
.member-modal { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.mm-x {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; z-index: 6;
  border: none; background: #f1ead9; color: var(--muted); border-radius: 50%;
  font-size: 16px; line-height: 1; cursor: pointer;
}
.mm-x:hover { background: #e6dcc4; }
.mm-tabs { display: flex; padding: 12px 20px 0; gap: 6px; flex: none; }
.mm-tab {
  flex: 1; border: 1px solid #e0d3ba; background: #fff; color: var(--muted);
  border-radius: 999px; padding: 8px 10px; font: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all .12s;
}
.mm-tab.on { background: linear-gradient(135deg, #c0392b, #a33025); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(160,50,35,.3); }
.mm-pane { padding: 6px 20px 18px; overflow-y: auto; min-height: 0; }
.mm-form { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
.fld { margin-bottom: 4px; }
.fld label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 8px 0 4px; letter-spacing: .2px; }
.xq-input {
  width: 100%; padding: 11px 12px; border: 1.5px solid #e0d3ba; border-radius: 11px;
  font: inherit; font-size: 14.5px; background: #fffdf8; color: var(--ink); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.xq-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(176, 58, 46, .12); }
select.xq-input { appearance: auto; -webkit-appearance: auto; height: auto; cursor: pointer; }
.btn-block {
  display: block; width: 100%; border: none; border-radius: 12px; padding: 12px;
  font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; margin-top: 10px;
  transition: transform .1s, opacity .15s;
}
.btn-block:active { transform: scale(.98); }
.btn-block:disabled { opacity: .45; cursor: default; }
.btn-block.primary { background: linear-gradient(135deg, #c0392b, #a33025); color: #fff; box-shadow: 0 3px 10px rgba(160,50,35,.35); }
.btn-block.ghost { background: #f1ead9; color: var(--ink); box-shadow: none; }
.fb { font-size: 13px; line-height: 1.45; color: #a4342a; min-height: 16px; margin: 6px 0 0; text-align: left; }
.fb.ok { color: #2e7d32; }
.hint-sm { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; text-align: center; line-height: 1.5; }
.hint-sm.dim { color: #a39684; }
.hint-sm a { color: var(--accent); font-weight: 700; }
.code-row { display: flex; gap: 8px; }
.code-row .code-inp { flex: 1; letter-spacing: 4px; font-weight: 800; text-align: center; }
.code-row .code-send { flex: 0 0 auto; width: auto; padding: 11px 14px; margin-top: 0; font-size: 13px; white-space: nowrap; }
.country-sel {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 12px; border: 1.5px solid #e0d3ba; border-radius: 11px; background: #fffdf8;
  font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; text-align: left;
}
.country-sel:hover { border-color: var(--accent); }
.country-sel .carat { color: var(--muted); }
.flag-ph { color: var(--muted); }
.dim { color: #a39684; }
.reg-step { display: flex; flex-direction: column; }
.mm-step-h { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 14.5px; margin: 6px 0 4px; color: var(--red-dark); }
.step-no {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #c0392b, #922b21); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.cnt { font-size: 11.5px; color: var(--muted); min-height: 15px; margin: 2px 0 0 2px; }

/* country picker window (full-screen pop) */
.country-win {
  position: fixed; inset: 0; z-index: 130;
  background: linear-gradient(rgba(245,239,226,.5), rgba(245,239,226,.5)), #fffdf8;
  display: flex; flex-direction: column; animation: modalin .16s ease;
}
.cw-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid #ecdfc6; background: #fff; }
.cw-back {
  width: 34px; height: 34px; border: 1px solid #e0d3ba; background: #fff; color: var(--ink);
  border-radius: 50%; font-size: 20px; line-height: 1; cursor: pointer;
}
.cw-back:hover { background: #f6eedb; }
.cw-title { font-weight: 800; font-size: 16px; color: var(--red-dark); }
.cw-search { padding: 12px 16px 4px; }
.country-list { flex: 1; overflow-y: auto; padding: 6px 16px 18px; }
.country-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 13px; margin-bottom: 6px; border: 1px solid #e7dbc2; border-radius: 11px;
  background: #fff; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
  text-align: left; transition: border-color .1s, background .1s;
}
.country-item:hover { border-color: var(--accent); background: #fdf4ef; }
.country-item.sel { border-color: var(--accent); background: #fbeae5; box-shadow: inset 0 0 0 1px var(--accent); }
.country-item .country-code { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .5px; }

/* profile */
.prof-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; }
.prof-ava {
  width: 54px; height: 54px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 32% 28%, #f3dfae, #e0b878); border: 2px solid #d8b264;
  color: var(--red-dark); font-family: "KaiTi", serif; font-weight: 800; font-size: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -2px 6px rgba(120,80,20,.25);
}
.prof-id { flex: 1; min-width: 0; }
.prof-name { font-size: 17px; font-weight: 800; }
.prof-mail { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.prof-cty { font-size: 12.5px; color: #6b4a2a; margin-top: 2px; }
.prof-score { text-align: center; flex: none; background: #fdf6e4; border: 1px solid #ecd9ae; border-radius: 14px; padding: 6px 12px; }
.prof-score b { display: block; font-size: 24px; color: var(--red-dark); line-height: 1.05; }
.prof-score small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; border: 1px solid #e7dbc2; border-radius: 12px; padding: 8px 4px; background: #fff; }
.stat b { display: block; font-size: 20px; line-height: 1.1; }
.stat small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat.st-w b { color: var(--red); }
.stat.st-l b { color: #5b6470; }
.stat.st-d b { color: #2e6da4; }
.rec-title { font-size: 11.5px; font-weight: 800; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; margin: 10px 0 6px; }
.rec-list { border: 1px solid #e7dbc2; border-radius: 12px; background: #fff; overflow: hidden; max-height: 240px; overflow-y: auto; }
.rec-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid #f0e8d6; font-size: 13px;
}
.rec-row:last-child { border-bottom: none; }
.rec-opp { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rec-mode {
  display: inline-block; font-style: normal; font-size: 10px; font-weight: 800;
  border-radius: 6px; padding: 1px 6px; margin-right: 7px; vertical-align: 1px;
  text-transform: uppercase; letter-spacing: .4px;
}
.mo-on { background: #fbeae5; color: #b03a2e; }
.mo-lo { background: #e8f0e8; color: #2e6da4; }
.rec-ai {
  font-style: normal; font-size: 9.5px; font-weight: 800; letter-spacing: .4px;
  background: #e8f2fb; color: #2e6da4; border-radius: 5px; padding: 1px 5px; vertical-align: 1px;
}
.rec-date { color: var(--muted); font-size: 11px; flex: none; }
.badge { font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: 999px; flex: none; }
.b-win { background: #fdecea; color: #b03a2e; }
.b-loss { background: #eef0f1; color: #5b6470; }
.b-draw { background: #e8f2fb; color: #2e6da4; }
.b-bonus { background: #fdf1d8; color: #9a6a12; }
.mo-bn { background: #fdf1d8; color: #9a6a12; }
.rec-row.rec-bonus { background: #fffaf0; }
.signout { margin-top: 14px; }

/* ---- rank badges (K1, K2, … shown after the member name) ---- */
.rank-badge {
  font-style: normal; font-family: Georgia, "Times New Roman", serif;
  font-weight: 700; font-size: 10.5px; line-height: 1;
  color: #fff; text-shadow: none;
  background: linear-gradient(135deg, #c9971f, #d4a017);
  padding: 2px 6px; border-radius: 999px; margin-left: 4px;
  vertical-align: 1.5px; letter-spacing: .5px;
  box-shadow: 0 1px 2px rgba(90, 60, 10, .35);
}
.rank-badge.rk-sm { font-size: 9.5px; padding: 1px 5px; margin-left: 3px; }
.stat.st-rank b { color: #b8860b; }

/* ---- admin console (webmaster, member name ktwebmaster) ---- */
.adm-shield { font-style: normal; font-size: 11px; margin-left: 2px; }
.adm-open { margin-top: 14px; }
.adm-open + .signout { margin-top: 8px; }
.adm-cards { margin-bottom: 10px; }
.adm-wrap {
  border: 1px solid #e7dbc2; border-radius: 12px; background: #fff;
  overflow: auto; max-height: 46vh;
}
.adm-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.adm-table th {
  position: sticky; top: 0; z-index: 1; background: #faf5e8; text-align: left;
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
  padding: 6px 7px; border-bottom: 1px solid #e7dbc2; white-space: nowrap;
}
.adm-table td { padding: 6px 7px; border-bottom: 1px solid #f0e8d6; white-space: nowrap; }
.adm-table tbody tr:last-child td { border-bottom: none; }
.adm-table tr.mrow { cursor: pointer; }
.adm-table tr.mrow:hover { background: #fdf6e4; }
.adm-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.adm-table .adm-nm { font-weight: 700; max-width: 118px; overflow: hidden; text-overflow: ellipsis; }
.adm-table tr.vrow { cursor: pointer; }
.adm-table tr.vrow:hover { background: #fdf6e4; }
.adm-table .adm-sm { font-size: 10.5px; color: var(--muted); }
.adm-cards-4 { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.adm-cards-4 .stat b { font-size: 16px; }
.adm-cards-4 .stat small { font-size: 9.5px; }
.adm-sec {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px dashed #e2d5b8;
}
.adm-sec-t { font-weight: 800; font-size: 12.5px; color: #6b5330; }
.adm-sec-n { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

/* modal one-line score result inside end-game dialog */
.rec-line { text-align: center; font-weight: 800; font-size: 14px; margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: #fdf6e4; border: 1px dashed #d8b264; color: var(--red-dark); }
.rec-line.draw { color: #2e6da4; }

/* demo "inbox" popup (bottom-right) */
.mail-pop {
  position: fixed; right: 14px; bottom: 14px; z-index: 300;
  width: min(330px, 92vw); background: #fff; border-radius: 16px;
  border: 1px solid #d8cdb8; box-shadow: 0 14px 40px rgba(30, 20, 10, .35);
  padding: 12px 14px 13px; font-size: 12.5px; color: var(--ink);
  animation: mailin .25s ease;
}
@keyframes mailin { from { opacity: 0; transform: translateY(14px); } }
.mail-pop .mp-bar { display: flex; align-items: center; justify-content: space-between; }
.mail-pop .mp-from { font-weight: 800; color: var(--red-dark); font-size: 13px; letter-spacing: .3px; }
.mail-pop .mp-x { border: none; background: none; color: var(--muted); font-size: 15px; cursor: pointer; padding: 2px 4px; }
.mail-pop .mp-sub { color: var(--muted); margin: 5px 0 2px; font-size: 12px; }
.mail-pop .mp-code {
  font-family: Consolas, Menlo, monospace; font-size: 24px; letter-spacing: 7px; text-indent: 7px;
  text-align: center; color: var(--red-dark); font-weight: 800;
  background: #fdf6e4; border: 1px dashed #d8b264; border-radius: 10px; padding: 7px 4px; margin: 7px 0;
}
.mail-pop .mp-body { line-height: 1.5; color: var(--ink); }
.mail-pop .mp-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; color: #a39684; font-size: 11.5px; }
.mail-pop .mp-copy { border: 1px solid #e0d3ba; background: #fff; color: var(--ink); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.mail-pop .mp-copy:hover { background: #f6eedb; }

/* ---------------- online matchmaking modal ---------------- */
.match-box {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 12px 6px 6px;
}
.match-spinner {
  width: 54px; height: 54px; border-radius: 50%;
  border: 4px solid rgba(176, 58, 46, .16);
  border-top-color: var(--red);
  animation: matchspin 1s linear infinite;
}
@keyframes matchspin { to { transform: rotate(360deg); } }
.match-timer {
  font-size: 36px; font-weight: 700; color: var(--red);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.match-hint { color: var(--muted); font-size: 13.5px; min-height: 19px; text-align: center; }
.match-progress {
  width: 100%; height: 6px; border-radius: 3px;
  background: rgba(176, 58, 46, .14); overflow: hidden;
}
.match-progress i {
  display: block; height: 100%; width: 0;
  background: var(--red); border-radius: 3px;
  transition: width .2s linear;
}
/* "nobody joined → an AI player takes the seat" notice */
.ai-note { gap: 10px; padding: 16px 8px 8px; }
.ai-ava {
  width: 62px; height: 62px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; background: #fdf6e4; border: 2px solid #ecd9ae;
  animation: aipulse 1.7s ease-in-out infinite;
}
@keyframes aipulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(176, 58, 46, .18); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 12px rgba(176, 58, 46, 0); }
}
.ai-line { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--ink); text-align: center; }
.ai-line.dim { color: var(--muted); font-size: 12.5px; }
