/* ==========================================================================
   main.css —— 全局样式：页面重置、布局、弹窗、背包UI、笔记面板
   ========================================================================== */

/* ---------- 重置 ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #ddd;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- 游戏容器 ---------- */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #0a0a0a;
}

/* ---------- 场景层 ---------- */
#scene {
  position: absolute;
  inset: 0;
}

/* ---------- 通用面板（背包 / 笔记本） ---------- */
.panel {
  position: absolute;
  z-index: 20;
  background: rgba(18, 16, 16, 0.88);
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 14px;
  letter-spacing: 2px;
  color: #cbb78b;
  border-bottom: 1px solid #333;
  cursor: move;
  touch-action: none;
  user-select: none;
}

.panel-toggle {
  background: none;
  border: none;
  color: #999;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.panel-toggle:hover { color: #cbb78b; }

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rank-btn {
  padding: 2px 10px;
  font-size: 12px;
  letter-spacing: 1px;
  color: #cbb78b;
  background: rgba(203, 183, 139, 0.12);
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  cursor: pointer;
}
.rank-btn:hover {
  background: rgba(203, 183, 139, 0.25);
  border-color: #cbb78b;
}

/* 面板收起时隐藏内容区 */
.panel.collapsed .panel-body { display: none; }

/* 面板右下角缩放手柄 */
.panel-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  touch-action: none;
  z-index: 2;
}
.panel-resize::after {
  content: '';
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 6px;
  height: 6px;
  border-right: 2px solid #666;
  border-bottom: 2px solid #666;
}

.panel-body {
  list-style: none;
  padding: 8px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  flex: 1;
  min-height: 0;
}

/* ---------- 背包 ---------- */
#inventory-panel {
  top: 16px;
  right: 16px;
  width: 240px;
  max-height: 40vh;
}

#inventory-list .inv-item {
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
}

#inventory-list .inv-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

#inventory-list .inv-item.selected {
  background: rgba(203, 183, 139, 0.2);
  outline: 1px solid #cbb78b;
}

#inventory-list .inv-empty {
  color: #777;
  font-style: italic;
}

/* ---------- 笔记本 ---------- */
#notebook-panel {
  top: 16px;
  left: 16px;
  width: 260px;
  max-height: 40vh;
}

#notebook-list li {
  padding: 4px 6px;
  border-bottom: 1px dashed #2a2a2a;
  color: #bbb;
}

#notebook-list .note-empty {
  color: #777;
  font-style: italic;
}

/* ---------- 检视弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

/* 确认/提示弹窗需叠加在其它弹窗之上（如存档弹窗里的读档、删除确认） */
#confirm-modal { z-index: 120; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
}

.modal-content {
  position: relative;
  z-index: 1;
  max-width: 80vw;
  max-height: 88vh;
  padding: 16px;
  background: #111;
  border: 1px solid #444;
  border-radius: 8px;
  text-align: center;
}

.modal-image {
  max-width: 72vw;
  max-height: 66vh;
  object-fit: contain;
  border-radius: 4px;
}

