:root {
  color-scheme: light;
  --paper: #f6f7f3; --ink: #193b32; --muted: #77847c; --line: #e0e6df;
  --accent: #287a54; --lime: #d8ed93; --toolbar: 72px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 14px; line-height: 1.6; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
button, input, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #69a779; outline-offset: 3px; }
button svg, nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.svg-symbols { position: absolute; width: 0; height: 0; overflow: hidden; }

/* 常驻工具栏；画面区域始终使用剩余的完整视口。 */
.topbar { height: calc(var(--toolbar) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 32px 0; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); background: var(--paper); position: relative; z-index: 50; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750; font-size: 21px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand-mark { font-size: 33px; line-height: 1; transform: rotate(90deg); }
.node-badge { font: 11px Consolas, monospace; padding-left: 14px; border-left: 1px solid #cad5ca; white-space: nowrap; color: var(--muted); min-width: 0; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; gap: 7px; margin-left: auto; }
.game-help-steps { padding-left: 22px; margin: 12px 0 0; line-height: 1.85; color: var(--muted); }
.game-help-steps li + li { margin-top: 12px; }
.waiting-room-code { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.waiting-room-code span { font-size: 14px; color: var(--muted); }
.waiting-room-code strong { font: 600 36px/1.3 Consolas, monospace; letter-spacing: 3px; user-select: all; overflow-wrap: anywhere; min-width: 0; }
.waiting-room-code .text-button { white-space: nowrap; font-size: 12px; }
.icon-button { width: 40px; height: 40px; border: 0; background: transparent; border-radius: 11px; color: #5f7467; position: relative; display: grid; place-items: center; }
.icon-button:hover, .icon-button[aria-expanded=true] { background: #e7eddf; color: var(--ink); }
.connection-dot { position: absolute; width: 5px; height: 5px; border-radius: 50%; right: 8px; top: 7px; background: #d2a248; outline: 2px solid var(--paper); }
.connection-dot.online { background: #3eaa70; }
#workspace { height: calc(100vh - var(--toolbar) - env(safe-area-inset-top)); height: calc(100dvh - var(--toolbar) - env(safe-area-inset-top)); position: relative; overflow: auto; }
.eyebrow { font: 600 10px/1.5 "Segoe UI", sans-serif; letter-spacing: 2.3px; color: #84917b; display: flex; align-items: center; gap: 9px; }
.mini-dot { width: 5px; height: 5px; border-radius: 50%; background: #78a45c; }
h1 { font-size: 58px; line-height: 1.3; letter-spacing: -2px; font-weight: 650; margin: 22px 0; }
h1 > span { color: #7da457; }
.intro { font-size: 14px; line-height: 1.9; color: var(--muted); margin: 14px 0 30px; }
.button { border: 1px solid #d7dfd4; border-radius: 10px; padding: 11px 17px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 14px; background: white; color: var(--ink); font-weight: 600; font-size: 13px; }
.button:hover:not(:disabled) { background: #ecf2e8; }
.button.primary { background: var(--ink); border-color: var(--ink); color: #f5f9ed; }
.button.primary:hover:not(:disabled) { background: #285243; }
.button.full { width: 100%; }
.entry-hint { color: #8d978c; font-size: 11px; margin: 16px 0 0; }
.entry-mode { font-size: 10px; color: #9da594; margin-top: 9px; }
.help { font-size: 11px; color: var(--muted); line-height: 1.9; margin: 14px 0; }

/* 加入入口：定位细节与手动房间号均在工具面板里。 */
.welcome-view { max-width: 950px; margin: auto; min-height: 100%; padding: 70px 60px 38px; position: relative; }
.join-button { padding: 16px 22px; border-radius: 12px; gap: 25px; }
.alias-field { display: flex; flex-direction: column; gap: 6px; width: min(100%, 310px); margin: 0 0 16px; position: relative; z-index: 2; }
.alias-field > span { font-size: 13px; font-weight: 600; }
.alias-field small { font-size: 11px; font-weight: 400; color: var(--muted); }
.alias-field > span small { margin-left: 8px; }
.alias-field input { width: 100%; min-height: 46px; border: 1px solid #d7dfd4; border-radius: 10px; padding: 10px 13px; color: var(--ink); background: #ffffffb8; }
.member-name { overflow-wrap: anywhere; min-width: 0; }
.device-art { width: 330px; height: 310px; position: absolute; right: 35px; top: 110px; pointer-events: none; }
.art-phone { position: absolute; width: 100px; height: 172px; border: 5px solid #e6eadf; border-radius: 21px; background: #e2eab9; box-shadow: 0 16px 38px #26442512; z-index: 1; display: flex; align-items: center; justify-content: center; font-style: normal; overflow: hidden; }
.art-phone:after { content: ""; position: absolute; inset: 65px -30px -60px; background: #73a270; border-radius: 50%; }
.art-phone b { z-index: 2; font: 26px Consolas, monospace; color: #f4f7db; font-weight: 400; }
.phone-a { left: 5px; top: 43px; transform: rotate(-18deg); }
.phone-b { left: 113px; top: 0; transform: rotate(8deg); background: #e9cf95; z-index: 2; }
.phone-b:after { background: #e5a76c; }
.phone-c { left: 221px; top: 73px; transform: rotate(20deg); background: #a7c9ad; }
.phone-c:after { background: #376e5b; }
.art-orbit { width: 295px; height: 210px; border: 1px dashed #c4d2b0; position: absolute; top: 85px; left: 0; border-radius: 50%; transform: rotate(-13deg); }

/* 划屏区域铺满可用宽度；仅文字保留阅读宽度和左右内边距。 */
.calibration-view { width: 100%; min-height: 100%; display: flex; flex-direction: column; padding: 22px 0 0; text-align: center; }
.calibration-view > :not(.swipe-zone) { width: 100%; max-width: 720px; margin-inline: auto; padding-inline: 30px; flex-shrink: 0; }
.calibration-view .eyebrow { justify-content: center; }
.calibration-view h1 { font-size: 36px; letter-spacing: -1px; margin: 10px 0; }
.calibration-view .intro { font-size: 12px; line-height: 1.7; margin-block: 8px 16px; }
.swipe-zone { touch-action: none; user-select: none; -webkit-user-select: none; min-height: 255px; width: 100%; background: #e8efda; border-block: 1px dashed #a7bd8c; display: flex; align-items: center; justify-content: center; flex-direction: column; color: #42754a; position: relative; }
.swipe-zone strong { font: 76px/1.2 Consolas, monospace; margin: 12px; }
.swipe-zone small { font-size: 11px; opacity: .65; margin-top: 8px; }
.swipe-track { letter-spacing: 8px; opacity: .45; font-size: 17px; }
.swipe-zone.registered { border-block-style: solid; }
.swipe-zone.flash { background: #f5ffd7; box-shadow: inset 0 0 80px #b6d97b; }
/* 最后一个区域填满剩余高度，底部不再保留说明或留白。 */
.calibration-view .swipe-zone { flex: 1; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }

/* Game discovery styles live in lobby.css. */
.guest-view { height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 6px; color: #9ca68f; font-size: 12px; }
.waiting-spark { font-size: 32px; color: #becbac; }
.game-view, #game-root, .game-slot { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
.game-view { background: #101914; }
.game-loading { position: absolute; top: 45%; left: 0; width: 100%; text-align: center; color: #b8c4b9; font-size: 13px; margin: 0; padding: 15px; }
.game-loading .button { margin-top: 16px; }
.light-game { background: #122b25; position: relative; overflow: hidden; }
.light-block { position: absolute; inset: 0 auto 0 0; background: var(--lime); will-change: transform; pointer-events: none; transition: none; }
.light-info { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; pointer-events: none; color: #d6e5cc; mix-blend-mode: difference; }
.light-info strong { font: 80px Consolas, monospace; }
.light-info p { font-size: 11px; }

/* 非模态工具面板允许直接切换上方图标，点击遮罩或 Escape 关闭。 */
.tool-backdrop { position: fixed; inset: calc(var(--toolbar) + env(safe-area-inset-top)) 0 0; background: #1a2c2320; z-index: 60; backdrop-filter: blur(2px); }
.topbar:has([aria-expanded=true]) { z-index: 80; }
.tool-dialog { position: fixed; left: auto; right: 18px; top: calc(var(--toolbar) + env(safe-area-inset-top) + 10px); width: min(390px, calc(100vw - 24px)); max-height: calc(100dvh - var(--toolbar) - env(safe-area-inset-top) - 30px); margin: 0; padding: 24px; border: 1px solid #e0e6d9; border-radius: 18px; box-shadow: 0 20px 70px #183c3324; background: white; color: var(--ink); z-index: 70; overflow: auto; }
.tool-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 16px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tool-heading h2 { font-size: 15px; margin: 0; font-weight: 650; }
.close-button { border: 0; background: #f0f3ec; color: #6e8068; width: 30px; height: 30px; border-radius: 50%; font-size: 22px; line-height: 1; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; margin: 18px 0; gap: 12px; }
.toggle-row strong { font-size: 12px; }
.toggle-row small { font-size: 10px; color: var(--muted); display: block; font-weight: 400; }
.toggle-row input { appearance: none; width: 39px; height: 23px; border-radius: 15px; background: #cbd3c5; position: relative; cursor: pointer; flex-shrink: 0; }
.toggle-row input:before { content: ""; width: 17px; height: 17px; border-radius: 50%; background: white; position: absolute; left: 3px; top: 3px; }
.toggle-row input:checked { background: #538556; }
.toggle-row input:checked:before { transform: translateX(16px); }
label { font-size: 11px; color: #71806b; }
input:not([type=checkbox]) { display: block; width: 100%; min-width: 0; border: 1px solid #dce4d7; border-radius: 8px; background: #fcfdf9; color: var(--ink); padding: 10px 12px; margin-top: 7px; font-size: 13px; }
.coordinates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-action { display: flex; gap: 8px; align-items: center; margin: 8px 0 0; }
.input-action input { margin: 0; }
.text-button { border: 0; background: transparent; padding: 12px 0; min-height: 42px; color: #538252; font-size: 11px; text-align: left; }
.text-button:hover { text-decoration: underline; }
.button-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.button-row .button { flex: 1; }
.danger { color: #ac6155; }
.connection-text { font-size: 11px; color: var(--muted); }
.share-code { font: 36px/1.5 Consolas, monospace; letter-spacing: 4px; color: var(--ink); }
#room-summary { margin: 18px 0; }
.room-overview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.room-details, .room-members { min-width: 0; }
.room-overview .share-code { font-size: clamp(24px, 8vw, 36px); letter-spacing: 3px; }
.room-members { padding-top: 10px; }
.room-members .section-heading { gap: 6px; }
.room-members .section-heading h3 { font-size: 12px; }
.room-members .members { margin: 8px 0 0; max-height: 148px; overflow-y: auto; overscroll-behavior: contain; }
.room-members .members li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 3px 7px; padding: 8px 0; }
.room-members .members li.empty { display: block; line-height: 1.6; }
.room-members .member-icon { grid-row: span 2; width: 24px; height: 24px; align-self: center; }
.room-members .member-name { font-size: 10px; }
.room-members .member-role { grid-column: 2; font-size: 9px; }
#room-maintenance { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 20px; }
.tag { display: inline-block; font-size: 10px; background: #f0f4e9; color: #6f825b; padding: 4px 8px; border-radius: 5px; white-space: nowrap; }
.tag.warn { background: #faf0d8; color: #a28743; }
.topology-scroll { overflow-x: auto; padding-top: 20px; }
.topology { position: relative; display: grid; gap: 18px 14px; margin: 22px 0; }
.topology-node { height: 52px; display: flex; align-items: center; justify-content: center; background: #f2f5ee; border: 1px solid #dce6d6; border-radius: 8px; font: 18px Consolas, monospace; position: relative; z-index: 1; }
.topology-node.self { background: #e3efd2; border-color: #7c9d61; }
.topology-node.offline { opacity: .4; }
.self-label { font: 8px sans-serif; position: absolute; bottom: 3px; right: 4px; }
.ring-edges { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 0; }
.ring-edges line, .ring-edges path { fill: none; stroke: #98b782; stroke-width: 1.5; stroke-dasharray: 4 3; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-heading h3 { font-size: 13px; margin: 0; }
.members { list-style: none; padding: 0; margin: 14px 0; }
.members li { display: flex; align-items: center; gap: 10px; font-size: 11px; padding: 11px 0; border-bottom: 1px solid #eff2ea; }
.member-icon { width: 28px; height: 28px; background: #edf3e5; border-radius: 7px; display: grid; place-items: center; color: #688b50; font: 13px Consolas, monospace; }
.member-name { flex: 1; overflow-wrap: anywhere; }
.member-role { font-size: 9px; color: #8c9980; white-space: nowrap; }
.empty { color: #9ba592; font-size: 12px; text-align: center; grid-column: 1/-1; }
.panel-divider { border-top: 1px solid var(--line); margin: 22px 0; }
.notice { position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 100; max-width: min(520px, calc(100vw - 32px)); width: max-content; background: #234c3c; color: #eff6e6; padding: 13px 20px; border-radius: 12px; box-shadow: 0 10px 40px #12332322; font-size: 12px; }
.notice.error { background: #96594b; }

@media (max-width: 760px) {
  :root { --toolbar: 60px; }
  .topbar { padding-left: 16px; padding-right: 12px; gap: 8px; }
  .brand { font-size: 17px; gap: 4px; } .brand-mark { font-size: 27px; }
  .tools { gap: 1px; } .icon-button { width: 36px; height: 38px; } .icon-button svg { width: 18px; height: 18px; }
  .node-badge { display: none; }
  .welcome-view { padding: 39px 28px 28px; max-width: 470px; }
  .welcome-view h1 { font-size: 40px; margin: 20px 0 14px; position: relative; z-index: 2; }
  .welcome-view .intro { font-size: 12px; position: relative; z-index: 2; margin-bottom: 24px; }
  .device-art { position: relative; top: auto; right: auto; width: 270px; height: 192px; margin: 6px auto 22px; }
  .art-phone { width: 75px; height: 129px; border-radius: 17px; border-width: 4px; }
  .phone-a { left: 12px; top: 29px; } .phone-b { left: 96px; top: 0; } .phone-c { left: 177px; top: 43px; }
  .art-phone:after { top: 51px; } .art-phone b { font-size: 20px; }
  .art-orbit { width: 243px; height: 119px; top: 62px; left: 4px; }
  .join-button { width: 100%; padding: 15px 14px; justify-content: space-between; }
  .alias-field { width: 100%; }
  .entry-hint, .entry-mode { text-align: center; } .welcome-view .eyebrow { font-size: 9px; }
  .calibration-view { padding: 12px 0 0; } .calibration-view > :not(.swipe-zone) { padding-inline: 24px; } .calibration-view h1 { font-size: 29px; } .calibration-view .intro { font-size: 11px; }
  .swipe-zone { min-height: 275px; }
  .tool-dialog { right: 12px; padding: 20px; } .game-loading { font-size: 12px; }
}
@media (max-width: 350px) {
  .topbar { padding-inline: 10px; } .tools { gap: 0; } .icon-button { width: 33px; }
  .brand { font-size: 15px; } .brand-mark { font-size: 24px; } .welcome-view { padding-inline: 23px; }
}
@media (max-height: 720px) and (max-width: 760px) {
  .welcome-view { padding-top: 28px; } .welcome-view h1 { font-size: 35px; margin-top: 14px; }
  .welcome-view .intro { margin-bottom: 12px; } .device-art { transform: scale(.85); margin-top: -10px; margin-bottom: 0; height: 167px; } .entry-hint { margin-top: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.recovery-panel { position: fixed; z-index: 35; top: calc(var(--toolbar) + env(safe-area-inset-top) + 8px); right: 14px; max-width: min(440px,calc(100vw - 28px)); }
.recovery-card { padding: 16px; border: 1px solid #d7dfcf; border-radius: 18px; background: #f6f7f3; box-shadow: 0 10px 35px #203a2420; }
.recovery-card strong { font-size: 18px; color: #254d3a; }
.recovery-card p { line-height: 1.7; margin: 9px 0; font-size: 13px; }
.recovery-panel.blocking { inset: calc(var(--toolbar) + env(safe-area-inset-top)) 0 0; max-width: none; background: #f6f7f3e8; display: flex; align-items: center; justify-content: center; padding: 16px; }
.recovery-panel[hidden] { display: none; }
.recovery-panel.blocking .recovery-card { width: min(440px,100%); }
.recovery-actions, .recovery-card .button-row { flex-wrap: wrap; }
.recovery-card .button { white-space: normal; min-height: 42px; }
.recovery-card summary { cursor: pointer; }
.recovery-panel:not(.blocking) .recovery-card { padding: 8px 12px; }
.recovery-panel:not(.blocking) .recovery-card strong { font-size: 12px; }
.icon-button[aria-pressed=true] { background: #e7eddf; color: #254d3a; }
#spectator-view small { display: block; padding: 10px 20px; color: #6b7c70; }
