:root {
  /* ── Design system ── */
  --primary: #1e4860;          /* 主色：文字、主要按鈕 */
  --on-primary: #ffffff;
  --secondary: #f2c14e;        /* 輔色：黃，用在點綴（看過的房間、箭頭、強調） */
  --on-secondary: #1e4860;
  --surface: rgba(255, 255, 255, 0.88); /* 次要按鈕、彈窗等白底 */
  --radius: 12px;

  --bg: #e6eef3;
  --ink: var(--primary);
  --muted: rgba(30, 72, 96, 0.72);
  --warm: var(--secondary);
  --line: rgba(30, 72, 96, 0.22);
  --card: rgba(255, 255, 255, 0.5);
  --sans: 'PingFang TC', -apple-system, 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; background: var(--bg); overflow: hidden; }

body {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  background: transparent; /* 底色留給 html，背景圖在 body::before */
}

/* 背景：主視覺大幅模糊＋白色提亮層 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(250, 248, 243, 0.45), rgba(250, 248, 243, 0.45)), /* 白色提亮層：整體明亮、深藍字清楚 */
    url('/img/bg-kv-blur.jpg') center / cover no-repeat;
}

button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }


.stage { position: relative; max-width: 480px; height: 100dvh; margin: 0 auto; }

/* 一個畫面 */
.scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 24px calc(32px + env(safe-area-inset-bottom));
  animation: scene-in 0.6s ease both;
}
.scene > * { flex-shrink: 0; }
.scene.out { animation: scene-out 0.35s ease both; }
.scene.top { justify-content: flex-start; padding-top: 56px; overflow-y: auto; }
@keyframes scene-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes scene-out { to { opacity: 0; transform: translateY(-10px); } }

.line {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.75;
  text-align: center;
  white-space: pre-line;
}
.line.big { font-size: 23px; font-weight: 600; }
.sub { text-align: center; color: var(--muted); font-size: 13px; margin-top: 8px; }

.options { display: flex; flex-direction: column; gap: 10px; margin-top: 32px; animation: scene-in 0.5s 0.35s ease both; }
.options.grid { display: grid; grid-template-columns: 1fr 1fr; }
.options.row { flex-direction: row; }
.options.row .opt { flex: 1; }
.opt {
  /* 油畫刷痕按鈕：形狀用 MJ 刷痕當遮罩，顏色仍由色票決定，上面疊一層筆觸紋理 */
  padding: 10px 16px;
  border: 0;
  border-radius: 0;
  /* 刷痕直接做成上好色的圖片（不用 CSS 遮罩：部分手機的 LINE 內建瀏覽器遮罩失效會讓按鈕整顆透明） */
  background: url('/img/btn-white.png') center / 100% 100% no-repeat;
  color: var(--primary);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.12em;
  transition: transform 0.15s ease;
}
.opt.primary { background-image: url('/img/btn-primary.png'); color: var(--on-primary); }
.opt.wide { grid-column: 1 / -1; }
.opt.picked { transform: scale(0.94); } /* 點下去只縮小，不變色 */
.opt:active { transform: scale(0.98); }


/* 房間卡片 */
.cards { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 22px -24px 0; padding: 0 24px 4px; scroll-padding-left: 24px; scrollbar-width: none; }
.cards::-webkit-scrollbar { display: none; }
.card { flex: 0 0 76%; scroll-snap-align: start; border-radius: 16px; overflow: hidden; background: var(--card); border: 1px solid var(--line); }
.card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: center 30%; }
.card .body { padding: 12px 14px 16px; }
.card h4 { font-family: var(--sans); font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.card h4 span { color: var(--warm); }
.card p { font-size: 15px; color: var(--muted); line-height: 1.6; }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: background 0.3s; }
.dots i.on { background: var(--warm); }
.scene.top .options { margin-top: 18px; }
.question { font-family: var(--sans); font-size: 21px; text-align: center; margin-top: 26px; }

.poster { display: block; width: 56%; margin: 22px auto 0; border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); }

