/* lucky-draw — 深色投影友善主題 */
:root {
  --bg: #14141f;
  --card: #1e1e30;
  --border: #33334d;
  --ink: #f2f2f7;
  --muted: #9c9cb8;
  --accent: #ffcf5c;   /* 金 */
  --accent-2: #ff6b6b; /* 紅 */
  --ok: #4ade80;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #232342 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2 { margin: 0 0 12px; }
h2 { font-size: 1.05rem; color: var(--accent); letter-spacing: .05em; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--accent-2); }
.highlight { color: var(--accent); font-weight: 700; }

/* ---- 按鈕與輸入 ---- */
.btn {
  background: #2c2c46;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: .95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform .06s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #f5a623); color: #221a02; border: none; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.big { padding: 14px 34px; font-size: 1.15rem; border-radius: 12px; }
.btn.danger { color: var(--accent-2); }
.w-full { width: 100%; }

input, textarea, select {
  background: #16161f;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; margin-bottom: 8px; }
.w-narrow { width: 84px; flex: none; }

.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; }

/* ---- 首頁 ---- */
.landing { max-width: 560px; margin: 8vh auto; padding: 0 16px; display: grid; gap: 16px; }
.logo { font-size: 2.4rem; text-align: center; margin: 0; }
.tagline { text-align: center; color: var(--muted); margin: -6px 0 8px; }

.plain-list { list-style: none; margin: 10px 0 0; padding: 0; }
.plain-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 4px; border-bottom: 1px solid var(--border);
  font-size: .95rem;
}
.plain-list li:last-child { border-bottom: none; }
.plain-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plain-list .sub { color: var(--muted); font-size: .8rem; flex: none; }
.plain-list .won { color: var(--muted); text-decoration: line-through; }
.plain-list a { color: var(--accent); text-decoration: none; }
.scroll { max-height: 300px; overflow-y: auto; }

.icon-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: .95rem; padding: 2px 6px; border-radius: 6px; flex: none;
}
.icon-btn:hover { color: var(--accent-2); background: #2c2c46; }

/* ---- 控制台 ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; padding: 14px 20px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h1 { margin: 0; font-size: 1.3rem; }
.topbar-actions { display: flex; gap: 8px; }
.code-badge {
  background: #2c2c46; border: 1px solid var(--border); border-radius: 8px;
  padding: 3px 10px; font-family: ui-monospace, Consolas, monospace;
  letter-spacing: .15em; color: var(--accent); font-weight: 700;
}
.count-badge { color: var(--muted); font-weight: 400; font-size: .9rem; }

.stage-wrap { margin: 0 20px; text-align: center; padding: 28px 18px; position: relative; overflow: hidden; }
.stage-prize { font-size: 1.3rem; color: var(--accent-2); font-weight: 700; min-height: 1.5em; position: relative; z-index: 2; }

/* 揭曉時的旋轉金光背景 */
#stage-rays {
  position: absolute; left: 50%; top: 42%;
  width: 1400px; height: 1400px;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255, 207, 92, .13) 0deg 11deg, transparent 11deg 26deg);
  border-radius: 50%;
  opacity: 0; pointer-events: none; z-index: 0;
  animation: rays-spin 26s linear infinite;
  transition: opacity .7s ease;
}
#stage-rays.on { opacity: 1; }
@keyframes rays-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.stage-center { position: relative; z-index: 1; min-height: 340px; display: flex; align-items: center; justify-content: center; }

/* 粒子星河畫布：鋪滿舞台中央區 */
#galaxy-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 12px;
}

/* 塌縮瞬間的全螢幕閃光（JS 控制 opacity） */
#stage-flash {
  position: fixed; inset: 0; z-index: 60;
  background: radial-gradient(circle at 50% 45%, #fff 0%, rgba(255, 207, 92, .9) 28%, rgba(255, 207, 92, 0) 72%);
  opacity: 0; pointer-events: none;
}

.w-theme { max-width: 160px; }

/* 拉霸滾軸 */
.reel-viewport {
  position: relative; width: min(640px, 92%); height: 330px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}
