:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel2: #263449;
  --green: #16a34a;
  --gold: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --text: #e2e8f0;
  --muted: #94a3b8;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1e3a5f 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--panel2);
  color: var(--text);
  transition: transform .1s, filter .15s;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, #22c55e, #15803d); color: #fff; }
.btn-gold { background: linear-gradient(135deg, #fbbf24, #d97706); color: #1c1917; }
.btn-red { background: linear-gradient(135deg, #f87171, #b91c1c); color: #fff; }
.btn-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 8px; }

.input {
  background: var(--panel2);
  border: 1px solid #334155;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
  outline: none;
}
.input:focus { border-color: var(--blue); }
.input::placeholder { color: var(--muted); }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: rgba(15, 23, 42, .7);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #1e293b;
}
.logo { font-size: 22px; font-weight: 800; letter-spacing: 1px; }
.logo span { color: var(--gold); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }

.hero { text-align: center; padding: 40px 0 28px; }
.hero h1 { font-size: 34px; margin-bottom: 12px; }
.hero p { color: var(--muted); font-size: 16px; }

.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 22px; margin-top: 26px; }
.game-card {
  background: linear-gradient(160deg, var(--panel) 0%, #0b1220 100%);
  border: 1px solid #2a3a52;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.game-card h2 { font-size: 20px; }
.game-card .desc { color: var(--muted); font-size: 14px; min-height: 42px; }
.game-card .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.game-card .players { color: var(--muted); font-size: 13px; }

.join-box {
  margin-top: 28px;
  background: var(--panel);
  border: 1px solid #2a3a52;
  border-radius: 14px;
  padding: 20px 24px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.join-box .input { flex: 1; min-width: 180px; text-transform: uppercase; }

.forum-entry {
  margin-top: 28px;
  text-align: center;
  padding: 24px;
  background: linear-gradient(135deg, rgba(59,130,246,.15), rgba(139,92,246,.15));
  border: 1px solid #334155;
  border-radius: 14px;
}
.forum-entry p { color: var(--muted); margin-bottom: 12px; }

/* forum page */
.forum-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.post {
  background: var(--panel);
  border: 1px solid #2a3a52;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.post .p-title { font-size: 16px; font-weight: 700; }
.post .p-meta { color: var(--muted); font-size: 12px; margin: 6px 0; }
.post .p-content { color: var(--text); font-size: 14px; white-space: pre-wrap; margin-bottom: 10px; }
.post .room-link { display: inline-flex; gap: 8px; align-items: center; }
.room-code-tag {
  background: var(--panel2);
  border: 1px dashed var(--blue);
  border-radius: 8px;
  padding: 4px 10px;
  font-family: monospace;
  letter-spacing: 2px;
  color: #93c5fd;
}
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal.open { display: flex; }
.modal-card {
  background: var(--panel); border: 1px solid #334155;
  border-radius: 14px; padding: 24px; width: min(440px, 92vw);
  display: flex; flex-direction: column; gap: 12px;
}
.modal-card h3 { font-size: 18px; }

/* game page layout */
.game-layout {
  display: flex;
  gap: 14px;
  height: calc(100vh - 62px);
  padding: 12px;
}
.board { flex: 1; position: relative; background: linear-gradient(180deg, #0e3a2c, #0a2a20); border-radius: 14px; overflow: hidden; }
.sidebar {
  width: 300px; background: var(--panel); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
}
.tabbar { display: flex; border-bottom: 1px solid #334155; }
.tabbar button { flex: 1; padding: 10px; background: transparent; border: none; color: var(--muted); font-size: 14px; cursor: pointer; }
.tabbar button.active { color: var(--gold); border-bottom: 2px solid var(--gold); }
.panel { display: none; flex: 1; overflow-y: auto; padding: 12px; }
.panel.active { display: block; }
.log-item { font-size: 13px; color: var(--muted); padding: 5px 0; border-bottom: 1px solid #1e293b; }
.chat-item { font-size: 13px; margin: 8px 0; }
.chat-item .c-name { color: var(--gold); font-weight: 600; margin-right: 6px; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #334155; }
.chat-input .input { flex: 1; }
.seat { padding: 10px; border-radius: 10px; background: var(--panel2); margin-bottom: 8px; font-size: 13px; }
.seat .s-name { font-weight: 600; }
.seat.turn { outline: 2px solid var(--gold); }
.seat .tag { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: #334155; margin-left: 6px; }
.seat .tag.bot { background: #3f3f46; color: var(--muted); }
.seat .tag.landlord { background: var(--red); color: #fff; }
.seat .tag.me { background: var(--blue); color: #fff; }
.seat .tag.host { background: var(--green); color: #fff; }
.toast-wrap {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center;
}
.toast {
  background: var(--panel2); border: 1px solid #334155;
  padding: 10px 20px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
  animation: slideIn .25s ease;
}
.toast.err { border-color: var(--red); color: #fca5a5; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

/* doudizhu board */
.ddz-table { position: absolute; inset: 0; }
.ddz-seat { position: absolute; text-align: center; }
.ddz-seat .who { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.ddz-seat .cnt { font-size: 12px; color: #cbd5e1; }
.ddz-me { bottom: 18px; left: 50%; transform: translateX(-50%); }
.ddz-left { top: 120px; left: 30px; }
.ddz-right { top: 120px; right: 30px; }
.ddz-bottom { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; }
.ddz-center { position: absolute; top: 44%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.ddz-combo { display: inline-flex; gap: 4px; background: rgba(0,0,0,.35); padding: 10px 14px; border-radius: 12px; }
.ddz-center .turn-tip { margin-top: 8px; font-size: 14px; color: var(--gold); }
.ddz-hand {
  display: flex; gap: 0; max-width: 94%;
}
.ddz-hand .card { margin-right: -34px; }
.ddz-hand .card:last-child { margin-right: 0; }
.ddz-hand .card.sel { margin-right: -34px; z-index: 5; }
.card {
  width: 64px; height: 92px; border-radius: 8px; background: #fff; color: #1e293b;
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700;
  box-shadow: 0 3px 8px rgba(0,0,0,.4); cursor: pointer; position: relative;
  border: 2px solid transparent; transition: transform .12s, margin-top .12s, box-shadow .12s;
  flex-shrink: 0;
}
.card.red { color: var(--red); }
.card.back { background: repeating-linear-gradient(45deg, #1e40af, #1e40af 8px, #1e3a8a 8px, #1e3a8a 16px); }
.card.back::after { content: ''; }
.card.small { width: 42px; height: 60px; font-size: 11px; border-radius: 6px; }
.card.mini { width: 30px; height: 42px; font-size: 9px; border-radius: 5px; }
.card.sel { margin-top: -18px; border-color: var(--gold); box-shadow: 0 0 12px var(--gold); }
.card.joker { background: linear-gradient(180deg, #fff, #f1f5f9); }
.card .corner { position: absolute; font-family: Georgia, 'Times New Roman', serif; font-weight: 800; line-height: 1.05; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.card .corner b { font-size: 11px; }
.card .corner i { font-style: normal; font-size: 8px; }
.card .corner.tl { top: 3px; left: 4px; }
.card .corner.tr { top: 3px; right: 4px; }
.card .corner.bl { bottom: 3px; left: 4px; transform: rotate(180deg); }
.card .corner.br { bottom: 3px; right: 4px; transform: rotate(180deg); }
.card .face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 30px; pointer-events: none; }
.card.joker .face { font-size: 11px; letter-spacing: 1px; }
.card.joker.small .face,
.card.joker.mini .face { font-size: 11px; letter-spacing: 0; }
body[data-card-skin="bigface"] .card .corner b { font-size: 13px; }
body[data-card-skin="bigface"] .card .corner i { font-size: 9px; }
body[data-card-skin="bigface"] .card .face { font-size: 46px; }
body[data-card-skin="minimal"] .card .corner.tr,
body[data-card-skin="minimal"] .card .corner.bl { display: none; }
body[data-card-skin="minimal"] .card .corner b { font-size: 12px; }
body[data-card-skin="minimal"] .card .corner i { font-size: 9px; }
body[data-card-skin="minimal"] .card .face { font-size: 42px; }
.card.small .corner b { font-size: 8px; }
.card.small .corner i { font-size: 6px; }
.card.small .face { font-size: 16px; }
.card.mini .corner { display: none; }
.card.mini .face { font-size: 11px; }
.ddz-actions {
  position: absolute; bottom: 116px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; z-index: 5;
}
.overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.55); z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.overlay h2 { font-size: 30px; }
.overlay .sub { color: var(--muted); }

/* mahjong board */
.mj-table { position: absolute; inset: 0; }
.mj-seat { position: absolute; }
.mj-me { bottom: 10px; left: 50%; transform: translateX(-50%); width: 96%; max-width: 640px; }
.mj-left { left: 16px; top: 50%; transform: translateY(-50%); }
.mj-right { right: 16px; top: 50%; transform: translateY(-50%); }
.mj-seat .who { font-size: 13px; font-weight: 700; text-align: center; }
.mj-seat .cnt { font-size: 11px; color: #cbd5e1; text-align: center; }
.mj-discards { display: flex; flex-wrap: wrap; max-width: 240px; gap: 3px; margin: 4px auto; justify-content: center; }
.mj-melds { display: flex; gap: 4px; justify-content: center; margin-top: 2px; }
.tile {
  width: 34px; height: 44px; border-radius: 6px; background: linear-gradient(160deg, #fefce8, #f8fafc);
  color: #1e293b; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; box-shadow: 0 2px 5px rgba(0,0,0,.4); border: 1px solid #cbd5e1;
  flex-shrink: 0;
}
.tile.w { color: #1e293b; } .tile.t { color: #166534; } .tile.s { color: #1d4ed8; }
.tile.small { width: 26px; height: 34px; font-size: 11px; border-radius: 5px; }
.tile.dim { opacity: .45; }
.tile.back { background: repeating-linear-gradient(45deg, #0f766e, #0f766e 5px, #115e59 5px, #115e59 10px); }
.tile.sel { margin-top: -12px; border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
.mj-hand { display: flex; gap: 4px; justify-content: center; }
.mj-actions { position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 5; }
.mj-center-info { position: absolute; top: 45%; left: 50%; transform: translate(-50%,-50%); text-align: center; font-size: 15px; color: var(--gold); }
.tile.w { background: linear-gradient(160deg, #fffdf2, #f3ead8); flex-direction: column; }
.tile.t { background: linear-gradient(160deg, #f8fbff, #e8eefb); }
.tile.s { background: linear-gradient(160deg, #f2fdf8, #ddf2e7); }
.tile.w b { color: #c0392b; font-size: 14px; font-weight: 800; line-height: 1.05; font-family: Georgia, 'Songti SC', serif; }
.tile.w i { color: #c0392b; font-style: normal; font-size: 16px; font-weight: 800; line-height: 1.05; font-family: 'Songti SC', Georgia, serif; }
.mj-dots { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 100%; height: 100%; padding: 3px; gap: 1px; }
.mj-dots .pip { border-radius: 50%; margin: 1px; }
.mj-dots .pip.on { background: radial-gradient(circle at 40% 35%, #6ea8ff, #1d4ed8); }
.mj-bars { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; padding: 3px; gap: 1px; align-content: center; }
.mj-bars .bar { background: linear-gradient(180deg, #0ea36e, #047857); border-radius: 2px; box-shadow: inset 1px 1px 0 rgba(255,255,255,.35); }

.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.skin-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.skin-label select,
.skin-row select {
  background: #1e293b; color: #e2e8f0; border: 1px solid #334155; border-radius: 8px;
  padding: 5px 8px; font-size: 13px; outline: none;
}
.skin-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px; gap: 8px; }
.skin-row span { font-size: 13px; color: var(--muted); font-weight: 600; }
.skin-row select { flex: 1; max-width: 200px; }
.action-bar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 38%; display: flex; gap: 10px; align-items: center; z-index: 10;
  background: rgba(0,0,0,.4); padding: 10px 16px; border-radius: 14px;
}

/* ---------------- responsive ----------------
   桌面(>768px)：左右布局，棋盘在左，侧栏在右
   手机(<=768px)：上下布局，棋盘在上(约60vh)，侧栏在下
*/
@media (max-width: 768px) {
  .header { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .header .logo { font-size: 18px; }
  .wrap { padding: 18px 12px; }
  .hero { padding: 24px 0 18px; }
  .hero h1 { font-size: 26px; }
  .games { grid-template-columns: 1fr; }
  .join-box { flex-direction: column; align-items: stretch; }
  .game-layout {
    flex-direction: column;
    height: auto;
    padding: 8px;
    gap: 8px;
  }
  .board {
    width: 100%;
    height: 58vh;
    min-height: 400px;
  }
  .sidebar {
    width: 100%;
    height: auto;
    border-radius: 12px;
  }
  .panel { max-height: 34vh; }
  .ddz-me { bottom: 118px; }
  .card {
    width: 38px; height: 56px; font-size: 12px; border-radius: 6px;
  }
  .card.small { width: 28px; height: 42px; font-size: 9px; border-radius: 5px; }
  .card.mini { width: 20px; height: 30px; font-size: 8px; border-radius: 4px; }
  .ddz-hand {
    bottom: 10px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    max-width: 96%;
  }
  .ddz-hand .card,
  .ddz-hand .card.sel { margin-right: 0; }
  .card.sel { margin-top: -12px; }
  .card .corner b { font-size: 9px; }
  .card .corner i { font-size: 7px; }
  .card .face { font-size: 22px; }
  .card.joker .face { font-size: 10px; }
  body[data-card-skin="bigface"] .card .face { font-size: 34px; }
  body[data-card-skin="minimal"] .card .face { font-size: 30px; }
  .card.small .face { font-size: 13px; }
  .card.mini .face { font-size: 8px; }
  .tile.w b { font-size: 10px; }
  .tile.w i { font-size: 11px; }
  .tile.small.w b { font-size: 8px; }
  .tile.small.w i { font-size: 9px; }
  .tile { width: 25px; height: 34px; font-size: 11px; border-radius: 5px; }
  .tile.small { width: 19px; height: 26px; font-size: 9px; border-radius: 4px; }
  .mj-hand {
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    max-width: 96%;
  }
  .mj-discards { max-width: 190px; }
  .mj-me { bottom: 8px; }
  .action-bar {
    bottom: 30%;
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .action-bar .btn { padding: 8px 14px; font-size: 13px; }
  .ddz-left { left: 12px; top: 90px; }
  .ddz-right { right: 12px; top: 90px; }
  .ddz-bottom { top: 8px; }
  .modal-card { padding: 18px; }
}
