:root {
  --bg: #0b1320;
  --panel: rgba(18, 25, 38, 0.96);
  --panel-2: #111a29;
  --line: rgba(255,255,255,0.08);
  --text: #eef3fb;
  --muted: #9fb0c8;
  --gold: #d8a143;
  --red: #f08a93;
  --green: #7ad29f;
  --blue: #77b7ff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, rgba(34, 78, 132, 0.28), transparent 30%), linear-gradient(180deg, #0a101a 0%, #0b1320 100%);
}
a { color: #f1cf88; text-decoration: none; }
.wrap { max-width: 1480px; margin: 0 auto; padding: 1rem; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 11, 18, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.topbar-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.logo { font-weight: 900; color: #fff; }
.nav { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.user-chip { background: #1a2740; padding: .35rem .75rem; border-radius: 999px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1rem;
  box-shadow: 0 18px 46px rgba(0,0,0,.25);
}
.hero { margin-top: 1.6rem; }
.two-col, .lobby-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.form-grid, .side-stack { display: grid; gap: .9rem; }
label { display: grid; gap: .35rem; color: var(--muted); }
input, textarea {
  width: 100%;
  padding: .8rem .9rem;
  border-radius: 14px;
  border: 1px solid #2d405c;
  background: #0b1220;
  color: #fff;
}
textarea { min-height: 120px; resize: vertical; }
button, .btn {
  border: none;
  border-radius: 14px;
  padding: .78rem 1rem;
  background: #25364e;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #d9a441, #b97819); color: #25180a; }
.small-btn { padding: .55rem .85rem; }
.subtle, .post-meta, .muted, .msg, .room-seats, .small { color: var(--muted); }
.msg.error { color: #ffb5bc; }
.notice {
  padding: .8rem .9rem;
  border-radius: 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.07);
}
.compact-notice { margin-top: .8rem; }
.error-box { color: #ffb5bc; border-color: rgba(240,138,147,.35); }
.info-list { line-height: 1.8; padding-left: 1.2rem; }
.actions-row, .player-card-top, .player-top, .board-main, .topbar-row { display: flex; gap: .7rem; flex-wrap: wrap; }
.player-card-top, .player-top, .board-main { justify-content: space-between; align-items: flex-start; }
.room-list-grid, .seat-grid { display: grid; gap: .8rem; }
.seat-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.room-card, .player-panel, .inner-panel {
  background: linear-gradient(180deg, #121b2b, #0e1624);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 18px;
  padding: .9rem;
}
.room-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1rem; }
.room-shell { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; margin-top: 1rem; }
.main-panel { min-height: 70vh; }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-bottom: .9rem; }
.seat-list { display: grid; gap: .6rem; }
.seat-row {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem;
  border-radius: 14px;
  background: rgba(255,255,255,.03);
}
.tags { display: flex; gap: .4rem; flex-wrap: wrap; }
.tag {
  display: inline-block;
  padding: .18rem .56rem;
  border-radius: 999px;
  background: #243650;
  color: #fff;
  font-size: .75rem;
}
.tag.gold { background: rgba(216,161,67,.18); color: #ffd98f; }
.tag.green { background: rgba(122,210,159,.16); color: #bdf2d0; }
.tag.blue { background: rgba(119,183,255,.16); color: #bdddff; }
.tag.red { background: rgba(240,138,147,.16); color: #ffc8cf; }
.player-panel.current { border-color: rgba(216,161,67,.58); box-shadow: 0 0 0 1px rgba(216,161,67,.24); }
.player-panel.mine, .seat-row.mine { border-color: rgba(119,183,255,.4); }
.trick-box {
  margin-top: .7rem;
  padding: .7rem;
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  min-height: 86px;
}
.mini-cards, .peek-hand, .hand-row, .card-back-row { display: flex; gap: .45rem; flex-wrap: wrap; }
.mini-card, .peek-card {
  display: inline-block;
  padding: .22rem .45rem;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: #f4f7fb;
  font-size: .82rem;
}
.card-back {
  width: 18px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(180deg, #34567c, #21344d);
  border: 1px solid rgba(255,255,255,.12);
}
.board-title { font-size: 1.1rem; font-weight: 900; }
.status-tags { display: flex; gap: .45rem; }
.my-hand-panel {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.07);
}
.hand-row { margin-top: .8rem; align-items: flex-end; }
.card {
  width: 72px;
  height: 108px;
  position: relative;
  border-radius: 16px;
  border: 1px solid #d6dce5;
  background: linear-gradient(180deg, #fcfcfd, #eef2f7);
  color: #1d2633;
  box-shadow: 0 8px 16px rgba(0,0,0,.22);
}
.card.clickable:not(:disabled) { cursor: pointer; }
.card.selected { transform: translateY(-12px); box-shadow: 0 12px 20px rgba(0,0,0,.28); border-color: #78c3ff; }
.corner, .rank { position: absolute; left: 8px; font-weight: 900; }
.corner { top: 8px; font-size: 1rem; }
.rank { top: 24px; font-size: 1.2rem; }
.center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: #27354a;
}
.red { color: #bf3145; }
.joker { font-size: 1.9rem; }
.log-box { display: grid; gap: .6rem; max-height: 620px; overflow: auto; }
.log-item {
  padding: .72rem .8rem;
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  color: #dfe7f3;
}
@media (max-width: 1080px) {
  .room-shell, .two-col, .lobby-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .card { width: 62px; height: 94px; }
  .center { font-size: 1.9rem; }
}

.inline-ai-tag {
  display: inline-block;
  margin-left: .45rem;
  padding: .1rem .45rem;
  border-radius: 999px;
  background: rgba(119,183,255,.16);
  color: #bdddff;
  font-size: .72rem;
  vertical-align: middle;
}
.chat-box {
  display: grid;
  gap: .65rem;
  max-height: 320px;
  overflow: auto;
  padding-right: .2rem;
}
.chat-box::-webkit-scrollbar { width: 10px; }
.chat-box::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 999px; }
.chat-item {
  padding: .7rem .8rem;
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
}
.chat-item.mine { border-color: rgba(110,183,255,0.26); background: rgba(16,27,40,0.96); }
.chat-meta { color: #f1cf88; font-size: .78rem; margin-bottom: .2rem; }
.chat-text { color: #d8e1ee; font-size: .9rem; line-height: 1.34; word-break: break-word; }
.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .65rem;
  margin-top: .8rem;
}
.chat-compose input { min-width: 0; }
.waiting-tools { align-items: center; }
@media (max-width: 1080px) {
  .chat-box { max-height: 220px; }
}
@media (max-width: 720px) {
  .chat-compose { grid-template-columns: 1fr; }
}

.ad-panel { margin-top: 1rem; }
.ad-panel-empty { border-style: dashed; }
.ad-label { font-size: .8rem; color: var(--gold); margin-bottom: .55rem; text-transform: uppercase; letter-spacing: .08em; }
.ad-content { overflow: auto; }
.ad-content img, .ad-content iframe { max-width: 100%; border-radius: 14px; }
.ad-content a { word-break: break-word; }
