html, body { height: 100%; margin: 0; }
body { background: #000; display: block; font-family: 'Courier New', monospace; overflow: hidden; font-size: 16px; }
/* 外层只负责居中与整体缩放。 */
#viewportWrap { width: 100vw; height: 100vh; display:flex; align-items:center; justify-content:center; overflow: hidden; }
#scaleContainer { transform-origin: 50% 50%; display: inline-block; }
.container { display: flex; flex-direction: column; align-items: center; gap: 15px; width: max-content; }
.center-topbar { width: 100%; max-width: 612px; display: flex; justify-content: space-between; align-items: center; }
.mode-top-label { color: #9fac8f; font-size: 24px; font-weight: bold; letter-spacing: 1px; }
.play-layout { display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 18px; }
.side-column { width: 280px; display: flex; flex-direction: column; gap: 15px; }
.center-column { width: auto; min-width: 592px; display: flex; flex-direction: column; align-items: center; gap: 15px; }
.panel-card { width: 100%; max-width: none; }
.panel-title { font-size: 15px; font-weight: bold; color: #20301a; margin-bottom: 8px; text-align: center; }
.connection-bar { background: #9fac8f; padding: 10px; border: 4px solid #555; width: 100%; display: flex; flex-direction: column; gap: 10px; align-items: stretch; font-size: 14px; box-sizing: border-box; transition: all 0.5s ease; }
.network-panel { background: #9fac8f; border: 4px solid #555; width: 100%; box-sizing: border-box; padding: 8px 10px; }
.network-panel summary { cursor: pointer; font-weight: bold; user-select: none; font-size: 15px; }
.network-settings-scroll { max-height: 320px; overflow-y: auto; margin-top: 8px; padding-right: 4px; }
.network-settings-scroll { scrollbar-width: thin; scrollbar-color: #555 #b7c2a9; }
.network-settings-scroll::-webkit-scrollbar { width: 10px; }
.network-settings-scroll::-webkit-scrollbar-track { background: #b7c2a9; border: 2px solid #555; }
.network-settings-scroll::-webkit-scrollbar-thumb { background: #555; border: 2px solid #3a3a3a; }
.diagnostics-panel { padding-top: 10px; }
.network-overview { display: grid; grid-template-columns: 1fr; gap: 6px; font-size: 14px; color: #222; }
.overview-item span { font-weight: bold; color: #123; }
.diagnostics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 10px; font-size: 14px; color: #222; }
.diagnostics-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.network-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-top: 10px; }
.network-field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: #222; }
.network-field textarea, .network-field input[type="text"], .network-field input[type="password"] { box-sizing: border-box; width: 100%; border: 2px solid #555; background: #dbe4cf; padding: 6px; font-family: inherit; font-size: 14px; }
.network-field textarea { resize: vertical; min-height: 68px; grid-column: 1 / -1; }
.checkbox-field { flex-direction: row; align-items: center; gap: 8px; }
.network-actions { display: flex; gap: 10px; margin-top: 10px; }
.network-hint { margin-top: 8px; font-size: 13px; color: #334; line-height: 1.4; }
.network-guide { margin-top: 8px; font-size: 13px; color: #223; line-height: 1.5; border-top: 2px solid rgba(0,0,0,0.15); padding-top: 8px; }
#my-id { font-weight: bold; color: #d32f2f; }
.copyable + #copy-tip { margin-right: 8px; }
#host-section { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#guest-section { display: flex; gap: 8px; }
#join-id { flex: 1; min-width: 0; }
.copyable { cursor: pointer; text-decoration: underline dotted; }
#copy-tip { display: inline-block; opacity: 0; font-size: 12px; color: #005588; margin-left: 5px; transition: opacity 0.2s ease; }
.retro-screen { background-color: #9fac8f; display: grid; grid-template-columns: 88px 400px 88px; width: auto; padding: 10px; border: 8px solid #555; border-radius: 4px; box-shadow: inset 0 0 50px rgba(0,0,0,0.2); box-sizing: border-box; align-items: center; column-gap: 10px; }
.canvas-wrapper { position: relative; border: 2px solid #444; background: #111; width: 400px; min-width: 400px; }
.side-panel { width: 88px; padding: 8px; display: flex; flex-direction: column; justify-content: center; align-items: center; box-sizing: border-box; overflow: visible; background: rgba(0, 0, 0, 0.08); border: 2px solid #555; }
.next-box { width: 100%; display: flex; flex-direction: column; align-items: center; }
.next-box .panel-title { width: 100%; margin: 0 0 6px; font-size: 14px; color: #20301a; }
.bottom-stats { background: #9fac8f; border: 4px solid #555; width: 100%; max-width: 612px; display: flex; justify-content: space-around; padding: 10px; box-sizing: border-box; font-weight: bold; }
.bottom-stats .stat-item { font-size: 15px; }
.retro-btn { background: #9fac8f; border: 3px solid #555; cursor: pointer; font-family: inherit; font-weight: bold; box-shadow: 3px 3px 0 #000; padding: 6px 16px; font-size: 16px; color: #111; text-decoration: none; }
.retro-btn:active { box-shadow: 0 0 0 #000; transform: translate(3px, 3px); }
.retro-btn.small { padding: 3px 10px; font-size: 14px; }
.mode-status { font-size: 16px; font-weight: bold; text-transform: uppercase; }
#statusMsg { font-weight: 700; color: #9fac8f; margin-top: 5px; }
.controls { width: 100%; display:flex; flex-direction:column; align-items:center; }
.start-btn-slot { width: 100%; min-height: 50px; display: flex; align-items: center; justify-content: center; }
#startBtn { margin: 0 !important; }
.tone-info { color: #24557a; }
.tone-success { color: #1e6b37; }
.tone-warn { color: #8a5a00; }
.tone-error { color: #9b2226; }
/* 棋盘与预览区使用固定列宽，避免 canvas 把侧栏挤出布局。 */
.canvas-wrapper canvas { width: 100%; height: auto; display: block; }
.next-canvas { width: 80px; height: 80px; border: 2px solid #444; background: #0f0f0f; }
.action-badge.show { opacity: 1; }

@media (max-width: 720px) {
  .connection-bar { gap: 8px; }
  #host-section { justify-content: space-between; }
  .network-grid { grid-template-columns: 1fr; }
  .diagnostics-grid { grid-template-columns: 1fr; }
  .network-actions { flex-direction: column; }
  #guest-section { flex-direction: column; }
  .diagnostics-actions { flex-direction: column; }
}