/* ═══════════════════════════════════════════════
   CSS 變數
═══════════════════════════════════════════════ */
:root {
  --bg:           #0a0a0a;
  --bg-card:      #161616;
  --bg-admin:     #111111;
  --gold:         #FFD700;
  --gold-dim:     #997a00;
  --gold-glow:    rgba(255, 215, 0, 0.6);
  --orange:       #FF6B35;
  --white:        #FFFFFF;
  --gray:         #888888;
  --red:          #e53e3e;
  --green:        #48bb78;

  /* 滾輪尺寸（JS 也有同步常數） */
  --item-height:  16vmin;
  --item-font:    9vmin;
  --reel-visible: 3;          /* 顯示幾個 item */

  /* 得獎者大字 */
  --winner-font:  clamp(4rem, 14vw, 18rem);
  --prize-label-font: clamp(1.5rem, 4vw, 5rem);
}

/* ═══════════════════════════════════════════════
   Reset & Base
═══════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: 'Noto Sans TC', 'Microsoft JhengHei', 'PingFang TC', sans-serif;
  background: var(--bg);
  color: var(--gold);
  -webkit-font-smoothing: antialiased;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: inherit;
}

/* ═══════════════════════════════════════════════
   Scene 切換系統
═══════════════════════════════════════════════ */
.scene {
  display: none;
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
}
.scene.active {
  display: flex;
}


/* ═══════════════════════════════════════════════
   ▌Scene A：Admin Panel
═══════════════════════════════════════════════ */
#scene-admin {
  background: var(--bg-admin);
  color: #cccccc;
  overflow: auto;
  position: relative;
}

.admin-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 32px;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  min-height: 100vh;
  align-content: start;
}

.admin-title {
  grid-column: 1 / -1;
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.card.flex-card {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.card-title {
  font-size: clamp(1rem, 1.8vw, 1.4rem);
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Textarea */
#name-input {
  width: 100%;
  min-height: 180px;
  background: #0f0f0f;
  border: 1px solid #333;
  border-radius: 8px;
  color: #ddd;
  font-family: inherit;
  font-size: 1rem;
  padding: 12px;
  resize: vertical;
  line-height: 1.8;
  transition: border-color 0.2s;
}
#name-input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

/* Button row */
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: clamp(0.85rem, 1.2vw, 1rem);
  font-weight: 700;
  transition: all 0.15s ease;
  letter-spacing: 0.5px;
}
.btn-secondary {
  background: #2a2a2a;
  color: #ccc;
  border: 1px solid #444;
}
.btn-secondary:hover {
  background: #333;
  color: #fff;
  border-color: var(--gold-dim);
}
.btn-primary {
  background: var(--gold);
  color: #000;
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  padding: 14px 36px;
  border-radius: 10px;
  font-weight: 900;
  box-shadow: 0 0 24px rgba(255,215,0,0.3);
  transition: all 0.2s ease;
}
.btn-primary:hover {
  background: #ffe033;
  box-shadow: 0 0 40px rgba(255,215,0,0.5);
  transform: translateY(-2px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-danger {
  background: transparent;
  color: #e06060;
  border: 1px solid #5a2a2a;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  transition: all 0.15s;
}
.btn-danger:hover {
  background: #2a1010;
  border-color: var(--red);
  color: #ff8080;
}

.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

/* Prize display */
#prize-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.prize-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1a1a1a;
  border-radius: 8px;
  border-left: 3px solid var(--gold-dim);
  transition: border-color 0.3s;
}
.prize-row.prize-done {
  border-left-color: var(--green);
  opacity: 0.6;
}
.prize-row.prize-current {
  border-left-color: var(--orange);
  background: #1e1500;
}
.prize-name {
  font-size: clamp(0.9rem, 1.3vw, 1.1rem);
  font-weight: 700;
  color: #ddd;
}
.prize-row.prize-current .prize-name {
  color: var(--gold);
}
.prize-meta {
  font-size: 0.85rem;
  color: var(--gray);
  white-space: nowrap;
}

/* Badge */
.badge {
  background: #2a2a2a;
  color: var(--gold);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid #3a3a3a;
}

/* Participant list */
.scroll-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.scroll-list::-webkit-scrollbar {
  width: 5px;
}
.scroll-list::-webkit-scrollbar-track { background: transparent; }
.scroll-list::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

.participant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  background: #1a1a1a;
  font-size: 0.95rem;
  color: #ccc;
  transition: background 0.1s;
}
.participant-item:hover { background: #222; }
.participant-item.drawn {
  opacity: 0.4;
  text-decoration: line-through;
  color: var(--green);
}
.btn-remove {
  background: none;
  color: #555;
  font-size: 1rem;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.1s;
}
.btn-remove:hover { color: var(--red); }

/* Winners list in admin */
.winners-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.winner-row {
  padding: 8px 12px;
  background: #1a1f0f;
  border-left: 3px solid var(--green);
  border-radius: 6px;
  font-size: 0.95rem;
  color: #bbb;
}
.winner-row .winner-prize { color: var(--green); font-size: 0.8rem; }
.winner-row .winner-name { font-weight: 700; color: #fff; font-size: 1rem; }

/* Admin right column */
.admin-right {
  display: flex;
  flex-direction: column;
}
.admin-right .card.flex-card {
  flex: 1;
  min-height: 0;
}


/* ═══════════════════════════════════════════════
   ▌Scene B：Draw Screen
═══════════════════════════════════════════════ */
#scene-draw {
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  padding: clamp(20px, 4vh, 50px) 24px;
  position: relative;
}

.draw-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  gap: 16px;
}

/* Prize badge at top */
.draw-header {
  text-align: center;
  padding-top: 8px;
}
.prize-badge {
  font-size: var(--prize-label-font);
  font-weight: 900;
  color: var(--orange);
  letter-spacing: 2px;
  text-shadow: 0 0 30px rgba(255, 107, 53, 0.5);
  line-height: 1.2;
  padding: 0 40px;
}

/* Reel container */
.reel-container {
  position: relative;
  width: min(85vw, 860px);
}

.reel-wrapper {
  height: calc(var(--item-height) * var(--reel-visible));
  overflow: hidden;
  border: 2px solid #2a2a2a;
  border-radius: 16px;
  background: #050505;
  position: relative;
}

.reel-strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
  transform: translateY(0);
}

