/* UNO 娱乐小游戏样式（与斗地主/21点同一套视觉语言：暗绿毛毡牌桌 + 金色点缀 + 白色卡片面板） */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --felt: #1c6b46;
  --felt-dark: #145034;
  --panel: #ffffff;
  --panel-border: #d9e2dc;
  --ink: #1c2b24;
  --accent: #0f8a5f;
  --accent-dark: #0b6b49;
  --warn: #c0392b;
  --gold: #d4a017;
  --red: #d63031;
  --gray: #7a8a80;
  --uno-yellow: #fdcb35;
  --uno-green: #00b894;
  --uno-blue: #0984e3;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #10281d 0%, #173a2a 55%, #10281d 100%);
  color: var(--ink);
  min-height: 100vh;
}

.app { max-width: 980px; margin: 0 auto; padding: 16px; }
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ---------- 通用 ---------- */
.btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 22px; border-radius: 10px; font-size: 15px;
  cursor: pointer; transition: .15s; font-weight: 600;
}
.btn:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.big { font-size: 19px; padding: 16px 34px; }
.btn.alt { background: #2563a8; }
.btn.alt:hover { background: #1d4f85; }
.btn.warn { background: var(--gold); color: #3a2c00; }
.btn.warn:hover { background: #b58910; }
.btn.ghost { background: transparent; color: #cfe3d7; border: 1px solid #3d5c4c; }
.btn.ghost:hover { background: rgba(255,255,255,.08); }
.btn.small { padding: 6px 12px; font-size: 13px; }

input {
  padding: 10px 12px; border: 1px solid #b9ccc1; border-radius: 8px;
  font-size: 15px; outline: none; background: #fbfdfc; color: var(--ink);
}
input:focus { border-color: var(--accent); }

.card-panel {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

.tag {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  background: #e4efe9; color: var(--accent-dark); font-size: 13px; font-weight: 600;
}
.tag.gold { background: #fdf3d5; color: #8a6400; }

/* ---------- 首页 ---------- */
.home-wrap { text-align: center; padding: 48px 12px; color: #eaf5ee; }
.logo { font-size: 56px; letter-spacing: 4px; color: #fff; text-shadow: 0 3px 12px rgba(0,0,0,.5); }
.logo span { color: var(--gold); }
.slogan { margin: 12px 0 34px; color: #a9c9b6; letter-spacing: 2px; }
.home-btns { display: flex; gap: 18px; justify-content: center; margin-bottom: 40px; flex-wrap: wrap; }

.rules { max-width: 620px; margin: 0 auto; text-align: left; }
.rules h3 { margin-bottom: 10px; color: var(--accent-dark); }
.rules li { margin: 6px 0 6px 20px; color: #33463c; font-size: 14px; line-height: 1.6; }

/* ---------- 大厅 ---------- */
.lobby-wrap { max-width: 560px; margin: 30px auto; }
.lobby-wrap h2 { color: #fff; margin-bottom: 16px; text-align: center; }
.form-panel label { display: block; font-size: 13px; color: var(--gray); margin: 14px 0 6px; }
.form-panel input { width: 100%; }
.form-panel .btn { width: 100%; margin-top: 18px; }
.divider { text-align: center; color: #a7b8ae; font-size: 13px; margin: 20px 0 6px; }
.join-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.join-row .code-input { width: 110px; text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }
.rejoin-tip { margin-top: 12px; font-size: 12px; color: var(--gray); line-height: 1.6; }
.rejoin-tip b { color: var(--accent-dark); }

/* ---------- 房间 ---------- */
.room-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px; color: #eaf5ee;
}
.room-code { font-size: 15px; }
.room-code b { font-size: 22px; letter-spacing: 5px; color: var(--gold); margin: 0 4px; }
#btn-copy { background: none; border: none; color: #a9c9b6; cursor: pointer; font-size: 15px; }

#need-more {
  background: #fff3cd; color: #7a5b00; text-align: center; font-weight: 700;
  padding: 10px; border-radius: 10px; margin-bottom: 14px; border: 1px solid #f1dc9b;
}

.table {
  background:
    radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  border-radius: 20px; padding: 22px 18px;
  border: 6px solid #6b4a1f; box-shadow: inset 0 0 60px rgba(0,0,0,.45), 0 8px 24px rgba(0,0,0,.4);
  margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 10px;
}

/* ---------- 对手席位 ---------- */
.opp-row { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.opp-seat {
  background: rgba(0,0,0,.28); border-radius: 14px; padding: 10px 8px;
  min-width: 140px; flex: 0 1 30%; text-align: center;
  border: 2px solid transparent; transition: .2s;
}
.opp-seat.is-turn { border-color: var(--gold); box-shadow: 0 0 14px rgba(212,160,23,.55); }
.pname { color: #fff; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.score-line { color: #ffd97a; font-size: 12px; font-weight: 700; margin-top: 5px; }
.count-line { color: #b7d6c4; font-size: 12px; margin-top: 3px; }

.card-backs { display: flex; justify-content: center; gap: 2px; min-height: 26px; margin-top: 6px; flex-wrap: wrap; max-width: 100%; }
.card-back {
  width: 16px; height: 24px; border-radius: 3px;
  background: repeating-linear-gradient(45deg, #264d8f 0 4px, #1d3d73 4px 8px);
  border: 1px solid #16305c; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ---------- 中央区 ---------- */
.center-area {
  min-height: 150px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.center-row { display: flex; align-items: center; justify-content: center; gap: 30px; flex-wrap: wrap; }

/* 摸牌堆（点击摸牌） */
.draw-pile { text-align: center; cursor: pointer; }
.pile-backs { position: relative; width: 56px; height: 80px; margin: 0 auto; }
.pile-back {
  position: absolute; width: 52px; height: 76px; border-radius: 8px;
  background: repeating-linear-gradient(45deg, #264d8f 0 6px, #1d3d73 6px 12px);
  border: 2px solid #16305c; box-shadow: 0 2px 6px rgba(0,0,0,.45);
}
.pile-back:nth-child(1) { left: 4px; top: 4px; }
.pile-back:nth-child(2) { left: 2px; top: 2px; }
.pile-back:nth-child(3) { left: 0; top: 0; }
.draw-pile.can-draw .pile-backs {
  outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 10px;
  box-shadow: 0 0 14px rgba(212,160,23,.55);
}
#draw-count { display: block; color: #ffd97a; font-size: 12px; font-weight: 700; margin-top: 8px; }

/* 弃牌堆顶牌 + 生效颜色 */
.discard-zone { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#discard-top { min-width: 76px; min-height: 108px; display: flex; align-items: center; justify-content: center; }
.face-down-big {
  width: 72px; height: 104px; border-radius: 9px;
  background: repeating-linear-gradient(45deg, #264d8f 0 6px, #1d3d73 6px 12px);
  border: 2px solid #16305c; box-shadow: 0 3px 8px rgba(0,0,0,.45);
}
.color-line { display: flex; align-items: center; gap: 8px; color: #a9c9b6; font-size: 12px; }
.color-dot {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.45);
  display: inline-block; background: #445; flex: 0 0 auto;
}
.color-dot.red { background: #d63031; }
.color-dot.yellow { background: #fdcb35; }
.color-dot.green { background: #00b894; }
.color-dot.blue { background: #0984e3; }
.color-dot.wild { background: conic-gradient(#d63031 0 25%, #fdcb35 0 50%, #0984e3 0 75%, #00b894 0); }

/* 摸牌待决展示 */
.drew-zone { text-align: center; }
.drew-zone .lp-name { color: #ffe9b0; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
#drew-card { display: flex; justify-content: center; }

/* ---------- UNO 牌卡 ---------- */
.ucard {
  width: 56px; height: 80px; background: #fff; border-radius: 9px;
  box-shadow: 0 3px 8px rgba(0,0,0,.45);
  border: 2px solid #e8e8e8; flex: 0 0 auto; cursor: pointer;
  transition: transform .12s, margin .12s, box-shadow .12s;
  position: relative; user-select: none; margin-left: -18px;
}
.my-hand .ucard:first-child { margin-left: 0; }
.my-hand .ucard:hover { transform: translateY(-6px); z-index: 2; }
.ucard.selected { transform: translateY(-14px); border-color: var(--gold); box-shadow: 0 6px 14px rgba(212,160,23,.5); }
.ucard.disabled { opacity: .35; filter: grayscale(.7); cursor: default; }
.ucard.disabled:hover { transform: none; }

.ucard .u-corner {
  position: absolute; top: 3px; left: 5px; z-index: 2;
  font-size: 14px; font-weight: 800; line-height: 1.1;
}
.ucard .u-corner.b { top: auto; left: auto; bottom: 3px; right: 5px; transform: rotate(180deg); }
.ucard .u-oval {
  position: absolute; left: 50%; top: 50%; z-index: 1;
  width: 74%; height: 62%;
  transform: translate(-50%, -50%) rotate(-22deg); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 23px; font-weight: 800;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.85), 0 1px 3px rgba(0,0,0,.25);
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.ucard.c-red .u-oval { background: #d63031; }
.ucard.c-red .u-corner { color: #d63031; }
.ucard.c-yellow .u-oval { background: #fdcb35; }
.ucard.c-yellow .u-corner { color: #c99700; }
.ucard.c-green .u-oval { background: #00b894; }
.ucard.c-green .u-corner { color: #00896e; }
.ucard.c-blue .u-oval { background: #0984e3; }
.ucard.c-blue .u-corner { color: #0984e3; }
.ucard.c-wild .u-oval { background: conic-gradient(#d63031 0 25%, #fdcb35 0 50%, #0984e3 0 75%, #00b894 0); }
.ucard.c-wild .u-corner { color: #555; }

/* 中央弃牌大图 */
.ucard-big { width: 72px; height: 104px; cursor: default; margin-left: 0; }
.ucard-big .u-corner { font-size: 18px; }
.ucard-big .u-oval { font-size: 32px; }

/* ---------- 我的座位 ---------- */
.my-seat {
  background: rgba(0,0,0,.28); border-radius: 14px; padding: 12px 14px;
  border: 2px solid transparent; transition: .2s;
}
.my-seat.is-turn { border-color: var(--gold); box-shadow: 0 0 14px rgba(212,160,23,.55); }
.my-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.my-head .pname { font-size: 15px; }
.my-head .score-line { margin-top: 0; }
.my-tip { color: #ffe9b0; font-size: 14px; font-weight: 600; min-height: 20px; margin: 8px 0 6px; }
.my-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.act-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- 手牌 ---------- */
.my-hand {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end;
  min-height: 96px; max-width: 100%;
  margin: 10px 0 4px; row-gap: 12px; padding: 14px 8px 12px;
}

/* ---------- 日志 ---------- */
.log-panel h4 { color: var(--accent-dark); margin-bottom: 8px; }
#log-list {
  max-height: 170px; overflow-y: auto; font-size: 13px; line-height: 1.8; color: #41564a;
}
#log-list div { border-bottom: 1px dashed #e4ece7; padding: 2px 0; }

/* ---------- 结算横幅 ---------- */
#round-banner {
  background: linear-gradient(90deg, #d4a017, #f0c94a);
  color: #3a2c00; text-align: center; font-size: 18px; font-weight: 800;
  padding: 12px; border-radius: 12px; margin-bottom: 14px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: #23342b; color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 99;
  box-shadow: 0 6px 18px rgba(0,0,0,.4); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 门户链接 ---------- */
.portal-link { margin: -22px 0 30px; }
.portal-link a { color: #a9c9b6; font-size: 14px; text-decoration: none; border-bottom: 1px dashed #3d5c4c; padding-bottom: 2px; }
.portal-link a:hover { color: #fff; }
.room-hall-link { color: #a9c9b6; font-size: 13px; text-decoration: none; border: 1px solid #3d5c4c; border-radius: 20px; padding: 4px 12px; transition: .15s; }
.room-hall-link:hover { color: #fff; background: rgba(255,255,255,.08); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-card { background: #fff; border-radius: 14px; padding: 18px; max-width: 360px; width: 100%; }
.modal-card h3 { margin-bottom: 10px; color: var(--accent-dark); }
.modal-card p { font-size: 14px; line-height: 1.6; color: #33463c; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }

/* 万能牌选色 */
.color-btns { display: flex; gap: 14px; justify-content: center; margin: 16px 0 4px; }
.color-btn {
  width: 54px; height: 54px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35);
  cursor: pointer; transition: .15s;
}
.color-btn:hover { transform: scale(1.12); }
.color-btn[data-color="red"] { background: #d63031; }
.color-btn[data-color="yellow"] { background: #fdcb35; }
.color-btn[data-color="green"] { background: #00b894; }
.color-btn[data-color="blue"] { background: #0984e3; }

/* ---------- 账号系统 ---------- */
.acct-box { border: 1px dashed #b9ccc1; border-radius: 10px; padding: 12px; margin-bottom: 16px; background: #f6faf7; }
.acct-row { display: flex; gap: 8px; }
.acct-row input { flex: 1; min-width: 0; }
.acct-btns { display: flex; gap: 8px; margin-top: 10px; }
.acct-btns .btn { flex: 1; }
.acct-hint { margin-top: 8px; font-size: 12px; color: var(--gray); }
#acct-profile { display: flex; align-items: center; gap: 12px; }
.acct-avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: #dfe9e2; cursor: pointer; border: 2px solid var(--accent); }
.acct-info { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 14px; min-width: 0; }
.acct-records, .acct-bank { color: var(--gray); font-size: 12px; }
.acct-box .btn { width: auto; margin-top: 0; }
.acct-box .btn.ghost { color: var(--gray); border-color: #b9ccc1; }
.acct-box .btn.ghost:hover { background: #eef4ef; color: var(--ink); }
.acct-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.acct-actions .acct-link { text-decoration: none; text-align: center; }
.seat-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; vertical-align: -6px; margin-right: 5px; border: 1px solid rgba(255,255,255,.4); }
.rec-line { color: #9db8a8; font-size: 11px; min-height: 14px; margin-top: 2px; }

/* ---------- 移动端 ---------- */
@media (max-width: 620px) {
  .logo { font-size: 40px; }
  .home-btns { flex-direction: column; align-items: center; }
  .app { padding: 10px; }
  .table { padding: 14px 10px; }
  .center-row { gap: 16px; }
  .opp-seat { min-width: 140px; min-width: 128px; flex: 0 1 46%; }
  /* 手牌 44×64，窄屏两行折行由 fitHand 处理 */
  .ucard { width: 44px; height: 64px; margin-left: -16px; }
  .ucard .u-corner { font-size: 11px; }
  .ucard .u-oval { font-size: 17px; }
  .ucard-big { width: 64px; height: 92px; }
  .ucard-big .u-oval { font-size: 26px; }
}

/* ---------- 房规面板 / UNO 按钮 / 惩罚叠加 ---------- */
.bottom-row { display: flex; gap: 12px; align-items: stretch; }
.bottom-row .log-panel { flex: 1; }
.rules-panel { flex: 0 0 300px; }
.rules-panel h4, .log-panel h4 { color: var(--accent-dark); margin-bottom: 8px; }
.rule-row { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; font-size: 12px; line-height: 1.5; }
.rule-flag { flex: 0 0 42px; font-weight: 800; text-align: center; border-radius: 10px; padding: 1px 0; font-size: 11px; }
.rule-flag.on { background: #dff0e5; color: var(--accent-dark); }
.rule-flag.off { background: #f0f0f0; color: #999; }
.rule-text { color: #33463c; }
.rules-panel.editable .rule-text { color: #1c2b24; }

/* 拨动开关 */
.rule-switch { position: relative; display: inline-block; width: 38px; height: 20px; flex: 0 0 38px; }
.rule-switch input { opacity: 0; width: 0; height: 0; }
.rule-slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 20px; transition: .2s; }
.rule-slider::before { content: ""; position: absolute; height: 14px; width: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.rule-switch input:checked + .rule-slider { background: var(--accent); }
.rule-switch input:checked + .rule-slider::before { transform: translateX(18px); }

/* UNO / 检举按钮 */
.uno-btn { background: var(--gold); color: #3a2c00; font-size: 20px; font-weight: 900; animation: uno-pulse 1s infinite; }
.uno-btn:hover { background: #b58910; }
.catch-btn { background: var(--red); color: #fff; font-weight: 800; }
.catch-btn:hover { background: #b51f20; }
@keyframes uno-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

@media (max-width: 720px) {
  .bottom-row { flex-direction: column; }
  .rules-panel { flex: none; }
}


/* 名次徽标 */
.rank-badge { background: var(--gold); color: #3a2c00; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 800; vertical-align: 1px; }
