.game {
  display: grid; height: 100vh; height: 100dvh;
  grid-template-columns: 1fr minmax(360px, 420px); grid-template-rows: auto 1fr;
  grid-template-areas: "top top" "stage panel";
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--bg-2); min-width: 0; z-index: 6;
}
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; background: var(--panel); font-size: 14px; min-width: 0; }
.chip.where { cursor: pointer; overflow: hidden; }
.chip.where span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.coin b { color: var(--coin); }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.me-name { color: var(--muted); font-size: 14px; max-width: 10em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 3D 舞台 */
.stage { grid-area: stage; position: relative; min-height: 0; overflow: hidden; background: #8fb8e6; }
.scene3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: grab; }
.scene3d:active { cursor: grabbing; }
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-left { position: absolute; left: 12px; top: 12px; display: grid; gap: 6px; max-width: calc(100% - 140px); pointer-events: none; }
.hud-where { padding: 8px 12px; display: grid; gap: 0; background: rgba(11, 16, 32, .78); backdrop-filter: blur(6px); font-size: 14px; min-width: 0; }
.hud-where b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-near { display: grid; gap: 4px; }
.hud-near .tag { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: rgba(11, 16, 32, .72); color: var(--muted); width: fit-content; }
.hud-near .tag.chat { background: rgba(20, 140, 110, .85); color: #fff; }
.hud-actions { position: absolute; right: 12px; top: 12px; display: flex; gap: 8px; }
.hud-actions .btn { background: rgba(11, 16, 32, .8); backdrop-filter: blur(6px); }
.hud-chat-btn { display: none; }
.hud-prompt { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); box-shadow: 0 8px 30px rgba(0, 0, 0, .35); font-size: 15px; padding: 10px 18px; white-space: nowrap; }
.hud-chat { position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%); width: min(520px, calc(100% - 40px)); }
.hud-chat input { margin: 0; background: rgba(11, 16, 32, .78); backdrop-filter: blur(6px); border-color: rgba(120, 150, 255, .35); }
.hud-help { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); font-size: 12px; color: #eef2ff; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); white-space: nowrap; pointer-events: none; }
.stick { position: absolute; left: 22px; bottom: 26px; width: 120px; height: 120px; border-radius: 50%; background: rgba(11, 16, 32, .35); border: 2px solid rgba(255, 255, 255, .35); display: none; touch-action: none; z-index: 3; }
.stick .knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255, 255, 255, .8); box-shadow: 0 4px 14px rgba(0, 0, 0, .3); transition: transform .06s; }
.stick.active { background: rgba(11, 16, 32, .5); }
.stick.active .knob { transition: none; }
@media (pointer: coarse) {
  .stick { display: block; }
  .hud-help { display: none; }
}

