/* 凡人修仙传 · 启动页（像素风参考图 + index 骨架对齐） */
@import url("https://fonts.googleapis.com/css2?family=Long+Cang&family=Ma+Shan+Zheng&family=Noto+Sans+SC:wght@400;600&display=swap");

:root {
  --splash-gold: #e8c547;
  --splash-gold-dim: #c9a227;
  --splash-gold-glow: rgba(255, 210, 120, 0.45);
  --splash-fg: #f5f5f0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: "Noto Sans SC", "Source Han Sans SC", sans-serif;
  background: #0d160f;
  color: var(--splash-fg);
}

#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* 背景图 + 暗角，贴近参考图黄绿氛围 */
#splash-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: #1a2e22;
  background-image: url("../assets/splash-bg.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#splash-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(10, 18, 12, 0.25) 0%, transparent 35%, rgba(5, 10, 8, 0.55) 100%),
    radial-gradient(ellipse 80% 60% at 50% 45%, transparent 0%, rgba(8, 14, 10, 0.35) 100%);
}

/* 轻微像素格扫描感（可选层次） */
#splash-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.06;
  background-image: repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(0, 0, 0, 0.35) 3px,
      rgba(0, 0, 0, 0.35) 4px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 3px,
      rgba(0, 0, 0, 0.25) 3px,
      rgba(0, 0, 0, 0.25) 4px
    );
}

#splash-content {
  position: relative;
  z-index: 2;
  padding: clamp(12px, 4vw, 28px);
  background: transparent;
  max-width: min(96vw, 520px);
  max-height: min(92vh, 760px);
  overflow: auto;
}

#splash-title {
  margin: 0;
  font-family: "Ma Shan Zheng", "Long Cang", serif;
  font-weight: 400;
  font-size: clamp(2.8rem, 12vw, 5.5rem);
  line-height: 1.05;
  letter-spacing: 0.06em;
  color: var(--splash-gold);
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.55),
    0 0 2px rgba(0, 0, 0, 0.8),
    0 0 14px var(--splash-gold-glow),
    0 0 36px rgba(200, 160, 60, 0.25);
  white-space: nowrap;
}

@media (max-width: 420px) {
  #splash-title {
    white-space: normal;
  }

  #splash-buttons {
    gap: 12px;
  }

  .splash-btn {
    padding: 12px 16px;
  }
}

#splash-info {
  margin: 12px 0 0;
  font-size: clamp(0.8rem, 2.8vw, 0.95rem);
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

#splash-buttons {
  margin-top: clamp(28px, 7vw, 44px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 3.5vw, 20px);
}

.splash-btn {
  width: min(280px, 86vw);
  padding: 14px 28px;
  font-size: clamp(1rem, 3.2vw, 1.2rem);
  font-family: "Noto Sans SC", sans-serif;
  font-weight: 600;
  color: var(--splash-gold);
  background: rgba(0, 0, 0, 0.48);
  border: 1px solid rgba(212, 175, 55, 0.92);
  border-radius: 2px;
  cursor: pointer;
  transition:
    background 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    transform 0.15s ease;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 235, 180, 0.12);
}

.splash-btn:hover {
  background: rgba(55, 42, 12, 0.72);
  border-color: rgba(255, 230, 150, 0.98);
  color: #ffe9a8;
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.5),
    0 0 22px rgba(255, 200, 80, 0.28),
    inset 0 1px 0 rgba(255, 235, 190, 0.22);
  transform: translateY(-1px);
}

.splash-btn:active {
  transform: translateY(0);
}

.splash-btn:focus-visible {
  outline: 2px solid var(--splash-gold-dim);
  outline-offset: 3px;
}

.splash-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* 次级按钮：用于弹窗内“清除”等（不用于首页主按钮） */
.splash-btn.splash-btn--secondary {
  color: rgba(245, 245, 240, 0.92);
  border-color: rgba(212, 175, 55, 0.45);
  background: rgba(0, 0, 0, 0.34);
}
.splash-btn.splash-btn--secondary:hover {
  color: #fff;
  border-color: rgba(255, 230, 150, 0.65);
  background: rgba(55, 42, 12, 0.55);
}

/* API 设置弹窗 */
.splash-modal-root {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.splash-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(2px);
}
.splash-modal {
  position: relative;
  z-index: 1;
  width: min(620px, 92vw);
  border: 1px solid rgba(212, 175, 55, 0.5);
  background: rgba(10, 16, 12, 0.92);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  padding: 18px 18px 14px;
  max-height: 92vh;
  overflow: auto;
}
.splash-modal-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: var(--splash-gold);
  letter-spacing: 0.04em;
}
.splash-modal-sub {
  margin: 0 0 12px;
  opacity: 0.85;
  font-size: 0.9rem;
}
.splash-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 2px;
  border: 1px solid rgba(212, 175, 55, 0.4);
  background: rgba(0, 0, 0, 0.35);
  color: var(--splash-gold);
  cursor: pointer;
}
.splash-form {
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
}
.splash-field {
  display: grid;
  gap: 6px;
  text-align: left;
}
.splash-field-k {
  font-size: 0.85rem;
  opacity: 0.9;
}
.splash-field-input {
  width: 100%;
  padding: 10px 10px;
  font-size: 0.95rem;
  color: var(--splash-fg);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 2px;
  outline: none;
}
.splash-field-input:focus {
  border-color: rgba(255, 230, 150, 0.7);
  box-shadow: 0 0 0 2px rgba(232, 197, 71, 0.12);
}
.splash-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-top: 4px;
}
/* 弹窗内按钮须覆盖首页 .splash-btn 的 min(280px, 86vw)，否则在手机上会像独立大条、与表单宽度脱节 */
.splash-modal .splash-modal-actions .splash-btn {
  width: auto;
  min-width: 110px;
  max-width: 100%;
  flex: 0 1 auto;
  padding: 10px 16px;
  font-size: 0.95rem;
  box-sizing: border-box;
}