.modal-text {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.7;
  color: #ccc;
  white-space: pre-wrap; /* 文案换行符按原样显示 */
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

.modal-close {
  position: absolute;
  top: 6px;
  right: 12px;
  background: none;
  border: none;
  color: #aaa;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #fff;
}

/* ---------- 提示气泡 ---------- */
#toast-container {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 8px 18px;
  background: rgba(10, 10, 10, 0.9);
  border: 1px solid #555;
  border-radius: 20px;
  font-size: 14px;
  color: #eee;
  white-space: pre-wrap; /* 文案换行符按原样显示 */
  animation: toast-in 0.25s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 检视按钮（右下角） ---------- */
.inspect-btn {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  padding: 10px 24px;
  font-size: 15px;
  letter-spacing: 4px;
  color: #cbb78b;
  background: rgba(18, 16, 16, 0.85);
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  cursor: pointer;
}
.inspect-btn:hover {
  background: rgba(203, 183, 139, 0.2);
  border-color: #cbb78b;
}

/* ---------- 设置按钮（右下角，检视按钮上方） ---------- */
.settings-btn {
  position: absolute;
  right: 24px;
  bottom: 72px;
  z-index: 40;
  padding: 10px 24px;
  font-size: 15px;
  letter-spacing: 4px;
  color: #cbb78b;
  background: rgba(18, 16, 16, 0.85);
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  cursor: pointer;
}
.settings-btn:hover {
  background: rgba(203, 183, 139, 0.2);
  border-color: #cbb78b;
}

/* ---------- 确认弹窗 ---------- */
.confirm-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  justify-content: center;
}
.confirm-actions button {
  padding: 8px 24px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #555;
  background: #222;
  color: #ddd;
  font-size: 14px;
}
.confirm-actions button:hover { background: #333; }
.confirm-actions .confirm-yes { background: #7a5c2e; border-color: #a0793c; color: #fff; }
.confirm-actions .confirm-yes:hover { background: #8c6a36; }

/* ---------- 密码输入弹窗 ---------- */
.password-title {
  margin-bottom: 14px;
  font-size: 16px;
  letter-spacing: 3px;
  color: #cbb78b;
  font-weight: normal;
}
.password-input {
  width: 220px;
  padding: 10px 12px;
  font-size: 24px;
  letter-spacing: 14px;
  text-align: center;
  background: #0a0a0a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #eee;
  outline: none;
}
.password-input:focus { border-color: #cbb78b; }
.password-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #777;
  letter-spacing: 1px;
}

/* ---------- 多人名密码输入弹窗 ---------- */
.multi-password-content {
  min-width: 300px;
}
.multi-password-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 6px 0 4px;
}
.multi-password-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.multi-password-label {
  width: 52px;
  text-align: right;
  color: #999;
  font-size: 13px;
  letter-spacing: 1px;
  flex: none;
}
.multi-password-input {
  flex: 1;
  padding: 8px 10px;
  font-size: 16px;
  text-align: center;
  background: #0a0a0a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #eee;
  outline: none;
}
.multi-password-input:focus { border-color: #cbb78b; }

/* ---------- 设置弹窗 ---------- */
.settings-content {
  min-width: 340px;
  text-align: left;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid #2a2a2a;
}
.settings-row.settings-save {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  border-bottom: none;
}
.settings-label {
  font-size: 14px;
  letter-spacing: 2px;
  color: #cbb78b;
  white-space: nowrap;
}
.settings-toggle {
  padding: 4px 20px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #555;
  background: #222;
  color: #ddd;
  font-size: 14px;
}
.settings-toggle:hover { background: #333; }
#volume-slider {
  width: 180px;
  accent-color: #cbb78b;
  cursor: pointer;
}
.new-game-btn {
  width: 100%;
  padding: 7px 0;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #555;
  background: #222;
  color: #ddd;
  font-size: 13px;
}
.new-game-btn:hover { background: #333; }

/* ---------- 存档弹窗 ---------- */
.save-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
  min-width: 300px;
  text-align: left;
}
.save-slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  background: #151515;
}
.save-slot-info {
  font-size: 13px;
  color: #bbb;
}
.save-slot-actions {
  display: flex;
  gap: 8px;
}
.save-slot-actions button {
  padding: 5px 14px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #555;
  background: #222;
  color: #ddd;
  font-size: 13px;
}
.save-slot-actions button:hover { background: #333; }
.save-slot-actions button:disabled { opacity: 0.4; cursor: not-allowed; }
.save-slot-actions button.danger { border-color: #7a3a3a; color: #e0a0a0; }
.save-slot-actions button.danger:hover { background: #3a2020; }

/* ---------- 视频播放弹窗 ---------- */
.modal-content.video-content {
  width: 84vw;
  height: 80vh;
  max-width: none;
  max-height: none;
  padding: 0;
  display: flex;
  flex-direction: column;
}
#video-frame-container {
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: #000;
  border-radius: 8px;
}
#video-frame-container iframe,
#video-frame-container video {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ---------- 特效遮罩层 ---------- */
#effect-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

/* ---------- 加载界面 ---------- */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  transition: opacity 0.4s ease;
}
#loading-screen.hidden { display: none; }
#loading-screen.fade-out { opacity: 0; }

.loading-inner {
  text-align: center;
  padding: 24px;
}
.loading-title {
  font-size: 40px;
  letter-spacing: 12px;
  color: #cbb78b;
  font-weight: normal;
  animation: loading-pulse 2.2s ease-in-out infinite;
}
.loading-subtitle {
  margin-top: 10px;
  font-size: 14px;
  letter-spacing: 8px;
  color: #888;
}
.loading-bar {
  margin: 30px auto 14px;
  width: 260px;
  height: 4px;
  background: #222;
  border-radius: 2px;
  overflow: hidden;
}
#loading-progress {
  width: 0;
  height: 100%;
  background: #cbb78b;
  transition: width 0.2s ease;
}
.loading-status {
  font-size: 12px;
  letter-spacing: 2px;
  color: #666;
}
@keyframes loading-pulse {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 1; }
}

/* ---------- 排行榜弹窗 ---------- */
.rank-content {
  min-width: 320px;
  max-width: 360px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.rank-list {
  list-style: none;
  margin-top: 8px;
  overflow-y: auto;
  min-height: 0;
}
.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px;
  border-bottom: 1px dashed #2a2a2a;
}
.rank-no {
  width: 40px;
  text-align: center;
  font-size: 16px;
  color: #cbb78b;
  font-weight: bold;
  flex: none;
}
.rank-no.top1 { color: #f0c040; }
.rank-no.top2 { color: #c0c0c0; }
.rank-no.top3 { color: #c07a3a; }
.rank-name {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ddd;
  font-size: 14px;
}
.rank-score {
  color: #999;
  font-size: 13px;
  flex: none;
}
.rank-empty {
  padding: 16px;
  color: #777;
  font-style: italic;
}
.rank-my {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #333;
  font-size: 14px;
  color: #cbb78b;
  letter-spacing: 1px;
}
