/* ================================
   Reset & Base
   ================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #000;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}

/* ================================
   App Frame — 1080:1920 centered
   ================================ */
#app-frame {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(100vw, calc(100dvh * 1080 / 1920));
  aspect-ratio: 1080 / 1920;
  max-height: 100dvh;
  overflow: hidden;
  z-index: 10;
  box-shadow: 0 0 0 200vmax #000;
}

/* ================================
   Page Base
   ================================ */
.page {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
}

.page-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* ================================
   P1 — 首頁
   ================================ */

/* 頁面容器 */
#p1 {
  display: none;
  background-image: url('../素材/page/00_首頁.jpg');
  background-size: contain;
}

/* 內容排版 */
#p1 .page-inner {
  justify-content: space-between;
  align-items: center;
  padding: 10% 8%;
}

/* 主視覺 / Logo 區塊 */
.p1-logo-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

/* 底部按鈕區塊 */
.p1-bottom {
  width: 100%;
  padding-top: 8%;
}

/* 開始按鈕 */
#start-btn {
  width: 47%;
  height: 8%;
  top: 56%;
  left: 26%;
}

/* ================================
   P2 — 資料填寫
   ================================ */

/* 頁面容器 */
#p2 {
  display: none;
  background-image: url('../素材/page/01_活動資料填寫.jpg');
  background-size: contain;
}

/* 內容排版 */
#p2 .page-inner {
  justify-content: center;
  align-items: center;
  padding: 10% 8%;
}

/* 表單整體區塊 */
.p2-form-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* 輸入框群組 */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 姓名輸入框 */
#name {
  position: absolute;
  width: 76%;
  top: 22%;
  padding: 10px 14px;
  border: 1px solid rgba(155, 155, 155, 1);
  border-radius: 9px;
  outline: none;
}

#name::placeholder {
  color: rgba(0, 0, 0, 0.35);
}

#name:focus {
  border-color: rgba(0, 0, 0, 0.6);
}

/* 手機號碼輸入框 */
#phone {
  position: absolute;
  width: 76%;
  top: 32%;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid rgba(155, 155, 155, 1);
  outline: none;
}

#phone::placeholder {
  color: rgba(0, 0, 0, 0.35);
}

#phone:focus {
  border-color: rgba(0, 0, 0, 0.6);
}

#hint1 {
  display: none;
  position: absolute;
  width: 80%;
  height: 6%;
  left: 14%;
  top: 27%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-image: url('../素材/content/blank_tip1.png');
}

#hint2 {
  display: none;
  position: absolute;
  width: 80%;
  height: 6%;
  left: 14%;
  top: 37%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-image: url('../素材/content/blank_tip2.png');
}

/* 勾選列 */
.checkbox-row {
  display: block;
  align-items: center;
  gap: 16px;
  cursor: pointer;
}

/* 同意 checkbox */
#agree {
  position: absolute;
  width: 7%;
  height: 3%;
  left: 12%;
  top: 45%;
  cursor: pointer;
}

.tos-btn {
  position: absolute;
  width: 70%;
  height: 7%;
  top: 45%;
  left: 19%;
}

/* 送出按鈕 */
#submit-btn {
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-image: url('../素材/page/確認送出.jpg');
  width: 47%;
  height: 8%;
  top: 56%;
  left: 26%;
}

/* ================================
   P3 — AR 相機畫面
   ================================ */

/* 頁面容器（透明覆蓋層） */
#p3 {
  pointer-events: none;
  display: none;
  background-image: url('../素材/page/02_AR.png');
  background-size: contain;
}

#p3 > * {
  pointer-events: auto;
}

/* 辨識中提示 */
#ar-aiming {
  display: none;
  position: absolute;
  width: 100%;
  height: 10%;
  top: 37%;
  left: 0%;
  z-index: 15;
  color: #000;
  background-image: url('../素材/content/ARloading.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

/* 返回按鈕（AR 內） */
#ar-back-btn {
  position: absolute;
  top: 5%;
  left: 5%;
  z-index: 10;
  padding: 16px 28px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  -webkit-appearance: none;
}

/* 說明按鈕 */
#info-btn {
  position: absolute;
  top: 3%;
  width: 15%;
  height: 8%;
  left: 77%;
  z-index: 10;
  border: none;
  background: none;
}

/* 底部按鈕列容器 */
.ar-bottom-bar {
  position: absolute;
  bottom: 6%;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  padding: 0 6%;
  z-index: 10;
}

/* 地圖總覽按鈕 */
#map-btn {
  position: absolute;
  border: none;
  background: none;
  border-radius: 50px;
  width: 20%;
  height: 13%;
  left: 73%;
  top: 70%;
}

