/* 互動空間：全螢幕的地圖畫面 */
html.sp-open, html.sp-open body { overflow: hidden; }
.sp { position: fixed; inset: 0; z-index: 400; background: #101018; color: #fff; user-select: none; -webkit-user-select: none; touch-action: none; font-family: 'Noto Sans TC', sans-serif; }
.sp[hidden] { display: none; }
.sp-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.sp-ui { position: absolute; inset: 0; pointer-events: none; padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.sp-ui > * { pointer-events: auto; }

.sp-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sp-rooms { display: flex; gap: 4px; background: rgba(20, 14, 30, .62); padding: 4px; border-radius: 999px; backdrop-filter: blur(6px); }
.sp-rooms button { border: 0; background: none; color: #fff; font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 999px; cursor: pointer; opacity: .75; }
.sp-rooms button[aria-pressed="true"] { background: #fff; color: #2a1420; opacity: 1; font-weight: 700; }
.sp-count { font-size: 13px; background: rgba(20, 14, 30, .62); padding: 7px 12px; border-radius: 999px; margin-right: auto; }
.sp-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: rgba(20, 14, 30, .72); color: #fff; font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 999px; cursor: pointer; backdrop-filter: blur(6px); }
.sp-btn:hover { background: rgba(232, 87, 126, .92); }
.sp-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sp-chat { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); width: min(380px, calc(100vw - 20px)); display: grid; gap: 6px; }
.sp-log { max-height: 30vh; overflow-y: auto; display: grid; gap: 2px; font-size: 14px; line-height: 1.5; padding: 8px 10px; border-radius: 12px; background: rgba(20, 14, 30, .5); backdrop-filter: blur(4px); user-select: text; -webkit-user-select: text; scrollbar-width: thin; }
.sp-log:empty { display: none; }
.sp-log b { margin-right: 6px; color: #ffd1dc; font-weight: 700; }
.sp-log b.creator { color: #ffd66b; }
.sp-log .sys { color: rgba(255, 255, 255, .6); font-size: 12.5px; }
.sp-emotes { display: flex; gap: 4px; flex-wrap: wrap; }
.sp-emotes button { border: 0; min-width: 38px; height: 34px; padding: 0 10px; border-radius: 10px; background: rgba(20, 14, 30, .62); color: #fff; font: inherit; font-size: 14px; cursor: pointer; }
.sp-emotes button:hover { background: rgba(232, 87, 126, .92); }
.sp-form { display: flex; gap: 6px; }
.sp-form input { flex: 1; min-width: 0; border: 0; border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px; background: rgba(255, 255, 255, .94); color: #2a1420; }
.sp-form button { border: 0; border-radius: 10px; padding: 0 16px; font: inherit; font-weight: 700; background: #e8577e; color: #fff; cursor: pointer; }

.sp-help { position: absolute; right: 14px; bottom: 12px; margin: 0; font-size: 12.5px; color: rgba(255, 255, 255, .8); background: rgba(20, 14, 30, .5); padding: 6px 12px; border-radius: 999px; }
.sp-pad { display: none; }

.sp-count3 { position: absolute; inset: 0; display: grid; place-items: center; font: 800 min(40vh, 240px)/1 'Huninn', 'Noto Sans TC', sans-serif; color: #fff; text-shadow: 0 6px 30px rgba(0, 0, 0, .5); pointer-events: none; }
.sp-count3[hidden] { display: none; }
.sp-count3.flash { background: #fff; animation: sp-flash .35s ease-out forwards; }
@keyframes sp-flash { from { opacity: .9; } to { opacity: 0; } }
.sp-status { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: rgba(20, 14, 30, .82); padding: 14px 22px; border-radius: 14px; font-size: 15px; }
.sp-status[hidden] { display: none; }

.space-enter svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* 觸控裝置：畫面上的方向鍵與跳躍鍵，聊天區移到上方 */
@media (pointer: coarse) {
  .sp-help { display: none; }
  .sp-pad { display: flex; gap: 10px; position: absolute; left: max(14px, env(safe-area-inset-left)); right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); align-items: flex-end; pointer-events: none; }
  .sp-pad button { pointer-events: auto; width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); background: rgba(20, 14, 30, .5); color: #fff; font: inherit; font-size: 20px; touch-action: none; }
  .sp-pad button:active { background: rgba(232, 87, 126, .9); }
  .sp-pad .jump { margin-left: auto; width: 76px; height: 76px; font-size: 18px; font-weight: 700; }
  .sp-chat { bottom: auto; top: calc(max(10px, env(safe-area-inset-top)) + 96px); width: min(320px, calc(100vw - 20px)); }
  .sp-log { max-height: 22vh; }
  .sp-btn span { font-size: 13px; }
}
@media (max-width: 560px) {
  .sp-rooms button { padding: 6px 10px; font-size: 13px; }
  .sp-btn svg { display: none; }
}
