/* ==========================================================
   panels.css — 存档/读档面板 · 设置面板 · 终局界面
   全部使用 UI2-*.png 烘焙素材，保持与游戏视觉统一
   ========================================================== */

/* —— 通用模态遮罩（复用组件风格，但独立类避免冲突） —— */
.pn-overlay {
  position: absolute;
  inset: 0;
  /* 必须高于首页 title-screen(z:200)，否则从首页打开设置会被背景盖住 */
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 3, 12, 0.78);
  backdrop-filter: blur(4px);
  animation: pn-fade 0.32s var(--ease);
}

@keyframes pn-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* —— 通用烘焙按钮（保持原图比例，文字已烘焙在图中） —— */
.pn-btn {
  display: block;
  padding: 0;
  border: 0;
  background: transparent center / contain no-repeat;
  cursor: pointer;
  transition: filter 0.2s var(--ease), transform 0.2s var(--ease);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6));
}
.pn-btn:hover:not(:disabled) {
  filter: brightness(1.18) drop-shadow(0 0 12px rgba(232, 201, 114, 0.55));
  transform: translateY(-1px);
}
.pn-btn:active { transform: translateY(0) scale(0.97); }
.pn-btn:disabled { filter: grayscale(0.5) brightness(0.6); cursor: not-allowed; }

/* 关闭按钮（圆形 X） */
.pn-close {
  position: absolute;
  top: 2.2%;
  right: 2.2%;
  width: clamp(34px, 3.4vw, 56px);
  aspect-ratio: 106 / 110;
  z-index: 6;
}

/* ==========================================================
   存档 / 读档 面板
   ========================================================== */
.sl-panel {
  position: relative;
  height: min(625px, 88vh);
  aspect-ratio: 774 / 625;
  max-width: 94vw;
  background: url('../assets/UI2-panel-saveload.png') center / 100% 100% no-repeat;
  filter: drop-shadow(0 22px 48px rgba(0, 0, 0, 0.8));
  animation: pn-pop 0.4s var(--ease);
}

@keyframes pn-pop {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.sl-title {
  position: absolute;
  /* 标题牌月亮对准底板月亮（底板月中心 x≈53.4% / y≈4.6%），向右上压住底板月亮 */
  top: 0.9%;
  left: 53.4%;
  transform: translateX(-50%);
  width: 36%;
  aspect-ratio: 299 / 138;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5));
}

/* 存档标题：相对读档略偏左一点 */
.sl-title.is-save { left: 52.2%; }

/* 槽位列表：收进右侧黄色纸张区（left 26% 起），3 槽垂直均匀分布 */
.sl-slots {
  position: absolute;
  top: 27%;
  left: 26%;
  right: 6%;
  bottom: 21%;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 0;
}
.sl-slot {
  position: relative;
  flex: 0 0 auto;
  /* 锁定与素材一致的宽高比，避免背景被拉伸变形 */
  aspect-ratio: 702 / 122;
  background: url('../assets/UI2-slot-empty.png') center / 100% 100% no-repeat;
  cursor: pointer;
  transition: filter 0.2s var(--ease), transform 0.2s var(--ease);
}
.sl-slot:hover { filter: brightness(1.12) drop-shadow(0 0 10px rgba(232, 201, 114, 0.4)); transform: translateX(2px); }
.sl-slot.is-empty:hover { filter: brightness(1.1); }
.sl-slot.is-selected { filter: brightness(1.18) drop-shadow(0 0 14px rgba(232, 201, 114, 0.6)); }

/* 缩略图框：按 16:9 截图比例显示，宽度贴合素材紫框，上下略高于紫框 */
.sl-slot-thumb {
  position: absolute;
  left: 4.35%;
  top: 50%;
  transform: translateY(-50%);
  width: 27.78%;
  height: auto;
  aspect-ratio: 16 / 9;
  box-sizing: border-box;
  padding: 3px;
  border-radius: 9px;
  /* 紫色相框画在缩略图内沿：宽度与素材紫框一致，高度随 16:9 截图一起延展 */
  box-shadow: inset 0 0 0 3px #8e7898;
  background-color: #1a1024;
  background-size: cover;
  background-position: center;
  background-clip: content-box;
  background-origin: content-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.sl-slot-thumb .sl-thumb-ico {
  font-size: clamp(16px, 1.5vw, 28px);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  opacity: 0.85;
}

/* 文本区（素材右部，缩略图放大后整体右移） */
.sl-slot-info {
  position: absolute;
  left: 34%;
  right: 9%;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
}
.sl-slot-name {
  font-family: var(--f-serif);
  font-size: clamp(11px, 0.95vw, 17px);
  font-weight: 600;
  color: #2a1a2e;
  letter-spacing: 2px;
}
.sl-slot-meta {
  font-size: clamp(8px, 0.66vw, 11px);
  color: #5a4630;
  letter-spacing: 0.5px;
}
.sl-slot-empty-text {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--f-serif);
  font-size: clamp(10px, 0.85vw, 15px);
  letter-spacing: 6px;
  color: #7a6a55;
  pointer-events: none;
}

