/* 暗海探秘 web client — layout matches the 1600x900 design space of the Windows
   rebuild; #stage is scaled with a CSS transform so the whole scene + DOM
   overlays stay pixel-aligned and responsive (letterboxed). */

@font-face {
  font-family: "pop1w5";
  src: url("assets/fonts/pop1w5.ttc") format("collection"),
       url("assets/fonts/pop1w5.ttc");
  font-display: swap;
}

:root {
  --cjk: "pop1w5", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC",
         "Hiragino Sans GB", "Source Han Sans SC", "Noto Sans CJK SC", "DengXian",
         "SimHei", sans-serif;
  --ink: #ecf8ff;
  --ink-dim: #b6dcec;
  --gold: #e6da82;
  --line: rgba(124, 204, 236, 0.46);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050f22;
  font-family: var(--cjk);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 0%, #0a2b44 0%, #050f22 70%);
}

#stage {
  position: relative;
  width: 1600px;
  height: 900px;
  transform-origin: center center;
  flex: 0 0 auto;
}

#game {
  position: absolute;
  inset: 0;
  width: 1600px;
  height: 900px;
  display: block;
}

#overlays {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#overlays > * { pointer-events: auto; }

.hidden { display: none !important; }

/* ---------- Loading ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#loading { background: linear-gradient(180deg, #07203c 0%, #04132a 100%); }
.loading-box { text-align: center; width: 520px; }
.loading-title {
  font-size: 56px;
  letter-spacing: 6px;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(70, 175, 240, 0.7);
  margin-bottom: 36px;
}
.loading-bar {
  width: 100%;
  height: 14px;
  border-radius: 8px;
  background: rgba(9, 35, 64, 0.85);
  border: 1px solid var(--line);
  overflow: hidden;
}
#loading-fill {
  height: 100%;
  width: 0%;
  border-radius: 8px;
  background: linear-gradient(90deg, #3aa6d8, #9fe8ff);
  transition: width 0.18s ease;
}
.loading-text { margin-top: 18px; font-size: 24px; color: var(--ink-dim); }

/* ---------- Shared modal styling ---------- */
.modal-shade { background: rgba(4, 18, 44, 0.72); }
.modal-box {
  position: relative;
  background: rgba(7, 28, 54, 0.94);
  border: 2px solid rgba(142, 216, 246, 0.46);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55), inset 0 0 40px rgba(20, 70, 120, 0.25);
  padding: 28px 34px;
  color: var(--ink);
}
.modal-title {
  text-align: center;
  font-size: 36px;
  letter-spacing: 2px;
  margin-bottom: 14px;
}
.glow { text-shadow: 0 0 22px rgba(70, 175, 240, 0.8); }
.modal-hint { text-align: center; color: var(--ink-dim); font-size: 22px; margin-bottom: 18px; }

.primary-btn {
  font-family: var(--cjk);
  font-size: 30px;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(40, 132, 192, 0.95), rgba(22, 86, 140, 0.95));
  border: 2px solid rgba(188, 236, 255, 0.65);
  border-radius: 12px;
  padding: 12px 30px;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.primary-btn:hover { filter: brightness(1.12); }
.primary-btn:active { transform: translateY(1px) scale(0.99); }
.primary-btn.big { font-size: 32px; padding: 16px 52px; margin-top: 8px; }

