* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #07070a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}

/* 相機畫面 */
#cam {
  position: fixed; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0; background: #000;
}

/* 無相機時的替代背景 */
#nofeed {
  position: fixed; inset: 0; z-index: 0; display: none;
  background:
    radial-gradient(ellipse 90% 60% at 50% 18%, #2a3040 0%, transparent 60%),
    radial-gradient(ellipse 120% 70% at 50% 120%, #191b21 0%, transparent 70%),
    linear-gradient(180deg, #12141a 0%, #0a0b0f 55%, #050507 100%);
}
body.nocam #nofeed { display: block; }
body.nocam #cam { display: none; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; }

/* 瞄準圈 */
#aim {
  position: fixed; left: 0; top: 0; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  z-index: 3; pointer-events: none; opacity: 0; transition: opacity .12s;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5), inset 0 0 12px rgba(0,0,0,.35);
}
#aim.show { opacity: .95; }
#aim::after {
  content: ''; position: absolute; inset: 22px; border-radius: 50%;
  background: rgba(255,60,60,.95); box-shadow: 0 0 8px rgba(255,60,60,.9);
}

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 4;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 0;
  pointer-events: none;
}
.chip {
  background: rgba(12,14,20,.62); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.14); border-radius: 999px;
  padding: 8px 15px; color: #eef1f6; font-size: 14px; font-weight: 500;
  letter-spacing: .02em;
}
.chip b { font-size: 18px; font-weight: 700; margin-left: 4px; }
#chipDarts { letter-spacing: 3px; font-size: 16px; }
#chipDarts .dead { opacity: .22; }

/* 中央提示（上一鏢結果） */
#toast {
  position: fixed; top: 21%; left: 0; right: 0; z-index: 4;
  text-align: center; pointer-events: none;
  opacity: 0; transform: translateY(8px);
  transition: opacity .18s, transform .18s;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast .big {
  font-size: 46px; font-weight: 800; color: #fff;
  text-shadow: 0 2px 18px rgba(0,0,0,.85), 0 0 40px rgba(255,255,255,.18);
  letter-spacing: .01em;
}
#toast .small {
  font-size: 15px; font-weight: 600; color: #ffd76a; margin-top: 2px;
  text-shadow: 0 2px 10px rgba(0,0,0,.9);
}
#toast.bull .big { color: #ff5a4d; }

/* 力道表 */
#power {
  position: fixed; right: 16px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 190px; z-index: 4;
  background: rgba(10,12,18,.6); border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px; overflow: hidden; display: none;
}
#power.show { display: block; }
#powerFill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: linear-gradient(180deg, #ff4d4d 0%, #ffd447 45%, #3ddc84 100%);
  transition: height .03s linear;
}
#powerIdeal {
  position: absolute; left: -4px; right: -4px; bottom: 34%; height: 2px;
  background: rgba(255,255,255,.85); border-radius: 2px;
}
#powerLabel {
  position: fixed; right: 34px; top: 50%; transform: translateY(-50%);
  z-index: 4; display: none; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  color: #fff; text-shadow: 0 1px 6px #000; writing-mode: vertical-rl;
}
#powerLabel.show { display: block; }
#powerLabel .good { color: #7dffb0; }
#powerLabel .bad  { color: #ff8b7d; }

/* 底部按鈕列 */
#bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; gap: 10px; justify-content: center; align-items: center;
  padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
}

button {
  font-family: inherit; font-size: 16px; font-weight: 600; color: #fff;
  background: rgba(30,34,46,.78); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.2); border-radius: 14px;
  padding: 13px 22px; cursor: pointer; -webkit-appearance: none;
  transition: transform .08s, background .15s;
}
button:active { transform: scale(.96); background: rgba(52,58,76,.9); }
button.primary {
  background: linear-gradient(180deg, #ff5a4d, #d92b1f);
  border-color: rgba(255,255,255,.35); font-size: 17px; padding: 15px 30px;
  box-shadow: 0 6px 22px rgba(217,43,31,.35);
}
button.primary:active { background: linear-gradient(180deg, #ff6b5f, #e03a2e); }

/* 開場 / 對話面板 */
.scrim {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 28px; text-align: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(24,28,40,.82), rgba(5,6,10,.94));
  backdrop-filter: blur(14px);
}
.scrim.hidden { display: none; }

.scrim h1 {
  font-size: 34px; font-weight: 800; color: #fff; letter-spacing: .02em;
  margin-bottom: 6px;
}
.scrim .sub { color: #9aa3b5; font-size: 14px; margin-bottom: 24px; }
.scrim .rules {
  color: #cfd6e4; font-size: 14px; line-height: 2; text-align: left;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px; padding: 16px 20px; margin-bottom: 26px; max-width: 340px;
}
.scrim .rules b { color: #ffd76a; }

#panel .resultGrid {
  display: flex; gap: 10px; margin: 18px 0 26px;
}
#panel .resultGrid .box {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px; padding: 12px 20px; min-width: 96px;
}
#panel .resultGrid .box .k { font-size: 11px; color: #97a0b3; letter-spacing: .1em; }
#panel .resultGrid .box .v { font-size: 26px; font-weight: 800; color: #fff; margin-top: 2px; }

#badge {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 78px);
  z-index: 4; font-size: 11px; color: #8b93a4;
  background: rgba(12,14,20,.6); border-radius: 999px; padding: 5px 12px;
  display: none;
}
#badge.show { display: block; }