/* 删除小按钮（存档模式、已有存档时显示） */
.sl-slot-del {
  position: absolute;
  right: 1.6%;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(20px, 1.8vw, 30px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(122, 47, 58, 0.85);
  color: #F2E3C0;
  font-size: clamp(10px, 0.85vw, 14px);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(232, 201, 114, 0.6);
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 4;
}
.sl-slot:hover .sl-slot-del { opacity: 1; }
.sl-slot-del:hover { background: #9a3f4a; }

/* 底部按钮行：居中于右侧黄色纸张区（纸张 x 24%~94.6%），避开底板底部装饰条 */
.sl-footer {
  position: absolute;
  left: 24%;
  right: 5.4%;
  bottom: 10.5%;
  display: flex;
  justify-content: center;
  gap: clamp(6px, 1.2vw, 18px);
  z-index: 5;
}
.sl-footer .pn-btn {
  width: clamp(96px, 10.5vw, 175px);
  aspect-ratio: 295 / 94;
}

/* 覆盖确认弹窗 */
.sl-overwrite {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  animation: pn-fade 0.25s var(--ease);
}
.sl-ow-dialog {
  position: relative;
  width: clamp(280px, 34vw, 520px);
  aspect-ratio: 525 / 348;
  background: url('../assets/UI2-dialog-overwrite.png') center / 100% 100% no-repeat;
  filter: drop-shadow(0 16px 36px rgba(0, 0, 0, 0.75));
  animation: pn-pop 0.3s var(--ease);
}
/* 弹窗内「取消 / 确定」热区（文字已烘焙在图中下方） */
.sl-ow-cancel,
.sl-ow-confirm {
  position: absolute;
  bottom: 11%;
  width: 32%;
  height: 22%;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.sl-ow-cancel { left: 12%; }
.sl-ow-confirm { right: 12%; }
.sl-ow-cancel:hover, .sl-ow-confirm:hover { filter: brightness(1.25); }

/* ==========================================================
   设置面板
   ========================================================== */
.st-panel {
  position: relative;
  height: min(680px, 92vh);
  aspect-ratio: 829 / 679;
  max-width: 95vw;
  background: url('../assets/UI2-panel-base.png') center / 100% 100% no-repeat;
  filter: drop-shadow(0 22px 48px rgba(0, 0, 0, 0.8));
  animation: pn-pop 0.4s var(--ease);
}

.st-title {
  position: absolute;
  /* 标题牌月亮对齐底板月亮（底板月中心 53.44% / 5.38%） */
  top: 1.1%;
  left: 54%;
  transform: translateX(-50%);
  width: 42%;
  aspect-ratio: 449 / 180;
  background: url('../assets/UI2-title-settings.png') center / contain no-repeat;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5));
  z-index: 3;
}

/* 右侧内容区：三组设置同页排列，整体居中于右侧黄色纸张区 */
.st-body {
  position: absolute;
  left: 27%;
  right: 8.5%;
  top: 21%;
  bottom: 18%;
  overflow-y: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.st-sec {
  margin-bottom: clamp(4px, 0.8vh, 12px);
}
.st-sec-title {
  width: clamp(150px, 17vw, 300px);
  aspect-ratio: 301 / 73;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: left center;
  margin-bottom: clamp(5px, 0.8vh, 12px);
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.45));
}
.st-sec.sound .st-sec-title { background-image: url('../assets/UI2-sec-sound.png'); }
.st-sec.picture .st-sec-title { background-image: url('../assets/UI2-sec-picture.png'); }
.st-sec.dialogue .st-sec-title { background-image: url('../assets/UI2-sec-dialogue.png'); }

.st-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(3px, 0.5vh, 7px) 4px;
}
.st-row-label {
  font-family: var(--f-serif);
  font-size: clamp(12px, 1vw, 17px);
  letter-spacing: 2px;
  color: #2a1a2e;
  font-weight: 600;
  white-space: nowrap;
  min-width: 5.4em;
}
.st-row-value {
  font-size: clamp(10px, 0.8vw, 13px);
  color: #6b5230;
  letter-spacing: 1px;
  min-width: 3em;
  text-align: right;
}

