/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: #1a1a2e;
  color: #333;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}
.screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== 按钮 ===== */
.btn-primary {
  padding: 12px 32px;
  font-size: 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #d4a574, #b8860b);
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(184,134,11,0.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(184,134,11,0.5); }
.btn-secondary {
  padding: 10px 24px;
  font-size: 14px;
  border: 2px solid #d4a574;
  border-radius: 8px;
  background: rgba(255,255,255,0.9);
  color: #8b6914;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
}
.btn-secondary:hover { background: #d4a574; color: #fff; }
.btn-small {
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-small:hover { background: #f0f0f0; }
.btn-danger { color: #c0392b; border-color: #c0392b; }
.btn-danger:hover { background: #c0392b; color: #fff; }

/* ===== Start 界面 ===== */
.start-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: url('../assets/backgrounds/start_bg.jpg') center/cover no-repeat;
  filter: brightness(0.7);
}
.start-content {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #fff;
}
.game-title {
  font-size: 64px;
  font-weight: 900;
  text-shadow: 0 4px 20px rgba(0,0,0,0.5);
  margin-bottom: 8px;
  letter-spacing: 8px;
}
.game-subtitle {
  font-size: 20px;
  opacity: 0.9;
  margin-bottom: 48px;
  letter-spacing: 4px;
}
.start-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.start-buttons .btn-primary { font-size: 20px; padding: 16px 48px; }

/* ===== 主菜单 ===== */
.menu-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: url('../assets/backgrounds/menu_bg.jpg') center/cover no-repeat;
  opacity: 0.15;
}
.menu-container {
  position: relative;
  z-index: 1;
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: rgba(255,253,245,0.95);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #d4a574;
}
.menu-header h2 { color: #8b6914; font-size: 24px; }
.progress-text { color: #888; font-size: 14px; }
.level-list-vn {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
}
.pack-section { margin-bottom: 20px; }
.pack-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: #555;
  font-size: 14px;
}
.pack-name { font-weight: bold; color: #8b6914; font-size: 16px; }
.level-grid-vn {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.level-card-vn {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid #e8dcc8;
  position: relative;
}
.level-card-vn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  border-color: #d4a574;
}
.level-card-vn.locked { opacity: 0.5; cursor: not-allowed; }
.level-thumb-vn {
  width: 100%;
  height: 120px;
  overflow: hidden;
  background: #f0e8d8;
}
.level-thumb-vn img { width: 100%; height: 100%; object-fit: cover; }
.level-info-vn { padding: 12px; }
.level-name-vn { font-weight: bold; color: #333; margin-bottom: 6px; font-size: 15px; }
.level-meta-vn { display: flex; gap: 8px; font-size: 12px; color: #888; flex-wrap: wrap; }
.best-time { color: #27ae60; font-weight: bold; }
.cleared-badge { color: #d4a574; }
.level-lock {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
}
.menu-footer {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e8dcc8;
}

/* ===== 游戏界面 ===== */
.game-layout {
  display: flex;
  width: 100%;
  height: 100%;
}
.scene-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}
.scene-background {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-size: cover;
  background-position: center;
  transition: opacity 0.3s;
}
.character-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.character-portrait {
  position: absolute;
  bottom: 120px;
  max-height: 55vh;
  max-width: 260px;
  height: auto;
  width: auto;
  object-fit: contain;
  border-radius: 12px;
  border: 3px solid rgba(201, 169, 110, 0.85);
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
  transition: opacity 0.3s;
}
.character-portrait.left { left: 40px; }
.character-portrait.right { right: 40px; }
.puzzle-container {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 10;
  overflow: hidden;
}
.puzzle-container iframe {
  transition: opacity 0.3s;
}

/* ===== 对话框 ===== */
.dialog-box-vn {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%;
  min-height: 140px;
  background: linear-gradient(180deg, rgba(20,20,40,0.85), rgba(10,10,30,0.95));
  border-top: 3px solid #d4a574;
  padding: 16px 32px 24px;
  z-index: 20;
  cursor: pointer;
}
.dialog-speaker {
  display: inline-block;
  padding: 4px 16px;
  background: #8b6914;
  color: #fff;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 8px;
}
.dialog-text-vn {
  color: #fff;
  font-size: 17px;
  line-height: 1.8;
  min-height: 60px;
}
.dialog-arrow {
  position: absolute;
  bottom: 12px;
  right: 32px;
  color: #d4a574;
  font-size: 16px;
  animation: arrowBounce 1s infinite;
}
@keyframes arrowBounce {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(6px); opacity: 0.5; }
}

/* ===== 右侧面板 ===== */
.side-panel-vn {
  width: 260px;
  background: linear-gradient(180deg, #fdf8ef, #f5ecd9);
  border-left: 3px solid #d4a574;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.panel-level-name {
  font-size: 18px;
  font-weight: bold;
  color: #8b6914;
  text-align: center;
  padding-bottom: 12px;
  border-bottom: 2px solid #e8dcc8;
}
.panel-timer {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.timer-label { display: block; font-size: 12px; color: #888; margin-bottom: 4px; }
.timer-value {
  display: block;
  font-size: 24px;
  font-weight: bold;
  color: #2c3e50;
  font-family: "Courier New", monospace;
  letter-spacing: 2px;
}
.panel-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool-btn {
  padding: 10px;
  font-size: 14px;
  border: 2px solid #d4a574;
  border-radius: 8px;
  background: #fff;
  color: #8b6914;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
  text-align: left;
  padding-left: 16px;
}
.tool-btn:hover { background: #d4a574; color: #fff; }
.panel-hint-box {
  margin-top: auto;
  background: rgba(212,165,116,0.15);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  color: #8b6914;
  line-height: 1.6;
}

/* ===== 结算界面 ===== */
.settlement-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
}
.settlement-card {
  position: relative;
  z-index: 1;
  background: rgba(255,253,245,0.98);
  border-radius: 16px;
  padding: 32px 48px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  min-width: 360px;
}
.settlement-card h2 { color: #8b6914; margin-bottom: 20px; font-size: 28px; }
.settlement-badge { margin-bottom: 20px; }
.settlement-badge img { width: 100px; height: 100px; }
.badge-name-vn { font-weight: bold; color: #8b6914; margin-top: 8px; }
.settlement-stats { margin-bottom: 24px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #e8dcc8;
  font-size: 15px;
}
.stat-row span:last-child { font-weight: bold; color: #2c3e50; }
.settlement-buttons { display: flex; gap: 12px; justify-content: center; }

/* ===== 徽章陈列室 ===== */
.gallery-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: url('../assets/backgrounds/menu_bg.jpg') center/cover no-repeat;
  opacity: 0.15;
}
.gallery-container {
  position: relative;
  z-index: 1;
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: rgba(255,253,245,0.95);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #d4a574;
}
.gallery-header h2 { color: #8b6914; }
.gallery-grid-vn {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-start;
  align-content: flex-start;
}
.gallery-badge-vn {
  width: 140px;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  border: 2px solid #e8dcc8;
}
.gallery-badge-vn.locked { opacity: 0.4; }
.gallery-badge-vn img { width: 72px; height: 72px; margin-bottom: 8px; }
.g-silhouette-vn {
  width: 72px; height: 72px;
  margin: 0 auto 8px;
  background: #ddd;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #999;
}
.g-name-vn { font-weight: bold; font-size: 13px; color: #333; margin-bottom: 4px; }
.g-level-vn { font-size: 11px; color: #888; }
.gallery-footer { text-align: center; margin-top: 16px; }

/* ===== 弹窗通用 ===== */
.overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.overlay-card {
  background: #fdf8ef;
  border-radius: 16px;
  padding: 24px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #d4a574;
}
.overlay-header h3 { color: #8b6914; }
.overlay-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #888;
  padding: 4px 8px;
}
.overlay-close:hover { color: #333; }

/* ===== 手札弹窗 ===== */
.handbook-card { width: 600px; }
.handbook-search-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #e8dcc8;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.search-input:focus { border-color: #d4a574; }
.handbook-count { font-size: 12px; color: #888; white-space: nowrap; }
.handbook-list-vn {
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.handbook-note-vn {
  background: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 10px;
  border-left: 4px solid #d4a574;
}
.handbook-note-vn h4 { color: #8b6914; margin-bottom: 6px; font-size: 15px; }
.handbook-level-tag { display: inline-block; font-size: 11px; background: rgba(139,105,20,0.12); color: #8b6914; padding: 2px 8px; border-radius: 10px; margin-right: 8px; font-weight: normal; vertical-align: middle; }
.handbook-note-vn p { font-size: 13px; color: #555; line-height: 1.7; }
.empty-notes { text-align: center; color: #aaa; padding: 40px 0; font-size: 14px; }
.handbook-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}
.page-info { font-size: 13px; color: #888; }

/* ===== 菜单弹窗 ===== */
.menu-card { width: 320px; }
.menu-options { display: flex; flex-direction: column; gap: 10px; }
.menu-option {
  padding: 14px;
  font-size: 15px;
  border: 2px solid #e8dcc8;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.menu-option:hover { border-color: #d4a574; background: #fdf8ef; }

/* ===== 设置弹窗 ===== */
.settings-card { width: 400px; }
.settings-body { display: flex; flex-direction: column; gap: 16px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.setting-row label { font-size: 14px; color: #555; min-width: 100px; }
.setting-row input[type="range"] { flex: 1; }

/* ===== 模态弹窗 ===== */
.modal-card { width: 360px; text-align: center; }
.modal-card h3 { color: #8b6914; margin-bottom: 12px; }
.modal-card p { color: #555; margin-bottom: 20px; line-height: 1.6; }

/* ===== Loading ===== */
.loading-content {
  text-align: center;
  color: #fff;
}
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #d4a574;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-content p { margin-bottom: 16px; font-size: 16px; }
.loading-bar {
  width: 240px;
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto;
}
.loading-progress {
  height: 100%;
  background: #d4a574;
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s;
}

/* ===== Toast ===== */
#toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f5ecd9; }
::-webkit-scrollbar-thumb { background: #d4a574; border-radius: 4px; }

/* ===== 草稿弹窗 ===== */
.draft-card {
  width: 720px;
  max-width: 92vw;
}
.draft-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}
.draft-canvas-wrap {
  width: 100%;
  height: 440px;
  border: 2px solid #c9a96e;
  border-radius: 6px;
  overflow: hidden;
  background: #f5e6c8;
  cursor: crosshair;
}
#draft-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.draft-hint {
  margin: 10px 0 0;
  font-size: 13px;
  color: #8b7355;
  text-align: center;
  font-style: italic;
}

/* ===== v2.1.1 修复 ===== */
/* 统一右侧面板工具按钮大小 */
.panel-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool-btn {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  vertical-align: middle;
}
.tool-btn * {
  line-height: 1;
  vertical-align: middle;
}
