/* 街頭海報風：米白紙、粗黑框、紅藍黃撞色、硬陰影 + 口袋純黑省電模式 + 管理介面 */
:root {
  --paper: #F3EFE6; --paper-2: #E9E3D6; --ink: #111; --grey: #77716A; --line: #C9C3B6;
  --red: #E8402A; --blue: #2457F5; --yellow: #FFD23F; --green: #1F9D55; --white: #fff;
  --bw: 2.5px; --shadow: 3px 3px 0 var(--ink); --shadow-lg: 4px 4px 0 var(--ink);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink);
  font-family: -apple-system, "PingFang TC", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans TC", "Noto Sans JP", "Yu Gothic UI", "Microsoft JhengHei", sans-serif; }
.hidden { display: none !important; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
.num { font-family: "Archivo Black", -apple-system, "PingFang TC", sans-serif; font-variant-numeric: tabular-nums; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--grey); }
.muted { color: var(--grey); margin: 0; } .small { font-size: 13px; }
.error { color: var(--red); font-weight: 700; min-height: 1em; margin: 0; font-size: 14px; }

.screen { max-width: 520px; margin: 0 auto; padding: 20px 18px 120px; display: flex; flex-direction: column; gap: 14px; }
#screen-home, #host-gate { justify-content: center; min-height: 100dvh; padding-bottom: 24px; gap: 18px; }

/* 首頁 */
.hero { position: relative; }
h1 { margin: 0; font-size: clamp(56px, 22vw, 96px); line-height: 1; font-weight: 900; letter-spacing: -2px; white-space: nowrap; }
.admin-title { font-size: clamp(40px, 14vw, 64px); }
.admin-h2 { margin: 2px 0 0; font-size: 24px; font-weight: 900; }
.admin-link { color: var(--grey); font-size: 13px; font-weight: 700; text-decoration: underline; }

.box { background: var(--white); border: var(--bw) solid var(--ink); border-radius: 16px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-lg); }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink); }
input { font: inherit; font-size: 16px; font-weight: 700; padding: 12px 14px; border-radius: 12px; border: var(--bw) solid var(--ink);
  background: var(--paper); color: var(--ink); width: 100%; outline: none; }
