/**
 * 手机竖屏适配 + 横屏拦截
 */

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app {
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
}

/* —— 竖屏默认：地图在上、侧栏在下 —— */
@media (orientation: portrait) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(40dvh, 48dvh) minmax(0, 1fr) auto auto;
  }

  .player-panel-head {
    display: none;
  }

  .map-pane {
    min-height: 0;
  }

  .map-frame {
    width: min(100%, calc(100% * 1600 / 1200));
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1600 / 1200;
  }

  .side-panel {
    border-left: 0;
    border-top: 1px solid #243044;
    min-height: 0;
    overflow: auto;
  }

  .player-panel {
    max-height: none;
    padding: 8px 10px;
  }

  .panel-entries {
    padding: 6px 8px 8px;
    gap: 6px;
  }

  .entry-btn {
    min-width: 72px;
    padding: 8px 10px;
    font-size: 12px;
  }

  .activity-ticker {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .activity-ticker-running {
    border-right: 0;
    border-bottom: 1px solid #2a3448;
    padding-right: 0;
    padding-bottom: 4px;
  }

  .bottom-bar {
    flex-wrap: wrap;
    gap: 4px 10px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .bb-item {
    flex: 1 1 auto;
    min-width: calc(33% - 10px);
  }

  .time-controls {
    top: 6px;
    left: 6px;
    right: auto;
    gap: 4px;
    max-width: calc(100% - 88px);
  }

  .time-date {
    font-size: 11px;
    padding: 3px 8px;
  }

  .time-btn {
    min-width: 28px;
    padding: 3px 5px;
    font-size: 10px;
  }

  .reset-btn,
  .game-back-btn {
    font-size: 11px;
    padding: 5px 8px;
  }

  .user-chip {
    top: 6px;
    right: 6px;
    font-size: 11px;
  }

  .marker-tag {
    font-size: 11px;
    padding: 3px 7px;
    min-width: 72px;
    max-width: 140px;
  }

  .auth-card {
    width: min(400px, 94vw);
    max-height: 92dvh;
    overflow: auto;
  }

  .create-shop {
    max-height: none;
  }
}

@media (orientation: portrait) and (max-width: 560px) {
  .app {
    grid-template-rows: minmax(36dvh, 44dvh) minmax(0, 1fr) auto auto;
  }

  .bb-item {
    min-width: calc(50% - 10px);
  }

  .world-content {
    padding: 16px 14px;
    padding-top: max(48px, env(safe-area-inset-top) + 12px);
  }

  .world-brand {
    font-size: clamp(32px, 10vw, 48px);
  }
}

/* —— 横屏：遮罩提示，请转回竖屏 —— */
html.force-portrait.is-landscape .portrait-tip {
  display: flex !important;
}

html.force-portrait.is-landscape .app,
html.force-portrait.is-landscape .world-screen {
  visibility: hidden !important;
  pointer-events: none !important;
}

.portrait-tip {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(56, 170, 120, 0.16), transparent 55%),
    linear-gradient(180deg, #0e1218 0%, #161c28 100%);
  color: #f2f5fa;
}

.portrait-tip-card {
  text-align: center;
  max-width: 280px;
}

.portrait-tip-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 16px;
  color: #78c8a0;
  animation: portrait-spin 1.6s ease-in-out infinite;
}

@keyframes portrait-spin {
  0%,
  100% {
    transform: rotate(0deg);
  }
  40% {
    transform: rotate(-90deg);
  }
  60% {
    transform: rotate(-90deg);
  }
}

.portrait-tip-title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
}

.portrait-tip-desc {
  margin: 0 0 18px;
  color: #96a5b9;
  font-size: 14px;
  line-height: 1.5;
}

.portrait-tip-btn {
  border: 1px solid #3d5a4a;
  border-radius: 10px;
  padding: 10px 16px;
  background: rgba(56, 170, 120, 0.2);
  color: #dff7ea;
  font-size: 14px;
  cursor: pointer;
}

.portrait-tip-btn:active {
  background: rgba(56, 170, 120, 0.35);
}

/* 兼容旧类名 */
.landscape-tip {
  display: none;
}

