:root {
  --bg: #0f1419;
  --card: #1a2332;
  --text: #e7ecf3;
  --muted: #8b9bb4;
  --accent: #3d9cf0;
  --ok: #3ecf8e;
  --warn: #f0b429;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #1a3050, var(--bg));
  color: var(--text);
  min-height: 100vh;
}
#app { max-width: 1100px; margin: 0 auto; padding: 1rem; }
header { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
h1 { font-size: 1.4rem; margin: 0.2rem 0 1rem; }
h2 { font-size: 1rem; margin: 0 0 0.6rem; }
.card {
  background: color-mix(in srgb, var(--card) 92%, black);
  border: 1px solid #2a3a52;
  border-radius: 12px;
  padding: 0.9rem;
  margin-bottom: 0.8rem;
}
.row { display: flex; gap: 0.5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; margin-bottom: 0.8rem; }
.layout { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.grow { flex: 1 1 420px; }
.side { flex: 1 1 280px; min-width: 260px; }
input {
  flex: 1;
  background: #0c121a;
  border: 1px solid #334660;
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}
button {
  background: var(--accent);
  color: #041018;
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
button.secondary { background: #334660; color: var(--text); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.muted { color: var(--muted); font-size: 0.9rem; }
.msg { min-height: 1.2em; color: var(--warn); }
.hidden { display: none !important; }
.pill {
  background: #243247;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
.floor {
  position: relative;
  display: block;
  min-height: 320px;
  height: min(52vh, 420px);
  background: #121a26;
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  cursor: crosshair;
  outline: none;
}
.floor:focus { box-shadow: 0 0 0 2px var(--accent); }
.zone-pins { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.zone-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  background: #0c121acc;
  border: 1px solid #3a516e;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}
.zone-bar { margin: 0.55rem 0 0.35rem; gap: 0.4rem; }
.zone-bar .zone {
  background: #243247;
  color: var(--text);
  border: 1px solid #3a516e;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
  min-height: 44px;
  flex: 1 1 auto;
}
.zone-bar .zone.active { outline: 2px solid var(--ok); background: #1d3a2a; }
.move-hint { margin: 0 0 0.45rem; font-size: 0.85rem; }
.log {
  height: 140px;
  overflow-y: auto;
  background: #0c121a;
  border-radius: 8px;
  padding: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
.log div { margin-bottom: 0.25rem; }
ul { list-style: none; padding: 0; margin: 0; }
li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid #243247;
  font-size: 0.9rem;
}
#avatars { position: absolute; inset: 0; pointer-events: none; }
.avatar {
  position: absolute;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #041018;
  font-size: 0.65rem;
  font-weight: 700;
  display: grid; place-items: center;
  transform: translate(-50%, -50%);
  border: 2px solid #fff3;
}
.avatar.afk { background: #667; }
@media (max-width: 700px) {
  .floor { height: min(48vh, 360px); min-height: 260px; }
}

.avatar-pick { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin: 0.6rem 0; }
.avatar-option {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  cursor: pointer; padding: 0.4rem; border-radius: 10px; border: 2px solid transparent;
  background: #121a26;
}
.avatar-option:has(input:checked) { border-color: var(--ok); }
.avatar-option img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.avatar-option input { position: absolute; opacity: 0; pointer-events: none; }
.me-row { display: flex; align-items: center; gap: 0.5rem; }
.me-bust { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid #3a516e; }
.floor {
  background-image: linear-gradient(#121a26cc, #121a26cc), url("/assets/art/slice1/floor-topdown.jpg");
  background-size: cover;
  background-position: center;
}
.avatar {
  background: transparent !important;
  width: 36px; height: 36px;
  border: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; transition: transform 0.12s; }
.avatar.me { z-index: 2; outline: 2px solid var(--ok); border-radius: 50%; }
.avatar.face-left img { transform: scaleX(-1); }
.avatar.walking img { animation: bob 0.35s ease-in-out infinite alternate; }
@keyframes bob { from { translate: 0 0; } to { translate: 0 -2px; } }

/* Mobile-first polish */
html { -webkit-text-size-adjust: 100%; }
body { padding-bottom: env(safe-area-inset-bottom, 0); }
#app { padding: 0.75rem; padding-left: max(0.75rem, env(safe-area-inset-left)); padding-right: max(0.75rem, env(safe-area-inset-right)); }
header { flex-wrap: wrap; gap: 0.4rem; }
h1 { font-size: 1.2rem; }
input, button { font-size: 16px; min-height: 44px; } /* avoid iOS zoom + tap targets */
.row { flex-wrap: wrap; }
.row > input { min-width: 0; width: 100%; flex: 1 1 140px; }
.avatar-pick { justify-content: center; }
.avatar-option img { width: 88px; height: 88px; }
.floor { min-height: 260px; touch-action: manipulation; }
.zone-bar .zone { font-size: 0.9rem; }
.log { height: 160px; -webkit-overflow-scrolling: touch; }
.side .card { margin-bottom: 0.7rem; }
@media (max-width: 700px) {
  .layout { flex-direction: column; }
  .grow, .side { flex: 1 1 auto; min-width: 0; width: 100%; }
  header { align-items: flex-start; }
  .me-bust { width: 36px; height: 36px; }
  #stats { font-size: 0.8rem; line-height: 1.35; }
}

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: #0a1018cc;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-card {
  background: var(--card); border: 1px solid #2a3a52; border-radius: 14px;
  padding: 1rem; max-width: 420px; width: 100%;
}
.afk-choices { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.75rem 0; }
.afk-choices button { text-align: left; min-height: 44px; }
