/* 星球合成 - 深空主题样式 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 50% -10%, #1b2450 0%, #0b0e22 55%, #05060f 100%);
  color: #e8ecff;
  min-height: 100%;
  display: flex;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

#app { width: 100%; max-width: 860px; padding: 10px 14px 20px; }

header { text-align: center; padding: 6px 0 10px; }
header h1 { font-size: 26px; letter-spacing: 2px; text-shadow: 0 0 18px rgba(120,160,255,.6); }
header .sub { font-size: 12px; color: #93a0d0; margin-top: 2px; }

#main { display: flex; gap: 14px; justify-content: center; align-items: flex-start; }

/* 舞台 */
#stage {
  position: relative;
  width: min(480px, 100%);
  flex: 0 1 auto;
}
#game {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 480 / 720;
  border-radius: 14px;
  box-shadow: 0 0 0 2px rgba(110,140,255,.25), 0 12px 40px rgba(0,0,0,.55);
  touch-action: none;
  cursor: crosshair;
  background: #0a0d20;
}

/* 覆盖层 */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 24, .78);
  backdrop-filter: blur(3px);
  border-radius: 14px;
  z-index: 5;
}
.panel-box {
  text-align: center;
  padding: 26px 30px;
  background: rgba(20, 26, 58, .92);
  border: 1px solid rgba(130,160,255,.35);
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(80,110,255,.25);
  max-width: 86%;
}
.panel-box h2 { font-size: 24px; margin-bottom: 14px; }
.panel-box .tip { font-size: 13px; color: #aeb9e8; margin: 6px 0; }
.score-line { font-size: 18px; margin: 10px 0 4px; }
.score-line span { color: #ffd75e; font-weight: 700; }
.best-line { font-size: 13px; color: #93a0d0; margin: 8px 0 14px; }
.best-line span { color: #ffd75e; }
.record { color: #ffd75e; font-size: 18px; font-weight: 700; animation: pulse 0.8s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }

/* /game UI 按钮贴图（无字图 + 运行时文字） */
.big-btn {
  display: block; width: 100%;
  margin-top: 12px;
  padding: 14px 22px;
  font-size: 17px; font-weight: 700;
  color: #08122e;
  border: none; border-radius: 14px;
  cursor: pointer;
  background-color: transparent;
  background-image: url("assets/ui/btn_primary_normal.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  box-shadow: 0 6px 18px rgba(255,190,60,.28);
  transition: transform .08s, filter .08s;
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
}
.big-btn:active {
  transform: translateY(2px) scale(0.99);
  background-image: url("assets/ui/btn_primary_pressed.png");
  filter: brightness(0.96);
}
.ghost-btn {
  display: block; width: 100%;
  margin-top: 10px;
  padding: 12px 22px;
  font-size: 14px; font-weight: 600;
  color: #e8ecff;
  border: none; border-radius: 14px;
  cursor: pointer;
  background-color: transparent;
  background-image: url("assets/ui/btn_secondary_normal.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform .08s, filter .08s;
}
.ghost-btn:active {
  transform: translateY(1px);
  background-image: url("assets/ui/btn_secondary_pressed.png");
  filter: brightness(0.92);
}

/* 侧面板 */
#panel {
  width: 132px;
  display: flex; flex-direction: column; gap: 10px;
  flex: 0 0 auto;
}
.card {
  background: rgba(22, 28, 62, .85);
  border: 1px solid rgba(120,150,255,.28);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
}
.card .label { font-size: 12px; color: #93a0d0; letter-spacing: 2px; }
.card .num { font-size: 24px; font-weight: 800; color: #ffd75e; margin-top: 2px; text-shadow: 0 0 12px rgba(255,200,80,.5); }
.next-card canvas { width: 72px; height: 72px; margin-top: 4px; }

.btns { display: flex; flex-direction: column; gap: 8px; }
.btns button, .more-panel button {
  padding: 9px 0;
  font-size: 14px;
  color: #dbe3ff;
  background: rgba(40, 52, 105, .9);
  border: 1px solid rgba(130,160,255,.35);
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
}
.btns button:active, .more-panel button:active { background: rgba(70, 88, 160, .9); }
.btns button.off, .more-panel button.off { color: #7a84ad; text-decoration: line-through; }
.more-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  padding: 8px;
  background: rgba(12, 16, 40, .9);
  border: 1px solid rgba(130,160,255,.28);
  border-radius: 12px;
}
.more-panel.hidden { display: none !important; }

/* 图鉴弹窗 */
.modal {
  position: fixed; inset: 0;
  background: rgba(4, 6, 18, .8);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
  padding: 16px;
}
.modal-box {
  background: rgba(20, 26, 58, .97);
  border: 1px solid rgba(130,160,255,.4);
  border-radius: 16px;
  padding: 20px;
  max-width: 560px; width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  text-align: center;
}
.modal-box h2 { margin-bottom: 12px; }
#codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.codex-cell {
  background: rgba(12, 16, 40, .8);
  border: 1px solid rgba(110,140,255,.22);
  border-radius: 10px;
  padding: 8px 4px 6px;
}
.codex-cell canvas { width: 56px; height: 56px; }
.codex-cell .cname { font-size: 13px; margin-top: 2px; }
.codex-cell .cscore { font-size: 11px; color: #ffd75e; }
.codex-note { font-size: 12px; color: #93a0d0; margin: 12px 0 4px; line-height: 1.6; }

/* 排行榜 */
.rank-box { max-width: 420px; }
.rank-sub { font-size: 12px; color: #93a0d0; margin: -4px 0 14px; }
.rank-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; text-align: left; }
.rank-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(12, 16, 40, .85);
  border: 1px solid rgba(110,140,255,.22);
  border-radius: 10px;
  font-size: 14px;
}
.rank-row.me {
  border-color: rgba(255, 215, 94, .55);
  box-shadow: 0 0 16px rgba(255, 200, 80, .15);
}
.rank-pos {
  font-weight: 800;
  color: #93a0d0;
  text-align: center;
}
.rank-row.top1 .rank-pos { color: #ffd75e; }
.rank-row.top2 .rank-pos { color: #cfd6ef; }
.rank-row.top3 .rank-pos { color: #e0a878; }
.rank-name { color: #e8ecff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { color: #ffd75e; font-weight: 700; min-width: 56px; text-align: right; }
.rank-date { color: #6a7599; font-size: 12px; min-width: 40px; text-align: right; }
.rank-empty { color: #93a0d0; font-size: 14px; margin: 20px 0 24px; }
.rank-tip { font-size: 13px; color: #7ec3ff; margin: 6px 0 8px; }
.rank-ok { font-size: 14px; color: #ffd75e; margin: 8px 0; font-weight: 700; }
.rank-submit { margin: 10px 0 6px; text-align: left; }
.rank-label { display: block; font-size: 12px; color: #93a0d0; margin-bottom: 6px; letter-spacing: 1px; }
.rank-input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid rgba(130,160,255,.4);
  background: rgba(8, 12, 32, .9);
  color: #e8ecff;
  font-size: 15px;
  outline: none;
}
.rank-input:focus { border-color: rgba(255, 215, 94, .7); box-shadow: 0 0 0 2px rgba(255, 200, 80, .15); }
.rank-input::placeholder { color: #5a6488; }

.hidden { display: none !important; }

/* 手机竖屏：面板移到上方横排 */
@media (max-width: 700px) {
  #main { flex-direction: column; align-items: center; }
  #panel {
    width: min(480px, 100%);
    flex-direction: row; flex-wrap: wrap;
    order: -1;
  }
  .card { flex: 1 1 60px; padding: 6px 8px; }
  .card .num { font-size: 18px; }
  .next-card { display: flex; align-items: center; justify-content: center; gap: 6px; }
  .next-card canvas { width: 44px; height: 44px; margin-top: 0; }
  .btns { flex-direction: row; flex: 1 1 100%; }
  .btns button { flex: 1; padding: 8px 0; font-size: 13px; }
  .more-panel { flex: 1 1 100%; flex-direction: row; }
  .more-panel button { flex: 1; }
  header h1 { font-size: 20px; }
  header .sub { display: none; }
}
