
/* ===========================================================
   三国杀 · 复古水墨金 主题
   =========================================================== */
:root {
  --ink: #0b0906;
  --ink2: #14100b;
  --ink3: #1d1810;
  --wood: #241a11;
  --wood2: #35271a;
  --gold: #c9a227;
  --gold2: #e8cd7a;
  --gold-dim: #8a6d18;
  --paper: #efe3ca;
  --paper2: #d9c8a5;
  --red: #9b2c25;
  --red2: #c4453b;
  --wei: #4f7fa8;
  --shu: #b04a40;
  --wu: #4d8f6c;
  --qun: #8f8f8a;
  --god: #c9a227;
  --line: rgba(201, 162, 39, 0.28);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  --serif: 'Noto Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  --brush: 'Ma Shan Zheng', 'STXingkai', 'KaiTi', var(--serif);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(120, 92, 40, 0.28), transparent 60%),
    radial-gradient(900px 600px at 90% 110%, rgba(90, 40, 30, 0.25), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px),
    linear-gradient(160deg, #100c08, #060504 60%, #0d0a06);
  color: var(--paper);
  font-family: var(--serif);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

/* 金线分隔 */
.gold-line { height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); }

/* ------------ 通用按钮 ------------ */
.btn {
  position: relative;
  padding: 10px 22px;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--gold2);
  background: linear-gradient(180deg, #3a2b18, #221a10);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 150, 0.14), 0 6px 14px rgba(0,0,0,.5);
  transition: .18s;
}
.btn:hover { color: #fff3cf; border-color: rgba(232, 205, 122, .7); box-shadow: inset 0 1px 0 rgba(255,220,150,.25), 0 0 18px rgba(201,162,39,.35); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(180deg, #a5261f, #6d1611); border-color: #d8a45e; color: #ffeccd; }
.btn.primary:hover { box-shadow: 0 0 22px rgba(196, 69, 59, .55), inset 0 1px 0 rgba(255,220,150,.3); }
.btn.ghost { background: rgba(20, 15, 10, .6); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.sm { padding: 6px 14px; font-size: 13px; letter-spacing: 1px; }

/* ------------ 登录 ------------ */
#login {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 60;
  background:
    radial-gradient(700px 480px at 50% 42%, rgba(120, 40, 30, .22), transparent 65%),
    linear-gradient(160deg, #0d0a07, #050403);
}
#login .wrap { width: 380px; text-align: center; animation: fadeUp .7s ease both; }
.brand { font-family: var(--brush); font-size: 78px; line-height: 1; color: #f3e1b8; letter-spacing: 6px;
  text-shadow: 0 0 40px rgba(201, 162, 39, .35), 0 6px 0 #3b2b12; }
.brand-sub { margin-top: 6px; font-size: 12px; letter-spacing: 8px; color: var(--gold-dim); }
.seal-mini { display: inline-block; margin-top: 14px; padding: 3px 8px; font-size: 11px; letter-spacing: 3px;
  color: #f0dcc0; background: var(--red); border-radius: 2px; transform: rotate(-3deg); box-shadow: 0 4px 12px rgba(155,44,37,.5); }
.login-card { margin-top: 32px; padding: 26px 24px; background: rgba(18, 14, 10, .82);
  border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.field { margin-bottom: 14px; text-align: left; }
.field label { display: block; font-size: 11px; letter-spacing: 3px; color: var(--gold-dim); margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 12px; font-size: 15px; color: var(--paper); background: rgba(0,0,0,.5);
  border: 1px solid rgba(201,162,39,.22); border-radius: 3px; outline: none; transition: .2s; letter-spacing: 1px; }
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,.12); }
#login .btn.primary { width: 100%; margin-top: 10px; padding: 12px; font-size: 16px; letter-spacing: 6px; }
.hint { margin-top: 16px; font-size: 11px; color: #7a6a52; line-height: 1.7; letter-spacing: .5px; }
.err { color: #e07a6e; font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ------------ 大厅 ------------ */
#lobby { position: fixed; inset: 0; display: none; flex-direction: column; }
.topbar { height: 58px; display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: linear-gradient(180deg, rgba(30,22,13,.95), rgba(12,9,6,.9)); border-bottom: 1px solid var(--line); }
.topbar .logo { font-family: var(--brush); font-size: 26px; color: #f0dcb0; letter-spacing: 3px; }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--paper2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px;
  background: linear-gradient(145deg, #5a4322, #2a2013); border: 1px solid var(--line); color: var(--gold2); }
.lobby-body { flex: 1; display: grid; grid-template-columns: 240px 1fr; overflow: hidden; }
.side { padding: 18px; border-right: 1px solid rgba(201,162,39,.14); background: rgba(10,8,5,.55); display: flex; flex-direction: column; gap: 10px; }
.side .stat { display: flex; justify-content: space-between; font-size: 12px; color: #a08f72; padding: 6px 0; border-bottom: 1px dashed rgba(201,162,39,.12); }
.side .stat b { color: var(--gold2); font-weight: 600; }
.main { padding: 22px 26px; overflow-y: auto; }
.sec-title { font-family: var(--brush); font-size: 30px; color: #f0dcb0; letter-spacing: 3px; margin-bottom: 4px; }
.sec-sub { font-size: 12px; color: #857453; letter-spacing: 2px; margin-bottom: 18px; }
.rooms { display: grid; gap: 10px; }
.room-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: linear-gradient(120deg, rgba(40,30,18,.8), rgba(16,12,8,.7));
  border: 1px solid rgba(201,162,39,.18); border-radius: 5px; transition: .18s; }
.room-card:hover { border-color: rgba(232,205,122,.5); transform: translateX(2px); box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.room-card .rname { font-size: 16px; color: var(--paper); letter-spacing: 1px; }
.room-card .rmeta { font-size: 11px; color: #8a7a5e; margin-top: 3px; letter-spacing: 1px; }
.badge { padding: 2px 8px; font-size: 11px; border-radius: 2px; letter-spacing: 1px; }
.badge.on { background: rgba(77,143,108,.2); color: #8fd6ae; border: 1px solid rgba(77,143,108,.5); }
.badge.wait { background: rgba(201,162,39,.15); color: var(--gold2); border: 1px solid rgba(201,162,39,.4); }
.badge.over { background: rgba(155,44,37,.2); color: #e59b92; border: 1px solid rgba(155,44,37,.5); }
.empty { padding: 40px; text-align: center; color: #6d5f49; font-size: 13px; letter-spacing: 2px; }

/* ------------ 房间 ------------ */
#room { position: fixed; inset: 0; display: none; flex-direction: column; }
.seat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 148px)); gap: 14px;
  justify-content: center; align-content: start; padding: 36px 26px; flex: 1; overflow-y: auto; }
.seat-row::before { content: '座次'; grid-column: 1 / -1; justify-self: center; font-size: 11px;
  letter-spacing: 6px; color: #6d5f49; margin-bottom: 4px; }
.seat { width: 148px; padding: 12px; text-align: center; background: linear-gradient(180deg, rgba(38,28,16,.85), rgba(14,10,7,.8));
  border: 1px solid rgba(201,162,39,.2); border-radius: 6px; position: relative; }
.seat.me { border-color: var(--gold); box-shadow: 0 0 20px rgba(201,162,39,.25); }
.seat .sname { font-size: 14px; color: var(--paper); margin-top: 8px; }
.seat .stag { font-size: 11px; margin-top: 4px; color: #8a7a5e; letter-spacing: 1px; }
.seat .host-tag { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); padding: 1px 8px; font-size: 10px;
  background: var(--red); color: #ffe9d0; border-radius: 2px; letter-spacing: 2px; }
.room-foot { padding: 16px 24px; display: flex; gap: 12px; justify-content: center; border-top: 1px solid var(--line); background: rgba(8,6,4,.85); }

/* ------------ 武将选择 ------------ */
#picker { position: fixed; inset: 0; display: none; z-index: 50; background: rgba(5,4,3,.94); flex-direction: column; overflow: hidden; }
#picker .head, .pick-foot { flex: 0 0 auto; }
#picker .head { padding: 18px 26px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; font-size: 12px; border: 1px solid rgba(201,162,39,.25); border-radius: 20px; color: #a08f72; letter-spacing: 1px; transition: .15s; }
.chip.on { background: rgba(201,162,39,.16); border-color: var(--gold); color: var(--gold2); }
.gen-grid { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 26px 30px; display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); grid-auto-rows: max-content; gap: 14px; align-content: start; }

/* 选将：左网格 + 右详情 */
.pick-body { flex: 1 1 auto; display: flex; min-height: 0; overflow: hidden; }
.pick-body .gen-grid { padding: 16px 20px 24px; }
#genGrid .gname { font-size: 26px; }
#genGrid .gname.len3 { font-size: 19px; }
#genGrid .gname.len4 { font-size: 14px; }
#genGrid .gtitle { font-size: 8px; letter-spacing: 0; width: 1em; }
.pick-info { width: 300px; flex: 0 0 300px; border-left: 1px solid var(--line); padding: 20px 18px;
  overflow-y: auto; background: linear-gradient(180deg, rgba(30,24,16,.55), rgba(10,8,6,.75)); }
.pi-empty { color: #6d5f49; font-size: 12px; letter-spacing: 2px; text-align: center; margin-top: 40px; }
.pi-head { display: flex; align-items: baseline; gap: 8px; }
.pi-name { font-family: "STKaiti","KaiTi","Kaiti SC","Songti SC",serif; font-size: 26px; color: var(--gold2); letter-spacing: 2px; }
.pi-title { font-size: 11px; color: #8a7a5e; letter-spacing: 1px; }
.pi-meta { display: flex; align-items: center; gap: 10px; margin: 10px 0 16px; }
.pi-k { font-size: 11px; padding: 2px 8px; border-radius: 3px; color: #1a1408; letter-spacing: 1px; }
.pi-k.k-wei { background: #6b8cbb; } .pi-k.k-shu { background: #c46a5a; }
.pi-k.k-wu { background: #5c9c7c; } .pi-k.k-qun { background: #9a9a9a; }
.pi-k.k-god { background: #c9a227; }
.pi-hp { display: flex; gap: 3px; }
.pi-hp i { width: 9px; height: 9px; border-radius: 50%; background: #b8362f; box-shadow: 0 0 6px rgba(184,54,47,.6); }
.pi-skills { display: flex; flex-direction: column; gap: 12px; }
.pi-skill { border-left: 2px solid rgba(201,162,39,.35); padding-left: 10px; }
.pi-sk { display: flex; align-items: baseline; gap: 6px; }
.pi-sk b { font-family: "STKaiti","KaiTi","Kaiti SC","Songti SC",serif; font-size: 17px; color: #e8d9b8; letter-spacing: 1px; }
.pi-sk em { font-style: normal; font-size: 10px; color: #7d6e55; border: 1px solid rgba(201,162,39,.25);
  padding: 0 5px; border-radius: 3px; }
.pi-sd { font-size: 12px; line-height: 1.75; color: #a8997c; margin-top: 4px; }
.pick-foot { padding: 12px 26px 18px; display: flex; justify-content: center; border-top: 1px solid var(--line); }
.pick-foot .btn { min-width: 180px; }
.gcard.on { box-shadow: 0 0 0 2px var(--gold), 0 12px 26px rgba(0,0,0,.65); transform: translateY(-3px); }
@media (max-width: 760px) {
  .pick-info { display: none; }
}

/* ------------ 武将卡 ------------ */
.gcard { position: relative; aspect-ratio: 5/7; border-radius: 5px; overflow: hidden; cursor: pointer;
  background: #0d0a07; border: 1px solid rgba(201,162,39,.22); transition: .2s; }
.gcard:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 14px 30px rgba(0,0,0,.7), 0 0 0 1px var(--gold); }
.gcard .wash { position: absolute; inset: 0; pointer-events: none; }
.gcard .wash::before { content: ''; position: absolute; inset: -20%; background: radial-gradient(60% 50% at 40% 30%, rgba(255,255,255,.2), transparent 65%); }
.gcard .peak { position: absolute; left: -10%; right: -10%; bottom: 0; height: 46%; pointer-events: none;
  background: #000; opacity: .55; clip-path: polygon(0 62%, 16% 34%, 30% 52%, 48% 22%, 66% 46%, 82% 28%, 100% 54%, 100% 100%, 0 100%); }
.gcard .gname { position: absolute; right: 8px; top: 8px; bottom: 22px; width: 1.15em;
  font-family: var(--brush); font-size: 30px; line-height: 1.06; color: #f7ecd9; text-align: center;
  writing-mode: vertical-rl; text-orientation: upright; letter-spacing: 1px;
  text-shadow: 0 2px 10px rgba(0,0,0,.95), 0 0 22px rgba(0,0,0,.6); pointer-events: none; }
.gcard .gname.len2 { font-size: 32px; width: 1.1em; }
.gcard .gname.len3 { font-size: 22px; }
.gcard .gname.len4 { font-size: 16px; letter-spacing: 0; }
.gcard .gtitle { position: absolute; left: 6px; top: 30px; bottom: 22px; font-size: 9px; color: rgba(255,255,255,.42);
  writing-mode: vertical-rl; text-orientation: upright; letter-spacing: 1px; overflow: hidden; max-height: 60%; pointer-events: none; }
.gcard .kh { position: absolute; left: 6px; top: 6px; width: 20px; height: 20px; display: grid; place-items: center;
  font-size: 12px; font-weight: 900; color: #fff6e2; border-radius: 2px; box-shadow: 0 2px 6px rgba(0,0,0,.7);
  border: 1px solid rgba(255,235,190,.35); pointer-events: none; }
.gcard .hp { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 2px; flex-wrap: wrap; width: 46px; pointer-events: none; }
.gcard .hp i { width: 7px; height: 7px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffd9a0, #c9a227 60%, #7a5c10);
  box-shadow: 0 0 4px rgba(255,190,80,.7); display: block; }
.gcard .hp i.off { background: #2a2418; box-shadow: none; opacity: .6; }
.gcard.sel { box-shadow: 0 0 0 2px var(--gold), 0 0 26px rgba(201,162,39,.5); }

.k-wei { background: linear-gradient(150deg, #2c4d68, #0d1620 62%, #07090c); }
.k-shu { background: linear-gradient(150deg, #7d322a, #1c0c0a 62%, #080505); }
.k-wu  { background: linear-gradient(150deg, #2c5c44, #0a1a13 62%, #050807); }
.k-qun { background: linear-gradient(150deg, #4b4b46, #131313 62%, #060606); }
.k-god { background: linear-gradient(150deg, #7a5f14, #1a1508 62%, #070602); }

/* ------------ 对局桌面 ------------ */
#table { position: fixed; inset: 0; display: none; }
#board { position: absolute; inset: 0; }
.p-seat { position: absolute; width: 172px; transform: translate(-50%, -50%); transition: .25s; z-index: 3;
  padding: 8px 10px; border-radius: 8px; background: linear-gradient(140deg, rgba(30,22,14,.86), rgba(10,8,5,.72));
  border: 1px solid rgba(201,162,39,.16); box-shadow: 0 8px 22px rgba(0,0,0,.5); backdrop-filter: blur(3px); }
.p-seat.dead { filter: grayscale(1) brightness(.5); opacity: .7; }
.p-seat .cardwrap { position: relative; display: flex; gap: 6px; align-items: flex-start; }
.p-seat .mini { width: 50px; flex: none; aspect-ratio: 5/7; border-radius: 3px; overflow: hidden; position: relative;
  border: 1px solid rgba(201,162,39,.3); box-shadow: 0 4px 12px rgba(0,0,0,.6); }
.p-seat .mini .kh { position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; font-size: 9px; border-radius: 2px;
  display: grid; place-items: center; color: #fff3dc; font-weight: 900; border: 1px solid rgba(255,235,190,.35); z-index: 2; }
.p-seat .mini .flip { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; font-size: 11px; color: #cbb; }
.p-seat .mini .gname { font-size: 15px; right: 4px; top: 4px; bottom: 4px; width: 1.15em; text-align: center; writing-mode: vertical-rl; text-orientation: upright; font-family: var(--brush); color: #f7ecd9; position: absolute; }
.p-seat .info { flex: 1; min-width: 0; }
.p-seat .pname { font-size: 13px; color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-seat .idtag { display: inline-block; margin-top: 4px; padding: 1px 6px; font-size: 10px; border-radius: 2px; letter-spacing: 1px; }
.id-lord { background: var(--red); color: #ffe7c8; }
.id-loyal { background: #6b5a20; color: #ffeec2; }
.id-rebel { background: #3a3f46; color: #cfd6de; }
.id-renegade { background: #2a3a2d; color: #bfe0c8; }
.p-seat .hpid { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 5px; max-width: 90px; }
.p-seat .hpid i { width: 6px; height: 6px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffd9a0, #c9a227 60%, #6d5210); display: block; }
.p-seat .hpid i.off { background: #2a2418; opacity: .55; }
.p-seat .hpid i.lost { background: #4a1a16; }
.p-seat .hcount { position: absolute; right: -8px; top: -10px; min-width: 20px; height: 20px; display: grid; place-items: center;
  font-size: 11px; color: #2a1f14; background: linear-gradient(160deg, #f0dfb6, #c9a227); border-radius: 10px; z-index: 5;
  font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.6); }
.p-seat .eq-mini { position: absolute; right: 0; bottom: -14px; display: flex; gap: 2px; flex-wrap: wrap; z-index: 4; }
.p-seat .eq-mini span { font-size: 9px; padding: 0 4px; background: rgba(10,8,5,.85); border: 1px solid rgba(201,162,39,.3); border-radius: 2px; color: #d8c79c; }
.p-seat .judges { position: absolute; left: 0; top: -22px; display: flex; gap: 3px; }
.p-seat .judges span { font-size: 9px; padding: 0 4px; border-radius: 2px; background: rgba(80,20,18,.9); border: 1px solid rgba(200,90,80,.5); color: #f0c8c0; }
.p-seat.turn::after { content: ''; position: absolute; inset: -10px; border-radius: 8px; pointer-events: none;
  border: 1px solid rgba(232,205,122,.6); box-shadow: 0 0 22px rgba(201,162,39,.35) inset, 0 0 18px rgba(201,162,39,.3);
  animation: pulse 2s infinite; }
.p-seat .offline { position: absolute; inset: 0; background: rgba(0,0,0,.45); border-radius: 6px; display: grid; place-items: center; font-size: 11px; color: #c88; }
.p-seat .targetable { position: absolute; inset: -8px; border-radius: 8px; border: 1px dashed rgba(232,120,100,.9); cursor: pointer;
  box-shadow: 0 0 16px rgba(220,80,60,.4); animation: pulse 1.4s infinite; }
.p-seat .targetable:hover { background: rgba(200,60,40,.18); }

/* 中央 */
#center { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); text-align: center; z-index: 2; pointer-events: none; }
#deckpile { width: 72px; height: 100px; margin: 0 auto; border-radius: 4px; position: relative;
  background: linear-gradient(145deg, #2f2416, #17110a); border: 1px solid rgba(201,162,39,.35);
  box-shadow: 0 0 0 3px rgba(0,0,0,.4), 0 10px 24px rgba(0,0,0,.6); }
#deckpile::after { content: attr(data-n); position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; color: var(--gold2); }
#deckpile::before { content: '牌堆'; position: absolute; bottom: -16px; left: 0; right: 0; font-size: 9px; color: #6a5c44; letter-spacing: 3px; }
#phaseTag { margin-top: 30px; font-size: 11px; letter-spacing: 4px; color: var(--gold-dim); text-shadow: 0 2px 8px #000; }

/* 我的手牌 */
#handbar { position: absolute; left: 0; right: 0; bottom: 0; height: 196px; z-index: 6;
  background: linear-gradient(0deg, rgba(8,6,4,.95) 40%, transparent); display: flex; align-items: flex-end;
  justify-content: center; padding-bottom: 10px; }
#myhand { display: flex; align-items: flex-end; justify-content: center; height: 176px; overflow: visible; max-width: 96vw; padding: 0 14px 12px; }
#handbar.overflow #myhand { justify-content: flex-start; overflow-x: auto; overflow-y: hidden; padding-top: 40px; height: 176px; }
/* 手牌过多而非溢出时，用负边距叠压，保证最后一张不被裁 */
#myhand.tight .hcard { margin-left: -12px; }
#myhand.tight .hcard:first-child { margin-left: 0; }
.hcard.locked { filter: brightness(.42) saturate(.35); cursor: default; }
.hcard.locked:hover { transform: none; box-shadow: 0 6px 14px rgba(0,0,0,.55); }
/* 出牌阶段：可用牌金色描边 + 呼吸微光，让玩家一眼看出哪些能打 */
.hcard.usable { box-shadow: 0 0 0 2px rgba(232,205,122,.85), 0 0 16px rgba(201,162,39,.5), 0 6px 14px rgba(0,0,0,.55); }
.hcard.usable::after {
  content: ''; position: absolute; inset: -2px; border-radius: 6px; pointer-events: none;
  border: 1px solid rgba(255,225,160,.55); animation: usablePulse 1.8s ease-in-out infinite;
}
@keyframes usablePulse {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}
.hcard.usable:hover { transform: translateY(-20px); }

/* 手牌上方提示条 */
#handHint {
  position: absolute; left: 50%; top: -22px; transform: translateX(-50%);
  font-size: 11px; letter-spacing: 1.5px; color: #b8a684; white-space: nowrap;
  padding: 2px 10px; border-radius: 10px; background: rgba(10,8,5,.7); pointer-events: none;
  z-index: 9;
}
#handHint b { color: var(--gold2); font-weight: 700; }
#handHint.dim { color: #6d5f49; }

/* 技能按钮区分：武将技 / 武器技 */
.btn.skill-general, .btn.skill-weapon { display: inline-flex; align-items: center; gap: 3px; }
.sk-tag {
  display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 2px;
  font-size: 9px; line-height: 1; letter-spacing: 0; margin-right: 2px;
}
.btn.skill-general .sk-tag { background: rgba(77,143,108,.35); color: #9fe0bd; border: 1px solid rgba(77,143,108,.6); }
.btn.skill-weapon .sk-tag { background: rgba(160,90,40,.4); color: #f0c089; border: 1px solid rgba(200,130,60,.65); }
.btn.skill-weapon { border-color: rgba(200,130,60,.55); }
.hcard:not(.locked):hover { box-shadow: 0 0 0 2px rgba(201,162,39,.85), 0 18px 30px rgba(0,0,0,.8); }
.hcard { position: relative; width: 82px; height: 118px; margin-left: 2px; border-radius: 5px; cursor: pointer; transition: transform .14s, box-shadow .14s; flex: none;
  background: linear-gradient(160deg, #f2e6cd, #d8c4a0); color: #2a1f14; border: 1px solid #a68c62;
  box-shadow: 0 6px 14px rgba(0,0,0,.55); flex: none; }
.hcard:first-child { margin-left: 0; }
.hcard:hover { transform: translateY(-20px); z-index: 20; box-shadow: 0 16px 30px rgba(0,0,0,.7); }
.hcard.up { transform: translateY(-22px); box-shadow: 0 0 0 2px var(--gold), 0 18px 30px rgba(0,0,0,.75); z-index: 19; }
.hcard.dis { filter: brightness(.62) saturate(.6); cursor: default; }
.hcard { }
.hcard.gap { margin-left: 10px; }
.hcard .corner { position: absolute; top: 3px; left: 5px; font-size: 13px; font-weight: 900; line-height: 1; }
.hcard .corner.red { color: #a3231c; }
.hcard .corner.blk { color: #241a12; }
.hcard .suitbig { position: absolute; top: 15px; left: 5px; font-size: 13px; }
.hcard .suitbig.red { color: #a3231c; } .hcard .suitbig.blk { color: #241a12; }
.hcard .cname { position: absolute; right: 7px; top: 7px; bottom: 20px; width: 1.1em; text-align: center;
  writing-mode: vertical-rl; text-orientation: upright; font-family: var(--brush); font-size: 24px; line-height: 1.05; letter-spacing: 0; color: #241a12; }
.hcard .cname.l4 { font-size: 15px; }
.hcard .ctype { position: absolute; bottom: 5px; left: 0; right: 0; text-align: center; font-size: 9px; color: #7c6543; letter-spacing: 1px; }
.hcard .vtag { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; font-size: 9px; color: #8a3b2c; }
.hcard.trick { background: linear-gradient(160deg, #efe2c8, #cdb794); }
.hcard.equip { background: linear-gradient(160deg, #e4ddcb, #b9ae94); }
.hcard .art { position: absolute; inset: 24px 10px 22px 26px; border-radius: 3px; opacity: .85;
  background: radial-gradient(70% 60% at 50% 40%, rgba(90,70,40,.16), transparent 70%); }

/* 操作条 */
#ops { position: absolute; right: 16px; bottom: 176px; display: flex; gap: 8px; z-index: 8; flex-wrap: wrap; justify-content: flex-end; max-width: 46vw; }
#tip { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 9; padding: 7px 18px;
  font-size: 13px; letter-spacing: 2px; color: var(--gold2); background: rgba(12,9,6,.9); border: 1px solid var(--line);
  border-radius: 20px; max-width: 76vw; text-align: center; display: none; }
#tip.show { display: block; animation: fadeUp .25s both; }

/* 日志 */
#logs { position: absolute; left: 14px; top: 14px; width: 258px; max-height: 46vh; overflow: hidden; z-index: 5;
  font-size: 11.5px; line-height: 1.55; color: #a5967a; pointer-events: none;
  padding: 10px 12px; border-radius: 6px;
  background: linear-gradient(180deg, rgba(10,8,5,.72), rgba(10,8,5,.28) 70%, transparent);
  border-left: 1px solid rgba(201,162,39,.18);
  mask-image: linear-gradient(180deg, transparent, #000 12%, #000 86%, transparent); }
#logs div { padding: 2px 0; text-shadow: 0 1px 3px #000; }
#logs .damage { color: #e8a08f; } #logs .heal { color: #9fd9b3; } #logs .skill { color: #e0c477; }
#logs .death { color: #e0705f; } #logs .win { color: #ffd98a; font-weight: 700; } #logs .turn { color: #c9a227; letter-spacing: 1px; }
#logs .secret { color: #d8b45e; } #logs .judge { color: #b9a6d8; }

/* 对侧信息 */
#oppbar { position: absolute; right: 12px; top: 12px; z-index: 5; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
#chatbox { position: absolute; right: 12px; bottom: 232px; width: 200px; z-index: 7; display: none; }
#chatbox input { width: 100%; padding: 8px 10px; font-size: 12px; background: rgba(10,8,5,.92); color: var(--paper);
  border: 1px solid var(--line); border-radius: 3px; outline: none; }
#chatToggle { display: none; }

/* 弹窗 / 交互面板 */
#modal { position: fixed; inset: 0; z-index: 40; display: none; background: rgba(4,3,2,.78); backdrop-filter: blur(3px); }
#modal.show { display: grid; place-items: center; }
.panel { width: min(560px, 92vw); background: linear-gradient(170deg, rgba(34,25,15,.98), rgba(12,9,6,.98));
  border: 1px solid rgba(201,162,39,.4); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; animation: fadeUp .22s both; }
.panel .ph { padding: 14px 20px; font-size: 14px; letter-spacing: 2px; color: var(--gold2);
  background: linear-gradient(90deg, rgba(155,44,37,.45), transparent); border-bottom: 1px solid var(--line); }
.panel .pb { padding: 20px; }
.panel .pf { padding: 12px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; }
.opt-list { display: flex; flex-direction: column; gap: 8px; }
.opt { padding: 12px 14px; text-align: left; font-size: 14px; color: var(--paper); background: rgba(0,0,0,.35);
  border: 1px solid rgba(201,162,39,.22); border-radius: 4px; transition: .15s; letter-spacing: 1px; }
.opt:hover { border-color: var(--gold); background: rgba(201,162,39,.1); transform: translateX(3px); }
.pick-cards { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-height: 46vh; overflow-y: auto; }

/* 提示气泡 */
#toasts { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 8px 18px; font-size: 13px; letter-spacing: 1px; background: rgba(14,10,6,.95); border: 1px solid var(--line);
  border-radius: 20px; color: var(--gold2); box-shadow: 0 8px 22px rgba(0,0,0,.6); animation: fadeUp .2s both; }
.toast.warn { border-color: rgba(200,80,60,.6); color: #f0b0a4; }

/* 结算 */
#result { position: fixed; inset: 0; z-index: 65; display: none; place-items: center; background: rgba(4,3,2,.9); }
#result.show { display: grid; }
.result-card { text-align: center; padding: 36px 44px; background: linear-gradient(170deg, rgba(40,28,14,.98), rgba(10,7,5,.98));
  border: 1px solid var(--gold); border-radius: 10px; box-shadow: 0 0 60px rgba(201,162,39,.25); animation: fadeUp .4s both; }
.result-card h1 { font-family: var(--brush); font-size: 46px; color: #ffe9b8; letter-spacing: 6px; margin-bottom: 6px; }
.result-card .sub { font-size: 12px; color: var(--gold-dim); letter-spacing: 4px; margin-bottom: 22px; }
.result-rows { display: flex; flex-direction: column; gap: 6px; min-width: 320px; margin-bottom: 22px; }
.result-rows .row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: rgba(0,0,0,.35); border-radius: 4px; font-size: 13px; }
.result-rows .row.win { background: rgba(155,44,37,.22); border: 1px solid rgba(201,162,39,.35); }
.result-acts { display: flex; gap: 12px; justify-content: center; }
.result-acts .btn { min-width: 140px; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(201,162,39,.25); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* 移动端 */
@media (max-width: 820px) {
  /* 顶栏压缩，保证"安装到手机"按钮不被挤掉 */
  .topbar { height: 50px; padding: 0 10px; gap: 8px; }
  .topbar .logo { font-size: 19px; letter-spacing: 1px; }
  .topbar .who { gap: 6px; font-size: 12px; }
  .topbar .who .avatar { width: 24px; height: 24px; font-size: 11px; }
  #myName { max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #btnInstall, #btnLogout { padding: 4px 8px; font-size: 11px; white-space: nowrap; }
  .p-seat { width: 132px; }
  .p-seat .mini { width: 40px; }
  .hcard { width: 58px; height: 84px; margin-left: 1px; }
  .hcard .cname { font-size: 18px; }
  .hcard .ctype { display: none; }
  #handbar { height: 128px; }
  #myhand { height: 116px; max-width: 100vw; padding: 0 6px 10px; }
  #handbar.overflow #myhand { padding-top: 30px; height: 116px; }
  /* 手机屏幕窄，提示条会与操作按钮重叠，这里隐藏只用顶部 #tip 提示 */
  #handHint { display: none !important; }
  /* 牌堆放到画面中部偏上，避免下方大片空白 */
  #center { top: 42%; }
  #deckpile { width: 62px; height: 86px; }
  #deckpile::after { font-size: 17px; }
  #phaseTag { margin-top: 26px; font-size: 10px; letter-spacing: 2px; }
  /* 行动中 / 等待提示：与操作条同一水平带，右对齐避开左侧自己的信息条 */
  #waiting { bottom: 132px !important; font-size: 11px !important; letter-spacing: 2px !important;
    padding: 4px 10px !important; left: auto !important; right: 8px !important; transform: none !important;
    max-width: 58vw !important; }
  /* 操作条可能换两行，整体上移避免压住手牌 */
  #ops { bottom: 172px; right: 8px; max-width: 58vw; gap: 6px; }
  #ops .btn { padding: 5px 9px; font-size: 11.5px; }
  #selfbar { left: 8px !important; bottom: 130px !important; max-width: 42vw; transform: scale(.92); transform-origin: left bottom;
    white-space: nowrap; }
  #selfbar .idtag { margin-left: 4px !important; }
  #logs { display: block; width: 150px; max-height: 22vh; font-size: 10px; padding: 6px 8px;
    top: 8px; left: 8px; opacity: .82; }
  #tip { top: 8px; font-size: 12px; padding: 5px 12px; max-width: 84vw; letter-spacing: 1px; }
  /* 聊天：移动端默认收起成小按钮，点开才显示输入框 */
  #chatbox { width: auto; right: 8px; bottom: auto; top: 8px; }
  #chatToggle { display: block; padding: 4px 10px; font-size: 10.5px; letter-spacing: 1px; cursor: pointer;
    color: var(--gold2); background: rgba(12,9,6,.9); border: 1px solid var(--line); border-radius: 14px; }
  #chatbox input { display: none; width: 138px; padding: 5px 8px; font-size: 11px; }
  #chatbox.open #chatToggle { display: none; }
  #chatbox.open input { display: block; }
  .lobby-body { grid-template-columns: 1fr; }
  .side { display: none; }
  .brand { font-size: 60px; }
}

/* 超窄屏（如 iPhone SE / 小安卓）：进一步压缩 */
@media (max-width: 400px) {
  .hcard { width: 52px; height: 76px; }
  .hcard .cname { font-size: 16px; }
  .hcard .cname.l4 { font-size: 12px; }
  #handbar { height: 116px; }
  #myhand { height: 106px; }
  #handbar.overflow #myhand { height: 106px; padding-top: 26px; }
  #waiting { bottom: 122px !important; }
  #ops { bottom: 158px; }
  #selfbar { bottom: 118px !important; transform: scale(.86); }
  .p-seat { width: 118px; padding: 6px 8px; }
  .p-seat .mini { width: 34px; }
  .p-seat .pname { font-size: 12px; }
  #logs { width: 124px; font-size: 9px; }
}