.error { color: #b3261e; }

@media (prefers-reduced-motion: reduce) {
  .scene, .scene.out, .options { animation: none; }
}

/* 房間（3D 示意圖做好前的暫代版）：2×2 可點的格子 */
.room-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.room { position: relative; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; padding: 0; background: var(--card); text-align: left; }
.room img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; opacity: 0.85; transition: opacity 0.3s; }
.room span { display: block; padding: 8px 12px 10px; font-size: 12px; color: var(--muted); }
.room b { display: block; font-family: var(--sans); font-size: 15px; color: var(--ink); }
.room.seen { border-color: var(--warm); }
.room.seen img { opacity: 1; }
.room.seen::after { content: ''; position: absolute; top: 10px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--warm); box-shadow: 0 0 12px 3px rgba(240, 169, 91, 0.7); }

/* 房間介紹彈窗（底部滑出） */
.popup { position: fixed; inset: 0; z-index: 20; background: rgba(30, 72, 96, 0.28); display: flex; align-items: center; justify-content: center; padding: 20px; }
/* 卡片約半個螢幕高：圖片最多 30dvh，字在圖片下方 */
.sheet { width: min(84vw, 340px); max-height: 76dvh; overflow: hidden; background: #f7f4ee; border-radius: 20px; box-shadow: 0 20px 60px rgba(30, 72, 96, 0.35); display: flex; flex-direction: column; }
.sheet img { display: block; width: 100%; height: min(36dvh, calc(min(84vw, 340px) * 1.1)); object-fit: cover; object-position: center 30%; flex: none; }
.sheet .body { padding: 14px 18px 18px; overflow-y: auto; }
.sheet h4 { font-family: var(--sans); font-size: 17px; margin-bottom: 8px; }
.sheet h4 span { color: var(--primary); }
.sheet p { color: var(--primary); font-size: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop-in { from { transform: scale(0.92); opacity: 0; } }

/* 填答框 */
.input { width: 100%; margin-top: 28px; padding: 14px 16px; border-radius: 16px; border: 1.5px solid var(--line); background: rgba(255, 255, 255, 0.7); color: var(--ink); font: inherit; font-size: 15px; resize: none; }
.input::placeholder { color: rgba(30, 72, 96, 0.45); }
.input:focus { outline: none; border-color: var(--warm); }
.scene .input + .options { margin-top: 18px; }

/* 最後一頁：「我還想要了解⋯」＋連結清單 */
.more-title { text-align: center; color: var(--muted); font-size: 13px; margin-top: 26px; letter-spacing: 0.05em; }
.links { list-style: none; padding: 0; margin-top: 10px; border-top: 1px solid var(--line); }
.links li { border-bottom: 1px solid var(--line); }
.links button { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 13px 4px; border: 0; background: none; font-size: 15px; text-align: left; }
.links button::after { content: '›'; color: var(--warm); font-size: 18px; line-height: 1; }

/* 自動換頁畫面上方的圓餅倒數：從滿圓逐漸被吃掉 */
@property --left { syntax: '<percentage>'; inherits: false; initial-value: 100%; }
.timer {
  position: absolute;
  top: calc(28px + env(safe-area-inset-top));
  left: 50%;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  background: conic-gradient(var(--primary) var(--left), transparent 0);
  background-clip: content-box;
  padding: 3px;
  opacity: 0.7;
  animation: countdown var(--dur) linear forwards;
}
@keyframes countdown { from { --left: 100%; } to { --left: 0%; } }

/* 3D 空間示意圖 */
.floor3d { width: calc(100% + 48px); margin: 0 -24px; height: min(72dvh, 520px); touch-action: none; }
.floor3d canvas { display: block; }

.floor3d { touch-action: manipulation; }

/* 照片格版本：還沒輪到的房間變淡 */
.room.dim { opacity: 0.45; }
#guide { font-size: 14px; color: var(--primary); }

.sheet .options { margin-top: 14px; animation: none; }
.sheet p { line-height: 1.75; }

/* 單一按鈕不撐滿整列，置中、最寬 240px，畫面比較輕 */
.options:not(.row):not(.grid) .opt:only-child { align-self: center; width: 100%; max-width: 200px; }

/* 句子下方的圖（燈箱實拍） */
.say-img { display: block; width: min(64vw, 260px); margin: 22px auto 0; border-radius: 16px; box-shadow: 0 12px 36px rgba(30, 72, 96, 0.25); }

/* 句子上方的圖（燈箱實拍） */
.ask-img { display: block; width: min(56vw, 230px); margin: 0 auto 22px; border-radius: 16px; box-shadow: 0 12px 36px rgba(30, 72, 96, 0.25); }

/* 全站字距 */
body { letter-spacing: 0.06em; }
.line { letter-spacing: 0.14em; }
.line.small { font-size: 15.5px; letter-spacing: 0.16em; }

/* 按鈕都不滿版：上下排的選項置中、最寬 240px */
.options:not(.row):not(.grid) { align-items: center; }
.options:not(.row):not(.grid) .opt { width: 100%; max-width: 240px; }

/* 黃色按鈕（secondary） */
.opt.yellow { background-image: url('/img/btn-yellow.png'); color: #fff; }

/* Reels 封面輪播 */
.reels { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 22px -24px 0; padding: 0 calc(50% + 24px - min(29vw, 120px)) 6px; /* 百分比依外層算，補回左右各伸出的 24px */ scrollbar-width: none; -webkit-overflow-scrolling: touch; touch-action: pan-x; }
.reels::-webkit-scrollbar { display: none; }
.reel { flex: 0 0 min(58vw, 240px); scroll-snap-align: center; padding: 0; border: 0; border-radius: 16px; overflow: hidden; background: none; box-shadow: 0 10px 30px rgba(30, 72, 96, 0.22); }
.reel img { display: block; width: 100%; aspect-ratio: 9 / 16; object-fit: cover; }
.scene .poster + .line { margin-top: 18px; }

/* 放大強調的字（例如「免費獲得」） */
.line .em { font-size: 1.35em; font-weight: 700; color: var(--primary); }
/* 結尾海報放大 */
.scene .poster { width: min(86%, calc(56dvh * 0.8)); } /* 海報放大；矮螢幕時以高度 56% 為上限，按鈕才不會被擠出畫面 */

/* 3D 畫面：畫布撐滿整個畫面（拉近時模型不會在畫面中間被切出直線），按鈕浮在底部 */
.scene.full { position: fixed; inset: 0; padding: 0; } /* 不受中間 480px 欄寬限制，撐滿整個視窗 */
.scene.full .floor3d { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; }
.scene.full .options { position: absolute; left: 0; right: 0; width: min(432px, calc(100% - 48px)); margin: 0 auto; bottom: calc(36px + env(safe-area-inset-bottom)); z-index: 2; }


/* 小按鈕（例如〔我反悔了〕） */
.options:not(.row):not(.grid) .opt.mini { max-width: 130px; padding: 7px 12px; font-size: 13px; }

/* 右上角語言切換 */
/* 語言切換＋AI 翻譯註記：上下間距 4px */
.lang-wrap { position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 12px; z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.lang { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.6); }
.lang button { border: 0; background: none; padding: 4px 9px; border-radius: 999px; font-size: 12px; letter-spacing: 0.04em; color: var(--muted); }
.lang button.on { background: var(--primary); color: #fff; }
.ai-note { margin: 0 2px 0 0; font-size: 11px; letter-spacing: 0.04em; color: var(--muted); }

/* 禁止選取文字、長按不跳選單（問卷畫面像 App，不需要選字） */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
img { -webkit-user-drag: none; }

/* 回訪「嗨，〇〇！」頁的海報：下面有 2～3 顆按鈕，高度上限比結尾頁低一點 */
.scene .poster.welcome { width: min(80%, calc(44dvh * 0.8)); margin: 0 auto 18px; }
