/* 百兵弈 · 基础样式 + 启动页（大厅见 lobby.css，对局见 game.css） */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1514; color: #eaf2e6;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
button { font-family: inherit; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; max-width: 560px; margin: 0 auto; overflow: hidden; background: #0b1514; }
.screen { position: absolute; inset: 0; }
:root {
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px));
  --content-top: calc(var(--safe-top) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --ink: #07100f; --ink2: #122120; --paper: #eaf2e6; --paper2: #b9cfc4; --red: #d9463c; --red2: #8e241c;
  --gold: #e8c26a; --gold2: #b08a2e; --jade: #3fbf94; --jade2: #1f7a5c; --blue: #3f8fd8;
  --panel: rgba(16, 32, 31, .94); --panel2: #1c3533; --line: rgba(232, 194, 106, .32);
  --kai: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", "STSong", serif;
}
.kai { font-family: var(--kai); }
.stroke { text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink), 1px 1px 0 var(--ink), -1px -1px 0 var(--ink); }

/* ---------- 按钮 ---------- */
.btn { position: relative; border: 2px solid var(--ink); border-radius: 10px; padding: 8px 16px; font-size: 15px; font-weight: 900; color: #fff; cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), 0 3px 0 var(--ink); transition: transform .06s, filter .1s; letter-spacing: 1px; white-space: nowrap; }
.btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25), 0 1px 0 var(--ink); }
.btn:disabled { filter: grayscale(.85) brightness(.75); pointer-events: none; }
.btn-gold { background: linear-gradient(#ffe39a, var(--gold) 50%, var(--gold2)); color: #3b1f06; text-shadow: 0 1px 0 rgba(255,255,255,.45); }
.btn-red { background: linear-gradient(#ff7a6a, var(--red) 55%, var(--red2)); text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.btn-jade { background: linear-gradient(#7fe0b0, var(--jade) 55%, var(--jade2)); text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.btn-blue { background: linear-gradient(#8fc0ff, var(--blue) 55%, #24539a); text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.btn-gray { background: linear-gradient(#a59a8a, #75695a 55%, #54493d); }
.btn-ink { background: linear-gradient(#2c4a47, #142625); color: var(--paper); border-color: var(--gold2); }
.btn-xl { font-size: 22px; padding: 12px 40px; border-radius: 14px; font-family: var(--kai); letter-spacing: 6px; }
.btn-sm { font-size: 12px; padding: 4px 10px; border-radius: 8px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 2px 0 var(--ink); }
.dot-red::after { content: ''; position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; border-radius: 50%; background: #ff3b3b; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--ink); }

/* ---------- 弹窗 / 提示 ---------- */
/* 弹窗避开 Telegram 全屏模式顶部的「关闭 / ⌄ / ⋮」按钮区（content-top），否则右上角 ✕ 会被盖住点不到 */
.mask { position: fixed; inset: 0; background: rgba(3,8,8,.74); display: flex; align-items: center; justify-content: center; z-index: 50; padding: calc(var(--content-top) + 12px) 16px calc(var(--safe-bottom) + 12px); animation: fadeIn .15s; }
.modal { width: 100%; max-width: 420px; max-height: calc(100vh - 24px - var(--content-top) - var(--safe-bottom)); max-height: calc(100dvh - 24px - var(--content-top) - var(--safe-bottom)); display: flex; flex-direction: column;
  background: linear-gradient(#1f3a37, #122423); border: 2px solid var(--gold2); border-radius: 16px; box-shadow: 0 0 0 3px var(--ink), 0 18px 40px rgba(0,0,0,.6); overflow: hidden; animation: popIn .18s; }
.modal-head { position: relative; padding: 12px 44px; text-align: center; background: linear-gradient(90deg, transparent, rgba(63,191,148,.45), transparent); border-bottom: 1px solid var(--line); }
.modal-title { font-family: var(--kai); font-size: 21px; font-weight: 900; color: #ffeab8; letter-spacing: 3px; text-shadow: 0 2px 0 var(--ink); }
.modal-close { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--ink); background: var(--red); color: #fff; font-weight: 900; cursor: pointer; }
.modal-body { padding: 14px; overflow-y: auto; flex: 1; }
.modal-body::-webkit-scrollbar { display: none; }
.modal-foot { display: flex; gap: 10px; justify-content: center; padding: 10px 14px 14px; border-top: 1px solid rgba(232,176,74,.18); }
.confirm-text { text-align: center; font-weight: 700; line-height: 1.7; white-space: pre-line; }
#toast-root { position: fixed; left: 0; right: 0; top: 38%; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 99; }
.toast { background: rgba(8,18,17,.94); border: 1px solid var(--gold2); color: #ffeab8; padding: 9px 18px; border-radius: 20px; font-weight: 700; font-size: 14px; max-width: 86%; text-align: center; animation: toastIn .2s; }
@keyframes fadeIn { from { opacity: 0 } }
@keyframes popIn { from { transform: scale(.85); opacity: 0 } }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0 } }
body.api-busy::before { content: ''; position: fixed; top: 0; left: 0; height: 3px; width: 40%; background: linear-gradient(90deg, transparent, var(--gold), transparent); z-index: 100; animation: busy 1s linear infinite; }
@keyframes busy { from { transform: translateX(-100%) } to { transform: translateX(260%) } }

/* ---------- 奖励 ---------- */
.rewards { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.rw { position: relative; width: 70px; min-height: 78px; border-radius: 12px; border: 2px solid var(--qc, rgba(255,255,255,.25)); background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.12), rgba(0,0,0,.35));
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 2px 4px; box-shadow: inset 0 0 12px color-mix(in srgb, var(--qc, #000) 35%, transparent); }
.rw i { font-style: normal; font-size: 28px; line-height: 1; }
.rw img { width: 38px; height: 38px; object-fit: contain; }
.rw.frag img { filter: drop-shadow(0 0 3px #ffd24a); }
.rw-name { font-size: 11px; font-weight: 700; margin-top: 3px; text-align: center; line-height: 1.2; color: var(--paper); }
.rw-n { position: absolute; right: 4px; top: 2px; font-size: 12px; color: #ffe39a; text-shadow: 0 1px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink); }

/* ---------- 启动页 ---------- */
.boot { display: flex; flex-direction: column; align-items: center; overflow: hidden;
  background: radial-gradient(ellipse 90% 55% at 50% 36%, #1f4a43 0%, #0f2624 55%, #050c0c 100%); }
.boot-ink { position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 80% 11%, rgba(240,210,130,.9) 0 34px, rgba(240,210,130,.25) 38px, transparent 80px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 160' preserveAspectRatio='none'%3E%3Cpath d='M0 160V92l40-34 34 22 50-56 44 40 30-20 52 46 40-32 46 28 42-38 22 18v94z' fill='%23000' fill-opacity='.45'/%3E%3Cpath d='M0 160v-40l56-24 42 20 64-36 48 32 44-16 60 28 46-22 40 16v42z' fill='%23000' fill-opacity='.6'/%3E%3C/svg%3E") bottom / 100% 42% no-repeat; }
#boot-art { position: relative; width: min(74vw, 300px); height: min(74vw, 300px); margin-top: calc(var(--content-top) + 18px); }
.boot-logo { position: relative; margin-top: -26px; text-align: center; }
.boot-logo span { display: block; font-family: var(--kai); font-size: 70px; font-weight: 900; letter-spacing: 12px; padding-left: 12px; line-height: 1.1;
  background: linear-gradient(180deg, #fff6d6 0%, #ffd97a 45%, #e39a2e 72%, #a8621a 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #06302a) drop-shadow(0 0 18px rgba(120,230,190,.35)); }
.boot-logo small { display: inline-flex; align-items: center; gap: 10px; margin-top: 6px; font-family: var(--kai); font-size: 16px; letter-spacing: 5px; color: #f6dfae;
  text-shadow: 0 2px 4px rgba(0,0,0,.8); }
.boot-logo small::before, .boot-logo small::after { content: ''; width: 34px; height: 1px; background: linear-gradient(90deg, transparent, #e8b04a); }
.boot-logo small::after { transform: scaleX(-1); }
.boot-bottom { position: absolute; bottom: calc(var(--safe-bottom) + 16px); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 20px; }
#boot-status { font-weight: 800; font-size: 14px; color: #ffe8b0; letter-spacing: 2px; text-shadow: 0 2px 4px rgba(0,0,0,.9); }
#boot-status.err { color: #ff9a8a; }
.boot-bar { width: 66%; max-width: 280px; height: 8px; background: rgba(0,0,0,.55); border: 1px solid rgba(232,176,74,.6); border-radius: 6px; overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #1f7a5c, #3fbf94, #ffe39a); transition: width .2s; }
.boot-tip { font-size: 10px; line-height: 1.6; text-align: center; color: rgba(243,226,190,.5); }
.maint-root { position: fixed; inset: 0; z-index: 90; background: rgba(3,8,8,.86); display: flex; align-items: center; justify-content: center; padding: 20px; }
.maint-box { background: var(--panel); border: 2px solid var(--gold2); border-radius: 16px; padding: 24px; text-align: center; max-width: 340px; }
.maint-ic { font-size: 48px; } .maint-t { font-family: var(--kai); font-size: 24px; margin: 6px 0; } .maint-msg { line-height: 1.6; margin-bottom: 6px; } .maint-sub { opacity: .6; font-size: 12px; margin-bottom: 14px; }

/* 激励广告 */
.ad-cover { position: fixed; inset: 0; z-index: 9000; background: #000; display: flex; align-items: center; justify-content: center; }
.ad-video { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.ad-tip { position: absolute; top: calc(var(--content-top) + 12px); right: 12px; background: rgba(0,0,0,.6); color: #fff; padding: 6px 12px; border-radius: 16px; font-weight: 900; font-size: 14px; }
/* 居中不用 transform：.btn:active 的按下位移会覆盖 transform，导致点击时按钮跳到右边 */
.ad-done { position: absolute; bottom: calc(var(--safe-bottom) + 40px); left: 0; right: 0; margin: 0 auto; width: 60%; max-width: 320px; font-size: 18px; padding: 12px 20px; }
.ad-more { position: absolute; bottom: calc(var(--safe-bottom) + 110px); left: 0; right: 0; margin: 0 auto; width: fit-content; }
.ad-tapany { position: absolute; bottom: calc(var(--safe-bottom) + 12px); left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 800; color: #fff; opacity: .75; }
