:root {
  --felt: #0f4a33;
  --felt-dark: #082a1d;
  --cream: #f6eedb;
  --gold: #e9c46a;
  --red: #c8312a;
  --edge: #1f7a4a;
  --back: #2a8a57;
  --trim: transparent;
  --felt-light: #17694a;
  --serif: "Songti SC", "STSong", "Noto Serif SC", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 30%, var(--felt-light) 0%, var(--felt) 45%, var(--felt-dark) 100%) fixed;
  transition: background .4s;
  color: var(--cream);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  display: flex; flex-direction: column; align-items: center;
  overflow: hidden; user-select: none; -webkit-user-select: none;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }

header {
  width: 100%; max-width: 560px; min-height: 52px; padding: 8px 16px 4px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
h1 {
  margin: 0; font-size: 22px; letter-spacing: 2px; font-family: var(--serif); font-weight: 900;
  color: var(--gold); text-shadow: 0 2px 0 #7a4b12; flex: 1;
}
.info { font-size: 13px; opacity: .9; text-align: right; line-height: 1.35; }
.info b { color: var(--gold); }
.icon-btn {
  background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.15); color: var(--cream);
  border-radius: 10px; padding: 6px 10px; font-size: 15px; cursor: pointer; white-space: nowrap;
}

/* ---------- 首页 ---------- */
.screen { width: 100%; display: flex; flex-direction: column; align-items: center; }
#home { padding: 24px 16px; gap: 18px; max-width: 420px; flex: 1; justify-content: center; }
.logo-tiles { display: flex; gap: 8px; }
.logo-tiles span {
  width: 58px; height: 76px; display: grid; place-items: center; border-radius: 9px;
  font: 900 36px var(--serif); color: var(--red);
  background: linear-gradient(160deg, #fffdf6, #f3ead2);
  box-shadow: 0 5px 0 #e6dcc0, 0 9px 0 var(--edge), 0 12px 16px rgba(0,0,0,.4);
  animation: bob 2.4s ease-in-out infinite;
}
.logo-tiles span:nth-child(2) { animation-delay: .15s; color: #1d7a46; }
.logo-tiles span:nth-child(3) { animation-delay: .3s; color: #1f4fa0; }
.logo-tiles span:nth-child(4) { animation-delay: .45s; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.tagline { margin: 4px 0 0; opacity: .85; font-size: 14px; text-align: center; }
.stat-card {
  width: 100%; padding: 14px 16px; border-radius: 14px; text-align: center;
  background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.1);
}
.stat-day { font-size: 13px; opacity: .75; margin-bottom: 4px; }
.stat-line { font-size: 15px; line-height: 1.6; }
.stat-line b { color: var(--gold); font-size: 18px; }
.who { font-size: 14px; opacity: .9; }
.who b { color: var(--gold); }
.account { font-size: 13px; opacity: .85; text-align: center; margin-top: -10px; }
.account b { color: var(--gold); }
.account .warn-dot { color: #ffd9a0; }
.link-btn { background: none; border: none; color: var(--cream); text-decoration: underline; opacity: .7; cursor: pointer; font-size: 13px; }
.home-btns { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 260px; margin-top: 6px; }

/* ---------- 牌桌 ---------- */
#play { flex: 1; min-height: 0; }
.banner {
  font-size: 12px; padding: 4px 12px; border-radius: 999px; margin-bottom: 4px;
  background: rgba(0,0,0,.3); color: #ffd9a0;
}
#stage { position: relative; flex: none; }
.tray {
  position: absolute; border-radius: 14px;
  background: linear-gradient(#6b3f1d, #4a2a12);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.15), inset 0 -3px 0 rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.4);
}
.tray-cell { position: absolute; border-radius: 8px; background: rgba(0,0,0,.25); }
.tray.danger { box-shadow: inset 0 2px 0 rgba(255,255,255,.15), 0 0 0 3px var(--red), 0 6px 18px rgba(0,0,0,.4); }
.temp-zone { position: absolute; border-radius: 12px; border: 2px dashed rgba(255,255,255,.12); }

.tile {
  position: absolute; cursor: pointer;
  width: var(--w); height: var(--h);
  border-radius: calc(var(--w) * .14);
  background: linear-gradient(160deg, #fffdf6 0%, #f3ead2 100%);
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.08),
    inset 0 0 0 calc(var(--w) * .05) var(--trim),
    0 calc(var(--w) * .07) 0 #e6dcc0,
    0 calc(var(--w) * .12) 0 var(--edge),
    0 calc(var(--w) * .14) calc(var(--w) * .12) rgba(0,0,0,.45);
  transition: left .28s cubic-bezier(.2,.8,.3,1), top .28s cubic-bezier(.2,.8,.3,1),
              transform .25s, opacity .3s, filter .2s;
}
.tile svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.tile.locked { filter: brightness(.5) saturate(.6); cursor: default; }
.tile.back { background: repeating-linear-gradient(45deg, var(--back) 0 6px, var(--edge) 6px 12px); }
.tile.back svg { visibility: hidden; }
@media (hover: hover) { .tile.free:hover { transform: translateY(-3px); } }
.tile.shake { animation: shake .25s; }
.tile.pop { transform: scale(1.25); opacity: 0; transition: transform .25s ease-in, opacity .25s ease-in; }
.tile.flip { animation: flip .4s; }
@keyframes shake { 0%,100% { margin-left: 0 } 25% { margin-left: -4px } 75% { margin-left: 4px } }
@keyframes flip { 50% { transform: rotateY(90deg) scale(.9); } }

.burst {
  position: absolute; pointer-events: none; z-index: 2000; white-space: nowrap;
  font-family: var(--serif); font-weight: 900;
  color: #fff1c2; -webkit-text-stroke: 2px var(--red);
  text-shadow: 0 4px 0 #7a1410, 0 0 20px rgba(255,200,80,.8);
  transform: translate(-50%, -50%) scale(.3); opacity: 0;
  animation: burst .8s ease-out forwards;
}
.burst.small { -webkit-text-stroke: 0; text-shadow: 0 2px 6px rgba(0,0,0,.6); color: #ffe6a8; }
@keyframes burst {
  20% { transform: translate(-50%, -70%) scale(1.25); opacity: 1; }
  60% { transform: translate(-50%, -90%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -130%) scale(1); opacity: 0; }
}

.tools { display: flex; gap: 10px; padding: 10px 16px 14px; justify-content: center; flex-wrap: wrap; }
.tool {
  position: relative; min-width: 84px; padding: 10px 14px; border-radius: 14px; border: none;
  font-size: 15px; font-weight: 700; color: #3b2208; cursor: pointer; font-family: inherit;
  background: linear-gradient(#ffe9a8, #e9b949);
  box-shadow: 0 4px 0 #a5731c, 0 6px 12px rgba(0,0,0,.35);
  transition: transform .1s, box-shadow .1s, filter .2s;
}
.tool:active { transform: translateY(3px); box-shadow: 0 1px 0 #a5731c; }
.tool:disabled { filter: grayscale(1) brightness(.7); cursor: not-allowed; }
.tool.big { font-size: 20px; padding: 14px; }
.tool.ghost { background: rgba(255,255,255,.1); color: var(--cream); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.tool .badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--felt);
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); z-index: 5000; padding: 16px;
}
.modal.show { display: flex; }
.card {
  background: linear-gradient(#fffaf0, #f1e4c3); color: #3b2208; border-radius: 20px;
  padding: 22px 22px; text-align: center; max-width: 360px; width: 100%; max-height: 88vh; overflow: auto;
  box-shadow: 0 10px 0 #a5731c, 0 20px 40px rgba(0,0,0,.5);
  animation: rise .35s cubic-bezier(.2,1.4,.4,1);
}
@keyframes rise { from { transform: translateY(30px) scale(.9); opacity: 0; } }
.card h2 { margin: 0 0 8px; font-size: 36px; color: var(--red); font-family: var(--serif); font-weight: 900; }
.card p { margin: 0 0 14px; font-size: 15px; line-height: 1.6; }
.card .big-num { font: 900 44px var(--serif); color: var(--red); line-height: 1.1; }
.card .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.card .tool.ghost { color: #3b2208; box-shadow: inset 0 0 0 1px rgba(59,34,8,.3); background: transparent; }
.card input {
  width: 100%; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid #c9b48a;
  margin-bottom: 14px; font-family: inherit; background: #fffdf6;
}
.board-list { list-style: none; padding: 0; margin: 0 0 12px; text-align: left; font-size: 14px; }
.board-list li { display: flex; gap: 10px; padding: 7px 4px; border-bottom: 1px dashed rgba(59,34,8,.15); }
.board-list .rk { width: 2em; text-align: center; font-weight: 700; }
.board-list .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list li.me { background: rgba(233,196,106,.35); border-radius: 6px; }
.muted { opacity: .65; font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: rgba(0,0,0,.8); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 14px;
  transition: all .25s; z-index: 6000; pointer-events: none;
  white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.form-err { color: var(--red); font-size: 13px; min-height: 1.4em; margin: -8px 0 8px; text-align: left; }
.form-hint { font-size: 12px; opacity: .7; text-align: left; margin: -8px 0 12px; }
.card .switch { margin-top: 12px; font-size: 13px; }
.card .switch button { color: #3b2208; }

.seg { display: flex; background: rgba(59,34,8,.08); border-radius: 10px; padding: 3px; margin: -2px 0 12px; }
.seg button { flex: 1; border: none; background: none; padding: 7px; border-radius: 8px; font: inherit; font-size: 14px; color: #6b5233; cursor: pointer; }
.seg button.on { background: #fffdf6; color: #3b2208; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.card select { width: 100%; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid #c9b48a; margin-bottom: 14px; background: #fffdf6; font-family: inherit; }
table.vs { width: 100%; margin: 6px 0 14px; border-collapse: collapse; }
table.vs th { font-size: 13px; font-weight: 400; opacity: .7; padding-bottom: 4px; }
table.vs td { font: 900 20px var(--serif); color: var(--red); text-align: center; }
table.vs td.muted { font: 13px inherit; color: inherit; }

/* ---------- 皮肤：桌布 ---------- */
header, .screen { position: relative; z-index: 1; }
.felt { background: radial-gradient(ellipse at 50% 30%, var(--felt-light) 0%, var(--felt) 45%, var(--felt-dark) 100%); position: relative; overflow: hidden; }
body.tt-texture::before, .swatch.tt-texture::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1.4px); background-size: 7px 7px;
}
.swatch.tt-texture::before { position: absolute; }
body.tt-vignette, .swatch.tt-vignette { box-shadow: inset 0 0 120px rgba(0,0,0,.55), inset 0 0 0 3px rgba(233,196,106,.35); }
body.tt-drift::before, .swatch.tt-drift::before { animation: drift 18s linear infinite; }
@keyframes drift { to { background-position: 140px 70px; } }
body.tt-sparkle::after, .swatch.tt-sparkle::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(2px 2px at 12% 20%, #fff8, transparent), radial-gradient(2px 2px at 78% 12%, #ffe08a, transparent),
    radial-gradient(1.5px 1.5px at 40% 70%, #fff9, transparent), radial-gradient(2px 2px at 88% 64%, #ffe08a, transparent),
    radial-gradient(1.5px 1.5px at 22% 88%, #fff8, transparent), radial-gradient(2px 2px at 60% 35%, #fff7, transparent);
  animation: twinkle 3s ease-in-out infinite alternate;
}
.swatch.tt-sparkle::after { position: absolute; }
@keyframes twinkle { from { opacity: .35; } to { opacity: 1; } }

/* ---------- 皮肤：牌背 ---------- */
.tb-pattern .tile {
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.08), inset 0 0 0 calc(var(--w) * .05) var(--trim),
    0 calc(var(--w) * .07) 0 #e6dcc0, 0 calc(var(--w) * .095) 0 var(--back), 0 calc(var(--w) * .13) 0 var(--edge),
    0 calc(var(--w) * .15) calc(var(--w) * .12) rgba(0,0,0,.45);
}
.tb-shimmer .tile { overflow: hidden; }
.tb-shimmer .tile::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%);
  background-size: 250% 100%; animation: sheen 3.2s ease-in-out infinite;
}
@keyframes sheen { from { background-position: 130% 0; } to { background-position: -30% 0; } }
.tb-glow .tile.free { filter: drop-shadow(0 0 calc(var(--w) * .1) var(--back)); }

/* ---------- 皮肤：碰特效 ---------- */
.particle { position: absolute; z-index: 2001; pointer-events: none; transform: translate(-50%, -50%); animation: fly .9s ease-out forwards; }
.particle.dot { width: 8px; height: 8px; border-radius: 50%; }
@keyframes fly { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.4); opacity: 0; } }
.flash { position: absolute; inset: -40px; z-index: 1999; pointer-events: none; opacity: .35; animation: flash .35s ease-out forwards; }
@keyframes flash { to { opacity: 0; } }
.shake-stage { animation: shakeStage .35s; }
@keyframes shakeStage { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, -1px); } 80% { transform: translate(2px, 1px); } }

/* ---------- 首页形象与入口 ---------- */
.me-card { display: flex; align-items: center; gap: 12px; }
.avatar-btn { border: none; background: none; padding: 0; cursor: pointer; border-radius: 50%; line-height: 0;
  box-shadow: 0 0 0 3px rgba(255,255,255,.15); transition: transform .15s; }
.avatar-btn:active { transform: scale(.94); }
.btn-row { display: flex; gap: 10px; }
.btn-row .tool { flex: 1; min-width: 0; padding: 10px 6px; }
.mini-av { line-height: 0; flex: none; }
.board-list li { align-items: center; }
.challenger-av { display: flex; justify-content: center; margin-bottom: 4px; }
.gift { color: #a86b00; font-weight: 700; }
.av-glow { animation: twinkle 1.6s ease-in-out infinite alternate; }

/* ---------- 抽奖 ---------- */
.gacha-stage { display: flex; justify-content: center; perspective: 600px; margin: 4px 0 14px; }
.gacha-card {
  width: 150px; min-height: 196px; border-radius: 16px; padding: 14px 8px; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: #fffdf6; box-shadow: 0 6px 0 #c9b48a, 0 12px 24px rgba(0,0,0,.25);
}
.gacha-card.back { background: repeating-linear-gradient(45deg, #c8312a 0 10px, #b3261e 10px 20px); }
.gacha-card.back span { font: 900 64px var(--serif); color: #ffe9a8; }
.gacha-card.spinning { animation: spin .9s ease-in-out; }
@keyframes spin { 50% { transform: rotateY(180deg) scale(1.08); } 100% { transform: rotateY(360deg); } }
.gacha-card.s2 { box-shadow: 0 6px 0 #42a5f5, 0 0 24px rgba(66,165,245,.6); }
.gacha-card.s3 { box-shadow: 0 6px 0 #ab47bc, 0 0 32px rgba(255,193,7,.9); animation: pop .5s; }
@keyframes pop { 50% { transform: scale(1.12); } }
.gacha-card .new { position: absolute; top: 8px; right: 8px; background: #c8312a; color: #fff; font: 700 11px sans-serif; padding: 2px 6px; border-radius: 6px; font-style: normal; }
.g-name { font-weight: 700; margin-top: 6px; }
.g-cat { font-size: 12px; opacity: .6; }
.big-inline { font-size: 20px; color: var(--red); }
.stars { color: #e0a100; letter-spacing: 1px; font-size: 13px; }
.stars .off { color: rgba(59,34,8,.18); }
table.odds { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
table.odds th, table.odds td { padding: 6px; border-bottom: 1px dashed rgba(59,34,8,.15); }

/* ---------- 衣柜 ---------- */
.seg button { padding: 7px 2px; }
.skin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.skin-cell { background: rgba(255,255,255,.6); border-radius: 12px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 2px solid transparent; }
.skin-cell.equipped { border-color: #e0a100; background: #fff8e1; }
.skin-cell.locked .skin-pic { filter: grayscale(1) opacity(.45); }
.skin-pic { position: relative; height: 60px; display: flex; align-items: center; justify-content: center; }
.skin-pic .lock { position: absolute; font-size: 18px; filter: none; }
.skin-name { font-size: 13px; font-weight: 700; }
.skin-cnt { font-size: 11px; opacity: .6; }
.skin-acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; min-height: 22px; }
.mini { font: inherit; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid #c9b48a; background: #fffdf6; color: #3b2208; cursor: pointer; }
.mini.on { background: #e9c46a; border-color: #e9c46a; }
.mini.gold { background: linear-gradient(#ffe9a8, #e9b949); border-color: #c9952a; font-weight: 700; }
.skin-prev { display: flex; align-items: center; justify-content: center; }
.skin-prev .tile { cursor: default; }
.swatch { border-radius: 10px; }
.fx-prev { position: relative; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: #2b2b2b; }
.fx-prev span { font-family: var(--serif); font-weight: 900; }
.fx-prev i { position: absolute; right: 2px; top: 0; font-style: normal; font-size: 14px; }
/* 弹窗是浅色底，链接要用深色 */
.card .link-btn { color: #8a5a1c; opacity: 1; }

/* ---------- 小人陪伴 ---------- */
.tools { align-items: flex-end; }
.tools .tool { min-width: 72px; padding: 10px 10px; }
.mascot { position: relative; flex: none; }
.mascot-av { border: none; background: none; padding: 0; cursor: pointer; line-height: 0; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.mascot-av.hop { animation: hop .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes hop { 40% { transform: translateY(-12px) rotate(-6deg); } }
.bubble {
  position: absolute; z-index: 3000; background: #fffdf6; color: #3b2208; font-size: 13px; line-height: 1.45;
  padding: 7px 10px; border-radius: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.3); pointer-events: none;
}
.bubble b { color: var(--red); }
.bubble::after { content: ''; position: absolute; border: 7px solid transparent; }
.mascot .bubble { bottom: calc(100% + 10px); left: -4px; width: max-content; max-width: min(240px, 70vw); }
.mascot .bubble::after { top: 100%; left: 18px; border-top-color: #fffdf6; }
.bubble.pop { animation: bubblePop .3s cubic-bezier(.3,1.5,.5,1); }
@keyframes bubblePop { from { transform: scale(.6) translateY(8px); opacity: 0; } }
.home-av-wrap { position: relative; }
.home-bubble { bottom: calc(100% + 8px); left: -6px; width: max-content; max-width: 220px; pointer-events: none;
  animation: bubblePop .4s cubic-bezier(.3,1.5,.5,1), float 2.6s ease-in-out .4s infinite; }
.home-bubble::after { top: 100%; left: 30px; border-top-color: #fffdf6; }
@keyframes float { 50% { transform: translateY(-4px); } }
.me-card { margin-top: 34px; }

/* ---------- 通关小人卡片 ---------- */
.hero { position: relative; display: flex; flex-direction: column; align-items: center; margin: 2px 0 10px; }
.hero-av { line-height: 0; border-radius: 50%; box-shadow: 0 0 0 4px #fff, 0 6px 16px rgba(0,0,0,.18); }
.hero.happy .hero-av { animation: cheer 1s ease-in-out infinite alternate; }
.hero.sad .hero-av { filter: saturate(.8); animation: sway 2.4s ease-in-out infinite; }
@keyframes cheer { to { transform: translateY(-6px) rotate(3deg); } }
@keyframes sway { 50% { transform: rotate(-4deg); } }
.hero-bubble { position: relative; margin-top: 12px; background: #fff; border-radius: 14px; padding: 8px 14px;
  font-size: 15px; line-height: 1.55; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.hero-bubble::before { content: ''; position: absolute; bottom: 100%; left: 50%; margin-left: -8px;
  border: 8px solid transparent; border-bottom-color: #fff; }
.hero-bubble b { color: var(--red); }
.confetti { position: absolute; top: 0; left: 50%; width: 8px; height: 8px; pointer-events: none;
  box-shadow: -70px 10px #e63946, -40px -6px #f4a261, -10px 14px #2a9d8f, 30px -8px #e9c46a, 60px 8px #457b9d,
              -85px 40px #ffb703, 85px 36px #8338ec, -55px 60px #06d6a0, 55px 64px #ef476f;
  border-radius: 2px; animation: confetti 1.6s ease-out infinite; }
.confetti.c2 { animation-delay: .5s; transform: scale(.8); }
.confetti.c3 { animation-delay: 1s; transform: rotate(40deg); }
@keyframes confetti { from { opacity: 1; transform: translateY(-10px); } to { opacity: 0; transform: translateY(70px) rotate(90deg); } }

/* ---------- 分享图 ---------- */
.share-img { width: 100%; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.2); margin-bottom: 10px; user-select: auto; -webkit-user-select: auto; -webkit-touch-callout: default; }
