/* 響應式 10-foot / 行動 UI。深色高對比，元素用 clamp() + vw/vh 自適應。 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --good: #22c55e;
  --warn: #eab308;
  --bad: #ef4444;
  --neutral: #38bdf8;
  --bg: #0b1220;
  --fg: #f8fafc;
  --pad: clamp(12px, 3vw, 40px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  overflow: hidden;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* 行動瀏覽器網址列自適應 */
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* 標題列 */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: var(--pad);
  background: linear-gradient(to bottom, rgba(0,0,0,.65), transparent);
  z-index: 5;
  pointer-events: none;
}
.title { font-size: clamp(20px, 4.2vw, 40px); font-weight: 800; letter-spacing: 1px; }
.subtitle { font-size: clamp(12px, 2.2vw, 22px); color: #cbd5e1; margin-top: 4px; }
#status { font-size: clamp(12px, 2vw, 22px); color: #94a3b8; text-align: right; max-width: 40%; }

/* 右側欄：示範 + 計數 flex 堆疊，任何尺寸都不重疊 */
.rightcol {
  position: absolute;
  top: clamp(60px, 12vh, 104px);
  right: var(--pad);
  width: clamp(92px, 24vw, 190px);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.4vw, 14px);
  z-index: 5;
}

/* 動作示範 */
#demoBox {
  width: 100%;
  background: rgba(15, 23, 42, .82);
  border: 2px solid rgba(34,197,94,.4);
  border-radius: 16px;
  padding: clamp(6px, 1.2vw, 12px);
  text-align: center;
}
.demoCaption { font-size: clamp(11px, 1.7vw, 17px); color: #86efac; font-weight: 700; margin-bottom: 4px; }
.demoSvg { width: 100%; height: auto; display: block; }

/* 計數卡 */
#counterCard {
  width: 100%;
  background: rgba(15, 23, 42, .82);
  border: 2px solid rgba(148,163,184,.3);
  border-radius: 16px;
  padding: clamp(8px, 1.5vw, 18px);
  text-align: center;
}
#counterCard .big { font-size: clamp(40px, 11vw, 90px); font-weight: 900; line-height: 1; color: var(--neutral); }
#counterCard .slash { font-size: clamp(18px, 4.5vw, 38px); color: #94a3b8; }
#counterCard .label { font-size: clamp(13px, 2.2vw, 22px); color: #cbd5e1; margin-top: 6px; }
#counterCard .clean { font-size: clamp(14px, 2.4vw, 24px); color: var(--good); margin-top: 10px; font-weight: 700; }
#counterCard.pulse .big { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); color: var(--good); } 100% { transform: scale(1); } }

/* 進度條 */
.progress {
  position: absolute;
  left: var(--pad); right: var(--pad);
  bottom: clamp(96px, 18vh, 150px);
  height: clamp(10px, 2vw, 18px);
  background: rgba(148,163,184,.25);
  border-radius: 10px;
  overflow: hidden;
  z-index: 5;
}
#progressBar { height: 100%; width: 0%; background: var(--good); transition: width .25s ease; }

/* 提示訊息 */
.message {
  position: absolute;
  left: 50%;
  bottom: clamp(96px, 8vh, 50px);
  transform: translateX(-50%);
  font-size: clamp(20px, 4.6vw, 46px);
  font-weight: 800;
  padding: clamp(10px, 2vw, 20px) clamp(18px, 4vw, 48px);
  border-radius: 16px;
  background: rgba(15,23,42,.85);
  border: 3px solid var(--neutral);
  z-index: 5;
  max-width: 92vw;
  text-align: center;
  white-space: nowrap;
}
.message.good { border-color: var(--good); color: #dcfce7; }
.message.warn { border-color: var(--warn); color: #fef9c3; }
.message.bad  { border-color: var(--bad);  color: #fee2e2; }
.message.neutral { border-color: var(--neutral); }

/* debug */
#debug {
  position: absolute;
  left: var(--pad);
  top: clamp(70px, 12vh, 120px);
  font-family: ui-monospace, monospace;
  font-size: clamp(12px, 1.8vw, 20px);
  color: #7dd3fc;
  background: rgba(0,0,0,.55);
  padding: 8px 14px;
  border-radius: 10px;
  z-index: 6;
  max-width: 60vw;
}
.hidden { display: none !important; }

/* 控制列 */
.controls {
  position: absolute;
  bottom: var(--pad); right: var(--pad);
  display: flex;
  gap: 10px;
  z-index: 6;
}
button {
  font-size: clamp(15px, 2.4vw, 24px);
  font-weight: 700;
  padding: clamp(10px, 1.6vw, 14px) clamp(16px, 2.6vw, 28px);
  border: none;
  border-radius: 12px;
  background: rgba(30,41,59,.92);
  color: var(--fg);
  cursor: pointer;
}
button:hover { background: #334155; }
button:disabled { opacity: .5; cursor: default; }

/* 開始 overlay */
#overlayStart {
  position: absolute;
  inset: 0;
  background: rgba(2,6,23,.94);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(16px, 3vw, 28px);
  z-index: 20;
  text-align: center;
  padding: var(--pad);
}
#overlayStart h1 { font-size: clamp(32px, 7vw, 56px); font-weight: 900; }
#overlayStart p { font-size: clamp(16px, 3vw, 26px); color: #cbd5e1; max-width: 800px; line-height: 1.6; }
#overlayStart .hint { font-size: clamp(13px, 2.2vw, 20px); color: #64748b; }
#startBtn { font-size: clamp(22px, 4vw, 32px); padding: clamp(14px, 2.5vw, 20px) clamp(36px, 7vw, 56px); background: var(--good); color: #06210f; }
#startBtn:disabled { background: #334155; color: #94a3b8; }

/* 直向窄螢幕：訊息允許換行、示範與計數縮小避免重疊 */
@media (max-aspect-ratio: 3/4) {
  .message { white-space: normal; max-width: 88vw; }
  .subtitle { display: none; }
}
/* 極矮（橫向手機）：示範與計數改並排，壓縮垂直空間 */
@media (max-height: 480px) {
  .rightcol { top: 52px; flex-direction: row; width: auto; gap: 8px; align-items: flex-start; }
  #demoBox, #counterCard { width: clamp(76px, 14vw, 128px); }
  .message { bottom: 56px; }
}
