/* 五子棋人机 · 娱乐小游戏（纯积分，无任何真实货币）
   视觉沿用 blackjack/doudizhu/uno 变量体系：暗绿毛毡、白卡片、金色点缀 */

* { 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;
  --gold-bright: #f3ce62;
  --gold-pale: #fff8df;
  --gold-deep: #8a6400;
  --gray: #7a8a80;
  --bg-deep: #07180f;
  --grid-line: rgba(212, 160, 23, .3);   /* 金色格线 30% 透明 */
  --stone-black: #1c2b24;
  --stone-white: #ffffff;
}

html { color-scheme: dark; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% -8%, rgba(212, 160, 23, .18), transparent 36%),
    radial-gradient(circle at 88% 110%, rgba(15, 138, 95, .25), transparent 40%),
    linear-gradient(160deg, var(--bg-deep), var(--felt-dark) 55%, var(--bg-deep));
  color: #eaf3ed;
  min-height: 100vh;
}

.app { max-width: 1180px; margin: 0 auto; padding: 18px 16px 28px; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-badge {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px;
  background: radial-gradient(circle at 35% 30%, #4a6154, var(--stone-black));
  border: 2px solid var(--gold);
  box-shadow: 0 0 18px rgba(212, 160, 23, .35);
}
.brand h1 { font-size: 22px; letter-spacing: 1px; }
.brand-en { font-size: 12px; color: var(--gold-bright); letter-spacing: 3px; margin-left: 6px; }
.slogan { font-size: 12.5px; color: #b9d2c4; margin-top: 3px; }
.slogan b { color: var(--gold-bright); }
.topbar-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.conn-tag {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, .06); border: 1px solid #3d5c4c;
  color: #cfe3d7; border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer;
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.conn-tag.on .conn-dot { background: #35d08c; }
.conn-tag.off .conn-dot { background: var(--warn); }

.settle-strip { display: flex; gap: 8px; }
.settle-item {
  background: rgba(0, 0, 0, .28); border: 1px solid #2c4a3a;
  border-radius: 10px; padding: 6px 12px; text-align: center; min-width: 78px;
}
.settle-item span { display: block; font-size: 11px; color: #9db8aa; }
.settle-item strong { font-size: 15px; color: var(--gold-bright); font-variant-numeric: tabular-nums; }

/* ---------- 主布局 ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; margin-top: 18px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* ---------- 毛毡棋盘：15×15 金色格线 ---------- */
.board {
  position: relative;
  width: min(88vw, 620px);
  aspect-ratio: 1;
  border-radius: 14px;
  background:
    repeating-linear-gradient(to right, var(--grid-line) 0 1px, transparent 1px calc(100% / 14)),
    repeating-linear-gradient(to bottom, var(--grid-line) 0 1px, transparent 1px calc(100% / 14)),
    radial-gradient(circle at 50% 40%, var(--felt), var(--felt-dark) 85%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45), inset 0 0 60px rgba(0, 0, 0, .25);
}
.board::after { content: ""; position: absolute; inset: 0; border: 1px solid var(--grid-line); border-radius: 14px; pointer-events: none; }

.cells, .stones { position: absolute; inset: 0; }
.cells { display: grid; grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(15, 1fr); }
.cell { cursor: pointer; }
.cell:hover::after {
  content: ""; position: absolute; width: calc(100% / 15 * .5); aspect-ratio: 1;
  border-radius: 50%; background: rgba(243, 206, 98, .4);
  transform: translate(-50%, -50%); pointer-events: none;
}
.cell { position: relative; }
.cell:hover::after { left: 50%; top: 50%; }
.board.locked .cell { cursor: default; }
.board.locked .cell:hover::after { display: none; }

/* ---------- 棋子 ---------- */
.stone {
  position: absolute; width: calc(100% / 15 * .72); aspect-ratio: 1;
  border-radius: 50%; transform: translate(-50%, -50%);
  pointer-events: none; z-index: 2;
}
.stone.black { background: radial-gradient(circle at 35% 30%, #3d5247, var(--stone-black)); border: 2px solid var(--gold); box-shadow: 0 3px 8px rgba(0, 0, 0, .5); }
.stone.white { background: radial-gradient(circle at 35% 30%, #ffffff, #d9ded9); border: 2px solid #9aa8a0; box-shadow: 0 3px 8px rgba(0, 0, 0, .4); }

/* AI 落子：250ms scale 淡入 + 涟漪扩散 */
.stone.pop { animation: pop .25s ease-out; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.25); opacity: 0; } }
.stone.pop::before {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--gold-bright); animation: ripple .5s ease-out forwards;
}
@keyframes ripple { from { opacity: .9; transform: scale(.8); } to { opacity: 0; transform: scale(1.9); } }

/* 最后一手：金圈 pulse */
.stone.last::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--gold-bright); animation: ring 1.2s ease-out infinite;
}
@keyframes ring {
  0% { opacity: .95; transform: scale(.72); }
  70% { opacity: 0; transform: scale(1.35); }
  100% { opacity: 0; transform: scale(1.35); }
}

/* 胜利五连：逐颗 bounce（delay 由 JS 按 i×80ms 注入） */
.stone.bounce { animation: bounce .6s ease-out both; z-index: 3; }
@keyframes bounce {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  40% { transform: translate(-50%, -62%) scale(1.14); }
}

/* 贯穿五连的金线（left/top/width/rotate 由 JS 计算） */
.win-line {
  position: absolute; height: 4px; z-index: 4; border-radius: 2px;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright), var(--gold));
  box-shadow: 0 0 14px rgba(212, 160, 23, .8);
  transform-origin: 0 50%; pointer-events: none;
}
.board-caption { font-size: 12.5px; color: #9db8aa; }

/* ---------- 侧栏卡片 ---------- */
.card-panel {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 14px; color: var(--ink);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
}
.card-panel + .card-panel { margin-top: 14px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 800; font-size: 14px; color: var(--accent-dark);
  border-bottom: 1px dashed var(--panel-border); padding-bottom: 8px; margin-bottom: 10px;
}
.panel-head .status { font-size: 13px; font-weight: 700; color: var(--gold-deep); }
.panel-head .status.thinking::after { content: "…"; }
.panel-head .status.thinking .dots i { animation: blink 1.2s infinite; }
.dots i { font-style: normal; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
.muted { color: var(--gray); font-weight: 600; }

.bet-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 10px; }
.bet-grid .btn { padding: 8px 2px; font-size: 13px; }
.bet-grid .btn.sel { outline: 2px solid var(--gold-deep); outline-offset: 1px; box-shadow: 0 0 10px rgba(212, 160, 23, .5); }

.btn {
  background: var(--accent); color: #fff; border: 1px solid transparent;
  padding: 10px 20px; border-radius: 10px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: background .15s, transform .15s, box-shadow .15s, opacity .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }
.btn.big { font-size: 18px; padding: 14px 26px; width: 100%; }
.btn.warn { background: var(--gold); color: #332500; }
.btn.warn:hover { background: #b58910; }
.btn.gold {
  background: linear-gradient(180deg, #f8dc86 0%, var(--gold) 55%, #ac7c08 100%);
  color: #2f2300; border-color: #ffe8a5; text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
}
.btn.gold:hover { background: linear-gradient(180deg, #ffe7a0 0%, #e3b32a 55%, #b9870b 100%); }
.btn.ghost { background: transparent; color: var(--accent-dark); border-color: #b9ccc1; }
.btn.ghost:hover { background: rgba(15, 138, 95, .08); }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.hint { font-size: 12px; color: var(--gray); margin: 8px 0 10px; }
.ledger { display: grid; gap: 6px; font-size: 12.5px; border-top: 1px dashed var(--panel-border); padding-top: 8px; }
.ledger > div { display: flex; justify-content: space-between; gap: 8px; }
.ledger span { color: var(--gray); }

.auth-form { display: grid; gap: 8px; }
.auth-form input {
  padding: 9px 11px; border: 1px solid #b9ccc1; border-radius: 9px;
  font-size: 14px; background: #fff; color: var(--ink); width: 100%;
}
.auth-btns { display: flex; gap: 8px; }
.auth-btns .btn { flex: 1; }
.auth-info { display: grid; gap: 8px; font-size: 13.5px; }
.auth-row { display: flex; justify-content: space-between; }
.auth-row strong { font-variant-numeric: tabular-nums; }

/* ---------- 结算浮层 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4, 16, 10, .66); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--gold); border-radius: 16px;
  padding: 26px 30px; text-align: center; min-width: min(320px, 86vw);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  animation: rise .25s ease-out;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.modal-card h2 { font-size: 30px; margin-bottom: 8px; letter-spacing: 4px; }
.modal-card h2.win { color: var(--gold-deep); text-shadow: 0 1px 0 var(--gold-pale), 0 0 18px rgba(212, 160, 23, .45); }
.modal-card h2.lose { color: var(--warn); }
.modal-card h2.draw { color: var(--gray); }
.modal-card p { font-size: 14.5px; color: #4d5c54; margin-bottom: 16px; line-height: 1.6; }
.modal-card p b { color: var(--gold-deep); font-size: 18px; }
.modal-btns { display: flex; gap: 10px; justify-content: center; }

/* ---------- Toast / Footer ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px);
  background: rgba(12, 30, 21, .94); color: #f1e6c8; border: 1px solid var(--gold-deep);
  padding: 10px 18px; border-radius: 10px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80;
  max-width: 86vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer { margin-top: 26px; text-align: center; font-size: 12.5px; color: #7fa090; }
.footer b { color: var(--gold-bright); }

/* ==================================================================
   以下为双模式改造新增（v=2）：首屏 / 联机大厅 / 房间页
   视觉沿用 blackjack/uno 体系：暗绿毛毡 + 金色点缀 + 白面板
   ================================================================== */

/* ---------- 屏幕切换 ---------- */
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* 暗底区域的 ghost 按钮（首页/大厅/房间用） */
#screen-home .btn.ghost, #screen-lobby .btn.ghost, #screen-room .btn.ghost {
  color: #cfe3d7; border-color: #3d5c4c;
}
#screen-home .btn.ghost:hover, #screen-lobby .btn.ghost:hover, #screen-room .btn.ghost:hover {
  background: rgba(255, 255, 255, .08);
}

/* ---------- 首屏：logo + 双大按钮 + 玩法速览白面板 ---------- */
.home-wrap { text-align: center; padding: 46px 12px; color: #eaf3ed; }
.logo { font-size: 54px; letter-spacing: 4px; color: #fff; text-shadow: 0 3px 12px rgba(0, 0, 0, .5); }
.logo span { color: var(--gold); }
.home-wrap .slogan { margin: 12px 0 30px; color: #a9c9b6; letter-spacing: 2px; font-size: 14px; }
.home-wrap .slogan b { color: var(--gold-bright); }
.home-btns { display: flex; gap: 18px; justify-content: center; margin-bottom: 10px; flex-wrap: wrap; }
.home-btns .btn.big { font-size: 20px; padding: 18px 40px; min-width: 240px; }
.portal-link { margin: 10px 0 26px; }
.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; }
.rules { max-width: 660px; 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: 26px auto; }
.lobby-wrap h2 { color: #fff; margin-bottom: 16px; text-align: center; letter-spacing: 2px; }
.form-panel { background: var(--panel); border: 1px solid var(--panel-border); color: var(--ink); }
.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; }
.join-row .btn { width: auto; margin-top: 0; }
.rejoin-tip { margin-top: 12px; font-size: 12px; color: var(--gray); line-height: 1.6; }
.rejoin-tip b { color: var(--accent-dark); }
.fee-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.fee-opt { padding: 9px 2px !important; font-size: 14px !important; margin-top: 0 !important; }
.fee-opt.sel { outline: 2px solid var(--gold-deep); outline-offset: 1px; box-shadow: 0 0 10px rgba(212, 160, 23, .5); }

/* 账号盒（blackjack 同款） */
.acct-box { border: 1px dashed #b9ccc1; border-radius: 10px; padding: 12px; 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; margin-top: 0; }
.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-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.acct-actions .acct-link { text-decoration: none; text-align: center; }
.acct-link { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- 房间页 ---------- */
.room-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 16px 0 14px; color: #eaf3ed;
}
.room-code { font-size: 15px; }
.room-code b { font-size: 22px; letter-spacing: 5px; color: var(--gold); margin: 0 4px; font-variant-numeric: tabular-nums; }
#btn-copy { background: none; border: none; color: #a9c9b6; cursor: pointer; font-size: 15px; }
#btn-copy:hover { color: #fff; }
.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; }
.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); }

#need-more {
  background: #fff3cd; color: #7a5b00; text-align: center; font-weight: 700;
  padding: 10px; border-radius: 10px; margin-bottom: 14px; border: 1px solid #f1dc9b;
}
#room-banner {
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  color: #3a2c00; text-align: center; font-size: 17px; font-weight: 800;
  padding: 12px; border-radius: 12px; margin-bottom: 14px;
}

/* 毛毡牌桌（金框内嵌棋盘） */
.table {
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  border-radius: 20px; padding: 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; align-items: center; gap: 12px;
}
.board-frame {
  border: 4px solid var(--gold); border-radius: 18px; padding: 10px;
  background: linear-gradient(180deg, #2a2321, #1f1a18);
  box-shadow: 0 0 22px rgba(212, 160, 23, .35), 0 14px 30px rgba(0, 0, 0, .5);
}
#room-board { width: min(84vw, 540px); }
.table .board-caption { color: #cfe3d7; }
.opp-seat {
  background: rgba(0, 0, 0, .28); border-radius: 14px; padding: 10px 14px;
  min-width: min(84vw, 400px); max-width: 100%; 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); }

/* 座位状态点 */
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #7a8a80; vertical-align: middle; }
.status-dot.dot-idle { background: var(--gold-bright); }
.status-dot.dot-ok { background: #35d08c; box-shadow: 0 0 6px rgba(53, 208, 140, .8); }
.status-dot.dot-off { background: var(--warn); }
.muted-line { color: #b9d2c4; font-size: 12.5px; }
.pname { color: #fff; font-weight: 700; font-size: 14.5px; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.my-seat .pname { color: var(--ink); }
.seat-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; vertical-align: -6px; border: 1px solid rgba(255, 255, 255, .4); }
.rec-line { color: #9db8a8; font-size: 12px; margin-top: 4px; }
.score-line { color: var(--gold-deep); font-size: 13px; font-weight: 700; }

/* 我的座位白面板 */
.my-seat { width: 100%; max-width: 100%; border: 1px solid var(--gold); border-radius: 14px; }
.my-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.my-panel-row { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 10px; }
.pot-info { display: flex; gap: 8px; flex-wrap: wrap; }
.pot-info .settle-item { background: #f3efe2; border: 1px solid #e2d7b7; }
.pot-info .settle-item span { color: var(--gray); }
.pot-info .settle-item strong { color: var(--gold-deep); font-variant-numeric: tabular-nums; }
.my-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.my-tip { color: #7a5b00; font-size: 13px; font-weight: 600; min-height: 18px; margin-top: 10px; }

/* 棋桌日志 */
.log-panel h4 { color: var(--accent-dark); margin-bottom: 8px; }
#room-log {
  max-height: 150px; overflow-y: auto; font-size: 13px; line-height: 1.8; color: #41564a;
}

#room-log div { border-bottom: 1px dashed #e4ece7; padding: 2px 0; }

/* 单机顶栏复用房间头布局 */
#screen-single .room-head { color: #eaf3ed; }

@media (max-width: 640px) {
  .logo { font-size: 38px; }
  .home-btns { flex-direction: column; align-items: center; }
  .home-btns .btn.big { width: 100%; }
  .fee-grid { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .my-panel-row { flex-direction: column; align-items: stretch; }
}
