:root {
  color-scheme: dark;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #eef3ff;
  background: radial-gradient(circle at top right, #162642 0%, #0b1220 55%, #070b14 100%);
  min-height: 100%;
  --surface: #131d30;
  --surface-2: #0e1626;
  --border: #263650;
  --muted: #98abc7;
  --accent: #5ce8ce;
  --gold: #ffd166;
  --danger: #ff7b89;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
main { width: min(100% - 2.5rem, 74rem); margin: 0 auto; padding: clamp(1.8rem, 4vw, 3.5rem) 0 4rem; }
p { margin: 0; }

.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 1.8rem; }
.eyebrow { font-size: .78rem; letter-spacing: .12em; color: var(--accent); font-weight: 700; margin-bottom: .45rem; }
h1 { margin: 0 0 .45rem; font-size: clamp(1.8rem, 4.2vw, 2.75rem); letter-spacing: -.03em; line-height: 1.1; }
h2 { margin: 0; font-size: 1.15rem; font-weight: 650; }
.muted, .hero p { color: var(--muted); font-size: .9rem; }
.hero-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: .5rem; border: 1px solid var(--border); border-radius: 999px; padding: .45rem .85rem; font-size: .88rem; background: var(--surface); }
.badge::before { content: ""; width: .52rem; height: .52rem; border-radius: 50%; background: currentColor; }
.badge[data-state="online"] { color: var(--accent); border-color: #2c6564; }
.badge[data-state="offline"] { color: var(--danger); border-color: #6b2f3b; }

button { color: inherit; background: #1c2a42; border: 1px solid #354b6e; border-radius: .6rem; padding: .52rem .9rem; font: inherit; font-size: .9rem; cursor: pointer; transition: background .15s, border-color .15s; }
button:hover { background: #263958; border-color: #4d6a98; }
button:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: linear-gradient(135deg, #1d7a72, #185c75); border-color: #3da8a0; color: #f3fffd; font-weight: 600; }
.btn-primary:hover { background: linear-gradient(135deg, #239087, #1f6f8d); }
.btn-bili { display: inline-flex; align-items: center; gap: .45rem; text-decoration: none; color: #fff0f5; background: linear-gradient(135deg, #d94c7a, #fb7299); border: 1px solid #ff9cb8; border-radius: .6rem; padding: .5rem .88rem; font-size: .88rem; font-weight: 650; transition: filter .15s, transform .15s; }
.btn-bili:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-bili svg { width: 1.05rem; height: 1.05rem; flex-shrink: 0; }
.site-footer { margin-top: 2.4rem; padding-top: 1.2rem; border-top: 1px solid var(--border); text-align: center; font-size: .86rem; color: var(--muted); display: flex; justify-content: center; align-items: center; gap: .35rem; flex-wrap: wrap; }
.site-footer a { color: #ff8fb1; font-weight: 650; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.btn-sm { padding: .3rem .62rem; font-size: .82rem; border-radius: .45rem; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; margin-bottom: 1.4rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: .95rem; padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .32rem; }
.stat-card.accent { background: linear-gradient(145deg, #122a36, #131f33); border-color: #2f696e; }
.stat-label { font-size: .82rem; color: var(--muted); }
.stat-value { font-size: clamp(1.4rem, 2.8vw, 2.1rem); font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-sub { font-size: .82rem; color: var(--muted); }

.lookup-bar { background: var(--surface); border: 1px solid var(--border); border-radius: .95rem; padding: 1.05rem 1.2rem; margin-bottom: 1.6rem; }
.lookup-input-wrap { display: flex; gap: .6rem; flex-wrap: wrap; }
input[type="text"] { flex: 1 1 16rem; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: .55rem; padding: .55rem .8rem; color: inherit; font: inherit; font-size: .92rem; }
input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.lookup-msg { margin-top: .55rem; font-size: .86rem; color: var(--muted); }
.lookup-msg.error { color: var(--danger); }
#lookup-result:not(:empty) { margin-top: 1rem; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-head p { margin-top: .25rem; }

.rooms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 31rem), 1fr)); gap: 1rem; }
.room-card { background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; padding: 1.2rem; display: flex; flex-direction: column; gap: .9rem; }
.room-card.full { border-color: #5b436e; }
.room-card.recruiting { border-color: #357c7a; box-shadow: 0 0 0 1px #2a6362 inset; }
.room-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.room-title-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.room-title-row h3 { margin: 0; font-size: 1.08rem; }
.tag { font-size: .74rem; padding: .16rem .5rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: var(--surface-2); }
.tag.public { color: var(--accent); border-color: #2b6362; }
.tag.private { color: var(--gold); border-color: #6c5928; }
.tag.perm { color: #9dc2ff; border-color: #345282; }
.seat-pill { font-size: .88rem; font-weight: 700; padding: .24rem .62rem; border-radius: .5rem; background: #192942; color: var(--accent); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.room-card.full .seat-pill { background: #362044; color: #e2a9ff; }

.room-key-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; background: var(--surface-2); border: 1px solid #202f47; border-radius: .6rem; padding: .48rem .7rem; }
.room-key-row code { font-family: ui-monospace, Consolas, monospace; font-size: .84rem; color: #c9dcff; word-break: break-all; }

.recruit-banner { display: flex; align-items: center; gap: .75rem; background: linear-gradient(135deg, #122738, #1c1d3d); border: 1px solid #396e7d; border-radius: .72rem; padding: .6rem .78rem; font-size: .88rem; }
.recruit-jacket { width: 54px; height: 54px; border-radius: .5rem; object-fit: cover; flex-shrink: 0; border: 1px solid rgba(255,255,255,.22); background: #0c1424; }
.recruit-jacket-placeholder { width: 54px; height: 54px; border-radius: .5rem; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; background: linear-gradient(135deg, #1b314a, #272047); border: 1px solid rgba(255,255,255,.15); }
.recruit-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .22rem; }
.recruit-picker { font-size: .75rem; color: var(--accent); font-weight: 650; }
.recruit-song { font-weight: 700; color: #f6fbff; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recruit-artist { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recruit-diff-col { display: flex; flex-direction: column; align-items: flex-end; gap: .24rem; flex-shrink: 0; }
.diff-badge { font-size: .74rem; font-weight: 850; padding: .18rem .52rem; border-radius: .38rem; letter-spacing: .05em; font-family: "Trebuchet MS", Inter, system-ui, sans-serif; text-transform: uppercase; }
.diff-BASIC { background: linear-gradient(135deg, #1ea85a, #147a40); color: #eafff2; border: 1px solid #59e395; }
.diff-ADVANCED { background: linear-gradient(135deg, #e08b14, #a86208); color: #fff6e0; border: 1px solid #ffc766; }
.diff-EXPERT { background: linear-gradient(135deg, #d92b4b, #96162f); color: #ffe5ea; border: 1px solid #ff7b93; }
.diff-MASTER { background: linear-gradient(135deg, #8b36d9, #581b94); color: #f3e6ff; border: 1px solid #c98cff; }
.diff-ULTIMA { background: linear-gradient(135deg, #1e0c18, #3d0c1c); color: #ff526f; border: 1px solid #ff4262; box-shadow: 0 0 8px rgba(255, 66, 98, 0.45); }
.const-pill { font-size: .8rem; font-weight: 800; padding: .1rem .44rem; border-radius: .34rem; font-variant-numeric: tabular-nums; background: rgba(8, 14, 26, 0.8); border: 1px solid rgba(255,255,255,.18); }
.const-BASIC { color: #6ef2a6; border-color: rgba(89, 227, 149, 0.45); }
.const-ADVANCED { color: #ffd070; border-color: rgba(255, 199, 102, 0.45); }
.const-EXPERT { color: #ff859b; border-color: rgba(255, 123, 147, 0.45); }
.const-MASTER { color: #d6a3ff; border-color: rgba(201, 140, 255, 0.45); }
.const-ULTIMA { color: #ff6b84; border-color: rgba(255, 66, 98, 0.6); }

.seats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.seat-box { position: relative; overflow: hidden; background: var(--surface-2); border: 1px solid #1e2d44; border-radius: .72rem; padding: .68rem .78rem; min-height: 5.4rem; display: flex; flex-direction: column; justify-content: space-between; gap: .38rem; }
.seat-box.occupied { border-color: #324f73; background: #111d30; }
.seat-box.has-nameplate { border-color: #546c94; }
.seat-nameplate-bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .34; pointer-events: none; z-index: 0; }
.seat-box.has-nameplate::after { content: ""; position: absolute; inset: 0; background: linear-gradient(95deg, rgba(11, 18, 32, 0.86) 0%, rgba(11, 18, 32, 0.56) 62%, rgba(11, 18, 32, 0.72) 100%); pointer-events: none; z-index: 0; }
.seat-box > *:not(.seat-nameplate-bg) { position: relative; z-index: 1; }
.seat-box.empty { opacity: .55; justify-content: center; align-items: center; font-size: .84rem; color: var(--muted); border-style: dashed; }
.seat-team-bar { display: flex; align-items: center; gap: .38rem; font-size: .73rem; font-weight: 700; padding: .14rem .48rem; border-radius: .36rem; background: linear-gradient(90deg, rgba(75, 130, 210, 0.45), rgba(162, 118, 224, 0.35), rgba(224, 180, 75, 0.35), rgba(45, 165, 120, 0.35)); border: 1px solid rgba(175, 205, 255, 0.28); color: #f5f9ff; overflow: hidden; }
.seat-team-label { font-size: .64rem; letter-spacing: .06em; padding: .04rem .28rem; border-radius: .24rem; background: rgba(15, 25, 45, 0.72); color: #9ee8ff; flex-shrink: 0; }
.seat-team-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-trophy { font-size: .75rem; font-weight: 700; text-align: center; padding: .16rem .5rem; border-radius: .34rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid #4c6282; background: rgba(16, 24, 38, 0.84); color: #eef5ff; transition: opacity .25s ease; }
.trophy-rare-0 { border-color: #7c8ea8; background: linear-gradient(90deg, rgba(45,56,74,.88), rgba(62,74,94,.88), rgba(45,56,74,.88)); }
.trophy-rare-1 { border-color: #c58a5b; background: linear-gradient(90deg, rgba(66,42,24,.9), rgba(92,58,34,.9), rgba(66,42,24,.9)); color: #ffdfc2; }
.trophy-rare-2 { border-color: #c2d2e8; background: linear-gradient(90deg, rgba(50,62,80,.9), rgba(84,98,120,.9), rgba(50,62,80,.9)); color: #f2f7ff; }
.trophy-rare-3, .trophy-rare-4 { border-color: #f4c44e; background: linear-gradient(90deg, rgba(78,56,14,.92), rgba(118,86,20,.92), rgba(78,56,14,.92)); color: #fff2c2; }
.trophy-rare-5 { border-color: #e4eeff; background: linear-gradient(90deg, rgba(46,66,94,.92), rgba(92,118,154,.92), rgba(46,66,94,.92)); color: #ffffff; box-shadow: inset 0 0 8px rgba(210, 232, 255, 0.25); }
.trophy-rare-6, .trophy-rare-7, .trophy-rare-9 { border-color: #ffd166; background: linear-gradient(90deg, rgba(95,30,68,.9), rgba(92,72,22,.9), rgba(22,82,78,.9), rgba(54,42,102,.9)); color: #fffdf5; }
.trophy-rare-special { border-color: #ff6b81; background: linear-gradient(90deg, rgba(95,18,34,.92), rgba(35,16,28,.92), rgba(95,18,34,.92)); color: #ffe0e6; }
.class-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.55rem; height: 1.2rem; padding: 0 .35rem; border-radius: .34rem; font-size: .72rem; font-weight: 850; font-family: Georgia, "Times New Roman", serif; letter-spacing: .02em; flex-shrink: 0; border: 1px solid rgba(255,255,255,.35); }
.class-base-1 { background: linear-gradient(135deg, #2758a8, #193870); color: #dcebff; border-color: #6ea8ff; }
.class-base-2 { background: linear-gradient(135deg, #8c5228, #573013); color: #ffe1c7; border-color: #d89b6a; }
.class-base-3 { background: linear-gradient(135deg, #6b7d96, #3d4b60); color: #f2f7ff; border-color: #cfdced; }
.class-base-4 { background: linear-gradient(135deg, #b88418, #704c06); color: #fff3c4; border-color: #ffd86b; }
.class-base-5 { background: linear-gradient(135deg, #4f236e, #241038); color: #ffe89e; border-color: #ffd166; box-shadow: 0 0 6px rgba(255, 209, 102, 0.35); }
.class-base-6 { background: linear-gradient(135deg, #ff6bd6, #ffd166, #5ce8ce, #8e9eff); color: #121224; border-color: #ffffff; }
.seat-main { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.seat-avatar { width: 44px; height: 44px; border-radius: .5rem; object-fit: cover; background: #0c1424; border: 1px solid #355075; flex-shrink: 0; }
.seat-avatar-placeholder { width: 44px; height: 44px; border-radius: .5rem; background: linear-gradient(135deg, #1b2c47, #111b2e); border: 1px solid #2b4060; color: var(--muted); font-weight: 700; font-size: .88rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.seat-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .28rem; }
.seat-top { display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
.player-name-group { display: flex; align-items: center; gap: .36rem; min-width: 0; flex-wrap: wrap; }
.player-name { font-weight: 650; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rating-badge { font-size: .73rem; font-weight: 800; padding: .12rem .44rem; border-radius: .36rem; font-variant-numeric: tabular-nums; flex-shrink: 0; letter-spacing: .01em; }
.tier-rainbow-kiwami {
  background: linear-gradient(135deg, #140f24 0%, #241236 50%, #112233 100%);
  border: 1px solid #ffd166;
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.45), inset 0 0 6px rgba(92, 232, 206, 0.25);
  color: transparent;
  background-clip: padding-box;
  position: relative;
}
.tier-rainbow-kiwami span {
  background: linear-gradient(90deg, #ff6bd6 0%, #ffe066 28%, #5cf2d6 60%, #99a8ff 85%, #ff8fd8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tier-rainbow { background: linear-gradient(120deg, #ff9ec7, #ffe58f, #87f5e1, #b8b8ff); color: #121829; }
.tier-platinum { background: linear-gradient(135deg, #eef4ff, #c5d6f5); color: #16233d; }
.tier-gold { background: linear-gradient(135deg, #ffe27a, #f4b942); color: #2b1d04; }
.tier-silver { background: linear-gradient(135deg, #d0dced, #98abc4); color: #10192b; }
.tier-bronze { background: linear-gradient(135deg, #d89f6f, #a86b3e); color: #1f1106; }
.tier-normal { background: #263650; color: #dbe7ff; }
.level-wrap { display: inline-flex; align-items: center; gap: .22rem; font-size: .73rem; color: #d5e2f7; background: #18253a; border: 1px solid #2b3f5e; padding: .08rem .38rem; border-radius: .34rem; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.star-badge { display: inline-flex; align-items: center; justify-content: center; width: 1.15rem; height: 1.15rem; position: relative; flex-shrink: 0; }
.star-badge svg { width: 100%; height: 100%; display: block; }
.star-num { position: absolute; font-size: .58rem; font-weight: 850; color: #2a1900; line-height: 1; top: 53%; left: 50%; transform: translate(-50%, -50%); }
.rtt { font-size: .76rem; color: var(--accent); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.seat-meta { font-size: .78rem; color: var(--muted); display: flex; justify-content: space-between; gap: .4rem; flex-wrap: wrap; }
.seat-recruit { font-size: .78rem; color: #a5f3e6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 2.5rem 1rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: 1rem; }

dialog { width: min(30rem, 100% - 2rem); border: 1px solid var(--border); border-radius: 1rem; padding: 1.4rem; background: var(--surface); color: inherit; }
dialog::backdrop { background: #050a14cc; }
dialog .muted { margin: .45rem 0 1rem; }
.form-field { display: flex; flex-direction: column; gap: .38rem; margin-bottom: .9rem; }
.form-field label { font-size: .86rem; color: #c8d7ee; }
.checkbox-row { display: flex; align-items: flex-start; gap: .55rem; font-size: .86rem; color: var(--muted); margin: .4rem 0 1rem; cursor: pointer; }
.form-error { color: var(--danger); font-size: .86rem; min-height: 1.2rem; margin-bottom: .6rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; }

.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: #16333d; border: 1px solid #398988; color: #ebfffc; padding: .6rem 1.1rem; border-radius: .65rem; font-size: .9rem; box-shadow: 0 10px 28px #00000066; z-index: 50; }

@media (max-width: 820px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  main { width: min(100% - 1.5rem, 74rem); }
  .seats-grid { grid-template-columns: 1fr; }
}
