:root {
  --bg: #061826;
  --panel: rgba(9, 30, 46, 0.82);
  --panel-solid: #0b2436;
  --line: rgba(120, 190, 230, 0.18);
  --text: #dcecf7;
  --muted: #8fb2c9;
  --accent: #57d9b0;
  --accent-2: #6ec6ff;
  --warn: #ffc86b;
  --bad: #ff7a7a;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  font-size: 14px;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: grab;
}

#game:active {
  cursor: grabbing;
}

/* --------------------------------------------------------------- 顶栏 */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(4, 18, 30, 0.9), rgba(4, 18, 30, 0));
  pointer-events: none;
  z-index: 5;
}

#resbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: auto;
}

.res {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto 3px;
  gap: 2px 6px;
  align-items: center;
  padding: 5px 9px;
  min-width: 78px;
  background: rgba(8, 28, 44, 0.78);
  border: 1px solid var(--line);
  border-radius: 9px;
  backdrop-filter: blur(6px);
}

.res-icon {
  font-size: 14px;
  line-height: 1;
}

.res-num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 13px;
  text-align: right;
  color: #eaf6ff;
}

.res-num.near {
  color: var(--warn);
}

.res-bar {
  grid-column: 1 / span 2;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.res-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  transition: width 0.25s ease;
}

#hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.pill-btn,
.icon-btn {
  border: 1px solid var(--line);
  background: rgba(8, 28, 44, 0.82);
  color: var(--text);
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s ease, background 0.15s ease;
}

.pill-btn {
  padding: 7px 12px;
  font-size: 13px;
}

.icon-btn {
  width: 34px;
  height: 32px;
  font-size: 15px;
  line-height: 1;
}

.pill-btn:hover,
.icon-btn:hover {
  background: rgba(24, 62, 88, 0.95);
}

.pill-btn:active,
.icon-btn:active {
  transform: scale(0.95);
}

/* --------------------------------------------------------------- 提示条 */
#hint-bar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 7px 16px;
  max-width: min(560px, calc(100vw - 380px));
  text-align: center;
  font-size: 12.5px;
  color: #bcd6e6;
  background: rgba(6, 24, 38, 0.75);
  border: 1px solid var(--line);
  border-radius: 20px;
  backdrop-filter: blur(6px);
  pointer-events: none;
  z-index: 6;
}

/* --------------------------------------------------------------- 右侧面板 */
#panel {
  position: absolute;
  top: 62px;
  right: 14px;
  bottom: 14px;
  width: 336px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  z-index: 7;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.tab {
  flex: 1;
  padding: 11px 4px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(87, 217, 176, 0.07);
}

.tab-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tab-body::-webkit-scrollbar {
  width: 6px;
}

.tab-body::-webkit-scrollbar-thumb {
  background: rgba(140, 200, 235, 0.25);
  border-radius: 3px;
}

.panel-note {
  margin: 0 0 2px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* --------------------------------------------------------------- 卡片 */
.card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  background: rgba(14, 42, 62, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.card:hover {
  background: rgba(22, 58, 84, 0.9);
  border-color: rgba(120, 210, 255, 0.4);
}

.card:active {
  transform: scale(0.985);
}

.card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(87, 217, 176, 0.4) inset;
}

.card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: rgba(4, 20, 32, 0.7);
  border-radius: 9px;
}

.card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-main b {
  font-size: 13.5px;
  font-weight: 700;
}

.card-main small {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
}

.card-tag {
  font-size: 11px;
  font-style: normal;
  color: #9fd7c4;
}

.card-tag.warn {
  color: var(--warn);
}

.done-tag {
  font-size: 10.5px;
  font-style: normal;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(87, 217, 176, 0.16);
  color: var(--accent);
}

.card-cost {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  font-size: 11.5px;
  color: #cfe6f4;
}

.card-cost .lack {
  color: var(--bad);
}

.explore-card {
  cursor: default;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(8, 28, 44, 0.55);
  border-radius: 9px;
}

.warn-box {
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #ffd9b0;
  background: rgba(255, 160, 80, 0.13);
  border: 1px solid rgba(255, 180, 100, 0.35);
  border-radius: 9px;
}

.crew-list,
.quest-done {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.crew-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(14, 42, 62, 0.6);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12.5px;
}

.crew-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5d7a8d;
}

.crew-dot.on {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(87, 217, 176, 0.8);
}

.crew-place {
  margin-left: auto;
  color: var(--muted);
  font-size: 11.5px;
}

