html,
body.chess3d-body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100%;
}

body.chess3d-body {
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(255, 220, 160, 0.35), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(15, 92, 76, 0.2), transparent 50%),
    linear-gradient(160deg, #2a1c12 0%, #4a321f 38%, #6b4528 72%, #3a2618 100%);
  font-family: var(--font-body);
}

body.chess3d-body canvas {
  display: block;
  position: fixed;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 0;
}

body.chess3d-body #gui,
body.chess3d-body #info,
body.chess3d-body .chess3d-bar,
body.chess3d-body .ui-dialog,
body.chess3d-body .ui-widget-overlay,
body.chess3d-body #progressbar,
body.chess3d-body #tips {
  z-index: 20;
}

/* 顶栏对齐围棋游戏页品牌区 */
.chess3d-bar {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.35rem 1.1rem;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(28, 20, 16, 0.72), rgba(28, 20, 16, 0.2) 70%, transparent);
}

.chess3d-bar .brand,
.chess3d-bar .topbar-actions {
  pointer-events: auto;
}

.chess3d-bar .brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  line-height: 1;
}

.chess3d-bar .brand a {
  text-decoration: none;
  color: inherit;
}

.chess3d-bar .brand p {
  margin: 0.25rem 0 0;
  color: rgba(248, 236, 214, 0.8);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}

.chess3d-bar .btn.secondary {
  background: transparent;
  color: var(--cream);
  border: 1px solid rgba(248, 236, 214, 0.35);
  border-radius: 12px;
  padding: 0.65rem 0.95rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  display: inline-flex;
}

/* 右侧面板：尽量贴近围棋侧栏卡片感 */
#gui {
  top: 6.2rem !important;
  right: 1.15rem !important;
  left: auto !important;
  width: min(300px, calc(100vw - 2rem)) !important;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 7.5rem);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 248, 235, 0.92) !important;
  border: 1px solid rgba(255, 245, 220, 0.55) !important;
  border-radius: 18px !important;
  box-shadow: 0 14px 32px rgba(20, 12, 8, 0.3);
  color: #1c1410 !important;
  font-family: var(--font-body), "Noto Serif SC", serif !important;
  padding-bottom: 0.55rem;
  backdrop-filter: blur(8px);
}

#gui .panel-title {
  background: rgba(15, 92, 76, 0.12);
  color: #1c1410;
  border: none;
  font-family: var(--font-display), "ZCOOL XiaoWei", serif;
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  margin: 0;
  padding: 0.75rem 1rem;
}

#gui .panel-title + .setup-panel,
#gui .panel-title + .ops-panel {
  border-top: none;
}

#gui .ops-panel {
  border-top: 1px solid rgba(61, 47, 38, 0.1);
}

#gui .setup-panel,
#gui .ops-panel {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem 0.95rem;
  color: #3d2f26;
}

#gui .field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

#gui ul {
  padding: 0;
  margin: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

#gui li {
  margin: 0;
}

#gui label {
  display: block;
  margin: 0;
  color: #3d2f26;
  font-size: 0.92rem;
}

#gui .btn-primary {
  width: 100% !important;
  box-sizing: border-box !important;
  background: #0f5c4c !important;
  color: #f7fff9 !important;
  border: none !important;
  border-radius: 12px !important;
  font-family: var(--font-body), serif !important;
  letter-spacing: 0.04em;
  padding: 0.65rem 0.5rem !important;
  cursor: pointer;
  min-height: 42px;
}

#gui .btn-primary:hover {
  background: #1a7a66 !important;
}

#gui select,
#gui textarea {
  width: 100% !important;
  max-width: 100%;
  box-sizing: border-box !important;
  background: rgba(255, 255, 255, 0.55) !important;
  border: 1px solid rgba(61, 47, 38, 0.25) !important;
  color: #1c1410 !important;
  border-radius: 10px !important;
  font-family: var(--font-body), serif !important;
  padding: 0.4rem 0.5rem;
}

