/* ============================================================
   样式：见 docs/DESIGN.md（海洋主题，横屏）
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #14568f;
  font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #f2ecdf;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overflow: hidden;
}

.hidden { display: none !important; }

#game-wrap {
  position: relative;
  height: 100dvh;
  width: 100vw;
  display: flex;
  justify-content: center;
  background: #0e2233;
}

#game-canvas {
  height: 100%;
  aspect-ratio: 800 / 450;
  max-width: 100vw;
  max-height: 56.25vw;
  display: block;
}

/* ---------- HUD（通栏横幅） ---------- */
#hud {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: min(100vw, calc(100dvh * 800 / 450));
  height: calc(env(safe-area-inset-top, 0px) + 44px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 4px) 16px 4px;
  background: #16324f;
  border-bottom: 3px solid #0e2233;
  font-size: 15px;
  font-weight: 700;
  z-index: 5;
}
#hud-level { color: #b8cfe0; flex-shrink: 0; }
#hud-score { color: #f5c542; font-size: 19px; flex-shrink: 0; text-shadow: 0 2px 0 rgba(0,0,0,0.35); }
#hud-time { font-size: 20px; color: #f2ecdf; flex-shrink: 0; }
#hud-time.warn { color: #e85a5a; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }
.hud-sep { flex: 1; }
.hud-coins-label { color: #f5c542; flex-shrink: 0; }
.hud-num { font-variant-numeric: tabular-nums; }
#hud-runcoins { color: #6fce6f; font-size: 12px; flex-shrink: 0; }

#btn-pause {
  width: 34px; height: 34px;
  border: none; border-radius: 8px;
  background: #16324f; color: #f2ecdf;
  font-size: 15px; cursor: pointer;
  flex-shrink: 0;
}

#btn-finish {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 46px);
  left: 50%; transform: translateX(-50%);
  z-index: 5;
  padding: 8px 16px;
}

/* ---------- 局内道具按钮（左上角竖排，不挡船夫） ---------- */
#level-items {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 50px);
  left: calc((100vw - min(100vw, calc(100dvh * 800 / 450))) / 2 + 10px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  z-index: 5;
}
#btn-finish { top: calc(env(safe-area-inset-top, 0px) + 92px); }