input:focus { background: #fff; box-shadow: 0 0 0 3px var(--yellow); }
input::placeholder { color: #A8A296; font-weight: 500; }
.code-input { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-family: "Archivo Black", sans-serif; }

button, .btn-link { font: inherit; font-size: 15px; font-weight: 700; padding: 11px 16px; border-radius: 12px; cursor: pointer;
  color: var(--ink); background: var(--white); border: var(--bw) solid var(--ink); box-shadow: var(--shadow);
  transition: transform .06s, box-shadow .06s; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:active, .btn-link:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
button.primary { background: var(--yellow); font-weight: 900; }
button.danger { background: var(--red); color: #fff; font-weight: 900; }
button.secondary, .btn-link.secondary { background: var(--white); }
button.ghost { background: none; border-color: transparent; box-shadow: none; color: var(--grey); text-decoration: underline; }
button.big { padding: 16px; font-size: 20px; border-radius: 14px; }
button.small { font-size: 13px; padding: 8px 12px; }

.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; } .row .grow { flex: 2; }
.compact-row > * { flex: 0 0 auto; }
.row.wrap { flex-wrap: wrap; align-items: center; }
.row.wrap > * { flex: 0 0 auto; }
.row.wrap .ghost { margin-left: auto; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 大廳 */
.lobby-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.room-code { font-size: 46px; line-height: 1; letter-spacing: 3px; }
.me-row { display: flex; gap: 8px; align-items: stretch; }
.me-badge { flex: 1; font-weight: 900; padding: 10px 14px; border: var(--bw) solid var(--ink); border-radius: 12px; background: var(--blue); color: #fff; }
.me-badge.seeker { background: var(--red); }
.gps-chip { display: flex; align-items: center; padding: 0 12px; border: var(--bw) solid var(--ink); border-radius: 12px;
  background: #fff; font-size: 13px; font-weight: 700; white-space: nowrap; }
.gps-chip.bad { background: var(--yellow); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { border: var(--bw) solid var(--ink); border-radius: 12px; padding: 8px 10px; background: #fff; }
.stat b { display: block; font-family: "Archivo Black", -apple-system, sans-serif; font-size: 24px; line-height: 1.1; }
.stat span { font-size: 11px; font-weight: 700; color: var(--grey); }
.sec { border-top: var(--bw) solid var(--ink); padding-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.sec h3 { margin: 0; font-size: 16px; font-weight: 900; display: flex; justify-content: space-between; align-items: baseline; }
#host-settings:not(.hidden) + .host-only-note { display: none; }

#player-list, .admin-player-list { list-style: none; padding: 0; margin: 0; max-height: 360px; overflow-y: auto; }
#player-list li, .adm-player-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1.5px dashed var(--line); }
#player-list li.offline, .adm-player-row.offline { opacity: .55; }
.avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; border: var(--bw) solid var(--ink); display: grid; place-items: center;
  font-weight: 900; color: #fff; background: var(--blue); }
.avatar.seeker { background: var(--red); border-radius: 8px; }
.avatar.spectator { background: var(--ink); border-radius: 8px; }
.pname { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 12px; font-weight: 900; padding: 4px 12px; border: 2px solid var(--ink); border-radius: 99px; background: #fff; color: var(--ink); box-shadow: none; }
button.tag { box-shadow: 2px 2px 0 var(--ink); }
.tag.seeker { background: var(--red); color: #fff; }

.map { width: 100%; }
.map-wrap { border: var(--bw) solid var(--ink); border-radius: 14px; overflow: hidden; }
.small-map { height: 260px; }
.sticky-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; padding: 12px 18px max(14px, env(safe-area-inset-bottom));
  background: var(--paper); border-top: var(--bw) solid var(--ink); display: flex; justify-content: center; }
.sticky-bottom > * { width: 100%; max-width: 484px; }
.wait { text-align: center; font-weight: 900; padding: 14px; border: var(--bw) dashed var(--ink); border-radius: 14px; }

/* 遊戲畫面 */
.game { position: fixed; inset: 0; }
.game .map { position: absolute; inset: 0; height: 100%; }
.hud { position: absolute; z-index: 600; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--paper); border: var(--bw) solid var(--ink); border-radius: 16px; box-shadow: var(--shadow-lg); }
.hud-left .label { margin-top: 5px; }
.role-chip { display: inline-block; font-size: 13px; font-weight: 900; padding: 3px 12px; border: 2px solid var(--ink); border-radius: 99px;
  background: var(--blue); color: #fff; }
.role-chip.seeker { background: var(--red); } .role-chip.caught { background: var(--grey); }
.timer { font-size: 38px; line-height: 1; }
.timer.urgent { color: var(--red); animation: beat 1s steps(2) infinite; }
@keyframes beat { 50% { opacity: .5; } }
.hud-right { text-align: right; }
.alive { font-size: 24px; line-height: 1.1; }
.gps { font-size: 11px; font-weight: 700; color: var(--grey); white-space: nowrap; margin-top: 2px; }
.gps.bad { color: #fff; background: var(--red); padding: 1px 6px; border-radius: 4px; display: inline-block; }

.banner { position: absolute; z-index: 600; top: calc(max(12px, env(safe-area-inset-top)) + 82px); left: 12px; right: 12px;
  padding: 8px 12px; border: var(--bw) solid var(--ink); border-radius: 12px; background: var(--yellow);
  font-weight: 900; font-size: 14px; text-align: center; box-shadow: var(--shadow); }
.banner.danger { background: var(--red); color: #fff; animation: shake .5s ease-in-out infinite alternate; }
@keyframes shake { to { transform: translateY(-2px); } }
.map-tools { position: absolute; z-index: 600; right: 12px; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 84px);
  display: flex; flex-direction: column; gap: 10px; }
.fab { width: 48px; height: 48px; padding: 0; border-radius: 12px; font-size: 17px; font-weight: 900; background: #fff; }
.fab-dark { background: #111; color: #FFD23F; }
.actions { position: absolute; z-index: 600; left: 12px; right: 12px; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.actions .big { flex: 1; font-size: 22px; box-shadow: var(--shadow-lg); }
.actions .stop { flex: none; }

/* 口袋全黑省電模式 */
.pocket { position: fixed; inset: 0; z-index: 9000; background: #000; color: rgba(255,255,255,.32);
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: max(48px, env(safe-area-inset-top)) 24px max(40px, env(safe-area-inset-bottom));
  touch-action: none; user-select: none; -webkit-user-select: none; }
.pocket-status { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.pocket-badge { font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.pocket-timer { font-size: 52px; line-height: 1; color: rgba(255,255,255,.36); transition: transform .15s, color .15s; }
.pocket-timer.cd-big { font-size: 120px; color: rgba(255,210,63,.65); }

/* 躲藏結束最後 10 秒大型倒數覆蓋層 */
.big-countdown { position: absolute; inset: 0; z-index: 750; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: radial-gradient(circle, rgba(17,17,17,.58) 0%, rgba(17,17,17,.22) 65%, transparent 100%); }
.big-cd-num { font-size: clamp(112px, 38vw, 180px); line-height: 1; color: var(--yellow);
  -webkit-text-stroke: 4px var(--ink); text-shadow: 6px 6px 0 var(--ink); animation: cd-pop .32s ease-out; }
.big-cd-num.final { color: var(--red); }
.big-cd-num.go { font-size: clamp(44px, 13vw, 72px); color: #fff; background: var(--red);
  padding: 14px 26px; border: 3px solid var(--ink); border-radius: 18px; box-shadow: 6px 6px 0 var(--ink); -webkit-text-stroke: 0; text-shadow: none; }
.big-cd-sub { background: var(--ink); color: #fff; font-size: 16px; font-weight: 900; padding: 6px 16px;
  border-radius: 99px; border: 2px solid var(--yellow); letter-spacing: .04em; }
@keyframes cd-pop { from { transform: scale(1.38); opacity: .35; } to { transform: scale(1); opacity: 1; } }
.pocket-info { font-size: 13px; font-weight: 700; }
.pocket-alert { margin-top: 12px; padding: 10px 16px; border-radius: 10px; background: rgba(232,64,42,.85); color: #fff; font-weight: 900; font-size: 15px; }
.pocket-unlock-wrap { width: 100%; max-width: 300px; }
.pocket-unlock { position: relative; overflow: hidden; width: 100%; padding: 18px 16px; border-radius: 16px;
  background: #0c0c0c; border: 1.5px solid rgba(255,255,255,.22); color: rgba(255,255,255,.45); box-shadow: none; }
.pocket-unlock:active { transform: none; box-shadow: none; }
.pocket-unlock-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: rgba(255,210,63,.35); pointer-events: none; }
.pocket-unlock-text { position: relative; z-index: 1; font-size: 15px; font-weight: 800; }

/* 地圖玩家標記 */
.pin-wrap { background: none; border: 0; }
.pin { display: flex; flex-direction: column; align-items: center; width: max-content; transform: translate(-50%, -16px); }
.pin .dot { width: 32px; height: 32px; display: grid; place-items: center; font-weight: 900; font-size: 15px; color: #fff;
  background: var(--blue); border: var(--bw) solid var(--ink); border-radius: 50%; box-shadow: 2px 2px 0 var(--ink); }
.pin.seeker .dot { background: var(--red); border-radius: 7px; }
.pin.caught .dot { background: #A8A296; }
.pin.me .dot { background: var(--yellow); color: var(--ink); }
.pin.me.seeker .dot { border-radius: 7px; }
.pin .name { margin-top: 3px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; white-space: nowrap; }
.pin.revealed .dot { animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { background: var(--yellow); color: var(--ink); } }

.leaflet-container { background: var(--paper-2); font-family: inherit; }
.leaflet-control-attribution { font-size: 9px; background: rgba(243,239,230,.85) !important; }
.leaflet-bar { border: var(--bw) solid var(--ink) !important; box-shadow: var(--shadow) !important; }

/* 對話框、管理列與提示 */
.modal { position: fixed; inset: 0; background: rgba(17,17,17,.55); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 18px; }
.modal-box { background: var(--paper); border: var(--bw) solid var(--ink); border-radius: 18px; padding: 20px; width: 100%; max-width: 440px;
  max-height: 82vh; overflow: auto; box-shadow: 6px 6px 0 var(--ink); animation: pop .15s ease-out; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-box h2 { margin: 0 0 8px; font-size: 24px; font-weight: 900; }
#modal-body p { line-height: 1.6; font-weight: 500; }
#modal-actions { margin-top: 16px; }
.pick { display: flex; align-items: center; gap: 10px; width: 100%; margin: 8px 0; text-align: left; padding: 10px 12px; }
.em-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1.5px dashed var(--line); }
.em-info { flex: 1; min-width: 0; }
.em-btns { display: flex; gap: 6px; flex: none; }
.invite-box { border-top: 1.5px dashed var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }

#toasts { position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 130px); left: 0; right: 0; z-index: 9500; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 14px; font-weight: 700; max-width: 90%;
  box-shadow: 3px 3px 0 var(--yellow); animation: pop .18s ease-out; }
.net-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4000; padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--red); color: #fff; border-top: var(--bw) solid var(--ink); font-size: 14px; font-weight: 900; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.net-bar-btn { background: var(--yellow); color: var(--ink); padding: 6px 12px; font-size: 13px; font-weight: 900; border: 2px solid var(--ink); border-radius: 8px; box-shadow: 2px 2px 0 var(--ink); }
.top-lang-bar { display: flex; justify-content: flex-end; }
.lang-switch { display: inline-flex; gap: 4px; background: var(--white); border: 2px solid var(--ink); border-radius: 99px; padding: 3px; box-shadow: 2px 2px 0 var(--ink); }
.lang-btn { font-size: 12px; font-weight: 800; padding: 4px 10px; border: 0; border-radius: 99px; background: transparent; color: var(--grey); box-shadow: none; }
.lang-btn:active { transform: none; box-shadow: none; }
.lang-btn.active { background: var(--ink); color: var(--yellow); }
.me-badge.spectator, .role-chip.spectator { background: var(--ink); color: #fff; }
.tag.spectator { background: var(--ink); color: #fff; }
button.spectate { margin-top: 4px; width: 100%; }
button.spectate.on { background: var(--ink); color: #fff; }
