/* 错觉回廊 - 柔和低多边形风格 UI */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: linear-gradient(180deg, #f7d9e3 0%, #d7e6f7 100%);
  color: #4a4460;
  user-select: none;
  -webkit-user-select: none;
}
#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  pointer-events: none; z-index: 5;
}
#hud > * { pointer-events: auto; }
#level-title {
  font-size: clamp(14px, 2.4vw, 19px); font-weight: 600; letter-spacing: 0.08em;
  color: #4a4460; text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.55); border-radius: 999px;
  padding: 7px 18px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.hud-right { display: flex; gap: 8px; }
.hud-btn {
  border: none; cursor: pointer; font-family: inherit;
  font-size: clamp(13px, 2vw, 15px); font-weight: 600; color: #4a4460;
  background: rgba(255,255,255,0.72); border-radius: 999px;
  padding: 9px 16px; min-height: 40px;
  box-shadow: 0 3px 10px rgba(90,80,130,0.18);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform 0.12s ease, background 0.2s ease;
}
.hud-btn:active { transform: scale(0.93); background: #ffffff; }

/* ---------- 提示条 ---------- */
#hint-bar {
  position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(92vw, 560px); text-align: center;
  font-size: clamp(12px, 2vw, 15px); line-height: 1.5; color: #565073;
  background: rgba(255,255,255,0.6); border-radius: 16px;
  padding: 9px 18px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 3px 12px rgba(90,80,130,0.14);
  pointer-events: none; z-index: 5;
}

/* ---------- 轻提示 ---------- */
#toast {
  position: absolute; left: 50%; bottom: calc(74px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  font-size: 14px; font-weight: 600; color: #b45a6a;
  background: rgba(255,255,255,0.85); border-radius: 999px; padding: 8px 20px;
  opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none; z-index: 6; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 全屏覆盖层 ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(240,238,250,0.35);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 20px;
}
.panel {
  background: rgba(255,255,255,0.82);
  border-radius: 26px; padding: 30px 34px;
  box-shadow: 0 18px 60px rgba(90,80,130,0.25);
  display: flex; flex-direction: column; align-items: center; gap: 13px;
  max-width: min(94vw, 480px); width: 100%;
  max-height: 88vh; overflow-y: auto;
}
.title-panel { padding: 38px 34px; }
.game-logo {
  font-size: clamp(38px, 9vw, 60px); font-weight: 800; letter-spacing: 0.16em;
  background: linear-gradient(135deg, #e8909c 0%, #9fb8e8 60%, #7fd0c5 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-indent: 0.16em;
}
.game-sub { font-size: clamp(13px, 2.4vw, 16px); color: #7a7494; letter-spacing: 0.3em; text-indent: 0.3em; margin-bottom: 12px; }
.panel-title { font-size: clamp(22px, 4.5vw, 30px); font-weight: 700; letter-spacing: 0.1em; }
#win-sub { font-size: 15px; color: #7a7494; margin-top: -6px; }
.title-note { margin-top: 10px; font-size: 12px; color: #9a94b4; letter-spacing: 0.06em; }

.big-btn {
  width: 100%; min-height: 52px;
  border: none; cursor: pointer; font-family: inherit;
  font-size: clamp(16px, 2.6vw, 19px); font-weight: 700; letter-spacing: 0.12em;
  color: #ffffff; border-radius: 16px;
  background: linear-gradient(135deg, #f0a3ae, #c9a8e8);
  box-shadow: 0 6px 18px rgba(200,140,180,0.4);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.big-btn:hover { filter: brightness(1.05); box-shadow: 0 8px 22px rgba(200,140,180,0.5); }
.big-btn:active { transform: scale(0.96); }
.big-btn.ghost {
  background: rgba(255,255,255,0.9); color: #6a6488;
  box-shadow: 0 3px 10px rgba(90,80,130,0.15);
}

/* ---------- 章节网格 ---------- */
#chapter-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%;
}
@media (min-width: 460px) { #chapter-grid { grid-template-columns: repeat(3, 1fr); } }
.chapter-btn {
  border: none; cursor: pointer; font-family: inherit;
  border-radius: 14px; padding: 12px 6px; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: linear-gradient(160deg, #ffffff, #f1ecf8);
  box-shadow: 0 3px 10px rgba(90,80,130,0.14);
  transition: transform 0.12s ease;
}
.chapter-btn:active { transform: scale(0.94); }
.chapter-btn .num { font-size: 12px; color: #a49ec0; letter-spacing: 0.1em; }
.chapter-btn .name { font-size: 15px; font-weight: 700; color: #565073; }
.chapter-btn.locked { cursor: not-allowed; filter: grayscale(0.7); opacity: 0.55; box-shadow: none; }
.chapter-btn.locked .name { color: #a49ec0; }
.chapter-btn.done .name::after { content: " ·"; color: #7fd0c5; font-weight: 800; }