.quest-done li {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 6px;
}

.active-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 11px;
  background: linear-gradient(160deg, rgba(24, 70, 96, 0.9), rgba(12, 38, 56, 0.9));
  border: 1px solid rgba(120, 210, 255, 0.28);
  border-radius: var(--radius);
}

.active-card b {
  font-size: 14px;
}

.active-card small {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

.active-card .hint {
  color: #9fd7c4;
}

.progress {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #57d9b0, #6ec6ff);
  transition: width 0.3s ease;
}

.mono {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 11.5px;
}

/* --------------------------------------------------------------- 按钮 */
.mini {
  flex: 0 0 auto;
  padding: 5px 10px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: rgba(30, 72, 98, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.mini:hover {
  background: rgba(44, 96, 126, 0.95);
}

.mini:active {
  transform: scale(0.94);
}

.mini.primary {
  background: rgba(46, 150, 118, 0.95);
  border-color: rgba(87, 217, 176, 0.5);
}

.mini.danger {
  background: rgba(120, 46, 46, 0.85);
  border-color: rgba(255, 130, 130, 0.35);
}

.mini.ghost {
  background: transparent;
}

.mini.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --------------------------------------------------------------- 选中面板 */
#selection {
  position: absolute;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  width: min(340px, calc(100vw - 40px));
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: rgba(9, 32, 48, 0.94);
  border: 1px solid rgba(120, 210, 255, 0.3);
  border-radius: 13px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  z-index: 8;
}

#selection.hidden {
  display: none;
}

.sel-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sel-icon {
  font-size: 20px;
}

.sel-head div {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}

.sel-head b {
  font-size: 14px;
}

.sel-head small {
  font-size: 11.5px;
  color: var(--muted);
}

.sel-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------- 美术素材 */
.sprite {
  display: block;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
}

.res-icon.sprite {
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

.cost-icon.sprite {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 1px;
  vertical-align: -2px;
}

.card-icon-art.sprite {
  width: 27px;
  height: 27px;
}

.sel-icon-art.sprite {
  width: 32px;
  height: 32px;
}

.stat-icon.sprite {
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-right: 3px;
  vertical-align: -3px;
}

/* 素材 404 或加载失败时由 assets.js 换回 Emoji，保持样式一致 */
.sprite-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* --------------------------------------------------------------- 提示 */
#toasts {
  position: absolute;
  left: 14px;
  bottom: 56px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 9;
  pointer-events: none;
}

.toast {
  padding: 8px 13px;
  max-width: 320px;
  font-size: 12.5px;
  line-height: 1.45;
  color: #eaf6ff;
  background: rgba(10, 34, 52, 0.94);
  border-left: 3px solid var(--accent-2);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.22s ease;
}

.toast.good {
  border-left-color: var(--accent);
}

.toast.warn {
  border-left-color: var(--warn);
}

.toast.bad {
  border-left-color: var(--bad);
}

.toast.quest {
  border-left-color: #b892ff;
  background: rgba(38, 24, 64, 0.95);
}

.toast.out {
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------- 弹窗 */
#modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 14, 22, 0.66);
  backdrop-filter: blur(3px);
  z-index: 20;
}

#modal.hidden {
  display: none;
}

.modal-card {
  width: min(380px, calc(100vw - 40px));
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0b2436;
  border: 1px solid rgba(120, 210, 255, 0.3);
  border-radius: 15px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.kv {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
  padding: 3px 0;
  border-bottom: 1px dashed rgba(120, 190, 230, 0.12);
}

.kv b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

/* --------------------------------------------------------------- 适配 */
@media (max-width: 860px) {
  #panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    height: 44vh;
  }

  /* 竖屏：提示和 Toast 移到顶部，给底部面板让位 */
  #hint-bar {
    top: 58px;
    bottom: auto;
    max-width: calc(100vw - 24px);
  }

  #selection {
    left: 8px;
    right: 8px;
    bottom: calc(44vh + 16px);
    width: auto;
    transform: none;
  }

  #toasts {
    top: 96px;
    bottom: auto;
    left: 8px;
    right: 8px;
    align-items: flex-start;
  }

  .toast {
    max-width: 100%;
  }

  .res {
    min-width: 66px;
    padding: 4px 7px;
  }

  .res-num {
    font-size: 12px;
  }
}

@media (max-width: 520px) {
  .pill-btn {
    display: none;
  }

  .res-icon {
    font-size: 13px;
  }
}