@media (max-width: 560px) {
  .splash-modal-actions {
    display: grid;
    gap: 8px;
    justify-content: stretch;
  }
  .splash-modal-actions.splash-modal-actions--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .splash-modal-actions.splash-modal-actions--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .splash-modal .splash-modal-actions .splash-btn {
    width: 100%;
    min-width: 0;
    max-width: none;
    padding: 10px 8px;
    font-size: 0.88rem;
  }
}
.splash-modal-status {
  margin-top: 10px;
  font-size: 0.88rem;
  opacity: 0.9;
  min-height: 1.2em;
}
.splash-modal-status--ok {
  color: rgba(140, 220, 150, 0.95);
}
.splash-modal-status--bad {
  color: rgba(255, 170, 170, 0.95);
}

/* 自定义对话框（替代浏览器 confirm/prompt，便于美化） */
.mj-dialog-root {
  position: fixed;
  inset: 0;
  z-index: 3800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.mj-dialog-root.hidden {
  display: none !important;
}

.mj-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(2px);
}

.mj-dialog {
  position: relative;
  z-index: 1;
  width: min(520px, 92vw);
  border: 1px solid rgba(212, 175, 55, 0.45);
  background: rgba(10, 16, 12, 0.94);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.65),
    0 0 28px rgba(255, 200, 80, 0.08);
  padding: 18px 18px 14px;
}

.mj-dialog-title {
  margin: 0 36px 10px 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--splash-gold);
}

.mj-dialog-message {
  margin: 0 0 12px;
  font-size: 0.92rem;
  line-height: 1.65;
  color: rgba(245, 245, 240, 0.92);
  opacity: 0.92;
  white-space: pre-wrap;
  word-break: break-word;
}

.mj-dialog-field {
  display: grid;
  gap: 6px;
  margin: 8px 0 12px;
}

.mj-dialog-input {
  width: 100%;
  padding: 10px 10px;
  font-size: 0.95rem;
  color: var(--splash-fg);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 2px;
  outline: none;
}

.mj-dialog-input:focus {
  border-color: rgba(255, 230, 150, 0.7);
  box-shadow: 0 0 0 2px rgba(232, 197, 71, 0.12);
}

.mj-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.mj-dialog-actions .splash-btn {
  width: auto;
  min-width: 110px;
  padding: 10px 16px;
  font-size: 0.95rem;
}

.mj-dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 2px;
  border: 1px solid rgba(212, 175, 55, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: var(--splash-gold);
  cursor: pointer;
}

.mj-dialog-close:hover {
  border-color: rgba(255, 230, 150, 0.65);
  background: rgba(55, 42, 12, 0.5);
}

/* 读取人生：存档列表 */
.save-load-list {
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
}

.save-load-empty {
  margin: 0;
  padding: 10px 0;
  opacity: 0.85;
  line-height: 1.6;
}

.save-load-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px 12px;
  border: 1px solid rgba(212, 175, 55, 0.22);
  background: rgba(0, 0, 0, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255, 235, 180, 0.06),
    0 10px 22px rgba(0, 0, 0, 0.28);
}

.save-load-row:hover {
  border-color: rgba(255, 230, 150, 0.32);
  background: rgba(55, 42, 12, 0.22);
}

.save-load-info {
  min-width: 0;
}

.save-load-name {
  font-weight: 700;
  color: rgba(255, 235, 190, 0.95);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0 6px;
}

.save-load-meta {
  font-size: 0.82rem;
  opacity: 0.84;
  line-height: 1.55;
  margin: 0;
}

.save-load-actions {
  display: grid;
  grid-auto-flow: column;
  gap: 10px;
  align-content: center;
}

/* 弹窗内按钮尺寸统一一点 */
.save-load-actions .splash-btn {
  width: auto;
  min-width: 120px;
  padding: 10px 16px;
  font-size: 0.98rem;
}

@media (max-width: 520px) {
  .save-load-row {
    grid-template-columns: 1fr;
  }
  .save-load-actions {
    grid-auto-flow: row;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
  }
  .save-load-actions .splash-btn {
    width: 100%;
    min-width: 0;
  }
}

/* 与命运抉择屏切换共用 */
.hidden {
  display: none !important;
}
