/* ============ 基础 ============ */
:root {
  --felt: #134236; --felt-dark: #0a241d;
  --wood: #5b3a22; --wood-dark: #2e1c10;
  --paper: #f5ecd7; --paper-dark: #e3d4b1; --ink: #2b2118;
  --gold: #e7b420; --gold-soft: #f3d77a; --accent: #f0c24b;
  --danger: #e0574f; --ok: #3fb67a;
  --cw: 96px; --chip: 60px;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "STSong", "SimSun", Georgia, serif;
  --num: "DIN Alternate", "Bahnschrift", "Roboto Condensed", "Arial Narrow", var(--font);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow-x: hidden; }
body {
  font-family: var(--font); color: #f4ead2; line-height: 1.4;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255,255,255,.07), transparent 62%),
    radial-gradient(ellipse at 50% 130%, rgba(0,0,0,.6), transparent 70%),
    url(/img/felt.webp?v=2) center / 900px auto repeat, var(--felt-dark);
  background-attachment: fixed;
  overscroll-behavior: none; -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
}
img { -webkit-user-drag: none; user-select: none; }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: not-allowed; opacity: .45; }
input, select { font: inherit; user-select: text; -webkit-user-select: text; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.ico { display: block; flex: none; }
.gem { display: inline-block; vertical-align: middle; object-fit: contain; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.45)); }
.hint { font-size: 12px; opacity: .45; }
.warn { color: #ffb4a8 !important; }

/* ============ 按钮 ============ */
.btn {
  border: 0; border-radius: 999px; padding: .62em 1.3em; font-weight: 700; letter-spacing: .03em;
  display: inline-flex; align-items: center; justify-content: center; gap: .4em; white-space: nowrap;
  background: linear-gradient(#fbe3a0, #e2b445 55%, #b98413); color: #3a2400;
  box-shadow: 0 2px 0 #7a5208, 0 6px 14px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.7);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 #7a5208, 0 3px 8px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.7); }
.btn.ghost { background: rgba(255,255,255,.08); color: #f4ead2; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.btn.ghost:hover:not(:disabled) { background: rgba(255,255,255,.15); }
.btn.dark { background: linear-gradient(#3b4a43, #22302a); color: #f4ead2; box-shadow: 0 2px 0 #0d1512, 0 6px 14px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.15); }
.btn.paper { background: #efe3c6; color: #5d4c35; box-shadow: inset 0 0 0 1px #cdbb94; }
.btn.sm { padding: .42em .95em; font-size: 13px; }
.btn.xs { padding: .2em .6em; font-size: 11px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: rgba(0,0,0,.28); border-radius: 50%; width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; color: #f3e6c4; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); position: relative; transition: background .15s; }
.icon-btn:hover { background: rgba(0,0,0,.45); color: #fff; }
.icon-btn .dot { position: absolute; top: 3px; right: 3px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--felt-dark); }

/* ============ 顶栏 ============ */
.topbar { position: sticky; top: 0; z-index: 30; height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: linear-gradient(rgba(8,26,20,.94), rgba(8,26,20,.8)); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(240,194,75,.18); }
.topbar .title { font-family: var(--serif); font-weight: 900; letter-spacing: .14em; color: var(--gold-soft); white-space: nowrap; font-size: 17px; }
.topbar .info { font-size: 12px; opacity: .7; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.ping { font-size: 11px; opacity: .75; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-family: var(--num); }
.ping i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; box-shadow: 0 0 6px var(--ok); }
.ping.mid i { background: #e8a33d; box-shadow: 0 0 6px #e8a33d; } .ping.bad i { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

/* ============ 纸面板（首页/大厅/弹窗） ============ */
.panel, .modal {
  background: linear-gradient(var(--paper), var(--paper-dark)); color: var(--ink); border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 18px 40px rgba(0,0,0,.45), 0 0 0 5px var(--wood), 0 0 0 6px var(--wood-dark);
}
.panel { padding: 22px; }
.panel h2, .modal h3 { margin: 0 0 14px; font-family: var(--serif); letter-spacing: .08em; font-size: 20px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: #6b5a44; margin-bottom: 6px; }
.seg { display: flex; background: rgba(0,0,0,.08); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 8px 0; font-weight: 700; color: #6b5a44; font-size: 14px; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid #cdbb94; background: #fffaf0; color: var(--ink); outline: none; }
.input:focus { border-color: #b98413; box-shadow: 0 0 0 3px rgba(231,180,32,.25); }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.divider { display: flex; align-items: center; gap: 10px; color: #8a7a5f; font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: #cdbb94; }
.code-input { text-transform: uppercase; letter-spacing: .35em; font-weight: 800; text-align: center; font-family: var(--num); }
.linkish { background: none; border: 0; color: #8a5a06; text-decoration: underline; padding: 0; font-size: 13px; }
.note { font-size: 13px; color: #6b5a44; line-height: 1.6; margin: 0 0 8px; }
.foot { margin-top: 16px; font-size: 11px; opacity: .55; line-height: 1.6; text-align: center; }
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #efe3c6; color: #6b5a44; font-weight: 700; margin-left: 6px; white-space: nowrap; vertical-align: 1px; }
.tag.host { background: #f5d76e; color: #5a3a00; } .tag.me { background: #cfe9da; color: #1d5c3a; }

/* 头像 */
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; position: relative; font-size: 15px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.22), 0 0 0 2px rgba(255,255,255,.18); }
.avatar .on { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #8d8d8d; box-shadow: 0 0 0 2px #10261f; }
.avatar .on.yes { background: var(--ok); }

/* ============ 首页 ============ */
.home { min-height: 100%; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.home-inner { width: min(980px, 100%); display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: center; }
.brand .hero { width: min(420px, 92%); display: block; margin: 0 0 4px -10px; filter: drop-shadow(0 18px 24px rgba(0,0,0,.5)); animation: float 6s ease-in-out infinite; }
.brand .logo-gems { display: flex; gap: 8px; margin-bottom: 10px; }
.brand .logo-gems img { width: 38px; height: 38px; animation: float 4s ease-in-out infinite; }
.brand .logo-gems img:nth-child(2n) { animation-delay: -1.3s; } .brand .logo-gems img:nth-child(3n) { animation-delay: -2.6s; }
@keyframes float { 50% { transform: translateY(-6px) rotate(3deg); } }
.brand h1 { font-family: var(--serif); font-size: clamp(40px, 6vw, 66px); margin: 0; letter-spacing: .12em; line-height: 1.1;
  background: linear-gradient(180deg, #fff6d6, #f0c24b 55%, #a87412); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.35)); }
.brand .sub { font-family: var(--serif); letter-spacing: .5em; opacity: .7; margin: 8px 0 14px; font-size: 12px; }
.brand p { opacity: .85; line-height: 1.8; max-width: 30em; margin: 0; }
.btn.block + .btn.block { margin-top: 10px; }
.mm-box { text-align: center; padding: 6px 0 2px; }
.mm-ring { width: 60px; height: 60px; margin: 4px auto 10px; border-radius: 50%; border: 4px solid rgba(185,132,19,.25); border-top-color: #b98413; animation: spin 1s linear infinite; }
.mm-box b { font-family: var(--num); font-size: 22px; }

/* ============ 大厅 ============ */
.lobby { min-height: calc(100% - 48px); display: grid; place-items: center; padding: 20px 14px calc(20px + var(--safe-b)); }
.lobby .panel { width: min(580px, 100%); }
.roomcode { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #fffaf0; border: 1px dashed #b99a62; border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; }
.roomcode b { font-size: 28px; letter-spacing: .28em; font-family: var(--num); }
.seats { display: grid; gap: 8px; margin-bottom: 16px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); min-height: 58px; flex-wrap: wrap; }
.seat.empty { background: transparent; border: 2px dashed #cdbb94; box-shadow: none; color: #8a7a5f; }
.seat .nm { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lv { display: inline-flex; gap: 3px; background: rgba(0,0,0,.06); padding: 2px; border-radius: 999px; }
.lv button { border: 0; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; background: transparent; color: #6b5a44; white-space: nowrap; }
.lv button.on { background: #2f4a3f; color: #fff; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }

/* ============ 弹窗 ============ */
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(4,14,11,.6); display: grid; place-items: center; padding: 16px; animation: fade .18s ease; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; animation: rise .26s cubic-bezier(.2,.8,.3,1.2); }
.modal.wide { width: min(640px, 100%); }
@keyframes rise { from { transform: translateY(24px) scale(.96); opacity: 0; } }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal .big-card { display: flex; gap: 16px; align-items: flex-start; }
.modal .big-card .card { --cw: 128px; }
.modal .big-card > div { flex: 1; min-width: 0; }
.paytable { width: 100%; border-collapse: collapse; font-size: 13px; }
.paytable th { font-weight: 600; color: #6b5a44; text-align: center; padding: 4px 2px; font-size: 12px; white-space: nowrap; }
.paytable td { text-align: center; padding: 5px 2px; border-top: 1px solid rgba(0,0,0,.08); white-space: nowrap; font-family: var(--num); font-size: 14px; }
.paytable td:first-child { text-align: left; font-family: var(--font); font-size: 13px; }
.paytable img { width: 16px; height: 16px; }
.paytable .tiny { border: 0; background: #efe3c6; border-radius: 6px; width: 24px; height: 24px; font-weight: 800; vertical-align: middle; }
.chipline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chipbtn { border: 0; background: transparent; padding: 2px; position: relative; border-radius: 50%; }
.chipbtn img { display: block; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
.chipbtn .n { position: absolute; right: -4px; top: -4px; background: #1b1b1b; color: #fff; border-radius: 999px; font-size: 11px; font-weight: 800; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; font-family: var(--num); }
.chipbtn.dim { opacity: .3; }
.return-pile { min-height: 56px; border-radius: 12px; border: 2px dashed #cdbb94; display: flex; gap: 6px; align-items: center; padding: 6px; flex-wrap: wrap; }
.standings { width: 100%; border-collapse: collapse; }
.standings td, .standings th { padding: 8px 6px; text-align: center; border-bottom: 1px solid rgba(0,0,0,.08); white-space: nowrap; }
.standings td { font-family: var(--num); font-size: 16px; }
.standings td:nth-child(2) { text-align: left; font-weight: 700; font-family: var(--font); font-size: 14px; }
.standings tr.win td { background: rgba(240,194,75,.25); }
.medal-img { width: 30px; height: 30px; object-fit: contain; display: block; margin: 0 auto; }
.trophy { text-align: center; margin: -4px 0 2px; }
.trophy-img { width: 116px; height: 116px; object-fit: contain; filter: drop-shadow(0 10px 14px rgba(0,0,0,.35)); animation: float 3s ease-in-out infinite; }
.trophy-img.hero-small { width: 170px; height: auto; }
.rules h4 { margin: 16px 0 6px; font-family: var(--serif); }
.rules p, .rules li { font-size: 14px; line-height: 1.75; color: #3d3226; }
.rules ul { padding-left: 1.2em; margin: 4px 0; }

/* ============ 抽屉 ============ */
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 92vw); z-index: 55; background: linear-gradient(#173b31, #0c221c);
  box-shadow: -10px 0 30px rgba(0,0,0,.5); transform: translateX(105%); transition: transform .26s cubic-bezier(.2,.8,.3,1); display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer .dh { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.drawer .tabs { display: flex; gap: 4px; flex: 1; }
.drawer .tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; opacity: .7; }
.drawer .tabs button.on { background: rgba(255,255,255,.12); opacity: 1; font-weight: 700; }
.drawer .body { flex: 1; overflow: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.drawer .foot2 { padding: 10px 12px calc(10px + var(--safe-b)); border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: 8px; }
.drawer .emotes { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.drawer .emotes button { border: 0; background: rgba(255,255,255,.08); border-radius: 10px; padding: 4px; display: grid; place-items: center; transition: transform .12s, background .12s; }
.drawer .emotes button:hover { background: rgba(255,255,255,.16); transform: translateY(-2px); }
.drawer .input { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.15); color: #fff; }
.msg-line { font-size: 13px; line-height: 1.5; word-break: break-word; }
.msg-line b { color: var(--gold-soft); }
.msg-line.sys { opacity: .6; font-style: italic; }
.log-line { font-size: 13px; line-height: 1.5; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.log-line img { width: 16px; height: 16px; }
.log-line .ico { color: var(--gold-soft); }
.emote-img { display: block; object-fit: contain; }

/* ============ 提示与特效 ============ */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 80; }
#fx > * { position: fixed; left: 0; top: 0; will-change: transform, opacity; }
#fx img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 6px 8px rgba(0,0,0,.45)); }
#toasts { position: fixed; left: 50%; top: 60px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: rgba(16,16,16,.9); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: toast 2.6s ease forwards; text-align: center; display: flex; align-items: center; gap: 6px; }
.toast img { width: 18px; height: 18px; }
.toast.err { background: rgba(160,40,36,.95); }
.toast.gold { background: linear-gradient(#fbe3a0, #e2b445); color: #3a2400; font-weight: 700; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }
.conn-banner { position: fixed; left: 0; right: 0; top: 48px; z-index: 40; background: #a8432c; color: #fff; text-align: center; font-size: 13px; padding: 6px; }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -3px; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.confetti { position: fixed; top: -12px; width: 10px; height: 14px; z-index: 85; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.banner { position: fixed; left: 50%; top: 40%; z-index: 70; transform: translate(-50%, -50%); pointer-events: none; text-align: center;
  font-family: var(--serif); font-weight: 900; font-size: clamp(26px, 5vw, 44px); letter-spacing: .2em; color: #fff3c9;
  text-shadow: 0 3px 0 rgba(0,0,0,.4), 0 0 30px rgba(240,194,75,.8); animation: banner 1.6s cubic-bezier(.2,.8,.3,1) forwards; white-space: nowrap; }
.banner small { display: block; font-size: .42em; letter-spacing: .1em; opacity: .85; margin-top: 4px; font-family: var(--font); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); } 30% { transform: translate(-50%, -50%) scale(1); } 78% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -62%); } }

@media (max-width: 720px) {
  .home-inner { grid-template-columns: 1fr; gap: 16px; }
  .brand { text-align: center; } .brand .hero { margin: 0 auto 4px; width: min(300px, 80%); }
  .brand .logo-gems { justify-content: center; } .brand p { margin: 0 auto; font-size: 14px; }
  .topbar { padding: 0 8px; gap: 6px; }
  .topbar .info, .ping { display: none; }
  .icon-btn { width: 33px; height: 33px; }
  .modal { padding: 16px; }
  .modal .big-card { flex-direction: column; align-items: center; }
  .modal .big-card .card { --cw: 112px; }
  .modal .big-card > div { width: 100%; }
  .opts { grid-template-columns: 1fr; }
}
@media (max-width: 380px) { .topbar .title { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* 抽屉关闭时不参与布局宽度；顶栏在窄屏压缩 */
html, body { overflow-x: clip; }
.drawer:not(.open) { visibility: hidden; transition: transform .26s cubic-bezier(.2,.8,.3,1), visibility 0s .26s; }
.topbar { min-width: 0; }
.topbar .room-btn { min-width: 0; overflow: hidden; }
@media (max-width: 720px) {
  .topbar .icon-btn[data-act="drawer"][data-tab="log"] { display: none; }
  .topbar .room-btn .rl { display: none; }
}
@media (max-width: 430px) {
  .topbar .title { display: none; }
  .topbar { gap: 5px; }
  .icon-btn { width: 32px; height: 32px; }
}