.reel { list-style: none; margin: 0; padding: 0; will-change: transform, filter; }
.reel li {
  height: 110px; display: flex; align-items: center; justify-content: center;
  font-size: clamp(2rem, 7vw, 3.2rem); font-weight: 900; letter-spacing: .04em;
  color: #b9b9d2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reel li.reel-hit { color: var(--accent); }
.reel-band {
  position: absolute; left: 0; right: 0; top: 50%; height: 110px;
  transform: translateY(-50%); pointer-events: none;
  border-top: 1px solid rgba(255, 207, 92, .4);
  border-bottom: 1px solid rgba(255, 207, 92, .4);
  background: rgba(255, 207, 92, .05);
}
.reel-pointer {
  position: absolute; top: 50%; width: 0; height: 0; pointer-events: none;
  border-top: 12px solid transparent; border-bottom: 12px solid transparent;
  transform: translateY(-50%);
}
.reel-pointer.left { left: 6px; border-left: 16px solid var(--accent); }
.reel-pointer.right { right: 6px; border-right: 16px solid var(--accent); }

.stage-name .ch { display: inline-block; }
.stage-name {
  font-size: clamp(3rem, 11vw, 7rem);
  font-weight: 900;
  min-height: 1.35em;
  color: var(--accent);
  letter-spacing: .04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-name.winner { animation: pop .55s ease; color: #fff; text-shadow: 0 0 34px var(--accent), 0 0 8px var(--accent); }
@keyframes pop {
  0% { transform: scale(.5); opacity: .3; }
  70% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}
.stage-controls { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.stage-controls select { max-width: 260px; }

.console-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  padding: 20px;
}

.qrcode-box { background: #fff; border-radius: 10px; padding: 12px; width: fit-content; margin: 0 auto 10px; }
.qrcode-box img { display: block; }
.join-url {
  font-family: ui-monospace, Consolas, monospace; font-size: .82rem;
  word-break: break-all; color: var(--muted); margin: 8px 0;
}

/* ---- 報名頁 ---- */
.join-card {
  max-width: 420px; margin: 14vh auto; padding: 32px 26px; text-align: center;
}
.join-card input { margin: 16px 0 12px; text-align: center; font-size: 1.15rem; }
.join-card h1 { font-size: 1.6rem; }
.big-emoji { font-size: 3.4rem; margin-bottom: 6px; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #2c2c46; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 20px; z-index: 70; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}

/* ---- 全螢幕開獎模式（body.show-mode）---- */
.show-exit, .show-qr { display: none; }

body.show-mode { overflow: hidden; }
body.show-mode .topbar,
body.show-mode .console-grid { display: none; }

body.show-mode .stage-wrap {
  position: fixed; inset: 0; z-index: 40; margin: 0;
  border: none; border-radius: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 5vh 5vw;
  background:
    radial-gradient(2px 2px at 12% 18%, rgba(255, 255, 255, .8) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 12%, rgba(255, 255, 255, .6) 50%, transparent 51%),
    radial-gradient(2px 2px at 33% 74%, rgba(255, 255, 255, .5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 64% 58%, rgba(255, 255, 255, .55) 50%, transparent 51%),
    radial-gradient(1.8px 1.8px at 89% 79%, rgba(255, 255, 255, .65) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 45% 34%, rgba(255, 255, 255, .5) 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 24% 46%, rgba(255, 255, 255, .45) 50%, transparent 51%),
    radial-gradient(2px 2px at 8% 85%, rgba(255, 207, 92, .6) 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 92% 38%, rgba(255, 207, 92, .5) 50%, transparent 51%),
    radial-gradient(1200px 700px at 50% -10%, #26264a 0%, rgba(38, 38, 74, 0) 60%),
    #101020;
}
body.show-mode .stage-center { flex: 1; min-height: 0; }
body.show-mode .stage-prize { font-size: clamp(1.6rem, 3.2vw, 2.8rem); letter-spacing: .1em; }
body.show-mode .stage-name { font-size: clamp(4rem, 13vw, 11rem); }
body.show-mode #stage-rays { width: 170vmax; height: 170vmax; }
body.show-mode #galaxy-canvas { border-radius: 0; }
body.show-mode .reel-viewport { width: min(1100px, 88%); height: 54vh; }
body.show-mode .reel li { height: 18vh; font-size: clamp(3rem, 8vw, 6.5rem); }
body.show-mode .reel-band { height: 18vh; }

/* 控制列平常淡出，滑過或聚焦才現身，觀眾幾乎看不到 */
body.show-mode .stage-controls { opacity: .25; transition: opacity .25s ease; }
body.show-mode .stage-controls:hover,
body.show-mode .stage-controls:focus-within { opacity: 1; }

body.show-mode .show-exit {
  display: block;
  position: absolute; top: 16px; right: 18px; z-index: 45;
  background: none; border: 1px solid var(--border); border-radius: 10px;
  color: var(--muted); font-size: 1.05rem; padding: 6px 12px; cursor: pointer;
  opacity: .3; transition: opacity .25s ease;
}
body.show-mode .show-exit:hover { opacity: 1; color: var(--ink); }

/* 報名 QR 角落卡（報名截止時 JS 會加 hidden）*/
body.show-mode .show-qr:not([hidden]) {
  display: block;
  position: absolute; left: 24px; bottom: 24px; z-index: 45;
  text-align: center;
}
.show-qr > div { background: #fff; padding: 10px; border-radius: 10px; width: fit-content; margin: 0 auto; }
.show-qr .show-count { color: var(--accent); font-weight: 700; margin: 8px 0 0; }
.show-qr .show-scan { color: var(--muted); font-size: .85rem; margin: 2px 0 0; }

@media (max-width: 640px) {
  .stage-wrap { margin: 0 12px; }
  .console-grid { padding: 12px; gap: 12px; }
  .landing { margin-top: 4vh; }
  .reel-viewport { height: 264px; }
  .reel li { height: 88px; }
  .reel-band { height: 88px; }
  .stage-center { min-height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  #stage-rays { animation: none; }
  .stage-name.winner { animation: none; }
}
