/* 马站底 · 入味鸭头铺（P0 微缩手作沙盘版）：全屏覆盖层，手机竖屏与桌面端自适应 */
.space-entry {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 46px; margin-top: 10px; padding: 10px 14px;
  border: 1px solid #c84628; border-radius: 14px; background: #fff7ef; color: #a53a20;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.space-entry:hover { background: #ffeede; }
.space-entry:focus-visible { outline: 3px solid #ffb35c; outline-offset: 2px; }
.space-entry[disabled] { opacity: .55; cursor: wait; }
.space-entry small { font-weight: 400; color: #8a5a3c; }

.space {
  position: fixed; inset: 0; z-index: 400; overflow: hidden;
  background: #dbd0c2; color: #fff8ee;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.space[hidden] { display: none; }
.space canvas.space-gl {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none;
  cursor: grab;
}
.space canvas.space-gl:active { cursor: grabbing; }
.space-flat { position: absolute; inset: 0; background: #3a2a20 center 30% / cover no-repeat; }
.space-flat::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(30, 20, 14, .15), rgba(30, 20, 14, .55)); }

.space-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 22px;
  background: linear-gradient(rgba(38, 26, 18, .48), rgba(38, 26, 18, 0));
}
.space-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 4px rgba(24, 14, 8, .55); }
.space-title small { font-weight: 400; opacity: .88; margin-left: 6px; }

.space-btn {
  min-height: 44px; min-width: 44px; padding: 8px 14px;
  border-radius: 12px; border: 1px solid rgba(255, 244, 228, .42);
  background: rgba(44, 28, 19, .66); color: #fff8ee;
  font: inherit; font-size: 15px; line-height: 1.2; cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.space-btn:hover { border-color: rgba(255, 244, 228, .85); }
.space-btn:focus-visible { outline: 3px solid #ffcf70; outline-offset: 2px; }
.space-btn.primary { background: #b83f24; border-color: #d96448; color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(140, 40, 20, .28); }
.space-btn[aria-pressed="true"] { background: #fbe3c2; border-color: #fbe3c2; color: #3a2418; font-weight: 600; }
.space-btn[aria-pressed="true"]::before { content: "✓ "; }
.space-btn[disabled] { opacity: .45; cursor: default; }
.space-btn.quiet { background: transparent; border-color: transparent; text-decoration: underline; padding-inline: 6px; }
.space-btn.cam-reset { min-height: 36px; padding: 6px 11px; font-size: 13px; border-radius: 999px; background: rgba(44, 28, 19, .56); }
.space-btn.cam-reset[hidden] { display: none; }

.space-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; pointer-events: none;
  display: flex; flex-direction: column; gap: 8px;
  padding: 28px 12px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(rgba(32, 21, 14, 0), rgba(32, 21, 14, .74) 36%);
}
.space-bottom > * { pointer-events: auto; }
.space-hint { pointer-events: none !important; }
.space-say {
  background: rgba(253, 248, 240, .94); color: #2b1d14; border-radius: 14px; padding: 10px 14px;
  font-size: 15px; line-height: 1.55; min-height: 46px;
  border: 1px solid rgba(190, 155, 120, .35);
  box-shadow: 0 6px 20px rgba(28, 16, 8, .18);
}
.space-say b { color: #b83f24; margin-right: 6px; }
.space-say[data-kind="sfx"] { font-style: italic; color: #6a4b38; }
.space-hint { font-size: 13.5px; color: #ffebd0; line-height: 1.45; min-height: 1.45em; text-shadow: 0 1px 3px rgba(0, 0, 0, .45); }
.space-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.space-note { font-size: 12.5px; color: #f6dcbc; line-height: 1.5; background: rgba(24, 15, 10, .42); border-radius: 10px; padding: 8px 10px; }
.space-note .space-actions { margin-top: 6px; }

.space-labels { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.space-label {
  position: absolute; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer;
  min-height: 30px; padding: 4px 11px; border-radius: 999px; white-space: nowrap;
  background: rgba(255, 249, 239, .94); color: #3a2418; border: 1px solid rgba(184, 63, 36, .45);
  font: inherit; font-size: 13px; font-weight: 600; box-shadow: 0 3px 10px rgba(28, 16, 8, .24);
}
.space-label::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 2px; height: 6px; background: rgba(255, 249, 239, .94); transform: translateX(-50%); }
.space-label[aria-pressed="true"] { background: #b83f24; color: #fff; border-color: #b83f24; }
.space-label[aria-pressed="true"]::after { background: #b83f24; }
.space-label.on { transform: translate(-50%, -50%); border-radius: 8px; padding: 3px 8px; min-height: 28px; }
.space-label.on::after { display: none; }

.space-loading { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; text-align: center; background: rgba(48, 35, 26, .86); font-size: 15px; color: #fff8ee; }
.space-loading[hidden] { display: none; }
.space-loading .bar { width: 180px; height: 6px; margin: 10px auto 0; border-radius: 3px; background: rgba(255, 255, 255, .18); overflow: hidden; }
.space-loading .bar i { display: block; height: 100%; width: 0; background: #e89b4c; transition: width .2s; }

.space-sheet {
  position: absolute; inset: 0; z-index: 5; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(22, 14, 10, .94);
}
.space-sheet[hidden] { display: none; }
.space-sheet img { width: min(86vw, 380px); height: auto; border-radius: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); -webkit-user-select: auto; user-select: auto; -webkit-touch-callout: default; }
.space-sheet .space-actions { justify-content: center; max-width: 520px; }
.space-sheet textarea { width: min(86vw, 380px); height: 150px; font-size: 16px; border-radius: 10px; padding: 8px; }
.space-sheet p { max-width: 380px; font-size: 13px; color: #f3dcc0; text-align: center; }

#spacePrint { display: none; }
@media print {
  body.space-printing > *:not(#spacePrint) { display: none !important; }
  body.space-printing #spacePrint { display: block !important; color: #2b1d14; font-family: "Songti SC", "STSong", "SimSun", serif; }
  #spacePrint .tk { border: 2px solid #b3392b; outline: 1px solid #b3392b; outline-offset: -6px; padding: 9mm 7mm; min-height: 128mm; }
  #spacePrint h1 { font-size: 20pt; text-align: center; margin: 0; }
  #spacePrint .sub { text-align: center; font-size: 9pt; color: #8a5a3c; margin-bottom: 4mm; }
  #spacePrint .row { display: flex; justify-content: space-between; font-size: 13pt; margin: 2mm 0; }
  #spacePrint hr { border: 0; border-top: 1px dashed #b3392b; margin: 4mm 0; }
  #spacePrint .say { font-size: 12pt; }
  #spacePrint .note { font-size: 8.5pt; color: #6a4b38; }
  @page { size: 105mm 148mm; margin: 6mm; }
}

@media (min-width: 900px) {
  .space-bottom { left: 50%; right: auto; width: 520px; transform: translateX(-50%); border-radius: 18px 18px 0 0; }
}
@media (min-width: 1000px) and (min-aspect-ratio: 7/5) {
  #space[data-step="choose"] .space-bottom {
    left: auto; right: 12px; bottom: 12px; width: min(28vw, 370px);
    box-sizing: border-box; transform: none; border-radius: 14px; padding: 12px;
    background: rgba(48, 31, 21, .86);
  }
}
@media (prefers-reduced-motion: reduce) {
  .space-loading .bar i { transition: none; }
}
