* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #12261d; color: #eef5f0; overflow-x: hidden;
  -webkit-user-select: none; user-select: none;
}
[hidden] { display: none !important; }
h1 { margin: 0 0 6px; font-size: 28px; }
h2 { margin: 0 0 12px; font-size: 17px; color: #bfe3cd; }
.sub { margin: 0 0 18px; color: #9dbfaa; }
.hint { color: #8fae9b; font-size: 13px; line-height: 1.7; margin: 16px 0 0; }
.grow { flex: 1; }

.screen { min-height: 100%; display: flex; flex-direction: column; }
.screen.center { align-items: center; justify-content: center; padding: 16px; }
.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.panel { background: #1b3a2c; border: 1px solid #2c5742; border-radius: 14px; padding: 20px; }
.panel.narrow { width: 100%; max-width: 400px; text-align: center; }

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  background: #0d1c15; border-bottom: 1px solid #244a38; font-size: 15px;
}
.coins { color: #ffd766; font-weight: 700; }

input, select {
  font: inherit; color: #eef5f0; background: #10241b; border: 1px solid #36674f;
  border-radius: 8px; padding: 10px 12px; outline: none;
}
input:focus, select:focus { border-color: #5fd092; }
#loginForm { display: grid; gap: 12px; }
#loginForm input { text-align: center; font-size: 17px; }

.btn {
  font: inherit; font-weight: 600; color: #eef5f0; background: #2c5742; border: 0;
  border-radius: 8px; padding: 10px 18px; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.primary { background: #2fae6b; color: #06200f; }
.btn.danger { background: #b9433f; }
.btn.small { padding: 6px 12px; font-size: 13px; }

.formrow { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.formrow.end { justify-content: flex-end; margin-top: 16px; }
.formrow label { display: grid; gap: 6px; font-size: 13px; color: #9dbfaa; }

.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: #16301f; border-radius: 10px; margin-bottom: 8px;
}
.row .meta { color: #9dbfaa; font-size: 13px; }
.empty { color: #7f9c8a; text-align: center; padding: 22px 0; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: #2c5742; color: #cfe9da; }
.tag.ok { background: #2fae6b; color: #06200f; }
.tag.warn { background: #b9433f; color: #fff; }
.tag.gold { background: #ffd766; color: #3b2c00; }
.info { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 16px; font-size: 15px; }
.info b { color: #ffd766; }

/* ---------- 对局 ---------- */
#game { background: radial-gradient(ellipse at 50% 20%, #23794b, #114527 75%); }
.gamebar { font-size: 16px; }
.gamebar b { color: #ffd766; font-variant-numeric: tabular-nums; }
#rivals { display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; }
.rival {
  flex: 1 1 0; min-width: 130px; max-width: 260px; background: rgba(0, 0, 0, .28);
  border-radius: 10px; padding: 7px 10px; font-size: 13px;
}
.rival.me { outline: 2px solid #ffd766; }
.rival.out { opacity: .5; }
.rival .top { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.rival .nm { overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.bar { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .18); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #ffd766; border-radius: 99px; transition: width .25s; }

#board { position: relative; flex: 1; margin: 6px 10px 10px; touch-action: none; }
.slot, .card {
  position: absolute; width: var(--cw); height: var(--ch); border-radius: calc(var(--cw) * .09);
}
.slot {
  border: 2px dashed rgba(255, 255, 255, .28); display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cw) * .5); color: rgba(255, 255, 255, .3);
}
.stock { cursor: pointer; }
.card {
  background: #fdfdf8; color: #1c1c1c; box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
  border: 1px solid #b9b9ad; overflow: hidden; cursor: grab;
}
.card.red { color: #cf2331; }
.card .cn {
  position: absolute; left: 7%; top: 3%; font-size: calc(var(--cw) * .25); line-height: 1.02;
  font-weight: 800; text-align: center;
}
.card .pip { position: absolute; right: 8%; bottom: 3%; font-size: calc(var(--cw) * .6); line-height: 1; }
.card.back, .stock.full {
  border: calc(var(--cw) * .05) solid #fdfdf8; cursor: default;
  background: repeating-linear-gradient(45deg, #2a55b3 0 6px, #1f4191 6px 12px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}
.stock.full { cursor: pointer; color: transparent; }
.card.dragging { z-index: 1000 !important; box-shadow: 0 8px 18px rgba(0, 0, 0, .5); cursor: grabbing; }
.card.shake { animation: shake .28s; }
@keyframes shake { 25% { margin-left: -5px; } 75% { margin-left: 5px; } }

/* ---------- 浮层 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .65); z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#resList { text-align: left; margin-bottom: 16px; }
#resList .row.win { outline: 2px solid #ffd766; }
#toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 3000;
  background: #0b0f0d; color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}

.overlay.solid { background: #12261d; z-index: 4000; }

/* ---------- 手机 / Telegram 小程序 ---------- */
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
@media (max-width: 520px) {
  .wrap { padding: 10px; gap: 10px; }
  .panel { padding: 14px; }
  .topbar { padding: 8px 12px; gap: 10px; font-size: 14px; }
  .formrow label { flex: 1 1 28%; }
  .formrow select { width: 100%; padding: 9px 6px; }
  .formrow .btn { flex: 1 1 auto; }
  #rivals { padding: 6px 8px; gap: 6px; }
  .rival { min-width: 112px; font-size: 12px; padding: 6px 8px; }
  #board { margin: 4px 6px 8px; }
  .card .cn { font-size: calc(var(--cw) * .3); left: 5%; }
  .card .pip { font-size: calc(var(--cw) * .56); }
}

/* ---------- 品牌图标 ---------- */
.logo { display: block; width: 96px; height: 96px; margin: 0 auto 14px; border-radius: 22px; box-shadow: 0 6px 18px rgba(0, 0, 0, .45); }
.logo.small { width: 28px; height: 28px; margin: 0; border-radius: 7px; box-shadow: none; }

/* ---------- 个人练习 ---------- */
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.level {
  font: inherit; color: #eef5f0; background: #16301f; border: 1px solid #2c5742; border-radius: 10px;
  padding: 12px 6px; cursor: pointer; display: grid; gap: 4px; text-align: center;
}
.level:hover { border-color: #5fd092; }
.level b { font-size: 16px; }
.level span { font-size: 12px; color: #9dbfaa; }
.level i { font-style: normal; font-size: 12px; color: #ffd766; }
.level:nth-child(1) b { color: #7be0a4; } .level:nth-child(2) b { color: #b9e07b; }
.level:nth-child(3) b { color: #ffd766; } .level:nth-child(4) b { color: #ffa25e; }
.level:nth-child(5) b { color: #ff7b72; }
.solobar { flex: 1; display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, .28); border-radius: 10px; padding: 6px 10px; font-size: 14px; }
#soloTag { font-weight: 700; }
.formrow.center { justify-content: center; }
@media (max-width: 520px) {
  .levels { grid-template-columns: repeat(3, 1fr); }
  .level span { display: none; }
  .solobar { font-size: 13px; padding: 5px 8px; }
  .solobar .btn.small { padding: 6px 9px; }
}

/* ============ 首页 / 房间页的新皮肤：亮蓝卡片、粗描边、立体绿按钮 ============ */
.fun {
  --navy: #0f2f7a; --ink: #0d2a66;
  color: #fff; font-weight: 700;
  background: #33466e radial-gradient(rgba(255, 255, 255, .06) 2px, transparent 2.5px) 0 0 / 22px 22px;
}
#lobby.fun { height: 100vh; height: 100dvh; min-height: 0; }
.fun-head, .fun .topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 15px;
  background: linear-gradient(#3b8cff, #1f62d6); border-bottom: 3px solid var(--navy);
}
.fun-title, .fun .topbar b { font-size: 18px; font-weight: 900; text-shadow: 0 2px 0 var(--ink); }
.pill, #roomMe {
  background: var(--navy); border-radius: 99px; padding: 5px 13px; color: #ffe14d; font-weight: 900;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, .3);
}
.fun-body { flex: 1; overflow-y: auto; width: 100%; max-width: 560px; margin: 0 auto; padding: 12px 12px 18px; }

.tabs { display: flex; gap: 6px; padding: 0 6px; }
.tab {
  flex: 1; font: inherit; font-size: 18px; font-weight: 900; color: #fff; cursor: pointer;
  background: linear-gradient(#ffe04a, #ffbf0f); text-shadow: 0 2px 0 #a86a00;
  border: 3px solid var(--navy); border-bottom: 0; border-radius: 18px 18px 0 0; padding: 11px 6px 9px;
}
.tab.on { background: linear-gradient(#3b8cff, #2a74ea); text-shadow: 0 2px 0 var(--ink); }
.tabbox { border-top: 3px solid var(--navy); margin: 0 -2px; padding: 2px 2px 0; }

.banner { margin: 14px 0 12px; text-align: center; line-height: 1.35; font-size: 16px; font-weight: 900; color: #ffe14d; text-shadow: 0 2px 0 #1a2440; }
.sec { margin: 10px 4px 8px; font-size: 19px; font-weight: 900; text-shadow: 0 2px 0 #1a2440; }

.tile, .fun .panel {
  display: flex; align-items: center; gap: 11px; margin-bottom: 10px; padding: 10px;
  background: linear-gradient(#2f80f5, #1f62d6); border: 3px solid var(--navy); border-radius: 18px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .28), 0 3px 0 #0b2258;
}
.tile.col, .fun .panel { display: block; padding: 14px; }
.tile-ic {
  flex: none; width: 58px; height: 58px; border-radius: 13px; background: var(--navy);
  display: grid; place-items: center; font-size: 32px; box-shadow: inset 0 2px 0 rgba(0, 0, 0, .35);
}
.tile-main { flex: 1; min-width: 0; }
.tile-main b { display: block; font-size: 17px; font-weight: 900; text-shadow: 0 2px 0 var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-main span { display: block; margin-top: 2px; font-size: 13px; line-height: 1.35; color: #d6e6ff; }
.tile-side { flex: none; display: grid; gap: 6px; justify-items: end; }
.reward { font-size: 15px; font-weight: 900; text-shadow: 0 2px 0 var(--ink); white-space: nowrap; }
.chip { background: var(--navy); border-radius: 99px; padding: 6px 12px; font-size: 13px; color: #ffe14d; }

.gbtn, .fun .btn {
  font: inherit; font-size: 18px; font-weight: 900; color: #fff; cursor: pointer; white-space: nowrap;
  min-width: 92px; padding: 6px 18px; border-radius: 12px;
  background: linear-gradient(#93ff52, #22c400); text-shadow: 0 2px 0 #0a6a00;
  border: 3px solid #0a6a00; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .55), 0 3px 0 #064d00;
}
.gbtn:active, .fun .btn:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .55), 0 1px 0 #064d00; }
.gbtn:disabled, .fun .btn:disabled {
  background: linear-gradient(#b9c3d6, #8794ad); border-color: #55607a; text-shadow: 0 2px 0 #55607a;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .4), 0 3px 0 #414a60; opacity: 1; cursor: not-allowed; filter: none;
}
.gbtn.big { display: block; width: 100%; margin-top: 14px; padding: 11px; font-size: 20px; }
/* 房间页里的次要按钮：蓝色 */
.fun .btn:not(.primary) {
  background: linear-gradient(#6fb4ff, #2f7df0); text-shadow: 0 2px 0 var(--ink);
  border-color: var(--navy); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), 0 3px 0 #0b2258;
}
.fun .btn.primary { color: #fff; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 label { display: grid; gap: 5px; font-size: 14px; font-weight: 900; text-shadow: 0 2px 0 var(--ink); }
.fun select {
  width: 100%; font: inherit; font-weight: 900; color: #12306f; background: #fff;
  border: 3px solid var(--navy); border-radius: 11px; padding: 8px 8px;
}

.fun-nav {
  display: flex; gap: 4px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(#3b8cff, #1f62d6); border-top: 3px solid var(--navy);
}
.navbtn {
  flex: 1; display: grid; justify-items: center; gap: 1px; padding: 5px 0 6px; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 var(--ink);
  background: none; border: 0; border-radius: 13px;
}
.navbtn i { font-style: normal; font-size: 27px; line-height: 1.15; text-shadow: none; }
.navbtn.on { background: #63adff; box-shadow: inset 0 3px 0 rgba(255, 255, 255, .4), inset 0 -3px 0 rgba(0, 0, 0, .15); }

/* 房间页沿用原来的结构，只换皮 */
#room.fun .wrap { max-width: 560px; padding: 12px; }
#room.fun .info { font-weight: 900; text-shadow: 0 2px 0 var(--ink); }
#room.fun .info b { color: #ffe14d; }
#room.fun .row { background: var(--navy); border-radius: 13px; font-weight: 900; }
#room.fun .hint { color: #d6e6ff; font-weight: 700; }
#room.fun .formrow.end { justify-content: center; }
#room.fun .formrow .btn { flex: 1 1 auto; min-width: 0; }
#room.fun .tag { background: #2a4a9a; color: #fff; }
#room.fun .tag.ok { background: #22c400; color: #fff; }
#room.fun .tag.gold { background: #ffcf1a; color: #5a3d00; }
#room.fun .tag.warn { background: #e0483f; }

/* ============ 牌桌、弹窗、加载页也用新皮肤 ============ */
body { background: #33466e; }
.fun .row { background: var(--navy); border-radius: 13px; font-weight: 900; }
.fun .row .meta { color: #c3d8ff; font-weight: 700; }
.fun .sub { color: #d6e6ff; }
.fun h1 { font-weight: 900; text-shadow: 0 3px 0 var(--ink); }
.fun .coins { color: #ffe14d; text-shadow: 0 2px 0 var(--ink); }
.fun .btn.small { min-width: 0; font-size: 14px; padding: 4px 11px; border-width: 2px; border-radius: 10px; }
.fun .btn.danger {
  background: linear-gradient(#ff8a7a, #e0362c); text-shadow: 0 2px 0 #8a1711;
  border-color: #8a1711; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 3px 0 #5e0f0b;
}
.fun input {
  font: inherit; font-weight: 900; color: #12306f; background: #fff;
  border: 3px solid var(--navy); border-radius: 12px; padding: 10px 12px;
}

/* 牌桌：深蓝桌面，亮色只留给牌 */
#game.fun {
  background:
    radial-gradient(rgba(255, 255, 255, .05) 2px, transparent 2.5px) 0 0 / 22px 22px,
    radial-gradient(ellipse at 50% 18%, #4a68b5, #27365e 78%);
}
#game.fun .gamebar { font-size: 16px; }
#game.fun .gamebar b { color: #ffe14d; font-size: 17px; }
#game.fun #soloTag { text-shadow: 0 2px 0 var(--ink); }
.fun .rival, .fun .solobar {
  background: var(--navy); border: 2px solid #0a2057; border-radius: 13px; font-weight: 900;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .12);
}
.fun .rival.me { outline: 0; border-color: #ffe14d; }
.fun .bar { height: 9px; background: #0a2057; }
.fun .bar i { background: linear-gradient(#93ff52, #22c400); }
#game.fun .slot { border-color: rgba(255, 255, 255, .35); color: rgba(255, 255, 255, .32); }
#game.fun .card { border-color: #0f2f7a; box-shadow: 0 2px 0 rgba(8, 20, 60, .55); }
#game.fun .card.back, #game.fun .stock.full {
  border: calc(var(--cw) * .05) solid #fff;
  background: repeating-linear-gradient(45deg, #ffcf1a 0 6px, #ffb300 6px 12px);
  box-shadow: 0 2px 0 rgba(8, 20, 60, .55), 0 0 0 1px #0f2f7a;
}
#game.fun .card.dragging { box-shadow: 0 10px 18px rgba(8, 20, 60, .6); }

/* 弹窗 */
.overlay.fun { background: rgba(10, 18, 44, .74); }
.overlay.solid.fun { background: #33466e radial-gradient(rgba(255, 255, 255, .06) 2px, transparent 2.5px) 0 0 / 22px 22px; }
.overlay.fun .panel, #login.fun .panel { padding: 20px 16px; }
.overlay.fun .btn, #login.fun .btn { padding: 9px 22px; }
.overlay.fun .formrow.center { gap: 10px; }
.overlay.fun .formrow.center .btn { flex: 1; }
#resList .row.win { outline: 0; background: linear-gradient(#ffe04a, #ffbf0f); color: #4a3200; }
#resList .row.win .meta { color: #6b4a00; }
#resList .row.win .coins { color: #0a6a00; text-shadow: none; }
#toast { background: #0f2f7a; border: 2px solid #fff; font-weight: 900; }