#gui textarea {
  min-height: 9rem;
  resize: vertical;
  margin-top: 0.35rem;
}

#gui button,
#gui .ui-button {
  width: 100% !important;
  box-sizing: border-box !important;
  background: #0f5c4c !important;
  color: #f7fff9 !important;
  border: none !important;
  border-radius: 12px !important;
  font-family: var(--font-body), serif !important;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.4rem !important;
}

#gui .ui-button:hover {
  background: #1a7a66 !important;
}

.ui-dialog {
  background: rgba(255, 248, 235, 0.97) !important;
  border: 1px solid rgba(255, 245, 220, 0.7) !important;
  border-radius: 16px !important;
  box-shadow: 0 18px 40px rgba(20, 12, 8, 0.35) !important;
  font-family: var(--font-body), "Noto Serif SC", serif !important;
  color: #1c1410 !important;
  padding: 0 !important;
}

.ui-dialog .ui-dialog-titlebar {
  background: rgba(15, 92, 76, 0.14) !important;
  border: none !important;
  border-radius: 16px 16px 0 0 !important;
  color: #1c1410 !important;
  font-family: var(--font-display), "ZCOOL XiaoWei", serif !important;
  letter-spacing: 0.08em;
}

.ui-dialog .ui-dialog-content {
  background: transparent !important;
  color: #3d2f26 !important;
}

.ui-dialog .ui-dialog-buttonpane {
  background: transparent !important;
  border-top: 1px solid rgba(61, 47, 38, 0.12) !important;
}

.ui-dialog .ui-button {
  background: #0f5c4c !important;
  color: #f7fff9 !important;
  border: none !important;
  border-radius: 10px !important;
}

#info {
  top: 6rem !important;
  left: 1.2rem !important;
  right: auto !important;
  color: #f3c27a !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  font-family: var(--font-display), serif !important;
  letter-spacing: 0.08em;
  background: rgba(28, 20, 16, 0.45);
  border: 1px solid rgba(255, 245, 220, 0.2);
  border-radius: 12px;
  padding: 0.45rem 0.75rem;
}

#progressbar {
  border-color: rgba(248, 236, 214, 0.45) !important;
}

#progress-label,
#tips {
  color: #f8ecd6 !important;
  font-family: var(--font-body), "Noto Serif SC", serif;
}

.webgl-fallback {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  gap: 0.75rem;
  padding: 2rem;
  text-align: center;
  color: #f8ecd6;
  background: rgba(28, 20, 16, 0.82);
  font-family: var(--font-body), "Noto Serif SC", serif;
}

.webgl-fallback h2 {
  margin: 0;
  font-family: var(--font-display), "ZCOOL XiaoWei", serif;
  letter-spacing: 0.12em;
}

.webgl-fallback a {
  color: #7dcfb6;
}

@media (max-width: 720px) {
  .chess3d-bar {
    padding: 0.7rem 0.85rem;
    padding-top: calc(0.7rem + env(safe-area-inset-top));
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .chess3d-bar .brand h1 {
    font-size: clamp(1.45rem, 7vw, 2rem);
  }

  .chess3d-bar .brand p {
    font-size: 0.8rem;
  }

  .chess3d-bar .btn.secondary {
    min-height: 40px;
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
  }

  #gui {
    top: auto !important;
    bottom: calc(0.65rem + env(safe-area-inset-bottom)) !important;
    right: 0.65rem !important;
    left: 0.65rem !important;
    width: auto !important;
    max-height: min(52vh, 440px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  #gui ul {
    grid-template-columns: 1fr 1fr;
  }

  #gui button,
  #gui .ui-button {
    min-height: 40px;
  }

  #info {
    top: auto !important;
    bottom: calc(min(38vh, 320px) + 1rem + env(safe-area-inset-bottom)) !important;
    left: 0.75rem !important;
    right: 0.75rem !important;
    font-size: 0.9rem;
  }
}
