* { box-sizing: border-box; }

:root {
  --panel-bg: rgba(7, 10, 14, 0.62);
  --panel-border: rgba(173, 194, 211, 0.28);
  --text-main: #edf2f5;
  --text-muted: #aab6bf;
}

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
  background-color: #050709;
  background-image: var(--scene-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  transition: background-image .45s ease-in-out;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 28px;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,.10), rgba(0,0,0,.32)),
    radial-gradient(circle at 50% 45%, transparent 0 52%, rgba(0,0,0,.24) 100%);
  pointer-events: none;
  z-index: 0;
}

#game {
  position: relative;
  z-index: 1;
  width: min(820px, 100%);
  min-height: 650px;
  max-height: calc(100vh - 56px);
  overflow: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(1.5px) saturate(.95);
  -webkit-backdrop-filter: blur(1.5px) saturate(.95);
  box-shadow: 0 28px 100px rgba(0,0,0,.48);
  display: flex;
  flex-direction: column;
}

.game-header {
  padding: 24px 30px 20px;
  border-bottom: 1px solid rgba(173,194,211,.18);
  background: rgba(4,7,10,.24);
}
.game-title { font-size: 28px; font-weight: 700; letter-spacing: 4px; }
.chapter-title { margin-top: 8px; color: var(--text-muted); font-size: 14px; }
.is-hidden { display: none !important; }

.main-menu {
  flex: 1;
  min-height: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.menu-content { width: 100%; max-width: 540px; text-align: center; }
.menu-eyebrow { color: var(--text-muted); font-size: 13px; letter-spacing: 3px; }
.menu-content h1 { margin: 18px 0 8px; font-size: clamp(42px, 8vw, 76px); letter-spacing: 7px; text-shadow: 0 4px 30px rgba(0,0,0,.65); }
.title-sub { font-size:.56em; letter-spacing:3px; font-weight:500; }
.menu-chapter { margin-bottom: 22px; color: var(--text-muted); font-size: 15px; letter-spacing: 2px; }
.menu-status { min-height: 24px; margin: 0 0 36px; color: var(--text-muted); line-height: 1.7; }
.menu-buttons { display: flex; flex-direction: column; gap: 14px; }

.menu-button, .choice-button {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid rgba(173,194,211,.26);
  background: rgba(13,18,24,.72);
  color: var(--text-main);
  font-size: 16px;
  cursor: pointer;
  transition: transform .16s, background .2s, border-color .2s;
}
.menu-button:hover:not(:disabled), .choice-button:hover {
  background: rgba(31,42,52,.88);
  transform: translateX(5px);
  border-color: rgba(198,220,235,.5);
}
.menu-button:disabled { opacity: .38; cursor: not-allowed; }

.game-screen { flex: 1; display: flex; flex-direction: column; }
.game-panel { flex: 1; padding: 36px 46px 24px; }
#scene-title { margin: 0 0 28px; font-size: 28px; text-shadow: 0 2px 18px rgba(0,0,0,.75); }
.scene-text { min-height: 250px; line-height: 1.95; font-size: 17px; text-shadow: 0 1px 8px rgba(0,0,0,.75); }
.scene-text p { margin: 0 0 .78em; }
.choices { margin-top: 32px; display: flex; flex-direction: column; gap: 12px; }
.choice-button { text-align: left; }
.game-footer {
  padding: 16px 26px;
  border-top: 1px solid rgba(173,194,211,.18);
  display: flex;
  align-items: center;
  gap: 22px;
  color: var(--text-muted);
  font-size: 14px;
  background: rgba(4,7,10,.24);
}
#menu-button, #restart-button {
  padding: 8px 14px;
  border: 1px solid rgba(173,194,211,.26);
  background: rgba(5,8,11,.38);
  color: var(--text-muted);
  cursor: pointer;
}
#menu-button { margin-left: auto; }
#menu-button:hover, #restart-button:hover { color:#fff; border-color:rgba(198,220,235,.55); }

/* 章節固定背景：每一章使用自己的主視覺。
   第一章目前固定使用 chapter1-bg.png。
   未來第二章只要加入 chapter2-bg.png，並新增對應 data-chapter 規則即可。 */
body[data-chapter="menu"],
body[data-chapter="1"] {
  --scene-image: url("images/chapter1-bg.png");
}

@media (max-width: 700px) {
  body { padding: 0; background-attachment: scroll; }
  #game { width:100%; min-height:100vh; max-height:none; border:0; border-radius:0; background: rgba(7,10,14,.68); }
  .main-menu { min-height: calc(100vh - 100px); padding: 30px 20px; }
  .game-panel { padding: 28px 22px 20px; }
  .game-header, .game-footer { padding-left: 22px; padding-right: 22px; }
  .game-footer { gap: 10px; flex-wrap: wrap; }
  #menu-button { margin-left: 0; }
}


/* v0.7：章節背景切換接口。未放入新章節圖片前，先沿用第一章主視覺。
   之後只要加入 chapter2-bg.png、chapter3-bg.png、chapter4-bg.png 並修改下列 URL 即可。 */
body[data-chapter="2"] { --scene-image: url("images/chapter2-bg.jpg"); }
body[data-chapter="3"] { --scene-image: url("images/chapter3-bg.jpg"); }
body[data-chapter="4"] { --scene-image: url("images/chapter4-bg.jpg"); }
