/* ============ Flip 7 样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f2f0ea;
  --ink: #2b2b33;
  --muted: #7a7885;
  --card-bg: #ffffff;
  --felt: #3f7d54;
  --felt-dark: #33684a;
  --primary: #2980b9;
  --primary-dark: #21618c;
  --danger: #c0392b;
  --gold: #b8860b;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(40, 40, 60, .12);
}

html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(ellipse at top, #faf8f2 0%, var(--bg) 60%);
  color: var(--ink);
  min-height: 100vh;
}

#app { max-width: 1180px; margin: 0 auto; padding: 16px; }
.hidden { display: none !important; }

/* ---------- 通用按钮 ---------- */
.btn {
  border: none; cursor: pointer; border-radius: 10px;
  padding: 10px 18px; font-size: 15px; font-weight: 600;
  transition: transform .12s, box-shadow .12s, opacity .12s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(41, 128, 185, .35); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid #ddd8cc; }
.btn-ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-big { width: 100%; padding: 14px; font-size: 17px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- 大厅 ---------- */
.lobby-head { text-align: center; padding: 36px 0 20px; }
.logo {
  font-size: 54px; font-weight: 900; letter-spacing: 4px;
  color: var(--ink); font-family: Georgia, serif;
}
.logo span { color: var(--danger); }
.logo-sm { font-size: 22px; letter-spacing: 1px; }
.slogan { color: var(--muted); margin-top: 6px; font-size: 15px; }

.lobby-card, .room-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; max-width: 620px; margin: 0 auto;
}
.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }

