:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #637083;
  --line: #d7dee8;
  --panel: #ffffff;
  --panel-soft: #f5f7fb;
  --accent: #0c7c59;
  --accent-dark: #075d43;
  --warn: #b45f06;
  --shadow: 0 18px 50px rgba(42, 52, 66, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #e9eef5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

button:hover:not(:disabled) {
  border-color: #93a1b4;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.lobby-shell {
  display: grid;
  gap: 28px;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
}

.lobby-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 18px;
}

.lobby-grid-wide {
  grid-template-columns: repeat(3, minmax(260px, 1fr));
}

.lobby-game {
  display: grid;
  grid-template-rows: 230px auto auto;
  gap: 18px;
  min-height: 430px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(42, 52, 66, 0.1);
}

.lobby-game.available:hover {
  border-color: rgba(12, 124, 89, 0.45);
  transform: translateY(-2px);
}

.lobby-game.locked {
  opacity: 0.72;
}

.lobby-game-art {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #d9ae72;
}

.gold-miner-art {
  background: linear-gradient(#b7d9d2 0 30%, #745039 30% 36%, #38291f 36%);
}
.gold-miner-art img { position: absolute; image-rendering: pixelated; }
.gold-miner-card-miner { width: 58px; top: 16px; left: calc(50% - 29px); }
.gold-miner-card-rope { position: absolute; height: 87px; width: 3px; background: #f2bc45; top: 68px; left: 50%; transform: rotate(-16deg); transform-origin: top; }
.gold-miner-card-gold { width: 58px; top: 130px; left: 55%; }
.gold-miner-card-diamond { width: 42px; top: 108px; left: 20%; }
.gold-miner-card-rock { width: 54px; top: 178px; left: 31%; }

.gomoku-art {
  background:
    linear-gradient(rgba(75, 49, 22, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(75, 49, 22, 0.28) 1px, transparent 1px),
    linear-gradient(135deg, #f0c984, #c9904d);
  background-size:
    34px 34px,
    34px 34px,
    auto;
}

.gomoku-art span {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(23, 33, 43, 0.24);
}

.gomoku-art span:nth-child(1),
.gomoku-art span:nth-child(3),
.gomoku-art span:nth-child(5) {
  background: radial-gradient(circle at 32% 28%, #647282, #101820);
}

.gomoku-art span:nth-child(2),
.gomoku-art span:nth-child(4) {
  background: radial-gradient(circle at 32% 28%, #ffffff, #d8dee7);
}

.gomoku-art span:nth-child(1) {
  left: 42%;
  top: 26%;
}

.gomoku-art span:nth-child(2) {
  left: 51%;
  top: 36%;
}

.gomoku-art span:nth-child(3) {
  left: 42%;
  top: 46%;
}

.gomoku-art span:nth-child(4) {
  left: 51%;
  top: 56%;
}

.gomoku-art span:nth-child(5) {
  left: 42%;
  top: 66%;
}

.tictactoe-art {
  background:
    linear-gradient(90deg, transparent 31%, rgba(68, 45, 17, 0.5) 31%, rgba(68, 45, 17, 0.5) 35%, transparent 35%, transparent 65%, rgba(68, 45, 17, 0.5) 65%, rgba(68, 45, 17, 0.5) 69%, transparent 69%),
    linear-gradient(transparent 31%, rgba(68, 45, 17, 0.5) 31%, rgba(68, 45, 17, 0.5) 35%, transparent 35%, transparent 65%, rgba(68, 45, 17, 0.5) 65%, rgba(68, 45, 17, 0.5) 69%, transparent 69%),
    linear-gradient(135deg, #f2cb7d, #d69d4f);
}

.tictactoe-art span {
  position: absolute;
}

.tictactoe-art span:nth-child(1),
.tictactoe-art span:nth-child(3) {
  width: 54px;
  height: 54px;
}

.tictactoe-art span:nth-child(1)::before,
.tictactoe-art span:nth-child(1)::after,
.tictactoe-art span:nth-child(3)::before,
.tictactoe-art span:nth-child(3)::after {
  content: "";
  position: absolute;
  left: 23px;
  top: -4px;
  width: 8px;
  height: 62px;
  border-radius: 8px;
  background: #17212b;
}

.tictactoe-art span:nth-child(1)::before,
.tictactoe-art span:nth-child(3)::before {
  transform: rotate(45deg);
}

.tictactoe-art span:nth-child(1)::after,
.tictactoe-art span:nth-child(3)::after {
  transform: rotate(-45deg);
}

.tictactoe-art span:nth-child(2),
.tictactoe-art span:nth-child(4) {
  width: 58px;
  height: 58px;
  border: 8px solid #f8fafc;
  border-radius: 50%;
}

.tictactoe-art span:nth-child(1) {
  left: 22%;
  top: 24%;
}

.tictactoe-art span:nth-child(2) {
  right: 22%;
  top: 24%;
}

.tictactoe-art span:nth-child(3) {
  left: 42%;
  bottom: 18%;
}

.tictactoe-art span:nth-child(4) {
  left: 22%;
  bottom: 18%;
}

.placeholder-art {
  color: #7b8796;
  background: #edf1f6;
  font-size: 62px;
  font-weight: 900;
}

.monopoly-art,
.ludo-art,
.checkers-art,
.animal-art,
.texas-art,
.blackjack-art,
.landlord-art,
.reversi-art,
.connect4-art {
  background: linear-gradient(135deg, #eef3f9, #dbe5f0);
}

.reversi-art {
  background:
    linear-gradient(rgba(75, 49, 22, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(75, 49, 22, 0.28) 1px, transparent 1px),
    linear-gradient(135deg, #f0c984, #c9904d);
  background-size:
    42px 42px,
    42px 42px,
    auto;
}

.reversi-art .disc {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(23, 33, 43, 0.24);
}

.reversi-art .disc.dark {
  left: 34%;
  top: 30%;
  background: radial-gradient(circle at 32% 28%, #596371, #111821);
}

.reversi-art .disc.light {
  right: 34%;
  top: 30%;
  background: radial-gradient(circle at 32% 28%, #ffffff, #dfe4ec);
}

.reversi-art .disc.small {
  top: 56%;
}

.connect4-art {
  display: block;
  background:
    radial-gradient(circle, #e9eef5 0 15px, transparent 16px) 10px 12px / 45px 38px,
    #1557a3;
}

.connect4-art span {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  box-shadow:
    inset 0 3px 8px rgba(12, 35, 70, 0.24),
    0 6px 12px rgba(23, 33, 43, 0.18);
}

.connect4-art span:nth-child(1) {
  left: 22%;
  bottom: 20%;
}

.connect4-art span:nth-child(2) {
  left: 34%;
  bottom: 20%;
}

.connect4-art span:nth-child(3) {
  left: 22%;
  bottom: 38%;
}

.connect4-art span:nth-child(4) {
  left: 46%;
  bottom: 20%;
}

.connect4-art span.red {
  background: radial-gradient(circle at 32% 28%, #ff8e8a, #d84242);
}

.connect4-art span.gold {
  background: radial-gradient(circle at 32% 28%, #fff3a8, #f2c94c);
}

.monopoly-art .chip,
.ludo-art .plane,
.checkers-art .checker {
  position: absolute;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(23, 33, 43, 0.18);
}

.monopoly-art .chip.red,
.ludo-art .plane.red {
  left: 26%;
  top: 38%;
  background: radial-gradient(circle at 32% 28%, #ff8e8a, #d63e47);
}

.monopoly-art .chip.blue,
.ludo-art .plane.blue {
  right: 26%;
  top: 38%;
  background: radial-gradient(circle at 32% 28%, #82c5ff, #336fd6);
}

.monopoly-art .money,
.ludo-art .dice-face {
  position: absolute;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #fff4d6;
  color: #8f6510;
  font-size: 30px;
  font-weight: 900;
}

.monopoly-art .money {
  left: calc(50% - 32px);
  top: 24%;
}

.ludo-art .dice-face {
  left: calc(50% - 32px);
  bottom: 20%;
}

.checkers-art {
  background:
    linear-gradient(45deg, #d7b687 25%, transparent 25%, transparent 75%, #d7b687 75%, #d7b687),
    linear-gradient(45deg, #d7b687 25%, transparent 25%, transparent 75%, #d7b687 75%, #d7b687),
    linear-gradient(135deg, #f3e3c8, #ad7f4f);
  background-position:
    0 0,
    22px 22px,
    0 0;
  background-size:
    44px 44px,
    44px 44px,
    auto;
}

.checkers-art .checker.dark {
  left: 34%;
  top: 32%;
  background: radial-gradient(circle at 32% 28%, #5f6a78, #19212b);
}

.checkers-art .checker.light {
  right: 28%;
  bottom: 24%;
  background: radial-gradient(circle at 32% 28%, #ffffff, #d7dce4);
}

.animal-art {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.7) 0 12%, transparent 13%),
    linear-gradient(180deg, rgba(35, 64, 96, 0.12), rgba(35, 64, 96, 0)),
    linear-gradient(135deg, #f6edd8, #d7b27a);
}

.animal-art .river {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 76%;
  height: 24%;
  transform: translate(-50%, -50%);
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.42), transparent 28% 72%, rgba(255, 255, 255, 0.42)),
    linear-gradient(180deg, #5eb5e6, #2d78b7);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.animal-art .den {
  position: absolute;
  width: 72px;
  height: 72px;
  border: 5px solid rgba(23, 33, 43, 0.18);
  border-radius: 18px;
  transform: rotate(45deg);
}

.animal-art .den.red {
  left: 22%;
  bottom: 18%;
  background: rgba(214, 62, 71, 0.72);
}

.animal-art .den.blue {
  right: 22%;
  top: 18%;
  background: rgba(51, 111, 214, 0.72);
}

.animal-art .animal {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 8px 16px rgba(23, 33, 43, 0.18);
}

.animal-art .animal.red {
  left: 24%;
  top: 24%;
  background: radial-gradient(circle at 32% 28%, #ff9d95, #d63e47);
}

.animal-art .animal.blue {
  right: 24%;
  bottom: 24%;
  background: radial-gradient(circle at 32% 28%, #8bc4ff, #336fd6);
}

.landlord-art .card {
  position: absolute;
  display: grid;
  place-items: center;
  width: 72px;
  height: 102px;
  border-radius: 8px;
  background: #ffffff;
  color: #16202b;
  font-size: 30px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(23, 33, 43, 0.18);
}

.landlord-art .card:nth-child(1) {
  left: 22%;
  top: 24%;
  transform: rotate(-12deg);
}

.landlord-art .card:nth-child(2) {
  left: calc(50% - 36px);
  top: 18%;
}

.landlord-art .card:nth-child(3) {
  right: 22%;
  top: 24%;
  transform: rotate(12deg);
}

.texas-art,
.blackjack-art {
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 255, 255, 0.08), transparent 36%),
    linear-gradient(180deg, #1b6f48, #0f4d33);
}

.texas-art .card,
.blackjack-art .card {
  position: absolute;
  display: grid;
  place-items: center;
  width: 72px;
  height: 102px;
  border-radius: 8px;
  background: #fff;
  color: #17212b;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(23, 33, 43, 0.18);
}

.texas-art .card:nth-child(1),
.blackjack-art .card:nth-child(1) {
  left: 24%;
  top: 28%;
  transform: rotate(-10deg);
}

.texas-art .card:nth-child(2),
.blackjack-art .card:nth-child(2) {
  left: 42%;
  top: 22%;
}

.texas-art .card:nth-child(3),
.blackjack-art .card:nth-child(3) {
  right: 24%;
  top: 28%;
  color: #d63e47;
  transform: rotate(10deg);
}

.beads-art { background: radial-gradient(circle, #52627e 1px, transparent 2px) 0 0 / 18px 18px, #202a43; }
.beads-art span { position: absolute; width: 45px; height: 45px; border: 13px solid #7768d8; border-radius: 50%; box-shadow: inset 0 2px 3px #0008, 0 4px 5px #0006; }
.beads-art span:nth-child(1) { left: 39%; top: 20%; border-color: #f27593; }
.beads-art span:nth-child(2) { left: 25%; top: 39%; border-color: #f27593; }
.beads-art span:nth-child(3) { left: 53%; top: 39%; border-color: #f27593; }
.beads-art span:nth-child(4) { left: 39%; top: 39%; border-color: #f2c85b; }
.beads-art span:nth-child(5) { left: 39%; top: 58%; border-color: #6cbeaf; }

.lobby-game-body {
  display: grid;
  align-content: start;
  gap: 8px;
}

.lobby-game-body h2,
.lobby-game-body p {
  margin: 0;
}

.lobby-game-body h2 {
  font-size: 26px;
}

.lobby-game-body p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.6;
}

.lobby-game > strong {
  align-self: end;
  justify-self: start;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}

.lobby-game.locked > strong {
  background: #7b8796;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  background: #f8fafc;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.brand h1,
.brand p,
.stage-header h2,
.stage-header p,
.panel-title h2 {
  margin: 0;
}

.brand h1 {
  font-size: 21px;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.game-list,
.connection-panel {
  display: grid;
  gap: 12px;
}

.back-link {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 800;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 74px;
  padding: 12px;
  text-align: left;
}

.game-card.active {
  border-color: rgba(12, 124, 89, 0.35);
  background: #edf8f4;
}

.game-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #dfe8f0;
  font-weight: 900;
}

.game-card strong,
.game-card small {
  display: block;
}

.game-card small {
  margin-top: 3px;
  color: var(--muted);
}

.connection-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-title,
.stage-header,
.score-strip,
.actions,
.share-box,
.button-grid {
  display: flex;
  align-items: center;
}

.panel-title,
.stage-header {
  justify-content: space-between;
  gap: 12px;
}

.panel-title h2 {
  font-size: 16px;
}

#connectionStatus {
  color: var(--warn);
  font-size: 12px;
  font-weight: 800;
}

.button-grid {
  gap: 8px;
}

.button-grid button,
.actions button {
  flex: 1;
}

.primary-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.primary-btn:hover:not(:disabled) {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.share-box {
  gap: 8px;
}

.share-box button {
  min-width: 62px;
}

/* ── 房间成员列表：服务器权威快照的渲染出口 ─────────────────── */
.member-box {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.member-title {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.member-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

.member-item[data-connected="false"] {
  opacity: 0.72;
}

.member-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.member-dot.online {
  background: var(--accent);
}

.member-dot.offline {
  background: var(--warn);
}

.member-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.member-badge {
  padding: 1px 6px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.member-state {
  margin-left: auto;
  font-size: 11px;
  font-weight: 800;
}

.member-state.online {
  color: var(--accent);
}

.member-state.offline {
  color: var(--warn);
}

.member-empty {
  padding: 6px 8px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.game-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 22px;
  padding: clamp(16px, 2.8vw, 30px);
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stage-header h2 {
  margin-top: 4px;
  font-size: 32px;
}

.score-strip {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.score-strip span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.score-strip span.active-timer {
  border-color: rgba(26, 115, 232, 0.42);
  background: #edf5ff;
  color: var(--text);
}

.board-layout {
  display: grid;
  grid-template-columns: minmax(360px, 760px) minmax(260px, 340px);
  align-items: start;
  gap: 22px;
}

.canvas-wrap {
  width: min(100%, 760px, calc(100svh - 210px));
  aspect-ratio: 1;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  background: #d9ae72;
}

.grid-canvas-wrap {
  background: linear-gradient(135deg, #f1c978, #d69d4f);
}

.grid-canvas-wrap.reversi-wrap {
  background: linear-gradient(135deg, #f0c984, #c9904d);
}

.grid-canvas-wrap.connect4-wrap {
  background: #1557a3;
}

.grid-game-shell .match-panel {
  min-width: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.match-panel {
  display: grid;
  gap: 14px;
}

.turn-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.record-card,
.piece-count-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.record-grid,
.piece-count-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.piece-count-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record-grid div,
.piece-count-grid div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.record-grid span,
.piece-count-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.record-grid strong,
.piece-count-grid strong {
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

#turnBadge {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

#matchStatus {
  line-height: 1.45;
}

.actions {
  gap: 10px;
}

.undo-request-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(12, 124, 89, 0.28);
  border-radius: 8px;
  background: #edf8f4;
}

.undo-request-panel[hidden] {
  display: none;
}

.undo-request-panel strong {
  color: var(--accent-dark);
  font-size: 14px;
}

.move-list {
  display: grid;
  gap: 8px;
  max-height: 380px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.move-list li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.modal-backdrop {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: block;
  padding: 0;
  background: transparent;
  pointer-events: none;
}

.modal-backdrop[hidden] {
  display: none;
}

.result-dialog {
  display: grid;
  gap: 14px;
  width: min(360px, calc(100vw - 48px));
  padding: 18px;
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.96);
  border: 1px solid rgba(199, 212, 225, 0.9);
  box-shadow: 0 16px 32px rgba(23, 33, 43, 0.16);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.result-dialog h2,
.result-dialog p {
  margin: 0;
}

.result-dialog h2 {
  font-size: 24px;
}

#resultSummary {
  color: var(--muted);
  line-height: 1.5;
}

.modal-record {
  margin-top: 4px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
}

.dialog-actions button {
  flex: 1;
}

.single-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.single-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  background: #f8fafc;
  border-right: 1px solid var(--line);
}

.single-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 20px;
  padding: clamp(16px, 2.8vw, 30px);
}

.info-card,
.control-card,
.surface-card,
.hand-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.single-stage h2,
.single-stage p,
.single-sidebar h2,
.single-sidebar p,
.info-card h3,
.control-card h3 {
  margin: 0;
}

.single-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.monopoly-layout {
  display: grid;
  grid-template-columns: minmax(760px, 1fr) minmax(260px, 340px);
  gap: 22px;
  align-items: start;
}

.monopoly-board-wrap {
  display: grid;
  justify-items: center;
}

.monopoly-map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  grid-template-rows: repeat(11, minmax(0, 1fr));
  gap: clamp(1px, 0.28vw, 3px);
  width: min(100%, 1040px, calc(100svh - 180px));
  aspect-ratio: 1;
  padding: clamp(8px, 1.2vw, 16px);
  border: clamp(6px, 0.8vw, 10px) solid #273c57;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(39, 60, 87, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(39, 60, 87, 0.08) 1px, transparent 1px),
    #cfe0e8;
  background-size: 28px 28px;
  box-shadow: 0 22px 45px rgba(23, 33, 43, 0.18);
}

.monopoly-center {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  grid-column: 3 / 10;
  grid-row: 3 / 10;
  min-width: 0;
  padding: clamp(14px, 2vw, 26px);
  border: 2px solid rgba(39, 60, 87, 0.24);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.95), rgba(237, 246, 241, 0.88) 45%, rgba(209, 226, 235, 0.88)),
    linear-gradient(135deg, #ffffff, #e9f1f5);
  text-align: center;
  overflow: hidden;
}

.monopoly-center h3,
.monopoly-center p {
  position: relative;
  z-index: 1;
  margin: 0;
}

.monopoly-center-globe {
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(12, 124, 89, 0.18);
  border-radius: 50%;
  opacity: 0.8;
}

.monopoly-center-globe span {
  position: absolute;
  inset: 10%;
  border: 1px solid rgba(12, 124, 89, 0.18);
  border-radius: 50%;
}

.monopoly-center-globe span:nth-child(2) {
  transform: scaleX(0.45);
}

.monopoly-center-globe span:nth-child(3) {
  transform: scaleY(0.45);
}

.monopoly-dice {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(54px, 5vw, 74px);
  height: clamp(54px, 5vw, 74px);
  border-radius: 16px;
  background: #fff4d6;
  color: #8f6510;
  font-size: clamp(24px, 2.6vw, 34px);
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(23, 33, 43, 0.12);
}

.monopoly-cell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1px;
  min-width: 0;
  min-height: 0;
  padding: clamp(3px, 0.35vw, 5px) clamp(2px, 0.35vw, 4px) clamp(3px, 0.35vw, 4px);
  border: 1px solid rgba(23, 33, 43, 0.22);
  border-radius: 3px;
  background: linear-gradient(180deg, #fffdf7, #f7f0df);
  color: var(--ink);
  text-align: center;
  overflow: hidden;
}

.monopoly-cell strong {
  display: grid;
  align-items: center;
  min-height: 0;
  font-size: clamp(8px, 0.78vw, 11px);
  line-height: 1.12;
  word-break: keep-all;
}

.monopoly-cell small {
  color: var(--muted);
  font-size: clamp(7px, 0.72vw, 11px);
  font-weight: 800;
}

.cell-index {
  position: absolute;
  top: 2px;
  left: 3px;
  color: rgba(36, 48, 62, 0.54);
  font-size: clamp(6px, 0.55vw, 8px);
  font-weight: 900;
}

.country-flag {
  position: relative;
  display: block;
  justify-self: center;
  width: clamp(20px, 3vw, 34px);
  height: clamp(12px, 1.7vw, 18px);
  border: 1px solid rgba(23, 33, 43, 0.2);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(23, 33, 43, 0.14);
}

.country-flag i {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(5px, 0.5vw, 7px);
  font-style: normal;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.country-symbol {
  display: grid;
  place-items: center;
  min-height: 0;
  font-size: clamp(10px, 1.2vw, 16px);
  line-height: 1;
}

.flag-br {
  background: linear-gradient(135deg, #229e45 0 35%, #f7d117 35% 65%, #229e45 65%);
}

.flag-ar {
  background: linear-gradient(#75aadb 0 33%, #fff 33% 66%, #75aadb 66%);
}

.flag-eg {
  background: linear-gradient(#ce1126 0 33%, #fff 33% 66%, #000 66%);
}

.flag-za {
  background: linear-gradient(135deg, #007a4d 0 42%, #ffb612 42% 52%, #de3831 52% 70%, #002395 70%);
}

.flag-ma {
  background: #c1272d;
}

.flag-es {
  background: linear-gradient(#aa151b 0 25%, #f1bf00 25% 75%, #aa151b 75%);
}

.flag-fr {
  background: linear-gradient(90deg, #0055a4 0 33%, #fff 33% 66%, #ef4135 66%);
}

.flag-de {
  background: linear-gradient(#000 0 33%, #dd0000 33% 66%, #ffce00 66%);
}

.flag-it {
  background: linear-gradient(90deg, #009246 0 33%, #fff 33% 66%, #ce2b37 66%);
}

.flag-gb {
  background:
    linear-gradient(32deg, transparent 42%, #fff 42% 48%, #c8102e 48% 54%, #fff 54% 60%, transparent 60%),
    linear-gradient(148deg, transparent 42%, #fff 42% 48%, #c8102e 48% 54%, #fff 54% 60%, transparent 60%),
    linear-gradient(90deg, transparent 42%, #fff 42% 58%, transparent 58%),
    linear-gradient(transparent 38%, #fff 38% 62%, transparent 62%),
    #012169;
}

.flag-ch {
  background:
    linear-gradient(90deg, transparent 36%, #fff 36% 64%, transparent 64%),
    linear-gradient(transparent 32%, #fff 32% 68%, transparent 68%),
    #d52b1e;
}

.flag-tr {
  background: radial-gradient(circle at 43% 50%, #e30a17 0 16%, #fff 17% 25%, #e30a17 26%), #e30a17;
}

.flag-in {
  background: linear-gradient(#ff9933 0 33%, #fff 33% 66%, #138808 66%);
}

.flag-sg {
  background: linear-gradient(#ef3340 0 50%, #fff 50%);
}

.flag-kr {
  background: radial-gradient(circle at 50% 50%, #cd2e3a 0 24%, #0047a0 25% 36%, transparent 37%), #fff;
}

.flag-jp {
  background: radial-gradient(circle at 50% 50%, #bc002d 0 28%, transparent 29%), #fff;
}

.flag-cn {
  background: radial-gradient(circle at 25% 32%, #ffde00 0 12%, transparent 13%), #de2910;
}

.flag-au,
.flag-nz {
  background:
    radial-gradient(circle at 72% 35%, #fff 0 5%, transparent 6%),
    radial-gradient(circle at 82% 62%, #fff 0 5%, transparent 6%),
    #012169;
}

.flag-ca {
  background: linear-gradient(90deg, #d52b1e 0 25%, #fff 25% 75%, #d52b1e 75%);
}

.flag-us {
  background:
    repeating-linear-gradient(#b22234 0 2px, #fff 2px 4px);
}

.flag-mx {
  background: linear-gradient(90deg, #006847 0 33%, #fff 33% 66%, #ce1126 66%);
}

.monopoly-cell.corner {
  background: linear-gradient(135deg, #fff8dd, #dff3e8);
  font-weight: 900;
}

.monopoly-cell.chance {
  background: linear-gradient(180deg, #e7f0ff, #f8fbff);
}

.monopoly-cell.tax {
  background: linear-gradient(180deg, #fde6e6, #fff6f6);
}

.monopoly-cell.station,
.monopoly-cell.utility {
  background: linear-gradient(180deg, #fff4d6, #fffaf0);
}

.monopoly-cell.teal {
  border-top: 6px solid #0c7c59;
}

.monopoly-cell.pink {
  border-top: 6px solid #d45d9f;
}

.monopoly-cell.blue {
  border-top: 6px solid #336fd6;
}

.monopoly-cell.orange {
  border-top: 6px solid #d8762f;
}

.monopoly-cell.green {
  border-top: 6px solid #2f9d64;
}

.monopoly-cell.gold {
  border-top: 6px solid #c7951d;
}

.monopoly-cell.red {
  border-top: 6px solid #d63e47;
}

.monopoly-cell.black {
  border-top: 6px solid #17212b;
}

.monopoly-sidecard,
.ludo-sidecard {
  box-shadow: 0 16px 32px rgba(23, 33, 43, 0.08);
}

.monopoly-sidecard .stat-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.ludo-layout {
  grid-template-columns: minmax(620px, 740px) 300px;
}

.ludo-map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  grid-template-rows: repeat(15, minmax(0, 1fr));
  gap: clamp(1px, 0.28vw, 3px);
  width: min(100%, 740px, calc(100svh - 190px));
  aspect-ratio: 1;
  padding: clamp(8px, 1vw, 14px);
  border: clamp(5px, 0.8vw, 8px) solid #1f2d3d;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(31, 45, 61, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(31, 45, 61, 0.06) 1px, transparent 1px),
    #fffaf0;
  background-size: 28px 28px;
  box-shadow: 0 22px 42px rgba(23, 33, 43, 0.16);
}

.ludo-home {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: auto repeat(2, 1fr);
  gap: clamp(4px, 0.8vw, 8px);
  align-items: center;
  justify-items: center;
  padding: clamp(6px, 0.9vw, 10px);
  border: clamp(2px, 0.35vw, 3px) solid currentColor;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.72);
}

.ludo-home strong {
  grid-column: 1 / -1;
  font-size: clamp(9px, 0.9vw, 12px);
}

.ludo-home span {
  width: 58%;
  aspect-ratio: 1;
  border: 2px solid rgba(23, 33, 43, 0.12);
  border-radius: 50%;
  background: currentColor;
}

.ludo-home.red,
.ludo-cell.red,
.ludo-team-card.red {
  color: #d63e47;
}

.ludo-home.blue,
.ludo-cell.blue,
.ludo-team-card.blue {
  color: #2469d9;
}

.ludo-home.green,
.ludo-cell.green,
.ludo-team-card.green {
  color: #15915d;
}

.ludo-home.gold,
.ludo-cell.gold,
.ludo-team-card.gold {
  color: #d1a000;
}

.ludo-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: clamp(1px, 0.24vw, 2px) solid currentColor;
  border-radius: 4px;
  background: #fff;
  color: #7a8795;
  font-size: clamp(8px, 0.85vw, 11px);
  font-weight: 900;
}

.ludo-cell.muted {
  color: #9aa8b5;
  background: #fff;
}

.ludo-cell.red,
.ludo-cell.blue,
.ludo-cell.green,
.ludo-cell.gold {
  background: color-mix(in srgb, currentColor 22%, white);
}

.ludo-cell.home-run {
  background: currentColor;
  color: #fff;
  border-color: rgba(23, 33, 43, 0.2);
}

.ludo-cell.start {
  border-width: 3px;
  background: #fff7d6;
}

.ludo-center {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background:
    conic-gradient(from 45deg, #2469d9 0 25%, #15915d 0 50%, #d1a000 0 75%, #d63e47 0);
  color: #fff;
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.24);
  z-index: 1;
}

.ludo-center span {
  font-size: clamp(18px, 2vw, 28px);
  line-height: 1;
}

.ludo-plane {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  align-self: center;
  justify-self: center;
  width: 78%;
  aspect-ratio: 1;
  border: 2px solid #fff;
  border-radius: 50%;
  background: currentColor;
  color: #fff;
  font-size: clamp(11px, 1.3vw, 17px);
  box-shadow: 0 6px 12px rgba(23, 33, 43, 0.18);
}

.ludo-plane::after {
  content: attr(data-label);
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  color: currentColor;
  font-size: 10px;
  font-weight: 900;
}

.ludo-plane.red {
  color: #d63e47;
}

.ludo-plane.blue {
  color: #2469d9;
}

.ludo-plane.green {
  color: #15915d;
}

.ludo-plane.gold {
  color: #d1a000;
}

.ludo-team-list {
  display: grid;
  gap: 10px;
}

.ludo-team-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, currentColor 28%, white);
  border-radius: 8px;
  background: color-mix(in srgb, currentColor 8%, white);
}

.ludo-team-card strong {
  color: var(--ink);
}

.owner-mark {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.owner-mark.red {
  background: #d63e47;
}

.owner-mark.blue {
  background: #336fd6;
}

.owner-mark.green {
  background: #2f9d64;
}

.owner-mark.gold {
  background: #8f6510;
}

.monopoly-cell .piece-row {
  position: absolute;
  right: 4px;
  bottom: 24px;
  left: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 20px;
}

.monopoly-cell .piece-dot {
  min-width: 24px;
  width: 24px;
  height: 24px;
  border: 2px solid #fff;
  font-size: 12px;
  box-shadow: 0 4px 8px rgba(23, 33, 43, 0.26);
}

.house-row {
  position: absolute;
  right: 4px;
  bottom: 4px;
  left: 4px;
  display: flex;
  gap: 2px;
  min-height: 17px;
}

.house-mark {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 3px;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 2px 5px rgba(23, 33, 43, 0.22);
}

.house-mark.red,
.property-chip.red {
  background: #d63e47;
}

.house-mark.blue,
.property-chip.blue {
  background: #336fd6;
}

.house-mark.green,
.property-chip.green {
  background: #2f9d64;
}

.house-mark.gold,
.property-chip.gold {
  background: #8f6510;
}

.asset-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.asset-card .monopoly-property-list {
  grid-column: 1 / -1;
}

.property-chip {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.asset-card small,
.asset-card span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.track-cell {
  display: grid;
  gap: 6px;
  min-height: 78px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: 12px;
}

.track-cell strong {
  font-size: 12px;
}

.track-cell.start {
  background: #edf8f4;
}

.track-cell.gold {
  background: #fff4d6;
}

.track-cell.tax {
  background: #fde6e6;
}

.track-cell.jump {
  background: #e7f0ff;
}

.piece-row,
.stat-grid,
.inline-actions,
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.piece-dot {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.player-token {
  border: 2px solid #fff;
  box-shadow: 0 5px 12px rgba(23, 33, 43, 0.28);
}

.piece-dot.red {
  background: #d63e47;
}

.piece-dot.blue {
  background: #336fd6;
}

.piece-dot.green {
  background: #2f9d64;
}

.piece-dot.gold {
  background: #8f6510;
}

.piece-button {
  min-width: 78px;
}

.mini-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.checkers-board {
  position: relative;
  width: min(100%, 760px, calc(100svh - 180px));
  aspect-ratio: 1 / 1.08;
  border: clamp(5px, 0.8vw, 8px) solid #17212b;
  border-radius: 8px;
  overflow: hidden;
  padding: 4%;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.08), transparent 34%),
    #050608;
  box-shadow: 0 22px 42px rgba(23, 33, 43, 0.18);
}

.animal-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 720px, calc(100svh - 180px));
  aspect-ratio: 7 / 9;
  padding: clamp(6px, 0.8vw, 10px);
  border: clamp(5px, 0.8vw, 8px) solid #4e321c;
  border-radius: 8px;
  background:
    linear-gradient(rgba(78, 50, 28, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(78, 50, 28, 0.12) 1px, transparent 1px),
    linear-gradient(135deg, #f1d8a5, #c99557);
  background-size: calc(100% / 7) calc(100% / 9);
  box-shadow: 0 22px 42px rgba(23, 33, 43, 0.18);
}

.animal-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(60, 38, 18, 0.24);
  border-radius: 8px;
  background: linear-gradient(180deg, #f7e5bc, #e1bf7d);
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
}

.animal-cell.river {
  border-color: rgba(31, 102, 156, 0.42);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 30%),
    linear-gradient(180deg, #67b9ea, #2b7bbc);
  color: #fff;
}

.animal-cell.den-red {
  background: linear-gradient(180deg, #f7b3b8, #d63e47);
  color: #fff;
}

.animal-cell.den-blue {
  background: linear-gradient(180deg, #a9d2ff, #336fd6);
  color: #fff;
}

.animal-cell.trap {
  background: linear-gradient(180deg, #faedd3, #d9b876);
}

.animal-cell.selected {
  outline: 4px solid rgba(12, 124, 89, 0.85);
  outline-offset: -4px;
}

.animal-cell.target {
  outline: 4px solid rgba(246, 211, 101, 0.95);
  outline-offset: -4px;
}

.animal-cell.last-move {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.36);
}

.animal-piece {
  position: absolute;
  inset: 12%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  color: #fff;
  font-size: clamp(11px, 1.5vw, 18px);
  font-weight: 900;
  box-shadow: 0 8px 16px rgba(23, 33, 43, 0.18);
}

.animal-piece.red {
  background: radial-gradient(circle at 32% 28%, #ff9d95, #d63e47);
}

.animal-piece.blue {
  background: radial-gradient(circle at 32% 28%, #8bc4ff, #336fd6);
}

.animal-cell .cell-label {
  position: absolute;
  left: 4px;
  top: 3px;
  color: rgba(23, 33, 43, 0.56);
  font-size: 10px;
  font-weight: 800;
}

.chinese-hole {
  position: absolute;
  display: grid;
  place-items: center;
  width: 5.6%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fbfaf7;
  transform: translate(-50%, -50%);
  box-shadow:
    inset 0 -4px 8px rgba(0, 0, 0, 0.08),
    0 3px 8px rgba(0, 0, 0, 0.36);
  cursor: pointer;
}

.chinese-hole.region-top {
  background: #30cf3a;
}

.chinese-hole.region-left {
  background: #473bff;
}

.chinese-hole.region-right {
  background: #f0ea00;
}

.chinese-hole.region-bottom {
  background: #f20404;
}

.chinese-hole.region-bottomLeft {
  background: #cf00e9;
}

.chinese-hole.region-bottomRight {
  background: #ff941b;
}

.chinese-hole.region-center {
  background: #fff;
}

.checker-piece {
  width: 94%;
  height: 94%;
  border-radius: 50%;
  box-shadow:
    inset 0 4px 8px rgba(255, 255, 255, 0.28),
    0 4px 10px rgba(0, 0, 0, 0.28);
}

.checker-piece.red {
  background: radial-gradient(circle at 32% 28%, #ff8e8a, #d63e47);
}

.checker-piece.blue {
  background: radial-gradient(circle at 32% 28%, #82c5ff, #336fd6);
}

.checker-piece.king {
  outline: 4px solid rgba(255, 244, 214, 0.82);
}

.chinese-hole.target {
  outline: 4px solid rgba(246, 211, 101, 0.95);
  outline-offset: 2px;
}

.card-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.player-strip .card-hand {
  align-items: flex-end;
  gap: 0;
  padding: 10px 0 4px;
  overflow-x: auto;
}

.playing-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 54px;
  height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(23, 33, 43, 0.08);
  padding: 5px 6px 4px;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease;
}

.player-strip .playing-card {
  flex: 0 0 54px;
  margin-right: -14px;
}

.player-strip .playing-card:hover:not(:disabled) {
  transform: translateY(-6px);
}

.playing-card.selected {
  border-color: var(--accent);
  background: #edf8f4;
  transform: translateY(-14px);
  z-index: 2;
}

.playing-card.red {
  color: #d63e47;
}

.playing-card.black {
  color: #16202b;
}

.card-corner {
  display: grid;
  line-height: 1;
  font-size: 10px;
}

.card-corner b,
.card-corner i {
  font-style: normal;
}

.card-corner.top {
  justify-self: start;
}

.card-corner.bottom {
  justify-self: end;
  align-self: end;
  transform: rotate(180deg);
}

.card-pip {
  align-self: center;
  justify-self: center;
  font-size: 26px;
  line-height: 1;
}

.joker-card .card-corner {
  font-size: 8px;
  letter-spacing: 0;
}

.joker-card .card-pip {
  font-size: 22px;
}

.card-back {
  position: relative;
  border-color: #b7c4d4;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.32) 25%, transparent 25%) 0 0 / 10px 10px,
    linear-gradient(135deg, transparent 75%, rgba(255, 255, 255, 0.32) 75%) 0 0 / 10px 10px,
    linear-gradient(135deg, #2c69c9, #163f8f);
  box-shadow: 0 8px 18px rgba(23, 33, 43, 0.1);
}

.card-back span {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 5px;
}

.player-strip .card-back.side {
  transform: rotate(90deg);
  margin-right: -28px;
}

.player-strip .card-back.side:hover {
  transform: rotate(90deg);
}

.stack-board {
  display: grid;
  gap: 18px;
}

.player-strip {
  display: grid;
  gap: 8px;
}

.player-strip header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.last-play {
  min-height: 72px;
}

.landlord-table {
  position: relative;
  display: grid;
  min-height: min(680px, calc(100svh - 180px));
  padding: clamp(14px, 2vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.08), transparent 34%),
    linear-gradient(180deg, #1b6f48, #0f4d33);
  box-shadow: 0 18px 40px rgba(23, 33, 43, 0.14);
}

.landlord-seats {
  position: relative;
  min-height: min(620px, calc(100svh - 240px));
}

.landlord-center {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  gap: 14px;
  width: min(480px, calc(100% - 80px));
  transform: translate(-50%, -50%);
}

.landlord-center-actions {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.landlord-center-actions .inline-actions {
  justify-content: center;
}

.landlord-center-actions button {
  min-width: 110px;
}

.landlord-bottom-card {
  justify-items: center;
}

.center-play {
  justify-content: center;
}

.landlord-seat {
  position: absolute;
  width: min(320px, 40%);
  background: rgba(255, 255, 255, 0.96);
}

.landlord-seat header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.seat-0 {
  left: 50%;
  bottom: 0;
  width: min(720px, calc(100% - 40px));
  transform: translateX(-50%);
}

.seat-1 {
  left: 0;
  top: 18%;
}

.seat-2 {
  right: 0;
  top: 18%;
}

.seat-played {
  min-height: 86px;
  align-items: center;
}

.landlord-seat.opponent .card-hand {
  justify-content: flex-start;
}

.landlord-seat.opponent .card-back.side {
  margin-right: -22px;
}

.poker-table {
  display: grid;
  gap: 18px;
  min-height: min(720px, calc(100svh - 180px));
  padding: clamp(14px, 2vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.1), transparent 38%),
    linear-gradient(180deg, #1b6f48, #0f4d33);
  box-shadow: 0 18px 40px rgba(23, 33, 43, 0.14);
}

.poker-board {
  justify-items: center;
  width: min(620px, 100%);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.96);
}

.poker-seat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}

.poker-seat {
  min-width: 0;
  background: rgba(255, 255, 255, 0.96);
}

.poker-seat.active {
  border-color: rgba(246, 211, 101, 0.9);
  box-shadow: 0 0 0 3px rgba(246, 211, 101, 0.28);
}

.poker-seat.winner {
  border-color: rgba(12, 124, 89, 0.62);
  background: #edf8f4;
}

.poker-seat header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.poker-seat .card-hand {
  min-height: 86px;
}

@media (max-width: 1180px) {
  .lobby-grid-wide {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }
}

@media (max-width: 980px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }

  .lobby-grid-wide {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .single-shell {
    grid-template-columns: 1fr;
  }

  .single-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .single-layout {
    grid-template-columns: 1fr;
  }

  .monopoly-layout {
    grid-template-columns: 1fr;
  }

  .monopoly-sidecard {
    order: 2;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .board-layout {
    grid-template-columns: 1fr;
  }

  .ludo-layout {
    grid-template-columns: 1fr;
  }

  .ludo-sidecard {
    order: 2;
  }

  .single-layout,
  .monopoly-layout,
  .board-layout {
    justify-items: center;
  }
}

@media (max-width: 620px) {
  .sidebar,
  .game-stage {
    padding: 18px;
  }

  .single-sidebar,
  .single-stage {
    padding: 18px;
  }

  .stage-header,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .stage-header h2 {
    font-size: 26px;
  }

  .score-strip {
    justify-content: flex-start;
  }

  .record-grid,
  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    flex-direction: column;
  }

  .modal-backdrop {
    position: static;
    margin-top: 12px;
  }

  .result-dialog {
    width: 100%;
  }

  .canvas-wrap {
    width: 100%;
  }

  .board-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .single-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .ludo-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .landlord-table {
    min-height: auto;
    padding: 14px;
  }

  .poker-table {
    min-height: auto;
    padding: 14px;
  }

  .poker-seat-grid {
    grid-template-columns: 1fr;
  }

  .landlord-table,
  .landlord-seats {
    display: grid;
    gap: 12px;
  }

  .landlord-seats {
    min-height: 0;
  }

  .landlord-center,
  .landlord-seat,
  .seat-0,
  .seat-1,
  .seat-2 {
    position: static;
    inset: auto;
    width: 100%;
    transform: none;
  }

  .landlord-center {
    order: -1;
  }

  .seat-played {
    min-height: 68px;
  }

  .monopoly-sidecard .stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .playing-card {
    width: 48px;
    height: 68px;
    padding: 4px 5px 3px;
  }

  .player-strip .playing-card {
    flex-basis: 48px;
    margin-right: -12px;
  }

  .card-pip {
    font-size: 22px;
  }

  .piece-button {
    width: 100%;
  }
}

@media (max-aspect-ratio: 4/5) {
  .board-layout,
  .single-layout,
  .monopoly-layout,
  .ludo-layout {
    grid-template-columns: 1fr;
  }

  .match-panel,
  .monopoly-sidecard,
  .ludo-sidecard {
    width: min(100%, 760px);
  }

  .canvas-wrap,
  .ludo-map,
  .monopoly-map,
  .checkers-board,
  .animal-board {
    width: min(100%, calc(100svh - 220px));
  }
}

/* ============================================================
 * 大厅两级结构（选游戏 → 选房间）与账号 UI
 * ============================================================ */

/* 顶栏用户区：徽章 + 登录/退出按钮 + 试玩入口。 */
.lobby-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-badge {
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.user-badge:hover {
  border-color: rgba(12, 124, 89, 0.45);
}

.user-badge.logged-in {
  border-color: rgba(12, 124, 89, 0.5);
  background: rgba(12, 124, 89, 0.08);
  color: var(--accent-dark);
  cursor: default;
}

.auth-open-btn,
.auth-logout-btn {
  padding: 7px 14px;
  border: 1px solid rgba(12, 124, 89, 0.5);
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.auth-open-btn:hover,
.auth-logout-btn:hover {
  background: var(--accent-dark);
}

.auth-logout-btn {
  background: var(--panel);
  color: var(--muted);
  border-color: var(--line);
}

.auth-logout-btn:hover {
  color: var(--warn);
  border-color: rgba(180, 95, 6, 0.5);
  background: var(--panel-soft);
}

.lobby-arcade-link {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.lobby-arcade-link:hover {
  color: var(--accent-dark);
  border-color: rgba(12, 124, 89, 0.45);
}

/* grid 布局容器上 hidden 属性需要显式覆盖 display。 */
.lobby-grid[hidden],
.lobby-rooms[hidden] {
  display: none;
}

/* 二级视图：房间列表。 */
.lobby-rooms {
  display: grid;
  gap: 16px;
  align-content: start;
}

.rooms-toolbar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.rooms-back-btn {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.rooms-back-btn:hover {
  border-color: rgba(12, 124, 89, 0.45);
  transform: translateX(-1px);
}

.rooms-title {
  margin: 0;
  font-size: 22px;
}

.rooms-count {
  color: var(--muted);
  font-size: 14px;
}

.rooms-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(42, 52, 66, 0.08);
}

.rooms-action-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.rooms-actions input {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 14px;
  min-width: 0;
  /* 覆盖全局 input 的 width:100%（那会让 inline-flex 组内输入框撑爆并挤换行按钮）。 */
  width: 200px;
  max-width: 42vw;
  flex: 0 1 auto;
}

.rooms-actions input:focus {
  outline: none;
  border-color: rgba(12, 124, 89, 0.55);
  background: #ffffff;
}

.rooms-actions input::placeholder {
  color: var(--muted);
}

.rooms-actions button {
  padding: 9px 16px;
  border: 1px solid rgba(12, 124, 89, 0.5);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-dark);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.rooms-actions button:hover {
  background: rgba(12, 124, 89, 0.08);
}

.rooms-actions .rooms-quick-btn {
  background: var(--accent);
  color: #ffffff;
}

.rooms-actions .rooms-quick-btn:hover {
  background: var(--accent-dark);
}

/* 房间行：整行可点，满员降透明度。 */
.room-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.room-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto auto;
  align-items: center;
  gap: 18px;
  padding: 14px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(42, 52, 66, 0.08);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.room-row:hover {
  border-color: rgba(12, 124, 89, 0.45);
  transform: translateY(-1px);
}

.room-row.full {
  opacity: 0.62;
  cursor: default;
}

.room-row.full:hover {
  transform: none;
}

.room-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.room-name {
  font-size: 16px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-id {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 1px;
}

.room-host {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.room-players {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.room-status-badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.room-status-badge.waiting {
  background: rgba(12, 124, 89, 0.12);
  color: var(--accent-dark);
}

.room-status-badge.playing {
  background: rgba(180, 95, 6, 0.14);
  color: var(--warn);
}

.room-status-badge.finished {
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.room-action button {
  padding: 8px 18px;
  border: 1px solid rgba(12, 124, 89, 0.5);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.room-action button:hover {
  background: var(--accent-dark);
}

.room-row.full .room-action {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.rooms-empty {
  margin: 0;
  padding: 44px 20px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--muted);
  text-align: center;
}

/* 登录/注册/游客弹窗：覆盖 .modal-backdrop 的右下角定位为全屏遮罩。 */
.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 33, 43, 0.46);
  pointer-events: auto;
}

.auth-backdrop[hidden] {
  display: none;
}

.auth-dialog {
  position: relative;
  display: grid;
  gap: 16px;
  width: min(380px, calc(100vw - 48px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}

.auth-close-btn:hover {
  background: var(--panel-soft);
  color: var(--ink);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  flex: 1;
  padding: 9px 4px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.auth-tab:hover {
  color: var(--ink);
}

.auth-tab.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form[hidden] {
  display: none;
}

.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.auth-form input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 14px;
}

.auth-form input:focus {
  outline: none;
  border-color: rgba(12, 124, 89, 0.55);
  background: #ffffff;
}

.auth-error {
  margin: 0;
  color: #b3261e;
  font-size: 13px;
  line-height: 1.5;
}

/* 窄屏适配：房间行改为纵向堆叠，操作按钮占满一行。 */
@media (max-width: 720px) {
  .room-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "main players"
      "main status"
      "host action";
    row-gap: 8px;
  }

  .room-main {
    grid-area: main;
  }

  .room-host {
    grid-area: host;
  }

  .room-players {
    grid-area: players;
    justify-self: end;
  }

  .room-status-badge {
    grid-area: status;
    justify-self: end;
  }

  .room-action {
    grid-area: action;
    justify-self: end;
  }

  .rooms-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .rooms-action-group {
    width: 100%;
  }

  .rooms-action-group input {
    flex: 1;
  }
}

