* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --ocean-deep: #041d36;
  --ocean-mid: #0a4270;
  --ocean-bright: #1476b8;
  --foam: #d9f6ff;
  --gold: #ffd166;
  --amber: #f59e0b;
  --emerald: #34d399;
  --danger: #fb7185;
  --panel-bg: rgba(7, 29, 52, 0.86);
  --panel-border: rgba(125, 211, 252, 0.28);
  --text-main: #f0f9ff;
  --text-muted: #9dd5f5;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 15%, #0e3d6b 0%, #051629 65%, #020a14 100%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
}

#app-shell {
  width: 100%;
  max-width: 430px;
  height: min(100dvh, 860px);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: #062848;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(125, 211, 252, 0.2);
}

@media (min-width: 460px) and (min-height: 700px) {
  #app-shell {
    border-radius: 26px;
  }
}

/* 微信小游戏仿真顶栏 */
#wx-header {
  height: 48px;
  flex: 0 0 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(4, 24, 46, 0.96), rgba(7, 37, 68, 0.92));
  border-bottom: 1px solid rgba(125, 211, 252, 0.16);
  z-index: 30;
}

.wx-back {
  color: #dbeafe;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background 0.15s ease, transform 0.12s ease;
}

.wx-back:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.16);
}

.wx-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #f0f9ff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}

.wx-capsule {
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.wx-icon-btn {
  width: 30px;
  height: 26px;
  border: none;
  background: transparent;
  color: #f0f9ff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  transition: background 0.15s ease;
}

.wx-icon-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.wx-divider {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.22);
}

/* 游戏舞台 */
#game-stage {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  background: #074475;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

/* 顶部 HUD */
#hud-top {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  z-index: 15;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(4, 24, 46, 0.72);
  border: 1px solid rgba(125, 211, 252, 0.28);
  backdrop-filter: blur(6px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.hud-phase-pill {
  color: #bae6fd;
}

.hud-phase-pill.storm {
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(30, 27, 75, 0.78);
}

.hud-phase-pill.boss {
  color: #fda4af;
  border-color: rgba(251, 113, 133, 0.6);
  background: rgba(69, 10, 26, 0.8);
}

.hud-timer {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 2px 12px;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(180deg, rgba(14, 116, 144, 0.85), rgba(8, 47, 73, 0.88));
  border: 1px solid rgba(186, 230, 253, 0.45);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.hud-timer.urgent {
  color: #fef08a;
  border-color: #fb7185;
  background: linear-gradient(180deg, rgba(190, 18, 60, 0.88), rgba(136, 19, 55, 0.92));
}

.hud-size-pill {
  color: #fef3c7;
}

.hud-row-res {
  gap: 6px;
}

.res-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: rgba(4, 24, 46, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.res-wood {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.38);
}

.res-scrap {
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.42);
}

.hp-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(4, 24, 46, 0.76);
  border: 1px solid rgba(251, 113, 133, 0.32);
}

.hp-heart {
  font-size: 13px;
  line-height: 1;
}

.hp-track {
  position: relative;
  flex: 1;
  height: 15px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ef4444, #fb7185, #34d399);
  background-size: 200% 100%;
  background-position: 100% 0;
  transition: width 0.18s ease;
}

.hp-fill.mid {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.hp-fill.low {
  background: linear-gradient(90deg, #dc2626, #fb7185);
}

.hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  font-variant-numeric: tabular-nums;
}

.blueprint-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 0;
}

.bp-mini {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #fef9c3;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(250, 204, 21, 0.45);
}

/* Boss 血条 */
#boss-bar-wrap {
  margin-top: 2px;
  padding: 6px 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(69, 10, 26, 0.88), rgba(30, 10, 36, 0.88));
  border: 1px solid rgba(251, 113, 133, 0.6);
  box-shadow: 0 4px 16px rgba(159, 18, 57, 0.4);
}

.boss-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #ffe4e6;
  margin-bottom: 4px;
}

.boss-bar-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  overflow: hidden;
}

#boss-hp-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #be123c, #f43f5e, #fb923c);
  transition: width 0.14s linear;
}

/* 大事件提示条 */
#banner-toast {
  position: absolute;
  top: 122px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #fffbeb;
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.94), rgba(3, 105, 161, 0.94));
  border: 1px solid rgba(186, 230, 253, 0.6);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
  white-space: nowrap;
  animation: toastPop 0.25s ease-out;
}

#banner-toast.warn {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.95), rgba(146, 64, 14, 0.95));
  border-color: rgba(253, 224, 71, 0.7);
}

#banner-toast.danger {
  background: linear-gradient(135deg, rgba(190, 18, 60, 0.96), rgba(126, 34, 206, 0.94));
  border-color: rgba(253, 164, 175, 0.8);
}

@keyframes toastPop {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* 建造提示条 */
#build-hint {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 14px;
  border-radius: 999px;
  background: rgba(6, 78, 59, 0.92);
  border: 1px solid rgba(52, 211, 153, 0.75);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  font-weight: 700;
  color: #ecfdf5;
  white-space: nowrap;
}

#btn-cancel-build {
  border: none;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
  color: #064e3b;
  background: #6ee7b7;
  cursor: pointer;
}

/* 底部建造工具栏 */
#hud-bottom {
  position: absolute;
  bottom: 10px;
  left: 8px;
  right: 8px;
  z-index: 16;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.build-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 4px 6px;
  border-radius: 14px;
  border: 1.5px solid rgba(125, 211, 252, 0.34);
  background: linear-gradient(180deg, rgba(12, 48, 82, 0.9), rgba(6, 26, 48, 0.94));
  color: #f0f9ff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.38);
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.build-btn:active {
  transform: scale(0.95);
}

