:root {
  --bg: #0b0b0f; --panel: #15151b; --card: #1c1c24; --line: #2a2a35;
  --text: #e8e8ef; --muted: #8b8b9a; --accent: #7dd3fc; --accent2: #38bdf8; --danger: #f87171;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* 不讓 .row/.qr-wrap 等 display:flex 蓋掉 hidden */
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", sans-serif; }
body { display: flex; flex-direction: column; min-height: 100vh; }
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; }
.hud { display: flex; gap: 22px; flex-wrap: wrap; }
.hud-item { display: flex; flex-direction: column; line-height: 1.15; }
.hud-item .lbl { font-size: 11px; color: var(--muted); }
.hud-item b { font-size: 18px; }
.hud-item small { color: var(--muted); font-size: 11px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

main { flex: 1; display: grid; grid-template-columns: 1fr 400px; min-height: 0; }
.stage { position: relative; min-height: 420px; display: flex; flex-direction: column; }
.stage canvas { flex: 1; width: 100%; height: 100%; display: block; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.stage-tools { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.stage-hint { position: absolute; bottom: 10px; left: 12px; right: 12px; font-size: 12px; color: var(--muted); }
.sep { width: 8px; }

.panel { border-left: 1px solid var(--line); background: var(--panel); overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.card-title { font-weight: 600; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-sub { font-weight: 600; margin: 10px 0 4px; font-size: 13px; }
.net-wrap { width: 100%; }
.net-wrap canvas { display: block; cursor: pointer; }
.net-wrap canvas[hidden] { display: none; }
.seg { display: flex; gap: 8px; font-weight: 400; font-size: 12px; color: var(--muted); }
.seg label { display: flex; align-items: center; gap: 3px; cursor: pointer; }
.switch { font-weight: 400; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }

button, .btn { background: #26262f; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent2); color: #062032; border-color: var(--accent2); font-weight: 700; }
button.danger { color: var(--danger); }
.movebar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 8px; }
.movebar button { padding: 5px 0; font-family: ui-monospace, Menlo, monospace; }
.levels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-bottom: 8px; }
.levels .lv { padding: 6px 0; }
.levels .lv.done { border-color: #4ade80; color: #4ade80; }
.levels .lv.active { background: var(--accent2); color: #062032; border-color: var(--accent2); font-weight: 700; }
details.small summary { cursor: pointer; color: var(--muted); }
#scrambleText { padding: 6px 0; word-break: break-all; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row input { background: #101016; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
table.records { width: 100%; border-collapse: collapse; font-size: 13px; }
table.records th, table.records td { padding: 4px 6px; text-align: center; border-bottom: 1px solid var(--line); }
table.records th { color: var(--muted); font-weight: 500; }
table.records tr.me td { color: var(--accent); font-weight: 600; }
#onlineCard select { background: #101016; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; }
.history { list-style: none; padding: 0; margin: 0; font-size: 12px; }
.history li { padding: 3px 0; border-bottom: 1px dashed var(--line); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; z-index: 10; }
.modal.show { display: flex; }
.modal-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px 28px; text-align: center; min-width: 300px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.modal-box h2 { margin: 0 0 6px; }
.stars { font-size: 30px; color: #f4d03f; letter-spacing: 4px; }
.tag { background: #14532d; color: #86efac; border-radius: 6px; padding: 1px 6px; font-size: 12px; }
.modal-box .row { justify-content: center; margin-top: 14px; }

.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar-sm { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 4px; }
.qr-wrap { display: flex; gap: 10px; align-items: center; margin: 6px 0; }
.qr svg { width: 120px; height: 120px; background: #fff; border-radius: 6px; padding: 2px; }
#joinUrlText { word-break: break-all; font-size: 11px; }
#muteBtn { font-size: 16px; padding: 4px 8px; }

.countdown { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(0,0,0,0.55); pointer-events: none; }
.countdown[hidden] { display: none; }
#countdownNum { font-size: min(40vw, 220px); font-weight: 900; color: #fbbf24; text-shadow: 0 0 40px rgba(251,191,36,0.6); line-height: 1; }
#countdownNum.pop { animation: pop 0.6s ease-out; }
.countdown-sub { color: #fff; font-size: 18px; margin-top: 12px; }
@keyframes pop { 0% { transform: scale(1.6); opacity: 0.2; } 100% { transform: scale(1); opacity: 1; } }

.join-box { max-width: 360px; }
.join-avatar { width: 160px; height: 160px; margin: 8px auto; border-radius: 50%; overflow: hidden; background: #101016; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; position: relative; }
.join-avatar img, .join-avatar video { width: 100%; height: 100%; object-fit: cover; }
.avatar-empty { font-size: 48px; color: var(--muted); }
.join-box input { width: 100%; font-size: 16px; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .stage { min-height: 55vh; }
  .panel { border-left: none; border-top: 1px solid var(--line); }
  .stage-hint { display: none; }
}