/* 圖章總覽按鈕 */
#stamp-btn {
  position: absolute;
  border: none;
  background: none;
  border-radius: 50px;
  width: 20%;
  height: 13%;
  left: 73%;
  top: 82%;
}

#ar-confirm {
  display: none;
  position: absolute;
  width: 20%;
  height: 13%;
  left: 40%;
  top: 50%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  background-image: url('../素材/content/AR_confirm.png');
}

#ar-finish {
  display: none;
  position: absolute;
  width: 50%;
  height: 20%;
  left: 25%;
  top: 50%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  background-image: url('../素材/content/AR_finish.png');
}

/* ================================
   P4 — 地圖總覽
   ================================ */

/* 頁面容器 */
#p4 {
  display: none;
  background-image: url('../素材/page/03_map.jpg');
  background-size: contain;
  z-index: 20;
}

/* 返回按鈕 */
#back-btn {
  width: 13%;
  height: 8%;
  border: none;
  background: none;
  display: block;
  left: 6%;
  top: 3%;
  position: absolute;
  z-index: 25;
}

/* ================================
   P5 — 圖章總覽
   ================================ */

/* 頁面容器 */
#p5 {
  display: none;
  background-image: url('../素材/page/04_list.jpg');
  background-size: contain;
  z-index: 20;
}

/* 返回按鈕 */
#back-btn2 {
  width: 13%;
  height: 8%;
  border: none;
  background: none;
  display: block;
  left: 6%;
  top: 3%;
  position: absolute;
  z-index: 25;
}

#to-redeem-btn {
  display: none;
  background: none;
  background-image: url('../素材/page/獲得抽獎機會.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute;
  width: 46%;
  height: 7%;
  z-index: 25;
  border: none;
  top: 80%;
  left: 28%;
}

/* 內容區（可捲動） */
#p5 .overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 5% 6%;
  -webkit-overflow-scrolling: touch;
}

/* 集章結果區塊（共用） */
.stamp-result {
  position: absolute;
  display: block;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 20;
  width: 30%;
  height: 15%;
}

/* 個別集章區塊 */
#stamp-result-1 {
  left: 18%;
  top: 14%;
}

#stamp-result-2 {
  left: 51%;
  top: 14%;
}

#stamp-result-3 {
  left: 18%;
  top: 32.5%;
}

#stamp-result-4 {
  left: 51%;
  top: 32.5%;
}

#stamp-result-5 {
  left: 18%;
  top: 51%;
}

/* 未集章狀態 */
#stamp-result-1.unselect {
  background-image: url('../素材/content/AR_1-1.jpg');
}

#stamp-result-2.unselect {
  background-image: url('../素材/content/AR_2-1.jpg');
}

#stamp-result-3.unselect {
  background-image: url('../素材/content/AR_3-1.jpg');
}

#stamp-result-4.unselect {
  background-image: url('../素材/content/AR_4-1.jpg');
}

#stamp-result-5.unselect {
  background-image: url('../素材/content/AR_5-1.jpg');
}

/* 已集章狀態 */
#stamp-result-1.select {
  background-image: url('../素材/content/AR_1.jpg');
}

#stamp-result-2.select {
  background-image: url('../素材/content/AR_2.jpg');
}

#stamp-result-3.select {
  background-image: url('../素材/content/AR_3.jpg');
}

#stamp-result-4.select {
  background-image: url('../素材/content/AR_4.jpg');
}

#stamp-result-5.select {
  background-image: url('../素材/content/AR_5.jpg');
}

/* ================================
   P6 — 完成頁面
   ================================ */

/* 頁面容器 */
#p6 {
  display: none;
  background-image: url('../素材/page/05_gift.jpg');
  background-size: contain;
  z-index: 20;
}

#password {
  display: block;
  position: absolute;
  width: 40%;
  height: 6%;
  left: 30%;
  top: 49%;
  background: none;
  border: none;
  outline: none;
  text-align: center;
  color: white;
}

#confirm-redeem-btn {
  display: block;
  position: absolute;
  width: 50%;
  height: 7%;
  left: 25%;
  top: 56%;
  background: none;
  border: none;
}

#p6-2 {
  display: none;
  background-image: url('../素材/page/06_體驗完成.jpg');
  background-size: contain;
  z-index: 20;
}

/* 內容排版 */
#p6 .page-inner {
  justify-content: center;
  align-items: center;
  gap: 6%;
  padding: 8%;
}

/* ================================
   TOS — 條款頁面
   ================================ */

/* 開啟按鈕（位於 P2） */
#tos-btn {
  position: absolute;
  width: 71%;
  height: 9%;
  left: 19%;
  top: 44%;
  border: none;
  background: none;
  display: block;
}

/* 頁面容器 */
#tos {
  display: none;
  background-image: url('../素材/page/06_同意書.jpg');
  background-size: contain;
  z-index: 25;
}

