/* 自由都市扩展层样式：沿用核心的配色变量与排版节奏 */

.free-sheet {
  width: min(688px, 100%);
  border-top-color: #e7b877;
  background: #101c26f4;
}

.free-sheet h2 { display: flex; align-items: center; gap: .58rem; }
.free-sheet h2::before {
  content: ""; width: .34em; height: .7em;
  border-inline: .11em solid var(--gold, #f0b070);
}

.free-hint {
  margin: .85rem 0 .15rem;
  color: #a9bdb6;
  font-size: .88rem;
  line-height: 1.55;
}

.free-body {
  display: grid;
  gap: 2px;
  margin-top: .7rem;
  max-height: min(58cqh, 32rem);
  overflow: auto;
  overscroll-behavior: contain;
}

.free-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name price" "detail price";
  gap: 1px .75rem;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: .46rem .72rem;
  border: 0;
  border-left: 2px solid transparent;
  background: #142630;
  color: #e6eeea;
  text-align: start;
  cursor: pointer;
  font: inherit;
}
.free-row:hover { background: #1c3240; border-left-color: #e7b877; }
.free-row:focus-visible { outline: 2px solid #f5c98e; outline-offset: 2px; }
.free-row.is-locked, .free-row:disabled { opacity: .45; cursor: not-allowed; }
.free-row-name { grid-area: name; font-size: .95rem; font-weight: 620; }
.free-row-detail { grid-area: detail; color: #93a8a2; font-size: .76rem; line-height: 1.35; }
.free-row-price { grid-area: price; color: #f0d9ab; font-size: .86rem; white-space: nowrap; }

.free-foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: .85rem;
  padding-top: .5rem;
  border-top: 1px solid var(--line, #d2dad83d);
  color: #b8c9c2;
  font-size: .78rem;
}

/* ------------------------------------------------------------- HUD 增量 */

.free-hud {
  margin-top: .25rem;
  padding: .16rem .42rem;
  border-left: 2px solid #e7b877;
  background: #0d1a2380;
  color: #e8ddc4;
  font-size: .72rem;
  letter-spacing: .02em;
  line-height: 1.35;
  white-space: nowrap;
}

.free-flash {
  align-self: center;
  margin-top: .3rem;
  padding: .34rem .7rem;
  border-left: 2px solid #7cc0d8;
  background: #0b1721de;
  color: #dbeae6;
  font-size: .8rem;
  line-height: 1.4;
  max-width: min(72cqw, 30rem);
}
.free-flash.bad { border-left-color: #d8736a; color: #f2d3cd; }

/* 手机/车库图标：与暂停键同一套按钮语言 */
.phone-mark {
  display: block;
  width: 12px; height: 17px;
  border: 1.6px solid currentColor;
  border-radius: 3px;
  position: relative;
}
.phone-mark::after {
  content: ""; position: absolute; left: 50%; bottom: 1.4px;
  width: 4px; height: 1.4px; margin-left: -2px;
  background: currentColor;
}

@media (max-width: 720px) {
  .free-row { min-height: 42px; }
  .free-body { max-height: min(52cqh, 22rem); }
}

/* ------------------------------------------------------------- 自由委托 */

.contract-sheet {
  width: min(688px, 100%);
  border-top-color: #7cc0d8;
  background: #0e1b24f4;
}

.contract-hint {
  margin: .7rem 0 .3rem;
  color: #a9bdb6;
  font-size: .86rem;
  line-height: 1.55;
}

.contract-list {
  display: grid;
  gap: 2px;
  margin-top: .6rem;
  max-height: min(56cqh, 30rem);
  overflow: auto;
  overscroll-behavior: contain;
}

.contract-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name pay" "detail pay";
  gap: 1px .75rem;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: .46rem .72rem;
  border: 0;
  border-left: 2px solid transparent;
  background: #142630;
  color: #e6eeea;
  text-align: start;
  cursor: pointer;
  font: inherit;
}
.contract-row:hover { background: #1c3240; border-left-color: #7cc0d8; }
.contract-row:focus-visible { outline: 2px solid #9ad6e8; outline-offset: 2px; }
.contract-name { grid-area: name; font-size: .95rem; font-weight: 620; }
.contract-detail { grid-area: detail; color: #93a8a2; font-size: .75rem; line-height: 1.35; }
.contract-pay { grid-area: pay; color: #f0d9ab; font-size: .86rem; white-space: nowrap; }

.contract-active {
  display: grid;
  gap: .18rem;
  margin-bottom: .4rem;
  padding: .5rem .72rem;
  border-left: 2px solid #e7b877;
  background: #1a2a33;
}
.contract-active-head { font-size: .95rem; font-weight: 620; color: #f5d9a8; }
.contract-active-body { font-size: .78rem; color: #a9bdb6; }
.contract-active-meta { font-size: .74rem; color: #8fa4a0; }
.contract-active .quiet { justify-self: start; margin-top: .3rem; }

.contract-foot {
  margin: .7rem 0 .2rem;
  padding-top: .45rem;
  border-top: 1px solid var(--line, #d2dad83d);
  color: #9fb2ad;
  font-size: .76rem;
  line-height: 1.5;
}

.contract-line {
  margin-top: .22rem;
  padding: .16rem .42rem;
  border-left: 2px solid #7cc0d8;
  background: #0d1a2380;
  color: #d8ecf2;
  font-size: .72rem;
  line-height: 1.35;
  white-space: nowrap;
}
.contract-line b { color: #f0d9ab; font-weight: 620; }
.contract-line-idle { border-left-color: #e7b877; color: #cbbfa4; }
.contract-line kbd { font-size: .68rem; padding: 0 .22em; }

@media (max-width: 720px) {
  .contract-row { min-height: 44px; }
  .contract-list { max-height: min(50cqh, 20rem); }
}

.contract-jump {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .6rem;
}
.contract-jump .quiet { min-height: 30px; padding: .18rem .7rem; font-size: .78rem; }

/* ------------------------------------------------------- 相机取景模式 */
/* 取景时把 HUD 与触摸层收掉，只留画幅和一条提示。 */
#game.free-photo #hud,
#game.free-photo .hud,
#game.free-photo #touch-layer,
#game.free-photo .free-hud,
#game.free-photo #free-flash { opacity: 0; visibility: hidden; transition: opacity .18s ease; }

#game.free-photo::before,
#game.free-photo::after {
  content: "";
  position: absolute; left: 0; right: 0; height: 8.5cqh;
  background: #05090c;
  pointer-events: none;
  z-index: 40;
}
#game.free-photo::before { top: 0; }
#game.free-photo::after { bottom: 0; }

#game.free-photo canvas { filter: contrast(1.04) saturate(1.06); }

#game.free-photo .photo-frame {
  position: absolute;
  inset: 12.5cqh 6cqw;
  border: 1px solid #e8ddc466;
  box-shadow: inset 0 0 22cqh #04080bb0;
  pointer-events: none;
  z-index: 41;
}
#game.free-photo .photo-frame::after {
  content: "K 拍照 · V 退出";
  position: absolute; left: 0; bottom: -.4rem;
  transform: translateY(100%);
  color: #cbd8d2; font-size: .72rem; letter-spacing: .08em;
}

.photo-bar {
  position: absolute;
  left: 50%; bottom: -.5rem;
  transform: translate(-50%, 100%);
  display: flex; gap: .5rem;
  pointer-events: auto;
  z-index: 42;
}
.photo-key {
  min-width: 56px; min-height: 32px;
  padding: 0 .7rem;
  border: 1px solid #e8ddc455;
  border-radius: 999px;
  background: #0b1721d9;
  color: #e7efe9;
  font: inherit; font-size: .78rem;
  letter-spacing: .06em;
}
.photo-key:active { background: #1a2c38f0; }

/* ==================================================================== *
 * 手机主控层
 * 顶栏芯片条 + 拇指热区按钮 + 面板底部通栏按钮
 * 布局原则：横屏手机上方中间那条留给芯片条，左右两侧留给核心 HUD 与触摸层。
 * ==================================================================== */

.free-chipbar {
  position: absolute;
  z-index: 3;
  top: max(4px, calc(var(--safe-top, 0px) + 4px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: min(58cqw, 460px);
  padding: 3px 5px;
  border: 1px solid #d2dad83d;
  border-radius: 999px;
  background: #0b1721cc;
  backdrop-filter: blur(4px);
  font-size: .68rem;
  line-height: 1;
  pointer-events: none;
  white-space: nowrap;
}

.free-chipbar .chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 19px;
  padding: 0 .42rem;
  border-radius: 999px;
  background: #16262f;
  color: #dce8e3;
  font-size: .68rem;
  font-style: normal;
}
.free-chipbar .chip-cash { color: #f2d9a8; background: #1d2b2a; font-variant-numeric: tabular-nums; }
.free-chipbar .chip-weapon { color: #e6c7ae; }
.free-chipbar .chip-loot { color: #c9b7dc; }
.free-chipbar .chip-spacer { flex: 0 0 2px; padding: 0; background: none; }

.free-chipbar .chip-target {
  --chip-color: #ffc06a;
  color: var(--chip-color);
  background: #1a2630;
  border: 1px solid color-mix(in srgb, var(--chip-color) 45%, transparent);
  font-weight: 640;
}
.free-chipbar .chip-target[hidden] { display: none; }
.free-chipbar .chip-target u { text-decoration: none; }

.chip-arrow {
  position: relative;
  display: block;
  width: 13px; height: 13px;
  flex: 0 0 13px;
}
.chip-arrow::before {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 0; height: 0;
  margin: -6px 0 0 -4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 8px solid currentColor;
  transform-origin: 50% 62%;
}
.chip-arrow::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 2px; height: 6px;
  margin: -2px 0 0 -1px;
  background: currentColor;
  opacity: .55;
}

/* 拇指热区：一排小按钮，贴在右侧工具键上方，右手拇指够得到。 */
.free-quick {
  position: absolute;
  right: var(--touch-right, 12px);
  bottom: calc(var(--touch-bottom, 13px) + var(--touch-height, 100px) + 8px);
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px;
  pointer-events: none;
}
.free-quick-btn {
  pointer-events: auto;
  min-width: 54px;
  min-height: 40px;
  padding: 4px 7px;
  display: grid;
  gap: 1px;
  justify-items: center;
  border: 1px solid #d2dad83d;
  border-radius: 11px;
  background: #0f1e27d9;
  color: #e6eeea;
  font: inherit;
  line-height: 1.1;
  cursor: pointer;
  touch-action: manipulation;
}
.free-quick-btn:active { background: #1d323e; border-color: #e7b877; }
.free-quick-btn:disabled { opacity: .38; cursor: not-allowed; }
.free-quick-btn.is-off { opacity: .45; }
.free-quick-btn:focus-visible { outline: 2px solid #f5c98e; outline-offset: 2px; }
.free-quick-name { font-size: .76rem; font-weight: 640; }
.free-quick-hint { font-size: .58rem; color: #93a8a2; }

/* 面板底部的通栏按钮：一行一条，按钮高度够手指点。 */
.free-quickbar {
  display: grid;
  gap: 5px;
  margin-top: .6rem;
}
.free-quickbar-btn {
  min-height: 46px;
  padding: .5rem .8rem;
  border: 1px solid #d2dad83d;
  border-radius: 10px;
  background: #142630;
  color: #e6eeea;
  font: inherit;
  font-size: .95rem;
  font-weight: 620;
  text-align: start;
  cursor: pointer;
  touch-action: manipulation;
}
.free-quickbar-btn.is-primary {
  border-color: #e7b877;
  background: linear-gradient(180deg, #3b3122, #241f18);
  color: #f6e2ba;
}
.free-quickbar-btn:active { background: #1d323e; }
.free-quickbar-btn:focus-visible { outline: 2px solid #f5c98e; outline-offset: 2px; }

/* ==================================================================== *
 * 中枢面板
 * 标签栏压在面板底部，竖排大行，手机单手可用。
 * ==================================================================== */

.hub-overlay { align-content: stretch; }

.hub-sheet {
  width: min(720px, 100%);
  height: 100%;
  max-height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: .4rem;
  padding: clamp(12px, 2cqw, 22px);
  border-top-color: #7cc0d8;
  background: #0d1a23f6;
  overflow: hidden;
}
.hub-sheet .panel-head { padding-bottom: .4rem; }
.hub-sheet .panel-head h2 { font-size: clamp(1.2rem, 2.2cqw, 1.7rem); }
.hub-sheet .eyebrow { font-size: .68rem; letter-spacing: .12em; color: #9fb2ad; }

.hub-hint {
  margin: 0;
  color: #a9bdb6;
  font-size: .8rem;
  line-height: 1.45;
}

.hub-body {
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.hub-body.hub-borrowed { display: block; }
.hub-body.hub-borrowed .contract-list { margin: 0; max-height: none; }

.hub-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name price" "detail price";
  gap: 1px .7rem;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: .5rem .75rem;
  border: 0;
  border-left: 2px solid transparent;
  background: #142630;
  color: #e6eeea;
  text-align: start;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.hub-row:hover { background: #1c3240; border-left-color: #7cc0d8; }
.hub-row:focus-visible { outline: 2px solid #9ad6e8; outline-offset: 2px; }
.hub-row.is-on { background: #1a2f38; border-left-color: #e7b877; }
.hub-row:disabled { opacity: .42; cursor: not-allowed; }
.hub-row-name { grid-area: name; font-size: .95rem; font-weight: 640; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.hub-row-name kbd { font-size: .64rem; padding: 0 .24em; }
.hub-row-detail { grid-area: detail; color: #93a8a2; font-size: .75rem; line-height: 1.35; }
.hub-row-price { grid-area: price; color: #f0d9ab; font-size: .86rem; white-space: nowrap; display: inline-flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.hub-row-price .quiet { min-height: 30px; padding: .1rem .55rem; font-size: .72rem; }
.hub-row-static { cursor: default; }
.hub-row-static:hover { background: #142630; border-left-color: transparent; }

.hub-divider {
  margin-top: .5rem;
  padding: .18rem .1rem;
  border-bottom: 1px solid #d2dad833;
  color: #9fb2ad;
  font-size: .72rem;
  letter-spacing: .1em;
}

.hub-card {
  margin-bottom: .35rem;
  padding: .55rem .75rem;
  border-left: 2px solid #e7b877;
  background: #1a2a33;
}
.hub-card-head { font-size: .95rem; font-weight: 640; color: #f5d9a8; }
.hub-card-body { margin-top: .16rem; color: #c2d2cc; font-size: .8rem; line-height: 1.4; }
.hub-card-actions { margin-top: .35rem; display: flex; gap: .4rem; }
.hub-card-actions .quiet { min-height: 34px; padding: .16rem .7rem; font-size: .78rem; }

.hub-note, .hub-foot-note { margin: .55rem .05rem .1rem; color: #9fb2ad; font-size: .76rem; line-height: 1.5; }
.hub-empty { margin: .8rem .1rem; color: #9fb2ad; font-size: .86rem; }
.hub-extra { display: block; }

.hub-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .6rem;
  padding-top: .34rem;
  border-top: 1px solid #d2dad83d;
  color: #b8c9c2;
  font-size: .74rem;
}
.hub-foot .mono { color: #f0d9ab; }

.hub-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px;
  margin-top: .25rem;
  padding-top: .35rem;
  border-top: 1px solid #d2dad83d;
}
.hub-tab {
  min-height: 44px;
  padding: .2rem .1rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: #142630;
  color: #cddbd5;
  font: inherit;
  font-size: .82rem;
  font-weight: 620;
  cursor: pointer;
  touch-action: manipulation;
}
.hub-tab.is-on { background: #2a3b33; border-color: #7cc0d8; color: #eaf5f1; }
.hub-tab:active { background: #1d323e; }
.hub-tab:focus-visible { outline: 2px solid #9ad6e8; outline-offset: 2px; }

.hub-paints {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 6px;
  padding: .35rem 0 .1rem;
}
.hub-paint {
  height: 42px;
  border: 1px solid #d2dad85c;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}
.hub-paint:active { transform: scale(.94); }
.hub-paint:focus-visible { outline: 2px solid #f5c98e; outline-offset: 2px; }

.hub-range { grid-template-areas: "name price" "detail price" "slider slider"; }
.hub-range input[type="range"] {
  grid-area: slider;
  width: 100%;
  margin-top: .35rem;
  accent-color: #7cc0d8;
  touch-action: manipulation;
}

.hub-confirm {
  position: absolute;
  z-index: 9;
  inset: auto 12px 12px;
  display: grid;
  gap: .4rem;
  padding: .7rem .8rem;
  border: 1px solid #e7b877;
  border-radius: 12px;
  background: #101f28f7;
  color: #e8ddc4;
  font-size: .84rem;
  line-height: 1.45;
}
.hub-confirm .quiet { min-height: 40px; }
.hub-confirm .is-danger { border-color: #d8736a; color: #f2d3cd; }

/* ==================================================================== *
 * 显示偏好
 * ==================================================================== */

/* 紧凑：面板行压扁，一屏能看更多条目。 */
html.free-compact .hub-sheet { gap: .25rem; padding: clamp(8px, 1.5cqw, 16px); }
html.free-compact .hub-row { min-height: 42px; padding: .34rem .6rem; }
html.free-compact .hub-row-name { font-size: .88rem; }
html.free-compact .hub-row-detail { font-size: .7rem; }
html.free-compact .hub-divider { margin-top: .3rem; }
html.free-compact .free-chipbar .chip { min-height: 17px; font-size: .62rem; }

/* 大字：给视力弱的玩家，读数优先。 */
html.free-large-text .hub-row-name,
html.free-large-text .hub-row-detail,
html.free-large-text .hub-hint,
html.free-large-text .hub-foot { font-size: 1.02rem; }
html.free-large-text .hub-row { min-height: 60px; }
html.free-large-text .free-chipbar { font-size: .78rem; }
html.free-large-text .free-chipbar .chip { font-size: .78rem; min-height: 22px; }

/* 静默闪屏：减弱收入提示的闪烁。 */
html.free-calm .free-flash { animation: none; transition: none; }

/* 顶栏芯片条：关掉就完全不显示。 */
html:not(.free-chip-bar) .free-chipbar { display: none; }

/* 大触摸：把触摸层按钮整体放大。 */
html.free-big-touch .free-quick-btn { min-width: 62px; min-height: 48px; }
html.free-big-touch .free-quick-btn .free-quick-name { font-size: .84rem; }
html.free-big-touch .hub-tab { min-height: 52px; font-size: .9rem; }
html.free-big-touch .free-quickbar-btn { min-height: 54px; }

/* ==================================================================== *
 * 手机横屏微调
 * ==================================================================== */

@container stage (max-height: 500px) and (orientation: landscape) {
  /* 芯片条夹在左上与右上两块之间，别压到它们。 */
  .free-chipbar { top: max(3px, calc(var(--safe-top, 0px) + 3px)); font-size: .64rem; }
  .free-chipbar .chip { min-height: 17px; padding: 0 .34rem; }
  .free-quick { bottom: calc(var(--touch-bottom) + var(--touch-height) + 4px); gap: 3px; }
  .free-quick-btn { min-width: 48px; min-height: 34px; padding: 3px 5px; }
  .free-quick-name { font-size: .7rem; }
  .free-quick-hint { display: none; }
  .hub-sheet { grid-template-rows: auto auto minmax(0, 1fr) auto auto; padding: 10px 12px 8px; }
  .hub-sheet .panel-head h2 { font-size: 1.15rem; }
  .hub-hint { font-size: .72rem; }
  .hub-row { min-height: 44px; }
  .hub-tab { min-height: 40px; font-size: .78rem; }
}

@container stage (max-height: 330px) and (orientation: landscape) {
  .free-chipbar { font-size: .6rem; }
  .free-quick-btn { min-width: 44px; min-height: 30px; }
  .free-quick-hint { display: none; }
}

/* 竖屏实测修：加载状态做成醒目药丸，等待时不再像卡死。 */
#title-screen .boot-status {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  z-index: 5;
  white-space: nowrap;
  font-size: 17px;
  font-weight: 600;
  color: #ffd970;
  background: rgba(8, 12, 18, .88);
  border: 1px solid rgba(255, 217, 112, .55);
  border-radius: 999px;
  padding: 10px 20px;
  text-align: center;
}
/* 触屏设备上环视提示里的调整键引用的是桌面按键，隐藏它只留关闭。 */
@media (pointer: coarse) {
  #look-hint-adjust { display: none !important; }
}

/* 层级收口：扩展弹窗、状态条、摆摊钮一律低于本体面板（.overlay 为 4），
   面板打开时不再被奇遇弹窗盖住；仍高于 HUD 与触控排。 */
#cl-dlg, #rm-dlg, #hs-dlg, #fl-dlg, #npc-dlg,
#cl-bar, #rm-bar, #hs-bar, #fl-bar, #npc-bar, #rm-stall-btn {
  z-index: 3 !important;
}

/* 触屏下去掉键盘提示片：关闭钮只留「关闭」，中枢行不再显示快捷键字母。 */
.touch-enabled [data-close] kbd, .touch-enabled .hub-row-name kbd {
  display: none !important;
}
