:root {
  --bg0: #060912;
  --bg1: #0b1226;
  --panel: rgba(16, 24, 46, 0.78);
  --panel2: rgba(22, 32, 60, 0.9);
  --line: rgba(130, 160, 255, 0.16);
  --line2: rgba(130, 160, 255, 0.3);
  --text: #e6ecff;
  --muted: #8b97b8;
  --accent: #38e1ff;
  --accent2: #7c5cff;
  --t0: #4ea8ff;
  --t1: #ff8a3d;
  --ok: #5ee39a;
  --warn: #ffd166;
  --bad: #ff5a7a;
  --radius: 14px;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 30% 0%, #13204a 0%, var(--bg0) 60%) fixed, var(--bg0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
#bgfx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
#app { position: relative; z-index: 1; height: 100%; }
button, input, select { font: inherit; color: inherit; }
code { font-family: var(--mono); background: rgba(124, 92, 255, 0.16); border: 1px solid rgba(124, 92, 255, 0.25); padding: 0 5px; border-radius: 5px; font-size: 0.92em; color: #d8ccff; }
kbd { font-family: var(--mono); font-size: 10px; opacity: 0.7; border: 1px solid rgba(255,255,255,.35); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  border: 1px solid var(--line2); background: rgba(40, 56, 100, 0.55); color: var(--text);
  padding: 8px 16px; border-radius: 10px; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: rgba(60, 80, 140, 0.7); border-color: rgba(150, 180, 255, .5); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, #2f7bff, #7c5cff); border-color: transparent; box-shadow: 0 6px 20px rgba(80, 100, 255, .3); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(80, 110, 200, .18); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.big { padding: 11px 26px; font-size: 15px; }
.btn.danger { border-color: rgba(255, 90, 122, .5); color: #ffb3c2; }
.icon-btn { background: rgba(30, 44, 80, .6); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px; cursor: pointer; }
input[type=text], input:not([type]), input[type=number], select {
  background: rgba(8, 13, 28, 0.75); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 225, 255, .15); }
select option { background: #0e1630; }
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; cursor: pointer; }

/* ---------- 屏幕 ---------- */
.screen { display: none; height: 100%; overflow-y: auto; }
.screen.active { display: block; animation: fadein .25s ease; }
#scr-game.active { display: grid; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page { max-width: 1100px; margin: 0 auto; padding: 22px 20px 40px; }
.page.narrow { max-width: 760px; }
.page.wide-page { max-width: 1280px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: 1px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 small { color: var(--muted); font-weight: normal; font-size: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.row-end { display: flex; justify-content: flex-end; margin-top: 16px; }

/* ---------- 菜单 ---------- */
#scr-menu { padding: 18px 20px 30px; }
.menu-top { display: flex; justify-content: flex-end; gap: 10px; max-width: 1000px; margin: 0 auto; }
.namebox { display: flex; align-items: center; gap: 8px; background: rgba(16, 24, 46, .7); border: 1px solid var(--line); border-radius: 12px; padding: 4px 4px 4px 12px; }
.namebox span { color: var(--muted); font-size: 13px; }
.namebox input { width: 150px; padding: 6px 10px; }
.logo { text-align: center; margin: 4vh 0 4vh; }
.logo-mark { width: 150px; height: 75px; filter: drop-shadow(0 0 18px rgba(56, 225, 255, .35)); }
.logo h1 { margin: 6px 0 4px; font-size: clamp(40px, 7vw, 68px); letter-spacing: 2px; font-weight: 800;
  background: linear-gradient(90deg, #8fd0ff, #ffffff 45%, #ffc29a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo h1 span { background: linear-gradient(90deg, #ffb27a, #ff7a3d); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo .sub { color: var(--muted); margin: 0; font-size: 15px; letter-spacing: 2px; }
.menu-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; max-width: 980px; margin: 0 auto; }
.menu-card {
  text-align: left; cursor: pointer; padding: 20px 20px 18px; border-radius: 18px; border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(30, 44, 86, .75), rgba(14, 20, 40, .8)); position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px; transition: transform .18s, border-color .18s, box-shadow .18s;
}
.menu-card::after { content: ''; position: absolute; inset: -40% -40% auto auto; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 225, 255, .18), transparent 70%); transition: opacity .2s; opacity: .5; }
.menu-card:hover { transform: translateY(-3px); border-color: rgba(56, 225, 255, .45); box-shadow: 0 14px 34px rgba(30, 120, 255, .22); }
.menu-card:hover::after { opacity: 1; }
.menu-card i { font-style: normal; font-size: 26px; }
.menu-card b { font-size: 18px; }
.menu-card small { color: var(--muted); font-size: 13px; line-height: 1.5; }
.menu-card.hot { border-color: rgba(255, 138, 61, .45); background: linear-gradient(160deg, rgba(90, 44, 30, .6), rgba(20, 18, 40, .85)); }
.menu-card.hot::after { background: radial-gradient(circle, rgba(255, 138, 61, .25), transparent 70%); }
.menu-foot { text-align: center; color: var(--muted); margin-top: 26px; font-size: 13px; }

/* ---------- 教程列表 / 手册 ---------- */
.tut-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tut-item { cursor: pointer; text-align: left; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); padding: 16px; transition: all .15s; position: relative; }
.tut-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.tut-item .n { font-family: var(--mono); color: var(--accent); font-size: 12px; }
.tut-item b { display: block; font-size: 16px; margin: 4px 0; }
.tut-item.done::after { content: '✓ 已通关'; position: absolute; top: 14px; right: 14px; color: var(--ok); font-size: 12px; }
.hb-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.hb-card { display: flex; flex-direction: column; gap: 8px; }
.hb-card canvas { width: 100%; height: 130px; border-radius: 10px; border: 1px solid var(--line); }
.hb-card .tags { color: var(--accent); font-size: 12px; }
.hb-card p { margin: 0; color: #c3cbe4; line-height: 1.65; font-size: 13.5px; flex: 1; }
.hb-card .expr { font-family: var(--mono); font-size: 13px; color: #fff; }
.rules-body { line-height: 1.8; color: #cdd5ee; font-size: 14px; }
.rules-body h4 { margin: 14px 0 4px; color: var(--accent); }
.rules-body ul { margin: 4px 0; padding-left: 20px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin-bottom: 8px; }
.form-grid.compact { gap: 8px 12px; }
.fg { display: flex; flex-direction: column; gap: 5px; }
.fg label { color: var(--muted); font-size: 12.5px; }
.fg select, .fg input { width: 100%; }
.fg .ro { padding: 7px 12px; border-radius: 10px; background: rgba(8, 13, 28, .5); border: 1px solid var(--line); font-size: 13.5px; }
.form-sep { grid-column: 1 / -1; border-top: 1px dashed var(--line); margin: 4px 0; }

/* ---------- 大厅 ---------- */
.server-card { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.server-card input { flex: 1; min-width: 220px; font-family: var(--mono); font-size: 13px; }
.srv-label { color: var(--muted); font-size: 13px; }
.conn-state { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin-left: auto; }
.conn-state .dot { width: 9px; height: 9px; border-radius: 50%; background: #59627e; }
.conn-state.ok .dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.conn-state.wait .dot { background: var(--warn); animation: blink 1s infinite; }
.conn-state.bad .dot { background: var(--bad); }
@keyframes blink { 50% { opacity: .3; } }
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lobby-grid .card { display: flex; flex-direction: column; gap: 10px; }
.lobby-grid .card.wide { grid-column: 1 / -1; }
.code-input { font-family: var(--mono); letter-spacing: 6px; text-transform: uppercase; font-size: 18px; text-align: center; }
.room-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.room-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; background: rgba(8, 13, 28, .5); border: 1px solid var(--line); }
.room-row .code { font-family: var(--mono); color: var(--accent); }
.room-row .nm { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-row .cnt { color: var(--muted); font-size: 13px; }
.room-row .st { font-size: 12px; padding: 2px 8px; border-radius: 20px; background: rgba(94, 227, 154, .14); color: var(--ok); }
.room-row .st.play { background: rgba(255, 209, 102, .14); color: var(--warn); }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* ---------- 房间 ---------- */
.room-code { font-family: var(--mono); font-size: 18px; letter-spacing: 4px; padding: 4px 14px; border-radius: 10px; cursor: pointer;
  background: rgba(56, 225, 255, .1); border: 1px dashed rgba(56, 225, 255, .5); color: var(--accent); }
.playing-banner { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px; border-radius: 12px; margin-bottom: 14px;
  background: rgba(255, 209, 102, .1); border: 1px solid rgba(255, 209, 102, .35); color: var(--warn); }
.room-body { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; }
.team { border-radius: var(--radius); padding: 14px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; min-height: 220px; }
.team.t0 { border-top: 3px solid var(--t0); }
.team.t1 { border-top: 3px solid var(--t1); }
.team.tspec { grid-column: 1 / -1; min-height: 0; border-top: 3px solid #59627e; }
.team-head { display: flex; align-items: baseline; gap: 8px; }
.team-head b { font-size: 16px; }
.t0 .team-head b { color: var(--t0); }
.t1 .team-head b { color: var(--t1); }
.team-head small { color: var(--muted); font-size: 12px; }
.members { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tspec .members { flex-direction: row; flex-wrap: wrap; }
.member { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(8, 13, 28, .55); border: 1px solid var(--line); }
.member .av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.t0 .member .av { background: rgba(78, 168, 255, .25); color: var(--t0); }
.t1 .member .av { background: rgba(255, 138, 61, .25); color: var(--t1); }
.tspec .member .av { background: rgba(140, 150, 180, .2); }
.member .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member.me { border-color: rgba(56, 225, 255, .5); }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 20px; background: rgba(130, 160, 255, .15); color: #b8c6f0; white-space: nowrap; }
.tag.host { background: rgba(255, 209, 102, .15); color: var(--warn); }
.tag.off { background: rgba(255, 90, 122, .15); color: var(--bad); }
.tag.bot { background: rgba(124, 92, 255, .2); color: #c7b8ff; }
.member .kick { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 14px; }
.member .kick:hover { color: var(--bad); }
.team-act { display: flex; gap: 6px; flex-wrap: wrap; }
.room-side { display: flex; flex-direction: column; gap: 14px; }
.chat-card { display: flex; flex-direction: column; min-height: 220px; }
.chat-card .log { height: 200px; }
.room-foot { display: flex; justify-content: flex-end; align-items: center; gap: 16px; margin-top: 16px; }

/* ---------- 日志 / 聊天 ---------- */
.log { overflow-y: auto; font-size: 13px; line-height: 1.55; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.log .ln { padding: 3px 8px; border-radius: 6px; background: rgba(8, 13, 28, .4); word-break: break-word; }
.log .ln.sys { color: var(--muted); background: none; font-size: 12px; }
.log .ln b.t0 { color: var(--t0); }
.log .ln b.t1 { color: var(--t1); }
.log .ln .shot { font-family: var(--mono); font-size: 12px; color: #dfe7ff; cursor: pointer; border-bottom: 1px dashed rgba(56, 225, 255, .5); }
.log .ln .shot:hover { color: var(--accent); }
.log .ln.good { border-left: 3px solid var(--ok); }
.log .ln.bad { border-left: 3px solid var(--bad); }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form input { flex: 1; min-width: 0; padding: 6px 10px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(130, 160, 255, .22); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 游戏布局 ---------- */
#scr-game { grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; overflow: hidden; }
.g-top { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: rgba(8, 12, 26, .7); backdrop-filter: blur(10px); }
.g-title { color: var(--muted); font-size: 13px; white-space: nowrap; }
.g-turn { flex: 1; text-align: center; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-turn.mine { color: #fff; text-shadow: 0 0 14px rgba(56, 225, 255, .8); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .75; } }
.g-timer { position: relative; width: 40px; height: 40px; flex: none; }
.g-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.g-timer circle { fill: none; stroke-width: 3; }
.g-timer .track { stroke: rgba(130, 160, 255, .15); }
.g-timer .arc { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 94.25; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear, stroke .3s; }
.g-timer.warn .arc { stroke: var(--bad); }
.g-timer span { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-size: 12px; }
.g-main { display: grid; grid-template-columns: minmax(0, 1fr) 250px; min-height: 0; }
.g-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; padding: 8px; }
#g-canvas { display: block; border-radius: 12px; box-shadow: 0 0 0 1px var(--line), 0 16px 40px rgba(0, 0, 0, .45); cursor: crosshair; }
.g-banner { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); max-width: 80%; padding: 6px 16px; border-radius: 20px;
  background: rgba(6, 10, 22, .82); border: 1px solid var(--line2); font-family: var(--mono); font-size: 13px; pointer-events: none;
  opacity: 0; transition: opacity .3s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-banner.show { opacity: 1; }
.g-coord { position: absolute; top: 16px; right: 18px; font-family: var(--mono); font-size: 12px; padding: 4px 10px; border-radius: 8px;
  background: rgba(6, 10, 22, .78); border: 1px solid var(--line); color: #bcd0ff; pointer-events: none; white-space: pre; line-height: 1.5; }
.g-coord:empty { display: none; }
.g-tut { position: absolute; left: 18px; top: 16px; width: min(380px, 46%); max-height: calc(100% - 32px); overflow-y: auto; padding: 14px 16px;
  border-radius: 14px; background: rgba(8, 13, 30, .9); border: 1px solid rgba(56, 225, 255, .35); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); font-size: 13.5px; line-height: 1.7; }
.g-tut h3 { margin: 0 0 6px; font-size: 16px; color: var(--accent); }
.g-tut .hint { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(255, 209, 102, .08); border: 1px dashed rgba(255, 209, 102, .4); }
.g-tut .acts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.g-tut.min { width: auto; }
.g-tut.min .body { display: none; }
.g-side { border-left: 1px solid var(--line); background: rgba(8, 12, 26, .55); display: flex; flex-direction: column; min-height: 0; padding: 10px; gap: 10px; }
.side-block h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.side-block.grow { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.side-block.grow .log { flex: 1; min-height: 60px; }
.plist { display: flex; flex-direction: column; gap: 6px; max-height: 36vh; overflow-y: auto; }
.pl { padding: 6px 8px; border-radius: 8px; background: rgba(8, 13, 28, .5); border: 1px solid transparent; }
.pl.t0 { border-left: 3px solid var(--t0); }
.pl.t1 { border-left: 3px solid var(--t1); }
.pl.cur { border-color: rgba(56, 225, 255, .55); box-shadow: 0 0 12px rgba(56, 225, 255, .2); }
.pl .top { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.pl .top .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .units { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.hpbar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.hpbar i { display: block; height: 100%; background: var(--ok); transition: width .4s; }
.hpbar.mid i { background: var(--warn); }
.hpbar.low i { background: var(--bad); }
.unit-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.unit-row .hpbar { flex: 1; }
.unit-row.dead { opacity: .4; text-decoration: line-through; }
.unit-row.act { color: #fff; }

/* ---------- 输入面板 ---------- */
.g-panel { display: grid; grid-template-columns: minmax(280px, 1.15fr) auto minmax(230px, .85fr); gap: 12px; padding: 10px 14px 12px; height: 252px;
  border-top: 1px solid var(--line); background: linear-gradient(180deg, rgba(12, 18, 38, .92), rgba(6, 10, 22, .96)); }
.p-left { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
.p-bar { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.p-tabs { display: flex; background: rgba(8, 13, 28, .7); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.p-tabs button { border: none; background: none; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 13px; }
.p-tabs button.on { background: linear-gradient(135deg, rgba(47, 123, 255, .5), rgba(124, 92, 255, .5)); color: #fff; }
.p-tools { display: flex; gap: 6px; }
.p-editors { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px; }
.fe-row { display: flex; align-items: stretch; gap: 8px; }
.fe-label { flex: none; display: flex; align-items: center; gap: 4px; font-family: var(--mono); color: #a9b8e8; font-size: 14px; min-width: 52px; white-space: nowrap; }
.fe-label input { width: 64px; padding: 3px 6px; font-family: var(--mono); font-size: 13px; }
.fe-row .pc-del { background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); cursor: pointer; padding: 0 8px; }
.fe-row .pc-del:hover { color: var(--bad); border-color: var(--bad); }
.pc-tools { display: flex; gap: 12px; align-items: center; }
.fe {
  flex: 1; min-width: 0; height: 44px; position: relative; border-radius: 10px; cursor: text;
  background: rgba(4, 8, 18, .85); border: 1px solid var(--line2); transition: border-color .15s, box-shadow .15s;
}
.fe.active { border-color: rgba(56, 225, 255, .55); }
.fe:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 225, 255, .14), inset 0 0 20px rgba(56, 225, 255, .05); }
.fe .fe-hl, .fe .fe-in {
  position: absolute; inset: 0; margin: 0; border: 0; padding: 0 12px; width: 100%; height: 100%;
  font-family: var(--mono); font-size: 19px; line-height: 42px; letter-spacing: 0; font-weight: 400; font-style: normal;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; font-kerning: none; tab-size: 4;
}
.fe-hl { white-space: pre; overflow: hidden; pointer-events: none; color: #e8eeff; }
.fe-hl-in { display: inline-block; white-space: pre; }
.fe .fe-in { background: transparent; color: transparent; caret-color: var(--accent); outline: none; box-shadow: none !important; border-radius: 10px; -webkit-text-fill-color: transparent; }
.fe-in::selection { background: rgba(56, 225, 255, .3); }
.fe-in::placeholder { color: rgba(139, 151, 184, .55); -webkit-text-fill-color: rgba(139, 151, 184, .55); font-family: var(--sans); font-size: 14px; }
.fe-hl .c-num { color: #ffe08a; }
.fe-hl .c-var { color: #7ff0c3; }
.fe-hl .c-const { color: #ffb3e6; }
.fe-hl .c-fn { color: #8fc7ff; }
.fe-hl .c-op { color: #d6defa; }
.fe-hl .c-unk { color: #ff8fa3; text-decoration: underline wavy rgba(255, 90, 122, .8); }
.fe-hl .br.d0 { color: #ffd166; }
.fe-hl .br.d1 { color: #ff7ad9; }
.fe-hl .br.d2 { color: #5ce1ff; }
.fe-hl .br.d3 { color: #9dff7a; }
.fe-hl .br.d4 { color: #ff9f5a; }
.fe-hl .br.d5 { color: #b79bff; }
.fe-hl .br.unm { color: #ff5a7a; text-decoration: underline wavy #ff5a7a; }
.fe-hl .br.mt { background: rgba(255, 255, 255, .2); border-radius: 3px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .45); }
.fe-hl .gb { text-shadow: 0 0 8px currentColor; }
.fe-hl .ing { background: rgba(56, 225, 255, .09); }
.fe-hl .err { background: rgba(255, 90, 122, .35); box-shadow: 0 0 0 1px #ff5a7a; border-radius: 2px; }
.fe-hl .c-errend { color: #ff5a7a; animation: blink 1s infinite; }
.p-msg { font-size: 12.5px; height: 18px; line-height: 18px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.p-msg.err { color: var(--bad); }
.p-msg .ok { color: var(--ok); }

.p-keys { display: flex; gap: 10px; align-items: flex-start; }
.kp { display: grid; gap: 4px; }
.kp-fn { grid-template-columns: repeat(4, 52px); }
.kp-num { grid-template-columns: repeat(5, 42px); }
.kp-nav { grid-template-columns: 34px; }
.key {
  height: 33px; border-radius: 8px; border: 1px solid rgba(130, 160, 255, .18); cursor: pointer; font-size: 14px;
  background: linear-gradient(180deg, rgba(40, 54, 96, .75), rgba(24, 33, 62, .85)); color: #e8eeff; transition: background .1s, transform .05s;
  font-family: var(--mono); padding: 0;
}
.key:hover { background: linear-gradient(180deg, rgba(60, 80, 140, .85), rgba(34, 46, 86, .9)); }
.key:active { transform: scale(.95); }
.key-fn { color: #8fc7ff; font-size: 13px; }
.key-n { font-size: 16px; color: #ffe08a; }
.key-op { color: #fff; font-size: 16px; }
.key-open, .key-close { color: #ffd166; font-size: 16px; font-weight: 700; }
.key-var { color: #7ff0c3; font-style: italic; font-size: 17px; background: linear-gradient(180deg, rgba(30, 90, 80, .8), rgba(18, 50, 50, .9)); }
.key-const { color: #ffb3e6; }
.key-bk { color: #ffb3c2; }
.key-clr { font-size: 12px; color: var(--muted); font-family: var(--sans); }
.key-nav { color: var(--accent); }

.p-right { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
.mini-wrap { position: relative; }
#p-mini { width: 100%; height: 92px; display: block; border-radius: 10px; border: 1px solid var(--line); }
.mini-cap { position: absolute; left: 8px; bottom: 4px; font-size: 10px; color: rgba(139, 151, 184, .7); pointer-events: none; }
.p-stats { flex: 1; font-size: 12.5px; line-height: 1.6; color: #c3cbe4; min-height: 0; overflow-y: auto; }
.p-stats .bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; margin: 3px 0 4px; }
.p-stats .bar i { display: block; height: 100%; background: linear-gradient(90deg, #38e1ff, #7c5cff); }
.p-stats .bar.hi i { background: linear-gradient(90deg, #ffd166, #ff5a7a); }
.p-stats .hit { color: #fff; }
.p-stats .hit.fr { color: var(--bad); }
.p-stats .crit { color: var(--warn); font-weight: 700; }
.p-fire { display: flex; gap: 8px; align-items: center; }
.btn.fire { flex: 1; padding: 12px; font-size: 17px; font-weight: 700; letter-spacing: 2px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #ff5a3d, #ff9a3d); box-shadow: 0 8px 24px rgba(255, 110, 60, .35); }
.btn.fire:hover:not(:disabled) { filter: brightness(1.1); }
.btn.fire:disabled { background: #2a3352; box-shadow: none; }

/* ---------- 浮层 ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(3, 6, 14, .72); backdrop-filter: blur(6px); animation: fadein .3s; }
.over-box { width: min(620px, 92vw); max-height: 90vh; overflow-y: auto; background: var(--panel2); border: 1px solid var(--line2); border-radius: 18px; padding: 26px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.over-box h2 { margin: 0 0 6px; font-size: 32px; letter-spacing: 3px; }
.over-box h2.win { color: var(--ok); text-shadow: 0 0 24px rgba(94, 227, 154, .5); }
.over-box h2.lose { color: var(--bad); }
.over-box table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13.5px; }
.over-box th, .over-box td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
.over-box th { color: var(--muted); font-weight: normal; font-size: 12.5px; }
.over-box td:first-child, .over-box th:first-child { text-align: left; }
.over-acts { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
#scr-game { position: relative; user-select: none; -webkit-user-select: none; }
#scr-game input { user-select: text; -webkit-user-select: text; }
.g-side .log { user-select: text; -webkit-user-select: text; }

#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 9px 18px; border-radius: 12px; background: rgba(14, 22, 44, .95); border: 1px solid var(--line2); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); font-size: 14px; animation: toastin .25s; max-width: 90vw; }
.toast.err { border-color: rgba(255, 90, 122, .6); color: #ffc2cf; }
.toast.ok { border-color: rgba(94, 227, 154, .6); color: #c6f5dc; }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } }
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(3, 6, 14, .7); backdrop-filter: blur(5px); }
.modal-box { width: min(640px, 92vw); max-height: 86vh; overflow-y: auto; background: var(--panel2); border: 1px solid var(--line2); border-radius: 18px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.modal-box h3 { margin: 0 0 12px; font-size: 18px; }
.modal-acts { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.pop { position: fixed; z-index: 80; min-width: 260px; max-width: min(440px, 94vw); max-height: 60vh; overflow-y: auto; background: var(--panel2); border: 1px solid var(--line2); border-radius: 12px; padding: 8px; box-shadow: 0 14px 40px rgba(0, 0, 0, .5); }
.pop-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.pop-item:hover { background: rgba(80, 110, 200, .2); }
.pop-item .t { font-weight: 600; font-size: 13px; white-space: nowrap; }
.pop-item .e { font-family: var(--mono); font-size: 12px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop h5 { margin: 6px 8px 4px; color: var(--muted); font-size: 12px; font-weight: normal; }
.slot { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 8px; }
.slot:hover { background: rgba(80, 110, 200, .12); }
.slot .no { width: 20px; text-align: center; color: var(--accent); font-family: var(--mono); font-size: 12px; }
.slot .e { flex: 1; font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.slot .e.empty { color: rgba(139, 151, 184, .5); cursor: default; }
.slot button { font-size: 11px; padding: 2px 7px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .g-panel { grid-template-columns: minmax(0, 1fr) auto; height: auto; }
  .p-editors { max-height: 150px; }
  .p-stats { height: 70px; flex: none; }
  .p-right.nomini { grid-template-columns: 1fr auto; }
  .p-right { grid-column: 1 / -1; display: grid; grid-template-columns: 200px 1fr auto; align-items: center; }
  #p-mini { height: 70px; }
  .p-stats { max-height: 70px; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lobby-grid, .room-body { grid-template-columns: 1fr; }
  #scr-game.active { display: block; height: auto; min-height: 100%; overflow: visible; }
  #scr-game { overflow: visible; }
  .screen.active#scr-game { overflow-y: auto; height: 100%; }
  .g-main { grid-template-columns: 1fr; }
  .g-stage { aspect-ratio: 5 / 3; padding: 4px; }
  .g-side { border-left: none; border-top: 1px solid var(--line); flex-direction: row; }
  .g-side .side-block { flex: 1; min-width: 0; }
  .side-block.grow .log { max-height: 130px; }
  .g-panel { grid-template-columns: 1fr; height: auto; }
  .p-keys { justify-content: center; flex-wrap: wrap; }
  .p-right { grid-template-columns: 1fr; }
  .g-tut { left: 8px; top: 8px; width: 72%; max-height: calc(100% - 16px); font-size: 12px; padding: 10px 12px; line-height: 1.55; }
  .g-coord { font-size: 10px; }
  .g-title { display: none; }
}
@media (max-width: 560px) {
  .menu-grid { grid-template-columns: 1fr; }
  .teams { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .kp-fn { grid-template-columns: repeat(4, minmax(44px, 1fr)); }
  .kp-num { grid-template-columns: repeat(5, minmax(38px, 1fr)); }
  .p-keys { flex-direction: column; align-items: stretch; }
  .kp-nav { grid-template-columns: repeat(4, 1fr); }
  .g-side { flex-direction: column; }
  .page { padding: 14px 12px 30px; }
}