/* 世界地图（长途交通）覆盖层 */
.map-layer { position: absolute; inset: 0; z-index: 4; background: #081022; }
.map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.map.dragging { cursor: grabbing; }
.map-head { position: absolute; left: 12px; right: 64px; top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; }
.map-head > span { background: rgba(11, 16, 32, .8); padding: 6px 12px; border-radius: 99px; }
.map-tools { position: absolute; right: 12px; top: 12px; display: grid; gap: 6px; }
.map-legend { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); background: rgba(11, 16, 32, .75); padding: 4px 10px; border-radius: 99px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 3px 0 8px; vertical-align: middle; }
.dot.me { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dot.peer { background: var(--peer); }
.dot.city { background: #8d9bd6; }
.sheet-handle { display: none; }

.panel { grid-area: panel; display: flex; flex-direction: column; gap: 12px; padding: 12px; overflow-y: auto; border-left: 1px solid var(--line); background: var(--bg); min-height: 0; }
.panel-tabs { position: sticky; top: -12px; z-index: 2; box-shadow: 0 6px 12px var(--bg); }
.tab-page { display: grid; gap: 12px; align-content: start; }

.status-card { display: grid; gap: 10px; background: linear-gradient(160deg, #17224a, #131b36 60%); }
.status-where { display: flex; gap: 12px; align-items: flex-start; }
.status-where .pin { font-size: 28px; line-height: 1; }
.status-where h2 { font-size: 20px; }
.status-where .sub { color: var(--muted); font-size: 13px; }
.coords { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--accent); }
.state-line { display: flex; align-items: center; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.idle { color: var(--ok); border-color: rgba(79, 220, 143, .5); }
.pill.traveling { color: #9fb0ff; border-color: rgba(124, 140, 255, .6); }
.pill.working { color: var(--coin); border-color: rgba(255, 195, 92, .6); }
.progress { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .9s linear; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.section-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--muted); margin: 4px 2px -4px; }
.list { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 12px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #120714; flex: none; }
.empty { text-align: center; color: var(--muted); padding: 18px 12px; border: 1px dashed var(--line); border-radius: 12px; font-size: 14px; }
.empty b { color: var(--text); }

.search-results { display: grid; gap: 6px; max-height: 240px; overflow: auto; }
.option { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.option .big { font-size: 26px; grid-row: span 2; }
.option .price { font-size: 20px; font-weight: 700; color: var(--coin); text-align: right; }
.option.off { opacity: .55; }
.option .why { grid-column: 2 / 4; font-size: 12px; color: var(--danger); }
.route-head { display: flex; align-items: center; gap: 8px; font-weight: 600; flex-wrap: wrap; }
.invite { border-color: rgba(255, 111, 174, .6); background: linear-gradient(160deg, #2a1736, #131b36); }

.job { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: center; }
.job .big { font-size: 30px; grid-row: span 2; }
.job .reward { color: var(--coin); font-weight: 700; }

.chat-page { min-height: 380px; grid-template-rows: auto 1fr auto; }
.chat-log { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 52vh; min-height: 220px; padding: 4px; }
.msg { max-width: 85%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; padding: 7px 11px; align-self: flex-start; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; background: #173a4a; border-color: #23586b; border-radius: 12px 12px 4px 12px; }
.msg .who { font-size: 12px; color: var(--muted); }
.msg .who b { color: var(--peer); font-weight: 600; }
.msg.mine .who b { color: var(--accent); }
.chat-form { display: flex; gap: 8px; }
.chat-form input { margin: 0; }
.notice { font-size: 12px; color: var(--muted); background: var(--bg-2); border-radius: 10px; padding: 8px 10px; }

.ledger .delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.ledger .plus { color: var(--ok); }
.ledger .minus { color: var(--danger); }
.stamps { display: flex; flex-wrap: wrap; gap: 6px; }
.stamp { border: 1px dashed var(--accent-2); color: #c4ccff; border-radius: 8px; padding: 3px 8px; font-size: 13px; }

@media (max-width: 900px) {
  .game { display: block; position: relative; height: 100dvh; overflow: hidden; }
  .topbar { position: absolute; left: 0; right: 0; top: 0; padding: 8px 10px; gap: 6px; }
  .brand-text, .me-name { display: none; }
  .stage { position: absolute; left: 0; right: 0; top: 50px; bottom: 0; }
  .hud-left { max-width: calc(100% - 110px); }
  .hud-where { font-size: 13px; padding: 6px 10px; }
  .hud-where .coords { font-size: 11px; }
  .hud-chat { display: none; }
  .hud-chat-btn { display: inline-flex; }
  .hud-actions { flex-direction: column; align-items: flex-end; }
  .hud-prompt { bottom: calc(var(--sheet-peek, 64px) + 24px); left: auto; right: 14px; transform: none; }
  .stick { bottom: calc(var(--sheet-peek, 64px) + 18px); }
  /* 底部抽屉面板：默认只露出标签栏，点标签展开。 */
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; max-height: 72dvh; border-left: 0;
    border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 4px 10px 10px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .35); transform: translateY(calc(100% - var(--sheet-peek, 64px)));
    transition: transform .25s ease; overflow: hidden;
  }
  .panel.open { transform: none; overflow-y: auto; }
  .panel .status-card { order: 2; }
  .panel .panel-tabs { order: 1; position: static; box-shadow: none; }
  .panel .tab-page { order: 3; }
  .sheet-handle { display: block; order: 0; width: 100%; height: 16px; border: 0; background: none; padding: 0; cursor: pointer; }
  .sheet-handle span { display: block; width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 6px auto 0; }
  .chat-log { max-height: 34dvh; min-height: 140px; }
  .chat-page { min-height: 0; }
  .map-legend { display: none; }
}
