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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #02040a;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  color: #eaf6ff;
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
}
#stage canvas { display: block; }

.hide { display: none !important; }

/* ---------- 玻璃面板 ---------- */
.panel {
  background: rgba(10, 18, 30, 0.55);
  border: 1px solid rgba(0, 255, 157, 0.25);
  border-radius: 18px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 28px rgba(0, 255, 157, 0.12), inset 0 0 22px rgba(0, 255, 157, 0.05);
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 18px;
  pointer-events: none;
  z-index: 10;
}
#hud .panel { pointer-events: auto; }

.panel-left {
  display: flex;
  gap: 18px;
  padding: 12px 20px;
}
.stat-label {
  font-size: 13px;
  letter-spacing: 2px;
  color: rgba(160, 210, 255, 0.75);
}
.stat .big {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  color: #00ff9d;
  text-shadow: 0 0 14px rgba(0, 255, 157, 0.6);
  font-variant-numeric: tabular-nums;
}
.stat .slash { color: rgba(160,210,255,0.4); margin: 0 3px; font-size: 26px; }
#timer.warn {
  color: #ff4472;
  text-shadow: 0 0 18px rgba(255, 68, 114, 0.8);
  animation: pulse 0.6s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.12); }
}

.panel-right {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
#combo {
  font-size: 20px;
  font-weight: 800;
  color: #ffd54d;
  text-shadow: 0 0 14px rgba(255, 213, 77, 0.7);
  letter-spacing: 1px;
  min-width: 96px;
  text-align: center;
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.25s;
}
#combo.on { opacity: 1; transform: translateY(0); }

.glass-btn {
  background: rgba(20, 40, 60, 0.45);
  border: 1px solid rgba(62, 200, 255, 0.4);
  color: #cfefff;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.glass-btn:hover:not(:disabled) {
  border-color: #00ff9d;
  box-shadow: 0 0 16px rgba(0, 255, 157, 0.45);
  color: #00ff9d;
}
.glass-btn:active:not(:disabled) { transform: scale(0.95); }
.glass-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---------- 覆蓋層 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(2, 10, 16, 0.55) 0%, rgba(2, 4, 10, 0.82) 100%);
}
.center-card {
  width: min(560px, 92vw);
  padding: 34px 40px 26px;
  text-align: center;
  animation: popIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.85) translateY(14px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #00ff9d;
  text-shadow: 0 0 16px rgba(0, 255, 157, 0.8);
}
.title {
  font-size: clamp(44px, 9vw, 72px);
  font-weight: 900;
  letter-spacing: 8px;
  background: linear-gradient(90deg, #3ec8ff, #00ff9d, #ffd54d);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 22px rgba(0, 255, 157, 0.45));
  margin: 6px 0 2px;
}
.sub {
  font-size: 13px;
  letter-spacing: 5px;
  color: rgba(150, 190, 255, 0.65);
  margin-bottom: 18px;
}

.rules {
  list-style: none;
  text-align: left;
  margin: 0 auto 22px;
  width: fit-content;
  font-size: 15px;
  line-height: 2;
  color: #cfe0f5;
}
.rules b.q { color: #3ec8ff; }
.rules b.a { color: #16c784; }
.rules b { color: #00ff9d; }
.rules li::before {
  content: "▸";
  color: #00ff9d;
  margin-right: 10px;
}

.cta {
  font-family: inherit;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #022a16;
  background: linear-gradient(90deg, #00ff9d, #16e0a0);
  border: none;
  border-radius: 14px;
  padding: 13px 46px;
  cursor: pointer;
  box-shadow: 0 0 26px rgba(0, 255, 157, 0.55);
  transition: all 0.2s;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 0 40px rgba(0, 255, 157, 0.8); }
.cta:active { transform: scale(0.96); }

.foot {
  margin-top: 18px;
  font-size: 12px;
  letter-spacing: 1px;
  color: rgba(150, 190, 255, 0.4);
}

/* ---------- 結果 ---------- */
.end-title {
  font-size: clamp(30px, 6vw, 46px);
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 4px;
}
.end-sub { color: rgba(200, 230, 255, 0.8); margin-bottom: 12px; }
#endOverlay.win .end-title {
  background: linear-gradient(90deg, #ffd54d, #00ff9d);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
#endOverlay.lost .end-title { color: #ff6b8a; }

#stars {
  font-size: 46px;
  letter-spacing: 8px;
  margin: 10px 0 8px;
}
.star { color: rgba(255, 255, 255, 0.15); text-shadow: none; }
.star.on {
  color: #ffd54d;
  text-shadow: 0 0 20px rgba(255, 213, 77, 0.9);
  animation: starIn 0.4s cubic-bezier(0.2, 1.8, 0.4, 1);
}
@keyframes starIn {
  from { opacity: 0; transform: scale(0.2) rotate(-40deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}

.stats {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 8px 0 22px;
  font-size: 14px;
  color: rgba(180, 215, 255, 0.8);
}
.stats b { color: #00ff9d; font-size: 22px; }
.stats span { font-size: 12px; color: rgba(150,190,255,0.5); }

@media (max-width: 640px) {
  .center-card { padding: 24px 20px 20px; }
  .panel-left { gap: 12px; padding: 10px 14px; }
  .panel-right { padding: 8px 10px; }
  .stat .big { font-size: 26px; }
  .glass-btn { font-size: 13px; padding: 8px 10px; }
  .stats { gap: 14px; }
}