/* 财务抽屉 */
.finance-drawer {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.finance-drawer[hidden] { display: none; }
.finance-drawer-card {
  width: min(560px, 96vw); max-height: 86vh; overflow: auto;
  background: #1f2433; color: #e8ecf5;
  border-radius: 14px 14px 0 0; padding: 14px 16px 22px;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.45);
}
.finance-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.finance-drawer-head h2 { font-size: 17px; margin: 0; }
.finance-close {
  border: none; background: transparent; color: #9aa3b8;
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0 6px;
}
.fin-summary {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin-bottom: 14px;
}
.fin-stat {
  background: #2a3145; border-radius: 8px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.fin-stat span { font-size: 11px; color: #8b94ad; }
.fin-stat b { font-size: 14px; font-weight: 600; }
.fin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fin-table th {
  text-align: left; color: #8b94ad; font-weight: 500;
  padding: 6px 8px; border-bottom: 1px solid #3a4258;
}
.fin-table td { padding: 7px 8px; border-bottom: 1px solid #2f364a; }
.fin-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-cat { display: block; font-size: 11px; color: #7a839c; margin-top: 2px; }
.fin-name { min-width: 120px; }
.finance-empty { text-align: center; color: #7a839c; padding: 18px; }
#financeBtn {
  margin: 0 6px; padding: 3px 10px; font-size: 12px;
  border: 1px solid #3a4258; background: #2a3145; color: #cdd4e6;
  border-radius: 6px; cursor: pointer;
}

/* 财务抽屉：成就/称号区块 */
.fin-section { margin-top: 16px; }
.fin-h3 { font-size: 14px; color: #cdd4e6; margin: 0 0 8px; border-left: 3px solid #4a5478; padding-left: 8px; }
.fin-quest { background: #2a3145; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.fin-quest.is-claimed { opacity: 0.55; }
.fin-quest-head { display: flex; justify-content: space-between; align-items: center; }
.fin-quest-prog { font-size: 12px; color: #8b94ad; font-variant-numeric: tabular-nums; }
.fin-bar { height: 6px; background: #1a1f2e; border-radius: 3px; margin: 6px 0; overflow: hidden; }
.fin-bar-fill { height: 100%; background: linear-gradient(90deg, #4a90d9, #6bb3f0); transition: width 0.3s; }
.fin-quest-foot { display: flex; justify-content: space-between; align-items: center; }
.fin-reward { font-size: 11px; color: #7a839c; }
.fin-claim { border: none; background: #4a90d9; color: #fff; font-size: 12px; padding: 4px 12px; border-radius: 5px; cursor: pointer; }
.fin-claim:disabled { opacity: 0.5; }
.fin-claimed { font-size: 11px; color: #5a6378; }
.fin-title { background: #2a3145; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.fin-title.is-equipped { border: 1px solid #4a90d9; }
.fin-title.is-locked { opacity: 0.5; }
.fin-title-head { display: flex; justify-content: space-between; align-items: center; }
.fin-title-buff { font-size: 11px; color: #6bb3f0; }
.fin-title-foot { margin-top: 4px; display: flex; justify-content: flex-end; }
.fin-equip { border: 1px solid #4a90d9; background: transparent; color: #6bb3f0; font-size: 12px; padding: 3px 10px; border-radius: 5px; cursor: pointer; }
.fin-equip:disabled { opacity: 0.5; }
.fin-locked { font-size: 11px; color: #5a6378; }

/* 财务抽屉：银行贷款 */
.fin-loan-stats { margin-bottom: 8px; }
.fin-debt { color: #f0a35e; }
.fin-loan-row { display: flex; gap: 6px; margin-bottom: 6px; }
.fin-loan-row input {
  flex: 1; min-width: 0; background: #1a1f2e; border: 1px solid #3a4258;
  color: #e6ebf5; font-size: 12px; padding: 5px 8px; border-radius: 5px; outline: none;
}
.fin-loan-row input:focus { border-color: #4a90d9; }
.fin-loan-quick {
  border: 1px solid #4a90d9; background: transparent; color: #6bb3f0;
  font-size: 12px; padding: 4px 10px; border-radius: 5px; cursor: pointer;
}
.fin-loan-hint { font-size: 11px; color: #7a839c; margin: 4px 0 0; }

/* 底部状态栏 */
.activity-ticker {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  padding: 6px 10px 4px;
  background: rgba(12, 16, 22, 0.96);
  border-top: 1px solid #283446;
  overflow: hidden;
}

.activity-ticker-running {
  display: flex;
  align-items: center;
  min-width: 0;
  flex-shrink: 0;
  padding-right: 8px;
  border-right: 1px solid #2a3448;
}

.activity-ticker-running .running-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  min-width: 0;
}

.activity-ticker-running .activity-chip {
  width: 100%;
  justify-content: flex-start;
}

.running-progress {
  height: 3px;
  border-radius: 999px;
  background: #1d2636;
  overflow: hidden;
}

.running-progress i {
  display: block;
  height: 100%;
  width: 100%;
  background: #78c8a0;
  transform: scaleX(0);
  transform-origin: left center;
}

.activity-ticker-notify {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.activity-notify {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
  width: 100%;
  min-width: 0;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #2f3a4e;
  background: #182032;
  color: #d5deef;
  font-size: 12px;
}

.activity-notify em {
  font-style: normal;
  font-size: 10px;
  color: #8fa0b8;
  flex-shrink: 0;
}

.activity-notify b {
  font-weight: 600;
  flex-shrink: 0;
}

.activity-notify small {
  color: #9aabbf;
  font-size: 11px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-notify.is-fresh {
  border-color: #3d6a55;
  background: #163126;
}

.activity-notify.is-fresh em {
  color: #78c8a0;
}

.activity-notify.is-empty {
  opacity: 0.7;
}

.activity-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #2f3a4e;
  background: #182032;
  color: #d5deef;
  font-size: 12px;
}

.activity-chip em {
  font-style: normal;
  font-size: 10px;
  color: #8fa0b8;
}

.activity-chip i {
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.activity-chip b {
  font-weight: 600;
}

.activity-chip small {
  color: #9aabbf;
  font-size: 11px;
}

.activity-chip.is-running {
  border-color: #3d6a55;
  background: #163126;
}

.activity-chip.is-running em {
  color: #78c8a0;
}

.activity-chip.is-empty {
  opacity: 0.7;
}

.bottom-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(14, 18, 24, 0.96);
  border-top: 1px solid #283446;
  font-size: 13px;
  overflow-x: auto;
}
.bb-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.bb-label {
  color: #96a5b9;
  font-size: 12px;
}
.bb-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.bb-value.accent {
  color: #78c8a0;
}

/* 入口按钮组（替代原 stat 列表） */
.panel-entries {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 12px;
}
.entry-btn {
  flex: 1 1 auto;
  min-width: 84px;
  padding: 10px 12px;
  border: 1px solid #283446;
  background: #1e2736;
  color: #f2f5fa;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.entry-btn:hover {
  background: #283446;
  border-color: #3a4a66;
}
.entry-btn:active {
  background: #3a4a66;
}

/* 个人面板抽屉内的 stat 列表适配 */
#profileDrawer .player-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
#profileDrawer .stat-item {
  background: #2a3145;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#profileDrawer .stat-label {
  font-size: 11px;
  color: #8b94ad;
}
#profileDrawer .stat-value {
  font-size: 15px;
  font-weight: 600;
}

/* 人才市场/批发市场抽屉候选卡片 */
.market-candidate {
  background: #2a3145;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.market-candidate-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.market-candidate-name {
  font-weight: 600;
}
.market-candidate-stats {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: #8b94ad;
  margin-bottom: 8px;
}
.market-candidate-stats b {
  color: #cdd4e6;
}
.market-candidate-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.market-check {
  font-size: 12px;
  color: #8b94ad;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.market-batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #1c2233;
  border: 1px solid #2f364a;
  font-size: 13px;
}
.market-batch-bar label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.wholesale-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #2a3145;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.wholesale-price {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.wholesale-price.up {
  color: #78c8a0;
}
.wholesale-price.down {
  color: #c45a5a;
}

/* 员工面板（店铺详情内员工页仍可用旧卡片样式） */
.emp-section { margin-bottom: 16px; }
.emp-section h3 { margin: 0 0 8px; font-size: 15px; }
.emp-tier {
  margin-bottom: 12px;
  padding: 8px 10px;
  background: #232a3c;
  border-radius: 8px;
}
.emp-tier.is-locked { opacity: 0.55; }
.emp-tier-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.emp-seat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.emp-seat {
  background: #2a3145;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.emp-seat.is-locked { opacity: 0.55; }
.emp-seat-name { font-weight: 600; margin-bottom: 4px; }
.emp-card {
  background: #2a3145;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.emp-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.emp-quality { font-size: 12px; font-weight: 600; }
.emp-card-meta { font-size: 12px; color: #8b94ad; margin-bottom: 4px; }
.emp-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.emp-card-actions button,
.emp-card-actions select {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid #3d4660;
  background: #1c2233;
  color: #e8ecf5;
  cursor: pointer;
}
.detail-staff-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #2a3145;
}