/* ---------- Nickname modal ---------- */
.nick-box { width: 520px; }
.nick-input {
  display: block;
  width: 100%;
  font-family: var(--cjk);
  font-size: 32px;
  color: var(--ink);
  text-align: center;
  background: rgba(9, 35, 64, 0.9);
  border: 2px solid rgba(160, 226, 250, 0.5);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 10px 0 22px;
  outline: none;
}
.nick-input::placeholder { color: #7fa6bd; }
.nick-box .primary-btn { display: block; margin: 0 auto; }

/* ---------- Settings panel ---------- */
.panel {
  position: absolute;
  left: 34px;
  top: 102px;
  width: 360px;
  background: rgba(6, 22, 46, 0.92);
  border: 1px solid rgba(124, 204, 236, 0.5);
  border-radius: 10px;
  padding: 14px 18px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.panel-title { font-size: 30px; margin-bottom: 12px; letter-spacing: 1px; }
.panel .row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  min-height: 38px;
}
.row-label { width: 92px; color: var(--ink-dim); font-size: 21px; flex: 0 0 auto; white-space: nowrap; }
.row-pct { width: 46px; text-align: right; color: var(--ink-dim); font-size: 20px; flex: 0 0 auto; }
.slider {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  border-radius: 6px;
  background: rgba(10, 34, 60, 0.9);
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: #dcf4ff; border: 2px solid #449acc; cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #dcf4ff; border: 2px solid #449acc; cursor: pointer;
}
.slider::-webkit-slider-runnable-track { height: 10px; border-radius: 6px; }
.seg { display: flex; gap: 8px; flex: 1 1 auto; }
.seg-btn {
  flex: 1 1 0;
  font-family: var(--cjk);
  font-size: 22px;
  color: var(--ink-dim);
  background: rgba(12, 44, 76, 0.66);
  border: 1px solid rgba(102, 178, 216, 0.35);
  border-radius: 7px;
  padding: 6px 0;
  cursor: pointer;
}
.seg-btn.active {
  color: #eafaff;
  background: rgba(56, 150, 190, 0.74);
  border-color: rgba(190, 235, 250, 0.66);
}
.nick-display { flex: 1 1 auto; color: var(--ink-dim); font-size: 22px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mini-btn, .wide-btn {
  font-family: var(--cjk);
  color: var(--ink);
  background: rgba(16, 82, 126, 0.85);
  border: 1px solid rgba(158, 222, 246, 0.46);
  border-radius: 7px;
  cursor: pointer;
}
.mini-btn { font-size: 22px; padding: 6px 16px; flex: 0 0 auto; }
.wide-btn { font-size: 22px; padding: 8px 0; flex: 1 1 auto; }
.wide-btn.busy { background: rgba(38, 126, 166, 0.9); }

/* ---------- Leaderboard modal ---------- */
.rank-box { width: 860px; height: 732px; padding: 24px 30px; }
.close-btn {
  position: absolute;
  top: 22px; right: 22px;
  width: 40px; height: 40px;
  font-size: 22px; line-height: 1;
  color: var(--ink);
  background: rgba(12, 44, 76, 0.7);
  border: 1px solid rgba(158, 222, 246, 0.46);
  border-radius: 8px;
  cursor: pointer;
}
.rank-status { text-align: center; color: var(--ink-dim); font-size: 26px; margin: 18px 0; min-height: 30px; }
.rank-columns { display: flex; gap: 30px; }
.rank-col {
  flex: 1 1 0;
  list-style: none;
  margin: 0; padding: 0;
  counter-reset: rank;
}
.rank-col li {
  display: flex;
  align-items: center;
  height: 24px;
  font-size: 21px;
  padding: 0 8px;
  border-radius: 4px;
}
.rank-col li:nth-child(odd) { background: rgba(25, 58, 86, 0.32); }
.rank-col li .rk { width: 42px; color: var(--gold); }
.rank-col li .nm { flex: 1 1 auto; color: var(--ink-dim); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rank-col li .sc { color: var(--gold); margin-left: 8px; }
.rank-col li.me { background: rgba(56, 150, 190, 0.4); }

/* ---------- Game over ---------- */
.gameover-content { text-align: center; }
.gameover-title { font-size: 64px; letter-spacing: 4px; margin-bottom: 18px; }
.gameover-score { font-size: 34px; color: var(--ink); margin-bottom: 8px; }
.gameover-level { font-size: 30px; color: var(--ink-dim); margin-bottom: 8px; }
.gameover-submit { font-size: 22px; color: var(--ink-dim); min-height: 26px; margin-bottom: 14px; }

/* ---------- Rotate hint (portrait phones) ---------- */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  font-size: 22px;
  color: var(--ink-dim);
  background: #04132a;
}
@media (max-aspect-ratio: 1/1) and (max-width: 820px) {
  #rotate-hint { display: flex; }
}