.build-btn.active {
  border-color: #34d399;
  background: linear-gradient(180deg, rgba(6, 95, 70, 0.95), rgba(6, 60, 50, 0.96));
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.35), 0 8px 18px rgba(16, 185, 129, 0.32);
  transform: translateY(-2px);
}

.build-btn.cant-afford {
  opacity: 0.52;
  border-color: rgba(148, 163, 184, 0.25);
}

.build-btn.pulse-ready {
  border-color: rgba(251, 191, 36, 0.72);
}

.b-icon {
  font-size: 19px;
  line-height: 1.1;
}

.b-name {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.b-cost {
  font-size: 10px;
  font-weight: 700;
  color: #fde68a;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

/* 遮罩与弹窗通用 */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(3, 18, 36, 0.56);
  backdrop-filter: blur(5px);
}

.start-card,
.modal-card {
  width: 100%;
  max-width: 378px;
  border-radius: 22px;
  padding: 18px 16px;
  background: linear-gradient(180deg, rgba(7, 36, 66, 0.94), rgba(5, 22, 43, 0.97));
  border: 1px solid rgba(125, 211, 252, 0.34);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  text-align: center;
}

.game-badge,
.modal-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.38);
  margin-bottom: 8px;
}

.game-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffffff;
  text-shadow: 0 3px 14px rgba(14, 165, 233, 0.55);
}

.logo-icon {
  font-size: 32px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.game-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

/* 模式选择 */
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: 14px;
  border: 1.5px solid rgba(125, 211, 252, 0.22);
  background: rgba(15, 41, 70, 0.72);
  color: #e0f2fe;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-btn.active {
  border-color: #38bdf8;
  background: linear-gradient(180deg, rgba(14, 116, 144, 0.62), rgba(7, 89, 133, 0.74));
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25), 0 6px 18px rgba(14, 165, 233, 0.28);
}

.mode-name {
  font-size: 12px;
  font-weight: 800;
}

.mode-desc {
  font-size: 10px;
  color: #bae6fd;
  line-height: 1.3;
}

/* 规则框 */
.rules-box {
  margin-top: 12px;
  padding: 10px 11px;
  border-radius: 14px;
  background: rgba(2, 18, 36, 0.62);
  border: 1px solid rgba(125, 211, 252, 0.18);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: #e0f2fe;
}

.rule-item b {
  color: #fde68a;
}

.rule-ico {
  font-size: 15px;
  line-height: 1.3;
  flex-shrink: 0;
}

.best-pill {
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  color: #fef08a;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.35);
}

/* 主按钮 */
.btn-primary,
.btn-secondary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-primary {
  margin-top: 14px;
  color: #042038;
  background: linear-gradient(135deg, #fde047, #f59e0b);
  box-shadow: 0 8px 22px rgba(245, 158, 11, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.btn-primary:active,
.btn-secondary:active,
.btn-ghost:active {
  transform: scale(0.97);
}

.btn-secondary {
  color: #e0f2fe;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(125, 211, 252, 0.35);
}

.btn-ghost {
  color: #bae6fd;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* 蓝图 3 选 1 */
.modal-title {
  font-size: 20px;
  font-weight: 900;
  color: #ffffff;
}

.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.blueprint-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.bp-choice {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 15px;
  border: 1.5px solid rgba(125, 211, 252, 0.28);
  background: linear-gradient(135deg, rgba(14, 52, 90, 0.88), rgba(7, 29, 56, 0.94));
  color: #f0f9ff;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.bp-choice:hover {
  border-color: #fde047;
  box-shadow: 0 6px 18px rgba(250, 204, 21, 0.22);
}

.bp-choice:active {
  transform: scale(0.97);
}

.bp-ico {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(125, 211, 252, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.bp-body {
  flex: 1;
  min-width: 0;
}

.bp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.bp-name {
  font-size: 14px;
  font-weight: 800;
  color: #fef9c3;
}

.bp-lv {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.bp-desc {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.38;
  color: #cbd5e1;
}

/* 暂停卡片 */
.modal-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions .btn-primary {
  margin-top: 0;
}

/* 结算卡片：末日航海日志 */
.end-card {
  position: relative;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.log-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #fde68a;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.38);
}

.rank-stamp {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 900;
  border: 3px solid currentColor;
  transform: rotate(-10deg);
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.45);
}

.rank-S {
  color: #fde047;
  background: rgba(234, 179, 8, 0.22);
}

.rank-A {
  color: #38bdf8;
  background: rgba(14, 165, 233, 0.22);
}

.rank-B {
  color: #34d399;
  background: rgba(16, 185, 129, 0.22);
}

.rank-C {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.2);
}

.end-title {
  font-size: 23px;
  font-weight: 900;
  color: #ffffff;
}

.end-subtitle {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
}

.boss-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #ffe4e6;
  background: linear-gradient(135deg, rgba(190, 18, 60, 0.72), rgba(126, 34, 206, 0.72));
  border: 1px solid rgba(251, 113, 133, 0.6);
}

.boss-badge.calm {
  color: #d1fae5;
  background: linear-gradient(135deg, rgba(6, 95, 70, 0.72), rgba(14, 116, 144, 0.72));
  border-color: rgba(52, 211, 153, 0.55);
}

.new-record {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  color: #fde047;
}

.stats-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-box {
  padding: 9px 8px;
  border-radius: 12px;
  background: rgba(2, 18, 36, 0.66);
  border: 1px solid rgba(125, 211, 252, 0.2);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 16px;
  font-weight: 900;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.best-summary {
  margin-top: 10px;
  font-size: 12px;
  color: #bae6fd;
  font-weight: 600;
}

.end-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 8px;
}

.end-actions .btn-primary {
  margin-top: 0;
}
