:root {
  --bg: #040a16;
  --bg-2: #071226;
  --panel: rgba(9, 22, 46, .9);
  --panel-2: rgba(14, 34, 68, .92);
  --line: rgba(84, 178, 255, .18);
  --line-strong: rgba(96, 196, 255, .42);
  --text: #dcebff;
  --muted: #7f9dc7;
  --dim: #4f6b92;
  --accent: #3fd8ff;
  --accent-2: #0a6cff;
  --accent-ink: #021019;
  --coral: #ff7a5c;
  --gold: #ffd166;
  --danger: #ff5f7a;
  --green: #42e6a4;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --shadow: 0 20px 60px rgba(0, 6, 20, .7);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --glow: 0 0 18px rgba(63, 216, 255, .35);
  --card-w: 88px;
  --red: #e03131;
  --blue: #2b8fe8;
  --yellow: #e0b31c;
  --green-c: #3a9e6f;
  --black: #23262e;
  --purple: #8b46d6;
  --white: #cbd5e1;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin: 0; }
b, strong { font-weight: 700; }

.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 45% at 18% 0%, rgba(24, 108, 255, .28), transparent 70%),
    radial-gradient(50% 40% at 88% 8%, rgba(63, 216, 255, .16), transparent 70%),
    radial-gradient(70% 60% at 50% 110%, rgba(10, 60, 160, .35), transparent 70%);
}
.bg-glow::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(70, 160, 255, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 160, 255, .055) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(75% 60% at 50% 35%, #000 30%, transparent 100%);
  mask-image: radial-gradient(75% 60% at 50% 35%, #000 30%, transparent 100%);
}

#app { position: relative; height: 100dvh; z-index: 1; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; opacity: 0; }
.screen.is-active { display: flex; opacity: 1; animation: screenIn .42s var(--ease) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(20px) scale(.988); } to { opacity: 1; transform: none; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

.hud-corners { position: relative; }
.hud-corners::after {
  content: ""; position: absolute; inset: 8px; pointer-events: none; z-index: 2;
  background:
    linear-gradient(var(--accent), var(--accent)) left top / 12px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left top / 1px 12px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right top / 12px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right top / 1px 12px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left bottom / 12px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left bottom / 1px 12px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 12px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 1px 12px no-repeat;
  opacity: .5;
}

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: 1px; color: var(--accent);
  border: 1px solid var(--line-strong); border-radius: 11px;
  background: radial-gradient(circle at 30% 20%, rgba(63, 216, 255, .22), rgba(5, 16, 36, .9));
  box-shadow: var(--glow), inset 0 0 18px rgba(63, 216, 255, .12);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: 2px; }
.brand-text span { font-size: 10px; color: var(--accent); letter-spacing: 3px; text-transform: uppercase; opacity: .8; }
.brand.small .brand-mark { width: 34px; height: 34px; font-size: 10px; }
.brand.small .brand-text strong { font-size: 13px; letter-spacing: 1px; }

/* ---------- buttons ---------- */
.btn {
  position: relative; isolation: isolate;
  height: 44px; padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; letter-spacing: .4px; white-space: nowrap;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(24, 60, 124, .85), rgba(6, 18, 40, .95));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(150, 220, 255, .12), 0 4px 18px rgba(0, 8, 24, .5);
  transition: border-color .18s, box-shadow .22s, transform .1s, background .22s;
  overflow: hidden;
}
.btn:hover { border-color: var(--accent); box-shadow: inset 0 1px 0 rgba(180, 235, 255, .25), 0 0 20px rgba(63, 216, 255, .35); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn-primary {
  color: #eaf9ff; border-color: transparent;
  background: linear-gradient(180deg, #8df0ff, #2a8bff 45%, #1350c8);
  text-shadow: 0 0 10px rgba(140, 225, 255, .55);
  box-shadow: none;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  filter: drop-shadow(0 0 14px rgba(24, 120, 255, .45));
}
.btn-primary::before {
  content: ""; position: absolute; inset: 1.6px; z-index: -1;
  background: linear-gradient(180deg, #1b6ce0, #0a2f78 70%, #061a44);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}
.btn-primary:hover { filter: drop-shadow(0 0 22px rgba(63, 216, 255, .7)); }
.btn-ghost { background: rgba(8, 20, 42, .55); border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-lg { height: 54px; font-size: 15px; border-radius: var(--r-md); padding: 0 24px; }
.btn-mini { height: 30px; padding: 0 11px; font-size: 11px; border-radius: 6px; letter-spacing: .2px; }
.btn-k { font-size: 15px; letter-spacing: 1px; }
.btn-d { font-size: 10px; font-weight: 500; opacity: .65; }
.btn.danger, .danger { color: var(--danger); }
.danger:hover { border-color: var(--danger); box-shadow: 0 0 16px rgba(255, 95, 122, .3); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center;
  border: 1px solid var(--line); background: rgba(8, 20, 42, .6); color: var(--muted);
  transition: .18s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--line-strong); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- inputs ---------- */
.input {
  width: 100%; height: 42px; padding: 0 13px;
  background: rgba(6, 16, 36, .78);
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); outline: none; transition: .18s;
}
.input::placeholder { color: var(--dim); }
.input:focus { border-color: var(--accent); background: rgba(12, 36, 74, .9); box-shadow: 0 0 16px rgba(63, 216, 255, .2); }
.input.mini { height: 32px; width: 64px; text-align: center; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 11px; color: var(--muted); letter-spacing: 1px; display: flex; justify-content: space-between; }
.field-label em { font-style: normal; color: var(--dim); }
.hint { min-height: 18px; font-size: 12px; color: var(--coral); }

/* ---------- login ---------- */
.gate-wrap {
  margin: auto; width: min(92vw, 430px); padding: 34px 30px 26px;
  display: flex; flex-direction: column; align-items: stretch;
  background: linear-gradient(180deg, rgba(10, 26, 54, .82), rgba(4, 12, 28, .92));
  border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow), inset 0 0 60px rgba(20, 70, 150, .12);
  backdrop-filter: blur(14px);
  animation: riseIn .55s var(--ease) both;
}
.gate-wrap .brand { align-self: flex-start; }
.logo-orb {
  width: 104px; height: 104px; margin: 24px auto 6px; border-radius: 50%;
  display: grid; grid-template-columns: 1fr 1fr; place-items: center;
  font-weight: 800; font-size: 22px; color: #eaf9ff;
  background: conic-gradient(from 210deg, #2a8bff, #3fd8ff, #0a3f9e, #2a8bff);
  box-shadow: 0 0 40px rgba(63, 216, 255, .35), inset 0 0 30px rgba(0, 10, 30, .8);
  position: relative;
}
.logo-orb::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; border: 1px dashed rgba(220, 245, 255, .4); }
.logo-orb span { opacity: .95; text-shadow: 0 0 12px rgba(0, 20, 50, .8); }
.gate-title { margin: 16px 0 4px; font-size: 24px; letter-spacing: 2px; text-align: center; }
.gate-sub { margin: 0 0 22px; color: var(--muted); font-size: 12px; letter-spacing: .6px; text-align: center; }
.gate-form { display: flex; flex-direction: column; gap: 14px; }
.gate-foot { margin: 18px 0 0; text-align: center; font-size: 10px; color: var(--dim); letter-spacing: 1.5px; }

/* ---------- topbar ---------- */
.topbar {
  height: 64px; padding: 0 26px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(5, 14, 32, .85), rgba(5, 14, 32, .2));
  backdrop-filter: blur(10px);
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.chip {
  height: 34px; padding: 0 12px; display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(8, 20, 42, .6); color: var(--muted); font-size: 12px;
}
.chip b { color: var(--text); }
.chip-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
.chip-me { color: var(--text); border-color: var(--line-strong); cursor: default; }

/* ---------- lobby ---------- */
.lobby-body { flex: 1; display: grid; grid-template-columns: 216px 1fr; min-height: 0; }
.lobby-side {
  border-right: 1px solid var(--line); padding: 20px 16px;
  display: flex; flex-direction: column; gap: 16px;
  background: rgba(5, 14, 30, .5);
}
.profile-card { padding: 18px 14px; text-align: center; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
.avatar {
  width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 16px;
  display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #eaf9ff;
  background: linear-gradient(145deg, #1b6ce0, #071a3e); border: 1px solid var(--line-strong);
  box-shadow: inset 0 0 18px rgba(63, 216, 255, .2);
}
.profile-card strong { display: block; font-size: 15px; }
.profile-sub { font-size: 11px; color: var(--muted); }
.side-nav { display: flex; flex-direction: column; gap: 6px; }
.side-tab {
  height: 42px; padding: 0 12px; display: flex; align-items: center; gap: 10px;
  border-radius: 8px; border: 1px solid transparent; color: var(--muted); font-size: 13px;
  transition: .16s;
}
.side-tab:hover { color: var(--text); background: rgba(20, 50, 100, .25); }
.side-tab.is-on { color: var(--accent); background: rgba(20, 70, 150, .25); border-color: var(--line); }
.side-tab svg { width: 18px; height: 18px; }
.side-logout { margin-top: auto; width: 100%; }

.lobby-main { padding: 22px 26px 30px; overflow-y: auto; min-height: 0; }
.lobby-pane { display: none; animation: riseIn .35s var(--ease) both; }
.lobby-pane.is-on { display: block; }
.match-hero {
  display: grid; grid-template-columns: 240px 1fr; gap: 22px;
  padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: linear-gradient(120deg, rgba(12, 34, 76, .8), rgba(6, 18, 42, .9));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero-cover {
  height: 190px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: linear-gradient(160deg, #123, #071a3e);
  background-size: cover; background-position: center;
  position: relative; overflow: hidden;
}
.hero-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(3, 10, 24, .9)); }
.hero-info { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.eyebrow { font-size: 10px; letter-spacing: 2.5px; color: var(--accent); text-transform: uppercase; }
.hero-info h2 { font-size: 28px; letter-spacing: 2px; }
.hero-info p { color: var(--muted); font-size: 12px; }
.hero-buttons { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

.home-row { display: grid; grid-template-columns: 1fr 320px; gap: 16px; margin-top: 16px; }
.panel { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h3 { font-size: 14px; letter-spacing: 1px; }
.panel-head h2 { font-size: 20px; letter-spacing: 1px; }
.panel-note { margin-top: 10px; color: var(--dim); font-size: 11px; }
.deck-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.deck-tile {
  position: relative; min-height: 92px; padding: 11px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: linear-gradient(150deg, rgba(20, 52, 104, .55), rgba(6, 16, 36, .8));
  display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden;
  transition: .18s;
}
.deck-tile:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.deck-tile.is-active { border-color: var(--accent); box-shadow: 0 0 18px rgba(63, 216, 255, .2); }
.deck-tile .dt-cover { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .35; }
.deck-tile .dt-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent, rgba(4, 12, 28, .92)); }
.deck-tile strong, .deck-tile span { position: relative; z-index: 1; }
.deck-tile strong { font-size: 13px; }
.deck-tile span { font-size: 10px; color: var(--muted); }
.deck-tile .dt-dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); z-index: 1; }
.join-row { display: flex; gap: 8px; }
.code-input { letter-spacing: 4px; text-transform: uppercase; font-weight: 700; }
.live-panel { margin-top: 16px; }
.live-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.live-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: rgba(8, 22, 46, .6);
  cursor: pointer; transition: .16s;
}
.live-row:hover { border-color: var(--line-strong); background: rgba(14, 40, 82, .65); }
.live-vs { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 10px; font-weight: 800; color: var(--accent); border: 1px solid var(--line-strong); background: rgba(8, 24, 52, .9); }
.live-names { flex: 1; display: flex; flex-direction: column; }
.live-names strong { font-size: 13px; }
.live-names span { font-size: 10px; color: var(--muted); }
.live-badge { font-size: 10px; color: var(--muted); border: 1px solid var(--line); padding: 3px 8px; border-radius: 999px; }
.empty-line { padding: 24px; text-align: center; color: var(--dim); font-size: 12px; }

/* ---------- deck gallery ---------- */
.lobby-deck-head { margin: 6px 0 18px; }
.head-btns { display: flex; gap: 8px; }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.deck-card {
  border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
  background: var(--panel); cursor: pointer; transition: .18s;
}
.deck-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: 0 12px 28px rgba(0, 8, 26, .5); }
.deck-card .dc-cover { height: 130px; background-size: cover; background-position: center; position: relative; background-color: #0a1a36; }
.deck-card .dc-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(4, 10, 24, .95)); }
.deck-card .dc-info { padding: 12px 14px; }
.deck-card .dc-info strong { display: block; font-size: 14px; }
.deck-card .dc-info span { font-size: 10px; color: var(--muted); }
.deck-card .dc-actions { display: flex; gap: 6px; padding: 0 14px 12px; }
.deck-badge { position: absolute; top: 10px; left: 10px; z-index: 1; font-size: 9px; letter-spacing: 1px; padding: 3px 7px; border-radius: 4px; background: rgba(4, 12, 28, .75); border: 1px solid var(--line-strong); color: var(--accent); }

/* ---------- deck editor ---------- */
.deck-topbar { gap: 12px; }
.deck-title-wrap { display: flex; align-items: center; gap: 12px; flex: 1; }
.deck-name-input { background: transparent; border: 0; border-bottom: 1px solid transparent; font-size: 17px; font-weight: 700; letter-spacing: 1px; padding: 4px 2px; outline: none; width: min(320px, 40vw); }
.deck-name-input:focus { border-bottom-color: var(--accent); }
.deck-status { font-size: 11px; color: var(--muted); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; }
.deck-status.ok { color: var(--green); border-color: rgba(66, 230, 164, .4); }
.deck-body { flex: 1; display: grid; grid-template-columns: 224px 1fr 280px; min-height: 0; }
.pool-filters { border-right: 1px solid var(--line); padding: 16px 14px; overflow-y: auto; background: rgba(5, 14, 30, .55); }
.search-box { position: relative; margin-bottom: 14px; }
.search-box svg { position: absolute; left: 10px; top: 10px; width: 17px; height: 17px; color: var(--dim); }
.search-box .input { padding-left: 34px; height: 38px; font-size: 12px; }
.filter-group { margin-bottom: 14px; }
.filter-label { display: block; font-size: 10px; letter-spacing: 2px; color: var(--dim); margin-bottom: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-filter {
  height: 25px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line);
  background: rgba(8, 20, 42, .6); color: var(--muted); font-size: 10px;
}
.chip-filter:hover { color: var(--text); }
.chip-filter.is-on { color: #041018; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.chip-filter.c-red.is-on { background: var(--red); }
.chip-filter.c-blue.is-on { background: var(--blue); }
.chip-filter.c-yellow.is-on { background: var(--yellow); }
.chip-filter.c-green.is-on { background: var(--green-c); }
.chip-filter.c-black.is-on { background: #4a5160; }
.chip-filter.c-purple.is-on { background: var(--purple); }
.chip-filter.c-white.is-on { background: var(--white); color: #10151f; }
.level-range { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 11px; }
.filter-note { margin-top: 18px; color: var(--dim); font-size: 10px; line-height: 1.6; }
.pool-main { display: flex; flex-direction: column; min-height: 0; padding: 14px 16px; }
.pool-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: var(--muted); font-size: 11px; }
.pool-pager { display: flex; align-items: center; gap: 8px; }
.card-pool { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; align-content: start; padding-right: 4px; }
.deck-panel { border-left: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; min-height: 0; background: rgba(5, 14, 30, .55); }
.deck-cover-preview { height: 132px; border-radius: 9px; border: 1px solid var(--line); background: #081a36 center/cover no-repeat; }
.deck-cover-actions { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 8px 0 10px; font-size: 10px; color: var(--muted); }
.deck-counts { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.deck-counts b { color: var(--text); }
.deck-color-bar { display: flex; height: 5px; border-radius: 3px; overflow: hidden; margin: 9px 0; background: rgba(255, 255, 255, .06); }
.deck-color-bar i { flex: 1; }
.deck-list-wrap { flex: 1; overflow-y: auto; min-height: 0; padding-right: 3px; }
.deck-group-title { position: sticky; top: 0; background: rgba(6, 16, 36, .96); padding: 7px 2px 5px; font-size: 10px; letter-spacing: 1.5px; color: var(--dim); z-index: 1; }
.deck-row { display: flex; align-items: center; gap: 6px; padding: 4px 2px; font-size: 11px; border-bottom: 1px solid rgba(84, 178, 255, .07); }
.deck-row .dr-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-row .dr-id { color: var(--dim); font-size: 9px; }
.deck-row .dr-x { width: 18px; height: 18px; border-radius: 4px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line); }
.deck-row .dr-x:hover { color: var(--danger); border-color: var(--danger); }
.deck-row b { color: var(--accent); font-size: 10px; }
.deck-footer { display: flex; gap: 6px; margin-top: 10px; }

/* ---------- card component ---------- */
.card {
  position: relative; width: 100%; aspect-ratio: 63 / 88; border-radius: 7px;
  overflow: hidden; border: 1px solid rgba(140, 190, 255, .25);
  background: #0a1730; cursor: pointer; isolation: isolate;
  transition: transform .14s var(--ease), box-shadow .18s, border-color .18s;
  user-select: none;
}
.card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 45%, rgba(2, 8, 20, .92));
}
.card .c-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.card .c-fallback {
  position: absolute; inset: 0; z-index: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 8px 6px; text-align: center;
  background:
    radial-gradient(80% 60% at 30% 10%, color-mix(in srgb, var(--cc, #2b8fe8) 55%, transparent), transparent 70%),
    linear-gradient(160deg, color-mix(in srgb, var(--cc, #2b8fe8) 32%, #081226), #060f22 70%);
}
.card .c-sigil { font-size: 24px; font-weight: 800; opacity: .32; letter-spacing: -1px; }
.card .c-name2 { font-size: 9px; line-height: 1.15; font-weight: 600; color: #dcebff; word-break: break-all; }
.card .c-id2 { font-size: 7px; color: rgba(200, 225, 255, .55); letter-spacing: .4px; }
.card .c-top { position: absolute; top: 4px; left: 4px; right: 4px; z-index: 2; display: flex; justify-content: space-between; gap: 2px; font-size: 7px; color: #eaf6ff; text-shadow: 0 1px 3px #000; }
.card .c-top .c-id { background: rgba(0, 0, 0, .45); padding: 1px 3px; border-radius: 2px; }
.card .c-top .c-lv { background: rgba(0, 0, 0, .45); padding: 1px 3px; border-radius: 2px; }
.card .c-bottom { position: absolute; left: 4px; right: 4px; bottom: 3px; z-index: 2; display: flex; align-items: flex-end; justify-content: space-between; gap: 2px; }
.card .c-title { font-size: 8px; line-height: 1.1; font-weight: 700; color: #eaf6ff; text-shadow: 0 1px 3px #000; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .c-dp { font-size: 8px; font-weight: 800; color: var(--gold); background: rgba(0, 0, 0, .55); padding: 1px 3px; border-radius: 3px; white-space: nowrap; }
.card:hover { transform: translateY(-4px) scale(1.03); box-shadow: 0 10px 26px rgba(0, 4, 16, .7), 0 0 0 1px var(--accent); z-index: 5; }
.card.is-selected { box-shadow: 0 0 0 2px var(--accent), 0 0 22px rgba(63, 216, 255, .45); transform: translateY(-4px); }
.card.can-target { box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(255, 209, 102, .4); }
.card.is-dim { opacity: .42; filter: saturate(.4); }
.card.is-suspended .c-img, .card.is-suspended .c-fallback { transform: rotate(90deg) scale(.74); }
.card.is-suspended { background: #060d1c; }
.card .c-status { position: absolute; top: 4px; right: 4px; z-index: 3; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.card .c-status i { font-style: normal; font-size: 7px; padding: 1px 4px; border-radius: 3px; background: rgba(0, 0, 0, .6); color: var(--gold); }
.card .c-count { position: absolute; right: 3px; bottom: 3px; z-index: 4; min-width: 17px; height: 17px; border-radius: 5px; display: grid; place-items: center; font-size: 9px; font-weight: 800; background: var(--accent); color: #041018; }
.card .c-stack { position: absolute; left: 4px; bottom: 3px; z-index: 4; font-size: 7px; padding: 1px 4px; border-radius: 3px; background: rgba(0, 0, 0, .6); color: #9fd8ff; }
.card .c-acts { position: absolute; inset: auto 0 0 0; z-index: 6; display: none; }
.card.tiny { width: 48px; }
.c-red { --cc: var(--red); }
.c-blue { --cc: var(--blue); }
.c-yellow { --cc: var(--yellow); }
.c-green { --cc: var(--green-c); }
.c-black { --cc: var(--black); }
.c-purple { --cc: var(--purple); }
.c-white { --cc: var(--white); }

.hand-cost {
  position: absolute; left: 3px; bottom: 3px; z-index: 6;
  min-width: 17px; height: 17px; padding: 0 3px; border-radius: 5px;
  display: grid; place-items: center; font-size: 9px; font-weight: 800;
  background: rgba(4, 12, 28, .85); color: var(--accent); border: 1px solid var(--line-strong);
}
.card.is-playable { box-shadow: 0 0 0 1px rgba(63, 216, 255, .55), 0 6px 18px rgba(0, 8, 24, .5); }
.board-dp {
  position: absolute; right: 3px; bottom: 3px; z-index: 5;
  font-size: 9px; font-weight: 800; color: var(--gold);
  background: rgba(0, 0, 0, .68); padding: 1px 4px; border-radius: 3px;
}
.order-slot { min-height: 120px; border: 1px dashed var(--line); border-radius: 7px; padding: 4px; display: flex; align-items: center; justify-content: center; position: relative; }
.order-num { font-size: 12px; font-weight: 800; color: var(--accent); }
.order-preview { margin: 10px 0; font-size: 11px; color: var(--muted); min-height: 18px; }
.clause { display: block; font-style: normal; font-size: 9px; color: var(--muted); margin-top: 2px; }
.choice-line.decline { opacity: .75; border-style: dashed; }
.mull-card { min-height: 124px; }

/* ---------- battle ---------- */
.battle-screen { background: radial-gradient(80% 60% at 50% 20%, #0a1d3d 0%, #040a16 65%); }
.battle-head {
  height: 54px; flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: rgba(4, 12, 26, .82); backdrop-filter: blur(10px); z-index: 5;
}
.battle-room { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); }
.room-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.battle-room b { color: var(--text); letter-spacing: 3px; font-size: 13px; }
.battle-room em { font-style: normal; color: var(--dim); font-size: 10px; }
.battle-phase { flex: 1; display: flex; align-items: center; gap: 10px; justify-content: center; }
.battle-phase span { font-size: 11px; color: var(--accent); letter-spacing: 2px; border: 1px solid var(--line-strong); padding: 3px 10px; border-radius: 999px; }
.battle-phase b { font-size: 12px; color: var(--muted); }
.head-btns { display: flex; gap: 6px; }

.battle-stage {
  flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center;
  gap: 4px; padding: 6px 22px 0; position: relative;
}
.battle-side { display: flex; flex-direction: column; gap: 4px; }
.player-plate { display: flex; align-items: center; gap: 10px; height: 40px; }
.plate-avatar {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  font-weight: 800; font-size: 12px; color: var(--accent);
  background: rgba(10, 30, 64, .9); border: 1px solid var(--line-strong);
}
.plate-info { display: flex; flex-direction: column; line-height: 1.2; }
.plate-info strong { font-size: 12px; }
.plate-info span { font-size: 9px; color: var(--muted); }
.plate-piles { margin-left: auto; display: flex; gap: 6px; }
.pile { display: flex; flex-direction: column; align-items: center; padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; background: rgba(6, 16, 36, .6); line-height: 1.1; }
.pile span { font-size: 12px; font-weight: 800; }
.pile em { font-style: normal; font-size: 7px; color: var(--dim); letter-spacing: 1px; }
.security-line { display: flex; align-items: center; gap: 10px; height: 44px; }
.line-label { font-size: 8px; letter-spacing: 2px; color: var(--dim); writing-mode: vertical-rl; transform: rotate(180deg); }
.security-cards { display: flex; gap: 4px; }
.sec-card {
  width: 26px; height: 36px; border-radius: 4px; border: 1px solid rgba(120, 180, 255, .3);
  background:
    repeating-linear-gradient(45deg, rgba(63, 216, 255, .08) 0 3px, transparent 3px 6px),
    linear-gradient(160deg, #0f2b5a, #071226);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
  position: relative;
}
.sec-card.face-up { background: #0b1b36; }
.sec-card.face-up img { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; }
.sec-card.checked { opacity: .25; }
.field-line { display: flex; align-items: center; gap: 10px; }
.breeding-zone { width: 82px; height: 108px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 9px; position: relative; flex: 0 0 auto; }
.breeding-zone .zone-label { position: absolute; top: -12px; left: 2px; font-size: 7px; letter-spacing: 1px; color: var(--dim); }
.battle-area { flex: 1; display: flex; gap: 8px; align-items: center; justify-content: center; min-width: 0; }
.slot {
  width: 100px; aspect-ratio: 63 / 88; border: 1px solid rgba(84, 178, 255, .12); border-radius: 8px;
  position: relative; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(70% 60% at 50% 40%, rgba(20, 50, 100, .22), transparent 75%);
}
.slot.empty::after { content: "空位"; font-size: 8px; color: var(--dim); opacity: .5; }
.slot .card { position: absolute; inset: 0; width: 100%; }
.trash-zone { width: 54px; height: 76px; flex: 0 0 auto; border-radius: 6px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 9px; position: relative; background: rgba(4, 10, 22, .6); }
.trash-zone .trash-count { font-size: 14px; font-weight: 800; color: var(--muted); }
.opp-hand { display: flex; justify-content: center; gap: 2px; height: 26px; overflow: hidden; }
.hand-back { width: 18px; height: 26px; border-radius: 3px; border: 1px solid rgba(100, 160, 240, .25); background: linear-gradient(160deg, #12305f, #071226); transform: translateY(-6px); }
.hand-back:nth-child(2n) { transform: translateY(-9px); }

.memory-rail {
  height: 42px; display: flex; align-items: center; gap: 12px; padding: 0 8px;
  flex: 0 0 auto;
}
.memory-side { font-size: 8px; letter-spacing: 2px; color: var(--dim); width: 34px; text-align: center; }
.memory-track {
  flex: 1; height: 14px; border-radius: 999px; position: relative;
  background:
    linear-gradient(90deg, rgba(255, 95, 122, .5), rgba(255, 95, 122, .08) 45%, rgba(63, 216, 255, .08) 55%, rgba(63, 216, 255, .5));
  border: 1px solid var(--line);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, .6);
}
.memory-track::before {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(220, 240, 255, .25) 0 1px, transparent 1px 5%);
  opacity: .7;
}
.memory-center { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: rgba(220, 240, 255, .35); }
.memory-marker {
  position: absolute; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #d8f8ff, #2a8bff 55%, #0a3f9e);
  border: 1px solid rgba(220, 250, 255, .8);
  box-shadow: 0 0 20px rgba(63, 216, 255, .65);
  transition: left .35s var(--ease);
  z-index: 2;
}
.memory-marker b { font-size: 12px; color: #04101f; font-weight: 900; }
.memory-fill { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; background: rgba(63, 216, 255, .18); border-radius: 999px; }

.battle-bottom { flex: 0 0 auto; padding: 4px 16px 10px; display: grid; grid-template-columns: 180px 1fr 220px; gap: 8px; align-items: end; }
.turn-actions { display: flex; flex-direction: column; gap: 5px; align-items: stretch; }
.turn-actions .btn { height: 34px; font-size: 11px; }
.action-hint { font-size: 10px; color: var(--dim); text-align: right; padding-bottom: 8px; line-height: 1.4; }
.hand-dock { min-height: 116px; display: flex; align-items: flex-end; justify-content: center; }
.hand-fan { display: flex; justify-content: center; align-items: flex-end; width: 100%; padding: 0 10px; }
.hand-fan .card { width: 82px; margin: 0 -8px; transform-origin: bottom center; }
.hand-fan .card:nth-child(odd) { transform: translateY(3px) rotate(-1.5deg); }
.hand-fan .card:nth-child(even) { transform: translateY(3px) rotate(1.5deg); }
.hand-fan .card:hover { transform: translateY(-18px) scale(1.12) rotate(0); z-index: 8; }
.hand-fan .card.is-selected { transform: translateY(-20px) scale(1.12) rotate(0); }

.battle-drawer {
  position: absolute; top: 54px; right: 0; bottom: 0; width: 320px; z-index: 20;
  background: rgba(5, 13, 28, .97); border-left: 1px solid var(--line-strong);
  display: flex; flex-direction: column; animation: drawerIn .25s var(--ease);
}
@keyframes drawerIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 12px; }
.battle-log { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.log-line { font-size: 11px; line-height: 1.45; color: var(--muted); border-left: 2px solid var(--line); padding-left: 8px; }
.log-line.bad { color: var(--coral); border-color: var(--coral); }
.log-line.chat { color: var(--text); border-color: var(--accent); }
.log-line b { color: var(--accent); }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form .input { height: 34px; font-size: 11px; }

/* ---------- overlays ---------- */
.ready-overlay, .result-overlay, .queue-overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(2, 8, 18, .72); backdrop-filter: blur(6px);
}
.ready-card, .queue-card, .result-card {
  width: min(92vw, 400px); padding: 28px; text-align: center;
  background: linear-gradient(180deg, rgba(12, 30, 62, .96), rgba(4, 12, 26, .98));
  border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow), 0 0 60px rgba(24, 100, 200, .22);
  animation: riseIn .35s var(--ease);
}
.ready-card h2, .queue-card h2, .result-card h2 { margin: 10px 0 8px; font-size: 24px; letter-spacing: 2px; }
.ready-card p, .queue-card p, .result-card p { color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.queue-spinner { display: flex; justify-content: center; gap: 7px; }
.queue-spinner i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: queueBounce 1s infinite; }
.queue-spinner i:nth-child(2) { animation-delay: .12s; }
.queue-spinner i:nth-child(3) { animation-delay: .24s; }
@keyframes queueBounce { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-8px); opacity: 1; } }
.private-actions { display: flex; gap: 8px; justify-content: center; }
.waiting-line { margin-top: 14px; color: var(--dim); font-size: 10px; }
.result-tag { display: inline-block; font-size: 10px; letter-spacing: 3px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--accent); }
.result-card.win .result-tag { color: var(--gold); border-color: var(--gold); box-shadow: 0 0 20px rgba(255, 209, 102, .25); }
.result-card.lose .result-tag { color: var(--danger); border-color: var(--danger); }
.result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 8, 18, .72); backdrop-filter: blur(6px); }
.modal-card {
  position: relative; width: min(92vw, 560px); max-height: 86dvh; overflow-y: auto;
  padding: 22px; border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(10, 26, 54, .98), rgba(4, 12, 28, .99));
  box-shadow: var(--shadow); animation: riseIn .28s var(--ease);
}
.modal-card.wide { width: min(94vw, 860px); }
.modal-card h2 { font-size: 19px; letter-spacing: 1px; margin-bottom: 6px; }
.modal-card p { color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.decision-prompt { font-size: 13px; color: var(--text); background: rgba(8, 24, 52, .7); border-left: 2px solid var(--accent); padding: 10px 12px; border-radius: 0 8px 8px 0; margin: 10px 0 14px; }
.decision-source { font-size: 10px; color: var(--dim); margin-bottom: 6px; letter-spacing: 1px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.choice-card { border: 1px solid var(--line); border-radius: 7px; padding: 8px; background: rgba(8, 20, 44, .7); cursor: pointer; text-align: center; }
.choice-card:hover { border-color: var(--line-strong); }
.choice-card.on { border-color: var(--accent); box-shadow: 0 0 14px rgba(63, 216, 255, .25); }
.choice-card strong { display: block; font-size: 11px; }
.choice-card span { font-size: 9px; color: var(--muted); }
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.choice-line { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: rgba(8, 20, 44, .7); cursor: pointer; font-size: 11px; }
.choice-line:hover { border-color: var(--line-strong); }
.choice-line.on { border-color: var(--accent); }
.choice-line .cl-idx { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-strong); font-size: 9px; color: var(--accent); }
.selection-count { font-size: 10px; color: var(--muted); margin-top: 10px; }

/* ---------- card tip ---------- */
.card-tip {
  position: fixed; z-index: 100; width: 250px; padding: 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: rgba(4, 12, 26, .98); box-shadow: var(--shadow);
  pointer-events: none; font-size: 11px; line-height: 1.5;
}
.card-tip .ct-head { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.card-tip .ct-name { font-size: 13px; font-weight: 700; }
.card-tip .ct-id { color: var(--accent); font-size: 9px; }
.card-tip .ct-meta { color: var(--muted); font-size: 9px; margin-bottom: 6px; }
.card-tip .ct-text { color: #c6dcf7; white-space: pre-wrap; max-height: 190px; overflow: hidden; }
.card-tip .ct-text em { color: var(--gold); font-style: normal; }

/* ---------- toast ---------- */
.toast-root { position: fixed; left: 50%; bottom: 108px; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  padding: 8px 16px; border-radius: 999px; font-size: 12px;
  background: rgba(4, 14, 30, .95); border: 1px solid var(--line-strong); color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); animation: toastIn .25s var(--ease);
}
.toast.bad { border-color: var(--danger); color: #ffd8df; }
.toast.good { border-color: var(--green); color: #d8fff0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .lobby-body { grid-template-columns: 180px 1fr; }
  .home-row { grid-template-columns: 1fr; }
  .deck-body { grid-template-columns: 190px 1fr 250px; }
  .match-hero { grid-template-columns: 190px 1fr; }
}
@media (max-width: 820px) {
  .topbar { padding: 0 12px; }
  .lobby-body { grid-template-columns: 1fr; }
  .lobby-side { display: none; }
  .lobby-main { padding: 12px; }
  .match-hero { grid-template-columns: 1fr; }
  .hero-cover { height: 140px; }
  .deck-body { grid-template-columns: 1fr; }
  .pool-filters { display: none; }
  .deck-panel { display: none; }
  .battle-stage { padding: 4px 6px 0; }
  .slot { width: 62px; }
  .breeding-zone { width: 52px; height: 74px; }
  .trash-zone { width: 40px; height: 56px; }
  .battle-bottom { grid-template-columns: 1fr; }
  .turn-actions { flex-direction: row; }
  .action-hint { text-align: center; }
  .hand-fan .card { width: 62px; margin: 0 -10px; }
  .card-tip { display: none; }
}