.name-row { display: flex; gap: 10px; align-items: center; }
.avatar-current {
  width: 46px; height: 46px; border-radius: 12px; background: #f5f2e9;
  display: flex; align-items: center; justify-content: center; font-size: 26px; cursor: pointer;
  border: 1.5px solid #e5e0d2; user-select: none;
}
.avatar-current:hover { border-color: var(--primary); }
#nameInput {
  flex: 1; padding: 12px 14px; font-size: 16px; border: 1.5px solid #e5e0d2;
  border-radius: 10px; outline: none; font-family: inherit;
}
#nameInput:focus { border-color: var(--primary); }
.avatar-pick {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding: 10px;
  background: #faf7ef; border-radius: 10px;
}
.avatar-opt { font-size: 22px; padding: 6px; background: none; border: none; cursor: pointer; border-radius: 8px; }
.avatar-opt:hover { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12); }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 11px; border: 1.5px solid #e5e0d2; background: #fff;
  border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; color: var(--muted);
  font-family: inherit;
}
.tab.active { border-color: var(--primary); color: var(--primary); background: #eaf4fb; }

.seat-list { display: flex; flex-direction: column; gap: 8px; }
.seat {
  display: flex; align-items: center; gap: 10px; background: #faf8f2;
  border: 1.5px solid #ece7da; border-radius: 10px; padding: 8px 12px;
}
.seat.bot { background: #f3f0fa; border-color: #e4dcf5; }
.seat-avatar {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 20px; border: 1.5px solid;
}
.seat-name { font-weight: 700; font-size: 15px; flex: 0 0 auto; }
.seat-tag { color: var(--muted); font-size: 12.5px; flex: 1; }
.seat-del {
  background: none; border: none; color: #bbb; font-size: 16px; cursor: pointer; padding: 4px 8px;
  border-radius: 6px;
}
.seat-del:hover { color: var(--danger); background: #fdeceb; }
.seat-actions { display: flex; gap: 8px; margin-top: 10px; }
.seat-actions .btn { flex: 1; padding: 8px; font-size: 14px; }

.level-row { display: flex; gap: 8px; }
.level {
  flex: 1; padding: 9px; border: 1.5px solid #e5e0d2; background: #fff; border-radius: 10px;
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); font-family: inherit;
}
.level.active { border-color: var(--primary); color: var(--primary); background: #eaf4fb; }

.online-cta { text-align: center; padding: 8px 0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 20px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: #e5e0d2; }
.join-row { display: flex; gap: 8px; }
.code-input {
  flex: 1; padding: 12px 14px; font-size: 20px; letter-spacing: 6px; text-align: center;
  text-transform: uppercase; border: 1.5px solid #e5e0d2; border-radius: 10px; outline: none;
  font-family: inherit;
}
.code-input:focus { border-color: var(--primary); }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 10px; text-align: center; }

.rules-box {
  max-width: 620px; margin: 16px auto 40px; background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 20px;
}
.rules-box summary { cursor: pointer; font-weight: 700; }
.rules-body ul { margin: 12px 0 4px 20px; line-height: 1.9; font-size: 14px; color: #4a4855; }
.rules-body b { color: var(--ink); }

/* ---------- 房间 ---------- */
.room-card h2 { margin-bottom: 16px; }
.room-code-wrap { text-align: center; margin-bottom: 18px; }
.room-code-label { color: var(--muted); font-size: 13px; }
.room-code {
  font-size: 46px; font-weight: 900; letter-spacing: 14px; color: var(--primary);
  font-family: "Courier New", monospace; margin: 4px 0 12px; text-indent: 14px;
}
.room-link-row { display: flex; gap: 8px; max-width: 420px; margin: 0 auto; }
#roomLinkInput {
  flex: 1; padding: 9px 12px; font-size: 13px; border: 1.5px solid #e5e0d2;
  border-radius: 8px; color: var(--muted); background: #faf8f2;
}

/* ---------- 游戏页 ---------- */
#screen-game { max-width: none; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.tb-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tb-chip {
  background: #f1eee6; padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 700;
  color: #5f5d6b;
}
.tb-right { display: flex; gap: 8px; }

.game-layout { display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start; }
.table {
  background: linear-gradient(160deg, #47875c, var(--felt-dark));
  border-radius: var(--radius); box-shadow: var(--shadow), inset 0 0 60px rgba(0,0,0,.15);
  padding: 14px; display: flex; flex-direction: column; gap: 12px; min-height: 70vh;
}

.opponents { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.opp {
  background: rgba(255,255,255,.94); border-radius: 12px; padding: 10px 12px;
  border: 2.5px solid transparent; transition: border-color .2s, transform .2s;
}
.opp.turn { border-color: #ffd54f; box-shadow: 0 0 0 4px rgba(255, 213, 79, .35); }
.opp.status-busted { opacity: .55; }
.opp.shake { animation: shake .5s; }
.opp.gone { opacity: .7; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-6px); }
  40%,80% { transform: translateX(6px); }
}
.opp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.opp-avatar {
  width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; font-size: 18px; border: 1.5px solid; flex-shrink: 0;
}
.opp-avatar.big { width: 48px; height: 48px; font-size: 27px; border-radius: 12px; }
.opp-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opp-total { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.opp-total b { font-size: 15px; color: var(--ink); }
.opp-cards { display: flex; flex-wrap: wrap; gap: 5px; min-height: 46px; align-items: center; }
.opp-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.opp-count { font-weight: 700; }
.no-card { color: #c5c2b8; font-size: 13px; }

.badge { padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.b-active { background: #e8f5e9; color: #2e7d32; }
.b-stayed { background: #e3f2fd; color: #1565c0; }
.b-busted { background: #fdecea; color: #c0392b; }

.center-strip { display: flex; align-items: center; gap: 14px; justify-content: center; min-height: 64px; }
.draw-pile { text-align: center; }
.pile-cards {
  width: 56px; height: 78px; border-radius: 9px; margin: 0 auto;
  background: repeating-linear-gradient(45deg, #35597a, #35597a 6px, #2c4a67 6px, #2c4a67 12px);
  border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center; font-size: 30px; color: rgba(255,255,255,.85);
}
.draw-pile.empty .pile-cards { background: #666; opacity: .4; }
.pile-count { font-size: 12px; color: #eafbe9; margin-top: 4px; font-weight: 700; }

.event-banner {
  font-size: 24px; font-weight: 900; color: #fff; opacity: 0;
  text-shadow: 0 2px 8px rgba(0,0,0,.35); padding: 6px 22px; border-radius: 12px;
}
.event-banner.show { animation: bannerIn 2.4s ease forwards; }
.event-banner.bad { color: #ffd3cd; }
.event-banner.gold { color: #ffe082; }
.event-banner.soft { color: rgba(255,255,255,.85); font-size: 19px; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateY(10px) scale(.9); }
  12% { opacity: 1; transform: translateY(0) scale(1.05); }
  20% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.my-area {
  background: rgba(255,255,255,.97); border-radius: 14px; padding: 14px 16px;
  border: 3px solid #ffd54f;
}
.my-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.my-title { flex: 1; min-width: 120px; }
.my-name { font-weight: 900; font-size: 17px; }
.my-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.my-score { text-align: right; margin-left: auto; }
.my-score-num { font-size: 30px; font-weight: 900; color: var(--primary); line-height: 1; }
.my-score-label { font-size: 11.5px; color: var(--muted); }
.my-cards { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; min-height: 96px; align-items: center; }
.my-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.my-controls .btn { flex: 1; min-width: 160px; padding: 13px; font-size: 17px; }
.my-controls small { display: block; font-weight: 400; font-size: 11px; opacity: .8; }
.btn-hit { background: var(--danger); color: #fff; box-shadow: 0 4px 14px rgba(192, 57, 43, .35); }
.btn-hit:hover:not(:disabled) { background: #a93226; }
.btn-stay { background: #27ae60; color: #fff; box-shadow: 0 4px 14px rgba(39, 174, 96, .35); }
.btn-stay:hover:not(:disabled) { background: #1e8449; }
.turn-hint { color: var(--muted); font-size: 13.5px; flex-basis: 100%; text-align: center; }

/* ---------- 卡牌 ---------- */
.card {
  width: 64px; height: 90px; border-radius: 10px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 900; position: relative;
  box-shadow: 0 3px 8px rgba(0,0,0,.25); border: 3px solid rgba(255,255,255,.9);
  text-shadow: 0 2px 4px rgba(0,0,0,.25); font-family: Georgia, serif; flex-shrink: 0;
}
.card.sm { width: 40px; height: 56px; font-size: 21px; border-width: 2px; border-radius: 7px; }
.card.mod {
  background: linear-gradient(160deg, #f6c453, #d9982a); color: #5c3a00;
  text-shadow: none; font-size: 26px;
}
.card.sm.mod { font-size: 16px; }
.card.chance {
  background: linear-gradient(160deg, #f78fb3, #e0568b); font-size: 26px; border-style: dashed;
}
.card.sm.chance { font-size: 18px; }
/* 爆牌凶牌：显示导致爆牌的重复数字 */
.card.bust {
  background: linear-gradient(160deg, #7b2d3b, #571d29);
  border-style: double;
}
.card.bust .bust-mark {
  position: absolute; top: -9px; right: -9px; font-size: 19px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); text-shadow: none;
}
.card.sm.bust .bust-mark { font-size: 14px; top: -7px; right: -7px; }
/* 爆牌后本轮已翻的牌：变暗表示作废 */
.card.dead { opacity: .45; filter: saturate(.35); }
.card.pop { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop {
  0% { transform: translateY(-26px) rotate(-8deg) scale(.6); opacity: 0; }
  100% { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
}

/* ---------- 侧栏 ---------- */
.sidebar { display: flex; flex-direction: column; gap: 12px; }
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.panel-title { font-weight: 800; font-size: 14px; margin-bottom: 10px; color: #4a4855; }
.log-list { max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.log-line { font-size: 12.5px; color: #5f5d6b; line-height: 1.5; padding: 4px 8px; background: #faf8f2; border-radius: 7px; }
.counter-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.counter-cell {
  background: #eef2ea; border-radius: 8px; padding: 6px 2px; text-align: center;
  border: 1.5px solid #dde5da;
}
.counter-cell .cv { display: block; font-weight: 900; font-size: 15px; color: #3c6e4c; }
.counter-cell .cn { display: block; font-size: 11.5px; color: var(--muted); }
.counter-cell.danger { background: #fdecea; border-color: #f2b8b2; }
.counter-cell.danger .cv { color: var(--danger); }
.counter-cell.zero { opacity: .35; }

/* ---------- 弹窗 ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(25, 25, 35, .55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: #fff; border-radius: 18px; padding: 24px 26px; max-width: 480px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); max-height: 88vh; overflow-y: auto;
  animation: modalIn .25s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes modalIn { from { transform: scale(.85) translateY(20px); opacity: 0; } }
.modal h3 { margin-bottom: 12px; font-size: 19px; }
.modal-hint { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.target-list { display: flex; flex-direction: column; gap: 8px; }
.target-btn {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: #faf8f2; border: 2px solid #ece7da; border-radius: 12px;
  cursor: pointer; font-family: inherit; font-size: 15px; text-align: left;
  transition: border-color .15s, transform .15s;
}
.target-btn:hover { border-color: var(--primary); transform: translateX(4px); }
.tb-avatar { font-size: 22px; }
.tb-name { font-weight: 800; }
.tb-info { margin-left: auto; color: var(--muted); font-size: 13px; }

.score-table { margin: 8px 0 18px; }
.score-row {
  display: grid; grid-template-columns: 1fr auto 70px 60px; gap: 8px; align-items: center;
  padding: 9px 12px; border-radius: 10px; font-size: 14.5px;
}
.score-row.head { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.score-row:nth-child(even) { background: #faf8f2; }
.score-row.busted { opacity: .55; text-decoration: line-through; }
.score-row.winner { background: #fff8e1; font-weight: 800; }
.sr-detail { font-size: 12px; color: var(--muted); }
.sr-round { text-align: right; font-weight: 800; color: var(--primary); }
.sr-total { text-align: right; font-weight: 900; }
.go-crown { text-align: center; font-size: 56px; margin-bottom: -6px; }

/* ---------- Toast ---------- */
#toastRoot { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #33313b; color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.3); animation: toastIn .3s;
}
.toast.warn { background: #b8860b; }
.toast.error { background: #c0392b; }
@keyframes toastIn { from { transform: translateY(-16px); opacity: 0; } }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
  .card { width: 52px; height: 74px; font-size: 27px; }
  .logo { font-size: 40px; }
  .my-controls .btn { min-width: 120px; }
  .room-code { font-size: 36px; letter-spacing: 10px; }
}
