/* --- 基礎設定與安全區 --- */
:root {
  --bg-color: #0f172a; 
  --primary: #38bdf8;
  --success: #10b981;
  --danger: #ef4444;
  --text-main: #f8fafc;
  /* 縮小底部導航高度，讓圖片能放得更大 */
  --bottom-bar-height: calc(55px + env(safe-area-inset-bottom)); 
}

[hidden] { display: none !important; }

body {
  margin: 0; padding: 0;
  background: var(--bg-color);
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw;
  height: 100dvh; 
  overflow: hidden; 
}

/* --- 全新街機風底部導航列 --- */
#game-bottom-bar {
  position: relative;
  height: var(--bottom-bar-height);
  width: 100%;
}

.game-nav-btn {
  background: none; border: none; box-shadow: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #94a3b8; 
  font-size: 0.7rem; 
  flex: 1;           
  padding: 4px 2px;  
  margin: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}
.game-nav-btn:hover, .game-nav-btn:active { color: var(--primary); transform: scale(1.05); }
.game-nav-btn span.icon { font-size: 1.5rem; margin-bottom: 2px; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5)); }

/* --- 按鈕設計 (電競暗黑版) --- */
button.primary-btn {
  width: 100%; padding: 14px 15px; font-size: 1.1rem; font-weight: bold;
  border: 1px solid #334155; border-radius: 12px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: var(--text-main);
  cursor: pointer; 
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  transition: all 0.15s ease;
}
button.primary-btn.menu-btn {
  text-align: left; padding-left: 20px; font-size: 1.1rem; letter-spacing: 1px; border-color: #475569;
}
button.primary-btn:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
  transform: translateY(-1px);
}
button.primary-btn:active:not(:disabled) {
  transform: translateY(2px) scale(0.98);
  background: #0f172a;
}
button.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* --- 狀態列 (HUD) --- */
.badge { color: white; border-radius: 25px; font-weight: bold; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.badge.level { box-shadow: 0 0 8px rgba(59, 130, 246, 0.6); }

/* 覆蓋層與彈窗 */
.overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 2000; background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); }
@keyframes popIn { 0% { transform: scale(0.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

#ranking-list { list-style: none; padding: 0; overflow-y: auto; flex:1; font-size: 1.1rem; }
#ranking-list li { padding: 16px 10px; border-bottom: 1px solid #334155; }

.footer-copyright { text-align: center; padding: 15px 10px; font-size: 0.85rem; line-height: 1.8; margin-top: auto; }
.footer-copyright a { font-weight: bold; text-decoration: none; }

.fade-in { animation: fadeIn 0.4s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.treasure-toast {
  border-radius: 12px; padding: 12px; text-align: center; box-shadow: 0 10px 20px rgba(0,0,0,0.5); animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 1px solid;
}

/* 倒數計時心跳特效 */
@keyframes heartPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.8; color: #ef4444; text-shadow: 0 0 10px rgba(239, 68, 68, 0.8); }
  100% { transform: scale(1); opacity: 1; }
}
.danger-pulse { animation: heartPulse 0.5s infinite; font-weight: 900 !important; color: #ef4444 !important; }

/* 分享按鈕樣式 */
.btn-share { box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4) !important; animation: popIn 0.5s ease; font-size: 1.2rem !important; padding: 16px !important; border-radius: 30px !important;}

/* --- 自訂 Modal (彈窗) --- */
.custom-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.7);
  display: flex; justify-content: center; align-items: center; z-index: 9999; padding: 20px;
}

.custom-modal-content {
  border-radius: 16px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5); animation: popIn 0.3s ease; overflow: hidden; text-align: left;
}

.custom-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; }
.custom-modal-header h3 { margin: 0; font-size: 1.2rem; }
.custom-modal-close { background: none; border: none; font-size: 1.8rem; cursor: pointer; line-height: 1; padding: 0; transition: color 0.2s;}
.custom-modal-close:hover { color: white !important; }
.custom-modal-body { padding: 20px; font-size: 1rem; line-height: 1.6; }

/* 寶物卡片 (深色版) */
.inventory-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); border: 1px solid #475569;
  border-radius: 16px; padding: 20px 10px; text-align: center;
  box-shadow: 0 8px 15px rgba(0,0,0,0.3); display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: popIn 0.3s ease forwards;
}
.inventory-card .icon { font-size: 3rem; margin-bottom: 12px; filter: drop-shadow(0 5px 5px rgba(0,0,0,0.4)); }
.inventory-card .name { font-weight: bold; color: #fbbf24; font-size: 1.05rem; margin-bottom: 12px; }
.inventory-card .count { font-size: 0.85rem; color: #cbd5e1; background: #334155; padding: 4px 14px; border-radius: 20px; font-weight: bold; }

/* 全破關畫面 */
#finish-screen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: #000;
  z-index: 9999; display: none; flex-direction: column; justify-content: center; align-items: center; cursor: pointer;
}
#finish-screen img { width: 100%; height: 100%; object-fit: cover; }
#finish-screen .click-to-continue {
  position: absolute; bottom: 8%; width: 100%; text-align: center; color: white; font-size: 1.2rem; font-weight: bold;
  letter-spacing: 2px; text-shadow: 0 2px 8px rgba(0,0,0,0.8); animation: pulse 1.5s infinite;
}

/* 找碴遊戲專用圈圈 */
.spot-marker {
  position: absolute; width: 45px; height: 45px; border: 5px solid #10b981; border-radius: 50%;
  transform: translate(-50%, -50%) scale(0); box-shadow: 0 0 15px rgba(16, 185, 129, 0.9), inset 0 0 8px rgba(16, 185, 129, 0.6);
  animation: markerPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; pointer-events: none; z-index: 20;
}

@keyframes markerPop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* 畫面邊框紅色閃爍警告 */
@keyframes screenAlert {
  0% { box-shadow: inset 0 0 0px rgba(239, 68, 68, 0); }
  50% { box-shadow: inset 0 0 50px rgba(239, 68, 68, 0.9); }
  100% { box-shadow: inset 0 0 0px rgba(239, 68, 68, 0); }
}
.danger-screen { animation: screenAlert 0.5s infinite; }
.flash-red { animation: screenAlert 0.4s ease-out; }

/* 底部關於與版權按鈕 */
.footer-btn-group { display: flex; justify-content: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.footer-btn {
  background-color: #1e293b; color: #cbd5e1; border: 1px solid #334155; border-radius: 8px;
  padding: 8px 14px; font-size: 0.9rem; cursor: pointer; font-weight: bold; transition: all 0.2s;
}
.footer-btn:hover { background-color: #334155; color: white; border-color: #475569;}
