/* 2048 · 娱乐小游戏（纯积分，无任何真实货币）
   视觉沿用 doudizhu / uno：暗绿毛毡、白色卡片、金色点缀 */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --felt: #1c6b46;
  --felt-dark: #145034;
  --board-deep: #0c3a26;
  --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;
  --red: #d63031;
  --gray: #7a8a80;
  --blue: #2563a8;
  --bg-deep: #07180f;
  --gap: 10px;
}

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 92% 4%, rgba(15, 138, 95, .26), transparent 38%),
    linear-gradient(160deg, #07180f 0%, #10281d 48%, #07180f 100%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.hidden { display: none !important; }

.app { max-width: 1080px; margin: 0 auto; padding: 18px 16px 26px; position: relative; z-index: 1; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-badge {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 28px;
  background: linear-gradient(160deg, var(--felt) 0%, #0b3a27 100%);
  border: 2px solid var(--gold-bright); box-shadow: 0 0 18px rgba(243, 206, 98, .25);
}
.brand-copy h1 { color: #fff; font-size: 26px; letter-spacing: 1px; }
.brand-en { font-size: 12px; color: var(--gold-bright); letter-spacing: 3px; margin-left: 6px; }
.slogan { color: #bcd6c8; font-size: 12.5px; margin-top: 2px; }
.slogan b { color: var(--gold-bright); }
.topbar-side { display: flex; align-items: center; gap: 10px; }

.conn-tag { display: inline-flex; align-items: center; gap: 7px; background: rgba(0,0,0,.35); color: #cfe3d7; border: 1px solid #3d5c4c; padding: 7px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); }
.conn-tag.online .conn-dot { background: #35d07f; box-shadow: 0 0 8px #35d07f; }
.conn-tag.connecting .conn-dot { background: var(--gold-bright); }
.conn-tag.offline .conn-dot { background: var(--red); }

/* ---------- 通用按钮 / 白卡片 ---------- */
.btn {
  background: var(--accent); color: #fff; border: 1px solid transparent; padding: 10px 18px;
  border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, transform .15s, opacity .15s, box-shadow .15s;
}
.btn:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.big { font-size: 17px; padding: 13px 22px; }
.btn.alt { background: var(--blue); }
.btn.warn { background: var(--gold); color: #332500; }
.btn.ghost { background: transparent; color: #cfe3d7; border-color: #3d5c4c; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.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);
}

.card-panel { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 14px 16px; box-shadow: 0 6px 22px rgba(0,0,0,.35); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.panel-head h2 { font-size: 15px; color: var(--ink); }
.tag { background: var(--gold-pale); color: var(--gold-deep); border: 1px solid #ecd9a0; font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 700; }

/* ---------- 顶部统计条 ---------- */
.stats-panel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; text-align: center; }
.stat span { display: block; font-size: 12px; color: var(--gray); }
.stat b { font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; position: relative; }
.stat b .score-pop { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); color: var(--accent); font-weight: 800; pointer-events: none; animation: rise .6s ease-out forwards; }
@keyframes rise { 0% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -26px); } }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.play-col { min-width: 0; }
.side-col { display: grid; gap: 14px; }

/* ---------- 棋盘 ---------- */
.board-panel { background: linear-gradient(180deg, #ffffff, #f4f7f3); }
.board-wrap { display: grid; place-items: center; }
.board {
  position: relative; width: min(440px, 100%); aspect-ratio: 1;
  background: var(--board-deep); border-radius: 12px; padding: var(--gap);
  touch-action: none; user-select: none; box-shadow: inset 0 0 0 2px rgba(255,255,255,.05);
  container-type: inline-size;
}
.bg-cells, .tiles { position: absolute; inset: var(--gap); }
.bg-cells { display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); gap: var(--gap); }
.bg-cells i { background: var(--felt-dark); border-radius: 8px; }

.tile {
  position: absolute; width: calc((100% - 3 * var(--gap)) / 4); height: calc((100% - 3 * var(--gap)) / 4);
  display: grid; place-items: center; border-radius: 8px;
  font-weight: 800; font-variant-numeric: tabular-nums;
  transform: translate(calc(var(--c) * (100% + var(--gap))), calc(var(--r) * (100% + var(--gap))));
  transition: transform 90ms ease-in-out;
  z-index: 2;
}
.tile span { font-size: 11cqw; }
.tile[data-len="3"] span { font-size: 9cqw; }
.tile[data-len="4"] span { font-size: 7cqw; }
.tile[data-len="5"] span { font-size: 5.6cqw; }
.tile[data-len="6"] span { font-size: 4.6cqw; }

.tile.new { animation: spawn 120ms ease-out; }
.tile.merged { animation: pop 180ms ease-in-out; }
@keyframes spawn { from { scale: 0; } to { scale: 1; } }
@keyframes pop { 0% { scale: 1; } 55% { scale: 1.25; } 100% { scale: 1; } }

.t2, .t4 { background: #f7f3e8; color: #5a5142; }
.t8 { background: #e9c96a; color: #fff; }
.t16 { background: var(--gold); color: #fff; }
.t32 { background: var(--warn); color: #fff; }
.t64 { background: var(--red); color: #fff; }
.t128, .t256, .t512 { background: var(--gold-deep); color: #fff; box-shadow: 0 0 12px rgba(212,160,23,.55); }
.t256 { box-shadow: 0 0 14px rgba(212,160,23,.7); }
.t512 { box-shadow: 0 0 16px rgba(212,160,23,.85); }
.t1024, .t2048 { background: var(--gold); color: #fff; animation: glow 1.5s ease-in-out infinite; }
.tbig { background: var(--gold-bright); color: #332500; animation: glow 1.5s ease-in-out infinite; }
@keyframes glow {
  0%, 100% { box-shadow: 0 0 10px rgba(243, 206, 98, .55); }
  50% { box-shadow: 0 0 26px rgba(243, 206, 98, 1); }
}

.board-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--gray); flex-wrap: wrap; }
.status-line { font-weight: 700; color: var(--accent-dark); }
.board-note { color: #9db8a9; font-size: 12px; margin-top: 10px; }
.board-note b { color: var(--gold-bright); }

/* ---------- 报名 / 对局 ---------- */
.bet-help { font-size: 12px; color: var(--gray); }
.bet-levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 10px; }
.bet-level { padding: 8px 4px; border-radius: 8px; border: 1.5px solid var(--panel-border); background: #fbfdfc; font-weight: 800; color: var(--ink); cursor: pointer; font-size: 13px; }
.bet-level.active { border-color: var(--gold); background: var(--gold-pale); color: var(--gold-deep); }
.bet-level:disabled { opacity: .4; cursor: not-allowed; }
.allin-btn { width: 100%; margin-bottom: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.low-chips { display: flex; align-items: center; gap: 8px; margin-top: 10px; background: #fdf3f2; border: 1px solid #eecac7; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--warn); }

/* ---------- 账号 ---------- */
.acct-form { display: grid; gap: 8px; }
.acct-form input { padding: 9px 11px; border: 1px solid #b9ccc1; border-radius: 8px; font-size: 14px; background: #fbfdfc; color: var(--ink); outline: none; }
.acct-form input:focus { border-color: var(--accent); }
.acct-info { display: grid; gap: 8px; }
.acct-line { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.acct-line.small { font-size: 12.5px; color: var(--gray); font-weight: 400; }
.acct-line img { border-radius: 8px; border: 1px solid var(--panel-border); }
.avatar-btn { position: relative; overflow: hidden; }

/* ---------- 奖励曲线 ---------- */
.curve-list { display: grid; gap: 5px; }
.curve-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 9px; border-radius: 7px; background: #f6f9f6; }
.curve-row b { color: var(--gold-deep); }
.curve-row.hot { background: var(--gold-pale); }
.curve-note { font-size: 11.5px; color: var(--gray); margin-top: 8px; }
.empty-note { color: var(--gray); font-size: 12.5px; }

/* ---------- 结算卡（全屏白面板） ---------- */
.modal { position: fixed; inset: 0; background: rgba(4, 16, 10, .66); display: grid; place-items: center; z-index: 50; }
.modal-card { background: var(--panel); border-radius: 18px; padding: 26px 30px; width: min(400px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.5); text-align: center; }
.settle-title { font-size: 15px; letter-spacing: 6px; color: var(--gray); margin-bottom: 14px; }
.settle-score b, .settle-mult b, .settle-payout b { display: block; font-variant-numeric: tabular-nums; }
.settle-score span, .settle-mult span, .settle-payout span { font-size: 12.5px; color: var(--gray); letter-spacing: 4px; }
.settle-score b { font-size: 46px; color: var(--ink); }
.settle-mult b { font-size: 26px; color: var(--accent); margin: 6px 0; }
.settle-payout b { font-size: 34px; color: var(--gold); }
.settle-payout.lose b { color: var(--warn); }
.settle-payout.flat b { color: var(--gray); }
.settle-note { font-size: 12px; color: var(--gray); margin: 12px 0 16px; }
#btn-settle-close { width: 100%; }

/* ---------- Toast / 页脚 ---------- */
.toast { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px); background: #12271c; color: #fff; padding: 10px 18px; border-radius: 10px; border: 1px solid #3d5c4c; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: 88vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.page-foot { text-align: center; color: #7fa08e; font-size: 12px; margin-top: 22px; }
.page-foot b { color: var(--gold-bright); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .stats-panel { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) {
  .stats-panel { grid-template-columns: repeat(2, 1fr); }
  .bet-levels { grid-template-columns: repeat(3, 1fr); }
}
