/* 五支原型共用的介面樣式。
   HUD 一律用 HTML/CSS 疊在 canvas 上,不要在 3D 場景裡做 UI ——
   文字排版、換行、多語系、無障礙,瀏覽器全部免費給你,自己在 3D 裡做全部要重寫。 */

:root {
  --bg: #05060a;
  --ink: #e8eaf0;
  --dim: #8b93a7;
  --line: rgba(255, 255, 255, .12);
  --panel: rgba(10, 13, 20, .72);
  --accent: #ffb347;
  --good: #5ddb9a;
  --bad: #ff6b6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

canvas { display: block; }

/* HUD 層:預設不吃滑鼠事件,免得擋住遊戲的點擊。
   需要互動的子元素自己開回來(見 .panel button)。 */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  user-select: none;
}

.panel {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  backdrop-filter: blur(10px);
  font-size: 13px;
  line-height: 1.7;
}
.panel button, .panel input, .panel select { pointer-events: auto; }

.top-left     { top: 16px; left: 16px; }
.top-right    { top: 16px; right: 16px; }
.bottom-left  { bottom: 16px; left: 16px; }
.bottom-right { bottom: 16px; right: 16px; }

/* 數值列:標籤靠左、數字靠右並用等寬字,跳動時不會左右抖 */
.stat {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  min-width: 150px;
}
.stat b {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.stat span { color: var(--dim); }

.btn {
  pointer-events: auto;
  appearance: none;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .08s;
}
.btn:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .3); }
.btn:active { transform: translateY(1px); }
.btn[aria-pressed="true"] {
  background: rgba(255, 179, 71, .18);
  border-color: var(--accent);
  color: var(--accent);
}
.btn:disabled { opacity: .35; cursor: not-allowed; }

/* 置中的開始/結束畫面 */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 4, 8, .78);
  backdrop-filter: blur(6px);
  z-index: 10;
  transition: opacity .4s ease;
}
.overlay[hidden] { display: none; }
.overlay .card {
  text-align: center;
  max-width: min(90vw, 460px);
  padding: 34px 40px;
}
.overlay h1 { margin: 0 0 8px; font-size: 27px; font-weight: 600; letter-spacing: .04em; }
.overlay p  { margin: 0 0 22px; color: var(--dim); font-size: 14px; line-height: 1.9; }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .06);
  font: 600 11px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
  text-align: center;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--dim);
  letter-spacing: .06em;
  pointer-events: none;
  white-space: nowrap;
}

/* 回到入口頁 */
.back {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--dim);
  text-decoration: none;
  letter-spacing: .1em;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color .2s, background .2s;
}
.back:hover { color: var(--ink); background: rgba(255, 255, 255, .06); }

/* ── 跳出的數字 ─────────────────────────────────────── */
.floaters {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}
.floater {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 700;
  letter-spacing: .02em;
  text-shadow: 0 0 10px currentColor, 0 2px 6px rgba(0, 0, 0, .85);
  white-space: nowrap;
  animation: floatUp .9s cubic-bezier(.16, .8, .3, 1) forwards;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  18%  { opacity: 1; transform: translate(-50%, -110%) scale(1.15); }
  35%  { transform: translate(-50%, -135%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -230%) scale(.92); }
}

/* ── 波次大字報 ─────────────────────────────────────── */
.banner {
  position: fixed;
  left: 50%; top: 34%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
}
.banner.show { animation: bannerIn 2.4s cubic-bezier(.16, .8, .3, 1) forwards; }
.banner .big {
  font: 800 clamp(30px, 5.4vw, 64px)/1 "Noto Sans TC", system-ui, sans-serif;
  letter-spacing: .16em;
  text-indent: .16em;
}
.banner .sub {
  margin-top: 12px;
  font-size: 13px;
  letter-spacing: .34em;
  text-indent: .34em;
  color: var(--dim);
}
@keyframes bannerIn {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.5); filter: blur(9px); }
  14%  { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(.97); }
}

/* ── 數值跳動 ───────────────────────────────────────── */
.bump { animation: bump .32s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.38); }
  100% { transform: scale(1); }
}

/* 漏怪時整個畫面邊緣染紅 */
#damage-flash {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(ellipse at center, transparent 38%, rgba(255, 40, 60, .6) 100%);
  opacity: 0;
  transition: opacity .5s ease;
}
#damage-flash.on { opacity: 1; transition: opacity .04s; }

@media (prefers-reduced-motion: reduce) {
  .floater, .banner.show { animation-duration: .01s; }
}