.reel-item {
  height: var(--item-height);
  min-height: var(--item-height);
  max-height: var(--item-height);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--item-font);
  font-weight: 900;
  color: #666;
  flex-shrink: 0;
  padding: 0 20px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 2px;
}
.reel-item.is-winner {
  color: var(--gold);
  text-shadow: 0 0 40px var(--gold-glow);
}
.reel-placeholder {
  color: #333;
  font-size: 2vmin;
  font-weight: 400;
}

/* 中央高亮框 */
.reel-center-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: var(--item-height);
  transform: translateY(-50%);
  border-top: 2px solid var(--gold-dim);
  border-bottom: 2px solid var(--gold-dim);
  box-shadow: 0 0 12px var(--gold-dim) inset,
              0 -1px 0 rgba(255,215,0,0.1),
              0  1px 0 rgba(255,215,0,0.1);
  pointer-events: none;
  z-index: 2;
}

/* 漸層遮罩 */
.reel-mask {
  position: absolute;
  left: 0;
  right: 0;
  height: 33%;
  z-index: 3;
  pointer-events: none;
}
.reel-mask-top {
  top: 0;
  background: linear-gradient(to bottom, #050505 0%, transparent 100%);
  border-radius: 14px 14px 0 0;
}
.reel-mask-bottom {
  bottom: 0;
  background: linear-gradient(to top, #050505 0%, transparent 100%);
  border-radius: 0 0 14px 14px;
}

/* Footer */
.draw-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
}

.remaining-count {
  font-size: clamp(0.9rem, 1.5vw, 1.2rem);
  color: var(--gray);
  letter-spacing: 1px;
}

.btn-spin {
  background: var(--gold);
  color: #000;
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  font-weight: 900;
  padding: clamp(12px, 2vh, 20px) clamp(40px, 6vw, 80px);
  border-radius: 50px;
  letter-spacing: 4px;
  box-shadow: 0 0 40px rgba(255,215,0,0.4), 0 4px 20px rgba(0,0,0,0.5);
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}
.btn-spin::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
}
.btn-spin:hover {
  background: #ffe033;
  box-shadow: 0 0 60px rgba(255,215,0,0.6), 0 4px 24px rgba(0,0,0,0.6);
  transform: translateY(-2px) scale(1.02);
}
.btn-spin:active {
  transform: translateY(0) scale(0.98);
}
.btn-spin:disabled {
  background: #444;
  color: #666;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

.shortcut-hints {
  display: flex;
  gap: 20px;
  color: #333;
  font-size: clamp(0.7rem, 1vw, 0.85rem);
  letter-spacing: 1px;
}
.shortcut-hints span::before {
  content: '⌨ ';
}

/* 返回管理小按鈕 */
.btn-back {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255,255,255,0.04);
  color: #444;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 1.2rem;
  transition: all 0.15s;
  z-index: 10;
}
.btn-back:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: rgba(255,215,0,0.05);
}


/* ═══════════════════════════════════════════════
   ▌Scene C：Winner Reveal
═══════════════════════════════════════════════ */
#scene-reveal {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
}

#confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.reveal-layout {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vh, 28px);
  padding: 20px;
  text-align: center;
  width: 100%;
}

.reveal-prize-label {
  font-size: var(--prize-label-font);
  font-weight: 900;
  color: var(--orange);
  letter-spacing: 3px;
  text-shadow: 0 0 20px rgba(255,107,53,0.4);
  opacity: 0;
}

.reveal-winner {
  font-size: var(--winner-font);
  font-weight: 900;
  color: var(--gold);
  text-shadow:
    0 0 40px var(--gold-glow),
    0 0 80px rgba(255,215,0,0.3),
    0 0 140px rgba(255,215,0,0.15);
  line-height: 1.1;
  max-width: 92vw;
  word-break: break-word;
  opacity: 0;
}