.icon-svg { vertical-align: -2px; }
.level-item-btn {
  min-width: 44px;
  padding: 9px 12px;
  border: none; border-radius: 10px;
  background: rgba(22, 50, 79, 0.92); color: #f2ecdf;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  opacity: 0.5;
}
.level-item-btn:not(:disabled) { opacity: 1; box-shadow: 0 0 0 2px #f5c542 inset; }
.level-item-btn:disabled { cursor: default; }

/* ---------- 竖屏提示层 ---------- */
.rotate-hint {
  position: fixed; inset: 0;
  background: #0e2233;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.rotate-inner { text-align: center; color: #b8cfe0; font-size: 18px; }
.rotate-icon { font-size: 52px; margin-bottom: 16px; animation: rotate-phone 1.6s infinite; }
@keyframes rotate-phone { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }

/* ---------- 全屏页面 ---------- */
.screen {
  position: absolute;
  inset: 0;
  width: min(100vw, calc(100dvh * 800 / 450));
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #2f9fdc, #1a5fa8);
  z-index: 10;
  display: flex;
  flex-direction: column;
}
.screen-inner { display: flex; flex-direction: column; height: 100%; padding: 14px 18px; gap: 10px; }
.scroll-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 24px; }

.screen-head { display: flex; align-items: center; gap: 12px; }
.screen-title { font-size: 22px; }
.screen-coins { margin-left: auto; color: #f5c542; font-weight: 700; }

/* 主菜单 */
.menu-inner {
  margin: auto;
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
  padding: 24px;
  width: min(420px, 90%);
}
.game-title {
  font-size: 44px;
  color: #f5c542;
  text-shadow: 0 3px 0 rgba(0,0,0,0.4);
  letter-spacing: 6px;
}
.menu-coins { font-size: 18px; color: #f2ecdf; }
.menu-best { color: #b8cfe0; font-size: 13px; text-align: center; }
.menu-row { display: flex; gap: 12px; width: 100%; }
.menu-row .btn { flex: 1; padding: 13px; font-size: 16px; }
.btn-sound { flex: 0 0 52px !important; }
.menu-version { color: #4e6a85; font-size: 11px; }

/* ---------- 卡片 ---------- */
.card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(22, 50, 79, 0.85);
  border-radius: 12px;
  padding: 12px;
  border-left: 4px solid transparent;
}
.card-equipped { box-shadow: 0 0 0 2px #f5c542 inset; }
.card-icon { flex-shrink: 0; }
.card-info { flex: 1; min-width: 0; }
.card-name { font-weight: 700; font-size: 15px; }
.card-desc { color: #b8cfe0; font-size: 12px; margin-top: 4px; }
.card-action { flex-shrink: 0; display: flex; align-items: center; }

.tag {
  font-size: 11px;
  background: #0e2233;
  color: #b8cfe0;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: 6px;
  font-weight: 400;
  white-space: nowrap;
}
.tag-on { background: #f5c542; color: #0e2233; font-weight: 700; }
.owned-label { color: #b8cfe0; font-size: 13px; padding: 0 4px; white-space: nowrap; }

.hat-dot {
  display: inline-block;
  width: 34px; height: 34px;
  border-radius: 50% 50% 6px 6px;
  border: 3px solid #0e2233;
}
.rod-icon {
  display: inline-block;
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #8f5a2c 60%, #f5c542 60%);
  border-radius: 8px;
  border: 2px solid #0e2233;
}
.item-dot {
  display: inline-block;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: #f5a623;
  border: 2px solid #0e2233;
}
.item-dot.clover, .item-dot.potion { background: #6fce6f; }
.item-dot.book { background: #5aa2e8; }
.item-dot.watch { background: #a86ee8; }
.grade-chip {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  color: #0e2233;
  font-weight: 700; font-size: 13px;
}
.grade-chip.big { width: 32px; height: 32px; font-size: 16px; }

.shop-tabs { display: flex; gap: 6px; }
.tab {
  flex: 1;
  padding: 9px 4px;
  border: none; border-radius: 10px;
  background: #16324f; color: #b8cfe0;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.tab.active { background: #f5a623; color: #0e2233; }
.shop-hint { color: #b8cfe0; font-size: 12px; text-align: center; padding: 4px; line-height: 1.6; }

/* ---------- 按钮 ---------- */
.btn {
  border: none; border-radius: 10px;
  padding: 10px 16px;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-main { background: #f5a623; color: #0e2233; }
.btn-sec { background: #16324f; color: #f2ecdf; }
.btn-big { padding: 14px 24px; font-size: 17px; width: 100%; }

.prep-coins { color: #f5c542; font-weight: 700; }
.prep-btns { display: flex; gap: 12px; margin-top: 8px; }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(5, 12, 22, 0.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 24px;
}
.modal-card {
  width: min(420px, 88vw);
  max-height: 86vh;
  overflow-y: auto;
  background: #16324f;
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.modal-card h3 { font-size: 22px; color: #f5c542; }
.modal-text { font-size: 15px; line-height: 1.8; }
.breakdown { border-top: 1px solid #0e2233; padding-top: 12px; color: #b8cfe0; text-align: left; }
.end-total { color: #f5c542; font-weight: 700; font-size: 17px; }
.milestone { color: #6fce6f; font-weight: 700; }
.chest-icon { font-size: 44px; }
.chest-name { font-size: 18px; font-weight: 700; }
.chest-sub { color: #b8cfe0; font-size: 13px; }

/* 关间道具询问 */
.outcarry-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.outcarry-item {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px;
  background: #0e2233;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
}
.outcarry-item.out { opacity: 0.45; }
.outcarry-desc { width: 100%; color: #b8cfe0; font-size: 12px; }
.outcarry-hint { color: #4e6a85; font-size: 11px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  left: 50%; transform: translateX(-50%);
  background: rgba(10, 22, 38, 0.92);
  color: #f2ecdf;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 60;
  white-space: nowrap;
}