/* 關閉按鈕 */
#tos-close-btn {
  display: block;
  position: absolute;
  border: none;
  background: none;
  width: 15%;
  height: 8%;
  top: 8%;
  left: 83%;
}

.tos-container {
  position: absolute;
  width: 74%;
  height: 72%;
  left: 13%;
  top: 14%;
  overflow-y: scroll;
}

.tos-rule {
  background-image: url('../素材/content/rule_w.png');
  width: 100%;
  height: 179%;
  background-size: 100% 100%;
}

/* ================================
   Info — 說明頁面
   ================================ */

/* 頁面容器 */
#info {
  z-index: 25;
  display: none;
  background-image: url('../素材/page/02_內容.jpg');
  background-size: contain;
}

/* 關閉按鈕列 */
.info-close-row {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  padding: 6% 6% 2%;
  flex-shrink: 0;
}

/* 關閉按鈕 */
#info-close-btn {
  position: absolute;
  width: 20%;
  height: 16%;
  left: 40%;
  top: 50%;
  border: none;
  background: none;
  display: block;
}

#info-close-btn:active {
  background: rgba(255, 255, 255, 0.22);
}

/* 說明內容區塊 */
.info-body {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  padding: 2% 8% 8%;
  -webkit-overflow-scrolling: touch;
}

/* ================================
   Stamp Pages — 集章成功
   ================================ */

/* --- 共用結構 --- */

/* 集章頁共用容器 */
.stamp-page {
  z-index: 30;
  background: rgba(10, 10, 10, 0.97);
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

/* 關閉按鈕列 */
.stamp-close-row {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  padding: 6% 6% 2%;
  flex-shrink: 0;
}

/* 關閉按鈕（共用） */
.btn-stamp-close {
  display: block;
  position: absolute;
  border: none;
  background: none;
  width: 40%;
  height: 10%;
  top: 70%;
  left: 30%;
}

/* 查看進度按鈕 (共用) */
.stamp-shortcut-btn {
  display: block;
  position: absolute;
  border: none;
  background: none;
  width: 20%;
  height: 14%;
  top: 82%;
  left: 73%;
}

/* 主要內容區塊（共用） */
.stamp-body {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 8%;
  min-height: 0;
}

/* 底部區塊（共用） */
.stamp-footer {
  width: 100%;
  padding: 6% 8%;
  flex-shrink: 0;
}

/* --- 個別頁面覆寫 --- */

/* 集章 1 */
#stamp1 {
  background-image: url('../素材/page/02說明_1.jpg');
  background-size: contain;
}

/* 集章 2 */
#stamp2 {
  background-image: url('../素材/page/02說明_2.jpg');
  background-size: contain;
}

/* 集章 3 */
#stamp3 {
  background-image: url('../素材/page/02說明_3.jpg');
  background-size: contain;
}

/* 集章 4 */
#stamp4 {
  background-image: url('../素材/page/02說明_4.jpg');
  background-size: contain;
}

/* 集章 5 */
#stamp5 {
  background-image: url('../素材/page/02說明_5.jpg');
  background-size: contain;
}

/* ================================
   Shared Buttons
   ================================ */
.btn-primary {
  display: block;
  position: absolute;
  border: none;
  background: none;
}

/* ================================
   Landscape Hint
   ================================ */
#landscape-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.96);
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 28px;
}

#landscape-hint p {
  padding: 20px;
  line-height: 1.5;
}

/* ================================
   Debug
   ================================ */
#toggle-debug {
  display: none;
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 1001;
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  -webkit-appearance: none;
  opacity: 0.6;
}

#debug {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 30vh;
  z-index: 1000;
  padding: 28px 8px 8px;
  background: rgba(0, 0, 0, 0.88);
  color: #ccc;
  font-family: monospace;
  font-size: 18px;
  line-height: 1.4;
  overflow-y: auto;
  word-break: break-all;
}

#debug-filters {
  position: sticky;
  top: -28px;
  display: flex;
  gap: 6px;
  padding: 4px 0;
  margin-top: -28px;
  background: rgba(0, 0, 0, 0.96);
  z-index: 1;
}

#debug-filters button {
  padding: 3px 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  font-family: monospace;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  background: transparent;
}

#debug-filter-log {
  color: #0f0;
}

#debug-filter-warn {
  color: #fc0;
}

#debug-filter-error {
  color: #f44;
}

/* ================================
   Loading Mask
   ================================ */
#loading-mask {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.65);
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 24px;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 5px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  color: #fff;
  font-size: 28px;
  letter-spacing: 0.05em;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }

}

/* ================================
 8th Wall overrides
 ================================ */
.poweredby-img {
  display: none;
}