.reveal-subtitle {
  font-size: clamp(1.2rem, 3vw, 2.5rem);
  color: #ffffff;
  opacity: 0;
  letter-spacing: 2px;
}

.btn-next {
  background: var(--gold);
  color: #000;
  font-size: clamp(1rem, 2vw, 1.5rem);
  font-weight: 900;
  padding: 14px 44px;
  border-radius: 50px;
  letter-spacing: 2px;
  box-shadow: 0 0 30px rgba(255,215,0,0.3);
  transition: all 0.15s ease;
  opacity: 0;
  margin-top: 8px;
}
.btn-next:hover {
  background: #ffe033;
  box-shadow: 0 0 50px rgba(255,215,0,0.5);
  transform: translateY(-2px);
}
.btn-next.visible { opacity: 1; }


/* ═══════════════════════════════════════════════
   ▌IG 爬蟲區塊（Admin）
═══════════════════════════════════════════════ */
.ig-scrape-card {
  border-color: #2a2a3a;
}
.ig-badge {
  background: #1a1a3a;
  color: #8080ff;
  border: 1px solid #3a3a6a;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
}
.btn-ig {
  background: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: clamp(0.85rem, 1.2vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: all 0.15s ease;
  cursor: pointer;
}
.btn-ig:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}
.ig-scrape-section {
  border-top: 1px solid #1f1f1f;
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ig-field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ig-label {
  font-size: 0.82rem;
  color: #777;
  font-weight: 700;
}
.ig-hint-link {
  color: #5566aa;
  font-size: 0.78rem;
  text-decoration: none;
}
.ig-hint-link:hover { text-decoration: underline; }
.ig-input {
  background: #0f0f0f;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  color: #ccc;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  transition: border-color 0.2s;
  width: 100%;
}
.ig-input:focus {
  outline: none;
  border-color: #5566aa;
}
.ig-url-textarea {
  resize: vertical;
  min-height: 72px;
  font-size: 0.82rem;
  line-height: 1.6;
}
.btn-scrape-main {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
}
.ig-scrape-note {
  font-size: 0.76rem;
  color: #444;
  align-self: center;
}

/* 管理頁名單：IG 小頭貼 + 留言預覽 */
.participant-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 4px;
  border: 1px solid #333;
}
.participant-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.participant-comment {
  font-size: 0.76rem;
  color: #555;
  flex-shrink: 0;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0 6px;
}


/* ═══════════════════════════════════════════════
   ▌IG 揭曉元素（Reveal Scene）
═══════════════════════════════════════════════ */

/* IG 模式：縮小 winner 字體，讓大頭貼有空間 */
.reveal-layout.ig-mode .reveal-winner {
  font-size: clamp(2.4rem, 7vw, 9rem);
}

/* 大頭貼容器 */
.reveal-ig-avatar-wrap {
  position: relative;
  z-index: 2;
  justify-content: center;
  align-items: center;
}

/* 圓形大頭貼 */
.reveal-ig-avatar {
  width:  clamp(90px, 16vmin, 200px);
  height: clamp(90px, 16vmin, 200px);
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--gold);
  box-shadow:
    0 0 0 2px rgba(255,215,0,0.2),
    0 0 40px var(--gold-glow),
    0 0 80px rgba(255,215,0,0.15);
  display: block;
}

/* 留言容器 */
.reveal-ig-comment-wrap {
  position: relative;
  z-index: 2;
  justify-content: center;
  align-items: center;
  max-width: min(80vw, 860px);
}

/* 留言氣泡 */
.reveal-ig-comment {
  font-size: clamp(1.1rem, 2.2vw, 2rem);
  color: rgba(255, 255, 255, 0.88);
  text-align: center;
  font-style: italic;
  line-height: 1.55;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 215, 0, 0.15);
  border-left: 3px solid var(--gold-dim);
  border-radius: 0 10px 10px 0;
  position: relative;
  word-break: break-word;
}
.reveal-ig-comment::before {
  content: '"';
  font-size: 2.5em;
  color: var(--gold-dim);
  line-height: 0;
  vertical-align: -0.4em;
  margin-right: 4px;
  font-style: normal;
}
.reveal-ig-comment::after {
  content: '"';
  font-size: 2.5em;
  color: var(--gold-dim);
  line-height: 0;
  vertical-align: -0.4em;
  margin-left: 4px;
  font-style: normal;
}


/* ═══════════════════════════════════════════════
   Toast 通知
═══════════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #222;
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 700;
  border: 1px solid #444;
  z-index: 9999;
  transition: transform 0.3s ease;
  white-space: nowrap;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
}


/* ═══════════════════════════════════════════════
   Responsive（手機 / 直向）
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .admin-layout {
    grid-template-columns: 1fr;
    padding: 20px;
  }
  .admin-title { font-size: 1.4rem; }
  :root {
    --item-height: 20vmin;
    --item-font: 11vmin;
  }
}

@media (max-height: 600px) {
  :root {
    --item-height: 22vmin;
    --item-font: 13vmin;
  }
  .draw-footer { gap: 6px; }
  .shortcut-hints { display: none; }
}