/* 自定义滑块（轨道图 + 钻石滑块） */
.st-slider {
  position: relative;
  flex: 1;
  max-width: 320px;
  height: clamp(22px, 2.4vh, 36px);
  cursor: pointer;
}
.st-slider-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 100%;
  transform: translateY(-50%);
  background: url('../assets/UI2-slider-track.png') center / 100% 100% no-repeat;
  pointer-events: none;
}
.st-slider-thumb {
  position: absolute;
  top: 50%;
  width: clamp(26px, 2.6vw, 44px);
  aspect-ratio: 69 / 43;
  transform: translate(-50%, -50%);
  background: url('../assets/UI2-slider-thumb.png') center / contain no-repeat;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
  transition: filter 0.15s;
  pointer-events: none;
}
.st-slider:hover .st-slider-thumb { filter: brightness(1.25) drop-shadow(0 0 8px rgba(232, 201, 114, 0.6)); }

/* 文字速度 三档按钮 */
.st-seg {
  display: flex;
  gap: 10px;
  margin-left: auto;
}
.st-seg button {
  font-family: var(--f-serif);
  font-size: clamp(10px, 0.82vw, 14px);
  letter-spacing: 2px;
  padding: 4px 14px;
  color: #6b5230;
  background: rgba(255, 246, 220, 0.5);
  border: 1px solid rgba(138, 109, 47, 0.5);
  border-radius: 5px;
  transition: all 0.18s;
}
.st-seg button.active {
  color: #F2E3C0;
  background: linear-gradient(180deg, #6a4788, #3a2450);
  border-color: rgba(232, 201, 114, 0.85);
  box-shadow: 0 0 8px rgba(232, 201, 114, 0.35);
}

/* 开关（自动播放） */
.st-switch {
  width: clamp(44px, 4.4vw, 64px);
  height: clamp(22px, 2.2vh, 30px);
  border-radius: 999px;
  background: rgba(60, 40, 30, 0.4);
  border: 1px solid rgba(138, 109, 47, 0.6);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.st-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  width: clamp(16px, 1.7vw, 24px);
  border-radius: 50%;
  background: linear-gradient(180deg, #E6C878, #8a6d2f);
  transition: transform 0.2s;
}
.st-switch.on { background: rgba(122, 47, 58, 0.7); border-color: rgba(232, 201, 114, 0.8); }
.st-switch.on::after { transform: translateX(calc(100% - 2px)); }

/* 全屏 / 窗口化 单选对 */
.st-radio-row {
  display: flex;
  gap: clamp(8px, 1.2vw, 18px);
  justify-content: flex-start;
  margin-top: 0;
}
.st-radio {
  width: clamp(100px, 10vw, 170px);
  aspect-ratio: 312 / 122;
  background: transparent center / contain no-repeat;
  border: 0;
  cursor: pointer;
  opacity: 0.5;
  filter: grayscale(0.4) brightness(0.75);
  transition: all 0.2s var(--ease);
}
.st-radio.full { background-image: url('../assets/UI2-radio-full-on.png'); }
.st-radio.window { background-image: url('../assets/UI2-radio-window-off.png'); }
.st-radio.active { opacity: 1; filter: brightness(1.15) drop-shadow(0 0 10px rgba(232, 201, 114, 0.55)); }

/* 底部按钮：居中于右侧黄色纸张区（纸张 x 25.1%~93.4%，中心≈59.3%），避开底板装饰条 */
.st-footer {
  position: absolute;
  left: 25.1%;
  right: 6.6%;
  bottom: 7.5%;
  display: flex;
  justify-content: center;
  gap: clamp(10px, 2vw, 28px);
  z-index: 5;
}
.st-footer .pn-btn {
  width: clamp(150px, 16vw, 260px);
}
.st-footer .pn-btn.restore { aspect-ratio: 396 / 122; }
.st-footer .pn-btn.confirm { aspect-ratio: 385 / 124; }

/* ==========================================================
   终局界面（深紫底板 + 真相文案 + 返回首页）
   ========================================================== */
.fn-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pn-fade 0.6s var(--ease);
}

/* 弹窗背后的酒馆吧台，压暗并轻微虚化，让弹窗更清晰 */
.fn-overlay::before {
  content: "";
  position: absolute;
  inset: -2%;
  background:
    linear-gradient(rgba(6, 4, 10, 0.62), rgba(6, 4, 10, 0.9)),
    url('../assets/bar-bg-01.png') center / cover no-repeat;
  filter: blur(5px) saturate(0.85);
  transform: scale(1.04);
  z-index: 0;
  pointer-events: none;
}

.fn-stage {
  position: relative;
  width: 66.667%;
  height: auto;
  aspect-ratio: 3 / 2;
  max-width: 94%;
  max-height: 86%;
  /* 底板 PNG 四周自带透明留白，不能再垫纯色底，否则会露出一圈紫色矩形 */
  background: url('../assets/UI2-finale-base.png') center / contain no-repeat;
  box-shadow: none;
  overflow: visible;
  z-index: 2;
  animation: fn-in 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes fn-in {
  from { opacity: 0; transform: scale(1.06); filter: blur(8px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* 月光粒子（终局氛围） */
.fn-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, rgba(185, 216, 232, 0.7), transparent),
    radial-gradient(1px 1px at 65% 22%, rgba(255, 235, 180, 0.6), transparent),
    radial-gradient(2px 2px at 80% 60%, rgba(185, 216, 232, 0.55), transparent),
    radial-gradient(1px 1px at 35% 75%, rgba(255, 235, 180, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 50% 45%, rgba(185, 216, 232, 0.6), transparent);
  animation: fn-float 9s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes fn-float {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(-16px); opacity: 1; }
}

/* 月光从上方洒落的渐变 */
.fn-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 40% 55% at 50% 12%, rgba(185, 216, 232, 0.22), transparent 70%);
  pointer-events: none;
  z-index: 1;
}

.fn-content {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 82%);
  max-height: 90%;
  overflow-y: auto;
  text-align: center;
  z-index: 5;
  animation: fn-content-in 1.4s var(--ease) 0.5s both;
}
.fn-content::-webkit-scrollbar { width: 0; }
@keyframes fn-content-in {
  from { opacity: 0; transform: translate(-50%, -46%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.fn-title {
  font-family: var(--f-serif);
  font-size: clamp(18px, 2vw, 30px);
  letter-spacing: 8px;
  color: #F2E3C0;
  text-shadow: 0 0 20px rgba(232, 201, 114, 0.5), 0 2px 8px rgba(0, 0, 0, 0.9);
  margin-bottom: 0.5em;
}
.fn-sub {
  font-family: var(--f-serif);
  font-size: clamp(11px, 0.95vw, 16px);
  letter-spacing: 4px;
  color: #C9B4E4;
  margin-bottom: 1em;
}
.fn-body {
  font-size: clamp(10px, 0.8vw, 13px);
  line-height: 1.9;
  color: #E8D8C8;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  margin-bottom: 1.2em;
  letter-spacing: 1px;
}

/* 缺失线索列表（失败结局） */
.fn-missing {
  margin: 0 auto 1.1em;
  max-width: 340px;
  text-align: left;
  background: rgba(20, 10, 28, 0.55);
  border: 1px solid rgba(201, 162, 74, 0.4);
  border-radius: 10px;
  padding: 8px 12px;
}
.fn-missing-title {
  font-family: var(--f-serif);
  font-size: clamp(12px, 1.05vw, 17px);
  letter-spacing: 3px;
  color: #F2C97A;
  margin-bottom: 8px;
}
.fn-missing-list {
  font-size: clamp(11px, 0.92vw, 15px);
  line-height: 1.9;
  color: #D9C6E6;
}
.fn-missing-list li { list-style: none; padding-left: 1em; position: relative; }
.fn-missing-list li::before { content: "◆"; color: #C9A24A; position: absolute; left: -0.2em; font-size: 0.7em; top: 0.3em; }
.fn-missing-list .guest { color: #E6C878; }

.fn-tip {
  font-size: clamp(10px, 0.82vw, 13px);
  color: #A79BAA;
  letter-spacing: 1px;
  margin-bottom: 1.6em;
}

/* 返回首页按钮 */
.fn-home {
  display: inline-block;
  width: 58%;
  aspect-ratio: 5.53 / 1;
  min-width: 0;
  padding: 0 4%;
  background: transparent url('../assets/ui-choice-frame.png') center / 100% 100% no-repeat;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  cursor: pointer;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5));
  transition: filter 0.25s var(--ease), transform 0.25s var(--ease);
  animation: fn-pulse 3s ease-in-out infinite;
}
.fn-home:hover {
  background: transparent url('../assets/ui-choice-frame.png') center / 100% 100% no-repeat;
  filter: brightness(1.15) drop-shadow(0 0 18px rgba(232, 201, 114, 0.6));
  transform: translateY(-2px);
}
.fn-home:active { transform: translateY(0) scale(0.97); }
/* 与选项按钮统一：空牌匾底图 + 居中金字 */
.fn-home span {
  display: block;
  font-family: var(--f-serif);
  font-size: clamp(12px, 1vw, 16px);
  font-weight: 700;
  letter-spacing: 4px;
  text-indent: 4px;
  color: #F2E3C0;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.8), 0 0 12px rgba(232, 201, 114, 0.35);
}

@keyframes fn-pulse {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(232, 201, 114, 0.35)) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.6)); }
  50% { filter: drop-shadow(0 0 22px rgba(246, 219, 140, 0.8)) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.6)); }
}
