/* NBD Quest - Main stylesheet */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: linear-gradient(135deg, #f0f4ff 0%, #fdf4ff 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ============ Login ============ */
.page-login { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%); }
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--card-bg); padding: 40px; border-radius: 24px;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 440px;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-header .logo { font-size: 56px; margin-bottom: 12px; }
.login-header h1 { margin: 0 0 6px; color: var(--primary-dark); font-size: 1.8rem; }
.login-header p { color: var(--text-secondary); margin: 0; }
.login-step label {
  display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 8px; color: #374151;
}
.login-step input {
  width: 100%; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 1rem; margin-bottom: 16px; transition: border-color .2s, box-shadow .2s;
}
.login-step input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.email-input-wrap {
  position: relative; display: flex; align-items: stretch; border: 1.5px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 16px;
  transition: border-color .2s, box-shadow .2s; background: #fff;
}
.email-input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.email-input-wrap input {
  flex: 1; border: none !important; padding: 14px 12px 14px 16px; font-size: 1rem; margin: 0 !important;
  outline: none; background: transparent;
}
.email-input-wrap .email-suffix {
  display: flex; align-items: center; padding: 0 14px; background: #f3f4f6; color: var(--text-secondary);
  font-size: 0.92rem; border-left: 1px solid var(--border); white-space: nowrap;
}
/* email-input-left：輸入框靠左、緊貼 @nbd-ai.com 域名 */
.email-input-wrap.email-input-left { justify-content: flex-start; }
.email-input-wrap.email-input-left input {
  flex: 0 1 auto; width: auto; min-width: 80px; max-width: 200px;
  padding-right: 4px; text-align: right; font-weight: 600;
}
.email-input-wrap.email-input-left .email-suffix {
  border-left: none; background: transparent; padding: 0 14px 0 0; color: var(--primary-dark);
  font-weight: 600;
}

/* OTP 6 格輸入 */
.otp-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 16px;
}
.otp-cell {
  width: 100%; padding: 14px 0 !important; text-align: center;
  font-size: 1.6rem !important; font-weight: 800; font-family: monospace;
  border: 1.5px solid var(--border); border-radius: 12px;
  background: #fff; transition: border-color .15s, box-shadow .15s;
  margin: 0 !important;
}
.otp-cell:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
@media (max-width: 420px) {
  .otp-grid { gap: 6px; }
  .otp-cell { font-size: 1.3rem !important; padding: 10px 0 !important; }
}
.divider {
  display: flex; align-items: center; gap: 12px; margin: 16px 0 14px;
  color: var(--text-secondary); font-size: 0.78rem;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.hint { color: var(--text-secondary); font-size: 0.85rem; margin: -10px 0 14px; }
.countdown { text-align: center; color: var(--text-secondary); font-size: 0.85rem; margin-top: 12px; }
.msg { margin-top: 10px; font-size: 0.88rem; min-height: 18px; }
.msg.error { color: var(--danger); }
.msg.success { color: var(--success); }

/* ============ Buttons ============ */
.btn {
  border: none; padding: 12px 20px; border-radius: 10px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: transform .12s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 16px rgba(99,102,241,0.4); }
.btn-secondary { background: #f3f4f6; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #e5e7eb; }
.btn-accent { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover:not(:disabled) { background: #d97706; }
.btn-link { background: transparent; color: var(--text-secondary); }
.btn-link:hover { color: var(--primary); }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.hidden { display: none !important; }

/* ============ App layout ============ */
.app { max-width: 1100px; margin: 0 auto; padding: 16px; }
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg); padding: 16px 20px; border-radius: 16px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 32px; }
.brand h1 { font-size: 1.3rem; margin: 0; color: var(--primary-dark); line-height: 1.2; }
.brand-sub {
  font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; letter-spacing: 0.5px;
}
.user-bar { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.user-bar .me-name { color: var(--text); font-weight: 600; }
.user-bar .me-email { color: var(--text-secondary); font-size: 0.78rem; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem;
  font-weight: 600;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fee2e2; color: #991b1b; }
.badge-mute { background: #f3f4f6; color: var(--text-secondary); }
.badge-locked { background: #ede9fe; color: #5b21b6; }
.badge-top-vote {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #7c2d12; font-weight: 800;
  box-shadow: 0 2px 6px rgba(245,158,11,0.4);
  animation: topVotePulse 1.6s ease-in-out infinite;
}
@keyframes topVotePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.wish-card.is-top-vote {
  border: 2px solid #fbbf24; box-shadow: 0 8px 24px rgba(251,191,36,0.25);
}

/* Tabs */
.tabs { display: flex; gap: 4px; background: var(--card-bg); border-radius: 14px; padding: 4px; margin-bottom: 16px; box-shadow: var(--shadow); overflow-x: auto; }
.tab {
  flex: 1; padding: 10px 12px; text-align: center; cursor: pointer; border-radius: 10px;
  color: var(--text-secondary); font-weight: 600; white-space: nowrap; font-size: 0.9rem;
}
.tab.active { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff; box-shadow: 0 2px 6px rgba(99,102,241,0.3); }
.tab:hover:not(.active) { background: #eef2ff; color: var(--primary-dark); }

.subtabs {
  display: flex; gap: 4px; background: rgba(255,255,255,0.6); border-radius: 12px; padding: 4px;
  margin-bottom: 12px; overflow-x: auto;
}
.subtab {
  padding: 8px 14px; cursor: pointer; border-radius: 8px; font-size: 0.85rem; font-weight: 600;
  color: var(--text-secondary); white-space: nowrap;
}
.subtab.active { background: var(--card-bg); color: var(--primary-dark); box-shadow: var(--shadow); }
.subtab:hover:not(.active) { color: var(--primary-dark); }

.panel { display: none; }
.panel.active { display: block; }
.subpanel { display: none; }
.subpanel.active { display: block; }

.card {
  background: var(--card-bg); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 12px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 12px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 0.95rem; font-family: inherit;
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 12px; }
.alert-info { background: #dbeafe; color: #1e40af; }
.alert-warn { background: #fef3c7; color: #92400e; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }

/* ============ Tooltips (?) ============ */
.tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  cursor: help; margin-left: 4px; position: relative; vertical-align: middle;
  flex-shrink: 0;
}
.tip-body {
  display: none; position: absolute; z-index: 50;
  bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 10px 12px;
  border-radius: 8px; min-width: 220px; max-width: 320px;
  font-size: 0.78rem; font-weight: 400; line-height: 1.5;
  white-space: normal; text-align: left;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.tip-body code {
  background: rgba(255,255,255,0.15); padding: 1px 4px; border-radius: 3px;
  color: #fde68a; font-family: monospace;
}
.tip-body::after {
  content: ''; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%); border: 6px solid transparent;
  border-top-color: #1f2937;
}
.tip:hover .tip-body, .tip:focus .tip-body, .tip:active .tip-body { display: block; }
@media (max-width: 700px) {
  .tip-body { min-width: 180px; max-width: 240px; left: auto; right: -4px; transform: none; }
  .tip-body::after { left: auto; right: 6px; transform: none; }
}

/* ============ Rules card ============ */
.rules-card { background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%); }
.rule-tagline {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); color: #78350f;
  padding: 14px 18px; border-radius: 12px; margin-bottom: 18px; font-size: 1.05rem;
  border-left: 4px solid #f59e0b;
}
.rule-h3 {
  margin: 22px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--primary-light);
  color: var(--primary-dark); font-size: 1.05rem;
}
.rule-list { padding-left: 22px; line-height: 1.9; }
.rule-list li { margin-bottom: 4px; }
.rule-list li.formula {
  background: #f8fafc; border-left: 3px solid var(--primary); padding: 8px 12px;
  border-radius: 0 8px 8px 0; margin: 8px 0; list-style: none; margin-left: -22px;
}
.rule-list li.formula code {
  background: #eef2ff; padding: 1px 6px; border-radius: 4px; color: var(--primary-dark); font-weight: 700;
}
.rule-origin {
  background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%);
  border-left: 4px solid #ec4899; padding: 14px 18px; border-radius: 12px;
  margin: 12px 0 18px; line-height: 1.85; color: #831843;
}
.rule-origin p { margin: 0 0 10px; }
.rule-origin p:last-child { margin-bottom: 0; }

.early-bird-box {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-left: 4px solid #fbbf24; padding: 14px 18px; border-radius: 12px;
  margin: 6px 0 18px; line-height: 1.7;
}

.hl { background: #fef3c7; padding: 1px 6px; border-radius: 4px; color: #78350f; font-weight: 700; }
.hl-warn { background: #fee2e2; padding: 1px 6px; border-radius: 4px; color: #991b1b; font-weight: 700; }
.hl-success { background: #d1fae5; padding: 1px 6px; border-radius: 4px; color: #065f46; font-weight: 700; }
.hl-info { background: #dbeafe; padding: 1px 6px; border-radius: 4px; color: #1e40af; font-weight: 700; }

/* Timeline */
.timeline {
  display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; gap: 8px;
  margin: 16px 0 8px; align-items: stretch;
}
.tl-stage {
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border-radius: 12px; padding: 14px 12px; text-align: center;
  border-top: 4px solid var(--primary); min-height: 110px;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.tl-stage.tl-wish    { background: linear-gradient(135deg, #d1fae5, #a7f3d0); border-top-color: #10b981; }
.tl-stage.tl-review  { background: linear-gradient(135deg, #fef3c7, #fde68a); border-top-color: #f59e0b; }
.tl-stage.tl-vote    { background: linear-gradient(135deg, #dbeafe, #bfdbfe); border-top-color: #3b82f6; }
.tl-stage.tl-draw    { background: linear-gradient(135deg, #fce7f3, #fbcfe8); border-top-color: #ec4899; }
.tl-day { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 4px; }
.tl-title { font-weight: 800; font-size: 1rem; color: var(--text); margin-bottom: 6px; }
.tl-desc { font-size: 0.78rem; color: var(--text); line-height: 1.5; }
.tl-arrow { display: flex; align-items: center; justify-content: center; color: var(--primary); font-weight: 800; }
@media (max-width: 800px) {
  .timeline { grid-template-columns: 1fr; }
  .tl-arrow { transform: rotate(90deg); padding: 4px 0; min-height: auto; }
}

/* Example table */
.example-table-wrap { overflow-x: auto; margin: 8px 0 4px; }
.example-table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.example-table th, .example-table td { padding: 8px 10px; border: 1px solid var(--border); text-align: center; }
.example-table th { background: var(--primary-dark); color: #fff; font-weight: 700; }
.example-table tbody tr.rA { background: rgba(209, 250, 229, 0.4); }
.example-table tbody tr.rB { background: rgba(219, 234, 254, 0.4); }
.example-table tbody tr.rC { background: rgba(252, 231, 243, 0.4); }
.example-table tbody tr.rD { background: rgba(254, 243, 199, 0.5); }
.example-table td:first-child { background: #f9fafb; font-weight: 700; }

/* Month blocks（範例的三個月份各自獨立卡片，以邊框＋色帶區分） */
.month-block {
  border-radius: 14px;
  padding: 0 0 4px;
  margin: 16px 0;
  border: 2px solid;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  overflow: hidden;
}
.month-block .example-table-wrap { padding: 0 12px 8px; }
.month-block-header {
  font-weight: 800;
  font-size: 1.05rem;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.month-tag {
  font-size: 0.78rem;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 700;
  background: rgba(255,255,255,0.85);
}

.month-block.month-1 {
  border-color: #10b981;
}
.month-block.month-1 .month-block-header {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}
.month-block.month-1 .month-tag { color: #047857; }

.month-block.month-2 {
  border-color: #f59e0b;
  box-shadow: 0 6px 22px rgba(245,158,11,0.22);
}
.month-block.month-2 .month-block-header {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}
.month-block.month-2 .month-tag { color: #b45309; }

.month-block.month-3 {
  border-color: #6366f1;
}
.month-block.month-3 .month-block-header {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
}
.month-block.month-3 .month-tag { color: #4338ca; }

/* Wish cards / vote */
.wish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.wish-card {
  background: #fff; border-radius: 14px; border: 1px solid var(--border); overflow: hidden;
  display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s;
}
.wish-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.wish-card .img {
  width: 100%; aspect-ratio: 4 / 3; background: #f3f4f6 center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; color: var(--text-secondary); font-size: 2rem;
}
.wish-card .body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; }
.wish-card h3 { margin: 0 0 6px; font-size: 1rem; color: var(--text); }
.wish-card .desc { color: var(--text-secondary); font-size: 0.85rem; flex: 1; white-space: pre-wrap; word-break: break-word; }
.wish-card .meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 0.8rem; color: var(--text-secondary); flex-wrap: wrap; }
.wish-card .vote-row { display: flex; gap: 6px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.vote-count { background: var(--primary); color: #fff; padding: 3px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; }
.purchase-link {
  display: inline-block; margin-top: 8px; padding: 4px 10px;
  background: #eef2ff; color: var(--primary-dark); text-decoration: none;
  border-radius: 8px; font-size: 0.82rem; font-weight: 600;
  border: 1px solid #c7d2fe; transition: all .15s;
}
.purchase-link:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

table.list { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.list th, table.list td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
table.list th { color: var(--text-secondary); font-weight: 600; background: #f9fafb; }
table.list tr.is-winner { background: #fffbeb; }
.scrollable { max-height: 400px; overflow: auto; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; }
.kv .k { color: var(--text-secondary); font-size: 0.85rem; }
.kv .v { color: var(--text); font-weight: 600; }

.score-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); color: #92400e; font-weight: 700; font-size: 0.85rem;
}

.cd {
  display: inline-block; margin-left: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600;
}
.cd-future { background: #dbeafe; color: #1e40af; font-family: monospace; }
.cd-past   { background: #f3f4f6; color: var(--text-secondary); font-family: monospace; }
.cd-tick { font-variant-numeric: tabular-nums; }
.cd-tick-anim { animation: cdPulse 2s ease-in-out infinite; }
@keyframes cdPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
  50%      { box-shadow: 0 0 0 4px rgba(59,130,246,0.18); }
}

/* 投票尚未開放（鎖定卡片） */
.vote-locked-card {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b; border-radius: 18px;
  padding: 36px 28px; text-align: center; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.vote-locked-icon { font-size: 3rem; margin-bottom: 8px; }
.vote-locked-title {
  margin: 0 0 14px; color: #92400e; font-size: 1.4rem; font-weight: 800;
}
.vote-locked-body {
  background: rgba(255,255,255,0.7); border-radius: 12px;
  padding: 14px 16px; color: #78350f; font-size: 0.95rem;
  margin-bottom: 12px; line-height: 1.7;
}
.vote-locked-body .vc-big-cd {
  display: block; font-size: 1.7rem; font-weight: 800; font-family: monospace;
  color: #b45309; letter-spacing: 1px; margin: 4px 0;
}
.vote-locked-hint {
  color: #78350f; font-size: 0.88rem; line-height: 1.6;
}
/* 投票面板鎖定狀態：所有 vote-can-interact 都暗化、停用 */
#panel-vote.vote-is-locked .vote-can-interact {
  display: none !important;
}

/* 投票流程式（垂直步驟） */
.vote-flow {
  display: flex; flex-direction: column; gap: 0;
}
.vote-step {
  display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: stretch;
}
.vote-step-num {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 1.5rem; font-weight: 900; font-family: monospace;
  border-radius: 50%; width: 56px; height: 56px; align-self: flex-start;
  margin-top: 14px; box-shadow: 0 4px 12px rgba(99,102,241,0.35);
  position: relative; z-index: 2;
}
.vote-step-body {
  margin-bottom: 0;
}
.vote-step-title {
  margin: 0 0 8px; font-size: 1.05rem; color: var(--primary-dark);
  display: flex; align-items: center; gap: 8px;
}
.vote-step-content { font-size: 0.92rem; }
.vote-step-arrow {
  color: var(--primary-light); font-size: 1.4rem; text-align: center;
  padding: 4px 0; margin-left: 28px;
  font-weight: 700;
}
.vote-step-status {
  display: inline-flex; align-items: center; padding: 0 12px;
  border-radius: 8px; font-size: 0.82rem; font-weight: 700;
  background: #f3f4f6; color: var(--text-secondary); white-space: nowrap;
}
.vote-step-status.is-set { background: #d1fae5; color: #065f46; }
.vote-step-status.is-unset { background: #fee2e2; color: #991b1b; }
.vote-step-status.is-locked { background: #ede9fe; color: #5b21b6; }

/* 「我是誰」輸入框與其他表單欄位一致 */
.vote-display-name-row {
  display: flex; gap: 8px; align-items: stretch;
}
.form-input {
  flex: 1; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 0.95rem; font-family: inherit; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.form-input:disabled { background: #f3f4f6; color: var(--text-secondary); cursor: not-allowed; }

.vote-meta-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; margin-top: 10px;
}
.vote-meta-label { font-size: 0.82rem; color: var(--text-secondary); margin-right: 6px; }

/* 上月投票狀況區塊 */
.prev-period-card {
  margin-top: 10px; padding: 12px 16px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
}
.prev-period-card h4 { margin: 0 0 8px; font-size: 0.95rem; color: var(--primary-dark); }
.prev-period-card .pp-row { font-size: 0.88rem; margin-bottom: 6px; line-height: 1.55; }
.prev-period-card .pp-account {
  color: #94a3b8; font-family: monospace; font-size: 0.8rem;
}
.prev-period-card .pp-top3 {
  margin: 8px 0 0; padding-left: 22px; font-size: 0.88rem; line-height: 1.7;
}

/* mywish 預覽 */
.mywish-preview {
  display: grid; grid-template-columns: 80px 1fr; gap: 12px;
  background: #f9fafb; border-radius: 10px; padding: 10px; align-items: center;
}
.mywish-preview .mw-img {
  width: 80px; height: 60px; background: #e5e7eb center/cover no-repeat;
  border-radius: 6px;
}
.mywish-preview .mw-name { font-weight: 700; font-size: 0.95rem; }
.mywish-preview .mw-desc {
  font-size: 0.78rem; color: var(--text-secondary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.mywish-missing {
  background: #fee2e2; color: #991b1b; padding: 12px 16px;
  border-radius: 10px; border-left: 4px solid #ef4444; font-weight: 600;
}
.mywish-missing a {
  color: #7f1d1d; text-decoration: underline; font-weight: 700;
}

/* 最終儲存按鈕卡片 */
.vote-save-card {
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border: 2px solid var(--primary-light);
}
.vote-save-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.vote-save-title { margin: 0 0 4px; font-size: 1.05rem; color: var(--primary-dark); }
.vote-save-hint { color: var(--text-secondary); font-size: 0.85rem; }
.vote-save-card .btn { font-size: 1rem; padding: 14px 28px; }

@media (max-width: 600px) {
  .vote-step { grid-template-columns: 44px 1fr; gap: 10px; }
  .vote-step-num { width: 44px; height: 44px; font-size: 1.2rem; margin-top: 12px; }
  .vote-step-arrow { margin-left: 22px; }
}

/* 投票完成度 checklist */
.vote-checklist-summary {
  padding: 14px 18px; border-radius: 12px; font-weight: 700;
  font-size: 1rem; margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.vote-checklist-summary.is-complete {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46;
  border: 2px solid #10b981;
}
.vote-checklist-summary.is-incomplete {
  background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b;
  border: 2px solid #ef4444;
}
.vote-checklist-summary.is-warn {
  background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e;
  border: 2px solid #f59e0b;
}
.vote-checklist-summary .vc-emoji { font-size: 1.5rem; }
.vote-checklist-list {
  display: flex; flex-direction: column; gap: 6px;
}
.vc-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px; background: #f9fafb;
  font-size: 0.9rem;
}
.vc-item.ok { background: #ecfdf5; color: #065f46; }
.vc-item.fail { background: #fef2f2; color: #991b1b; font-weight: 600; }
.vc-item.skip { background: #f3f4f6; color: var(--text-secondary); }
.vc-item .vc-icon { width: 22px; text-align: center; font-size: 1.05rem; }

/* 我的猜獎號碼（強調） */
.guess-block {
  margin-top: 14px; padding: 14px 16px;
  background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
  border: 2px solid #fb923c; border-radius: 14px;
}
.guess-block-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 10px;
}
.guess-block-header label {
  font-weight: 700; color: #9a3412; font-size: 1rem; margin: 0;
}
.guess-block-header label .tip { background: #ea580c; }
.guess-controls {
  display: grid; grid-template-columns: 1fr 110px auto; gap: 10px; align-items: center;
}
.guess-controls input[type=range] {
  -webkit-appearance: none; width: 100%; height: 8px; border-radius: 999px;
  background: linear-gradient(to right, #fbbf24, #ef4444); outline: none;
  cursor: pointer; padding: 0; border: none;
}
.guess-controls input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid #ea580c; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.guess-controls input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid #ea580c; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.guess-controls input[type=number] {
  padding: 8px 10px; border: 2px solid #fb923c; border-radius: 8px;
  font-size: 1.1rem; font-weight: 700; text-align: center; font-family: monospace;
  color: #9a3412; background: #fff;
}
.guess-controls input[type=number]:focus {
  outline: none; border-color: #ea580c; box-shadow: 0 0 0 3px rgba(234,88,12,0.2);
}
.guess-meta { margin-top: 8px; font-size: 0.85rem; color: #7c2d12; }
.guess-meta .guess-saved.is-set { color: #065f46; font-weight: 700; }
.guess-meta .guess-saved.is-unset { color: #b91c1c; font-weight: 700; }
@media (max-width: 600px) {
  .guess-controls { grid-template-columns: 1fr; gap: 8px; }
}

/* 「沒有中意的」投票卡 */
.wish-card.none-of-above {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border: 2px dashed #94a3b8;
}
.wish-card.none-of-above .img {
  background: #cbd5e1; font-size: 3rem; color: #475569;
}
.wish-card.none-of-above h3 { color: #334155; }
.wish-card.none-of-above .desc { color: #475569; font-style: italic; }

/* 早鳥特權卡片 */
.early-bird-card {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 2px solid #fbbf24;
}
.early-bird-card .card-title { color: #78350f; }
.early-bird-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: rgba(255,255,255,0.7); padding: 14px 18px; border-radius: 12px; margin-top: 12px;
}
.early-bird-info { flex: 1; }
.early-bird-label { font-weight: 700; color: #92400e; font-size: 1rem; }
.early-bird-sub { color: #78350f; font-size: 0.85rem; margin-top: 4px; }
.early-bird-locked-note {
  margin-top: 12px; background: rgba(255,255,255,0.7); padding: 12px 16px;
  border-radius: 10px; color: #78350f; font-size: 0.88rem; line-height: 1.6;
}
.eb-status-line {
  background: rgba(255,255,255,0.6); padding: 10px 14px; border-radius: 8px;
  color: #78350f; font-size: 0.9rem; margin-bottom: 8px;
}
.eb-status-line b { color: #92400e; }
.eb-status-line.eb-not-eligible {
  background: rgba(255,255,255,0.5); color: #6b7280;
}
.eb-status-line.eb-not-eligible .card-sub { color: #6b7280; line-height: 1.55; }

/* iOS 風格開關 */
.switch {
  position: relative; display: inline-block; width: 56px; height: 32px; flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #d1d5db; border-radius: 999px; transition: .25s;
}
.switch .slider::before {
  content: ''; position: absolute; height: 26px; width: 26px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: .25s; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: linear-gradient(135deg, #f59e0b, #d97706); }
.switch input:checked + .slider::before { transform: translateX(24px); }
.switch input:disabled + .slider { opacity: 0.5; cursor: not-allowed; }

/* 通用 Modal */
.qm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 250;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.qm-dialog {
  background: #fff; border-radius: 18px; max-width: 440px; width: 100%;
  padding: 28px 28px 22px; box-shadow: var(--shadow-lg);
}
.qm-title { font-size: 1.15rem; font-weight: 800; color: var(--text); margin: 0 0 10px; }
.qm-body { color: var(--text); font-size: 0.95rem; line-height: 1.6; margin-bottom: 18px; }
.qm-body code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-size: 0.88em; }
.qm-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* 投票狀況表 */
.voting-status-table tr.is-pending { background: #fef3c7; }
.voting-status-table tr.is-pending td:first-child { color: #92400e; font-weight: 700; }
.voting-status-table tr.is-excluded { opacity: 0.55; }
.voting-status-table .badge-vote-yes { background: #d1fae5; color: #065f46; }
.voting-status-table .badge-vote-no  { background: #fee2e2; color: #991b1b; }
.voting-status-summary {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.voting-status-summary .vs-pill {
  padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 0.88rem;
}
.vs-pill-eligible { background: #dbeafe; color: #1e40af; }
.vs-pill-voted { background: #d1fae5; color: #065f46; }
.vs-pill-pending { background: #fee2e2; color: #991b1b; }

/* 早鳥名單表 */
.eb-table .pill-used { background: #d1fae5; color: #065f46; padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.eb-table .pill-pending { background: #f3f4f6; color: var(--text-secondary); padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }

/* Danger zone (測試重置) */
.danger-zone {
  background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
  border: 2px dashed #f87171;
}
.danger-zone .card-title { color: #991b1b; }
.danger-zone .dz-h3 {
  margin: 14px 0 8px; font-size: 0.95rem; color: #7f1d1d; font-weight: 700;
}
.danger-zone .dz-row { gap: 8px; }
.danger-zone .dz-result {
  margin-top: 14px; font-size: 0.85rem; color: #1f2937;
  white-space: pre-wrap; font-family: monospace;
  background: rgba(255,255,255,0.7); padding: 10px 14px;
  border-radius: 8px; min-height: 0;
}
.danger-zone .dz-result:empty { display: none; }

/* ============ Draw page (viewport-locked) ============ */
html.is-draw, body.page-draw {
  height: 100vh; overflow: hidden;
}
.page-draw {
  background: radial-gradient(ellipse at top, #1e1b4b 0%, #0f172a 100%);
  color: #fff;
}
.draw-app {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "left right"
    "action action";
  gap: 16px; padding: 16px;
  height: 100vh;
  box-sizing: border-box;
}
.draw-col {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px; padding: 18px; backdrop-filter: blur(10px);
  min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
.draw-col h2 { margin: 0 0 12px; color: #fbbf24; font-size: 1.15rem; }
.col-left { grid-area: left; }
.col-right { grid-area: right; }

.col-left .prize-content {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column;
}
.draw-prize-img {
  width: 100%; flex: 0 1 auto; aspect-ratio: 4 / 3;
  max-height: 45vh;
  background: #1f2937 center/contain no-repeat; border-radius: 12px; margin-bottom: 12px;
}
.draw-prize-name { font-size: 1.4rem; font-weight: 800; color: #fff; margin: 0 0 8px; }
.draw-prize-desc { color: #cbd5e1; white-space: pre-wrap; line-height: 1.6; font-size: 0.92rem; }
.draw-prize-vote { display: inline-block; background: var(--accent); color: #1f2937; padding: 4px 14px; border-radius: 999px; font-weight: 700; margin-bottom: 10px; font-size: 0.85rem; }

.participant-list {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; padding-right: 6px;
}
.participant {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 12px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px;
  transition: all .4s; flex-shrink: 0;
}
.participant.is-winner {
  background: linear-gradient(135deg, rgba(251,191,36,0.4), rgba(245,158,11,0.6));
  border-color: #fbbf24; transform: scale(1.05); box-shadow: 0 8px 24px rgba(251,191,36,0.5);
}
.participant .pname { font-weight: 700; }
.participant .pscore { color: #fbbf24; font-weight: 700; font-family: monospace; font-size: 1.05rem; }
.participant .ppct { color: #cbd5e1; font-size: 0.78rem; margin-left: 8px; }
.participant .pscore-detail { font-size: 0.78rem; color: #cbd5e1; }

.draw-action { grid-area: action; text-align: center; }
.btn-draw {
  font-size: 1.2rem; padding: 16px 48px; border-radius: 999px; border: none;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  color: #fff; cursor: pointer; box-shadow: 0 12px 32px rgba(239,68,68,0.4);
  transition: transform .15s, box-shadow .2s; font-weight: 800;
}
.btn-draw:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(239,68,68,0.55); }
.btn-draw:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 900px) {
  .draw-app {
    grid-template-columns: 1fr;
    grid-template-rows: 40vh 1fr auto;
    grid-template-areas: "left" "right" "action";
  }
  .draw-prize-img { max-height: 25vh; }
}

.draw-modal {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.85); z-index: 100;
}
.draw-modal.show { display: flex; }
.draw-number {
  font-size: clamp(4rem, 14vw, 9rem); font-weight: 900; color: #fbbf24; font-family: monospace;
  text-shadow: 0 0 60px rgba(251,191,36,0.8); letter-spacing: 12px;
}
.draw-modal .label { color: #fff; font-size: 1.4rem; margin-bottom: 24px; letter-spacing: 4px; }
.draw-modal .countdown-text { color: #cbd5e1; font-size: 1.2rem; margin-top: 24px; }
@keyframes lockPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); color: #fff; text-shadow: 0 0 80px #fff; }
}
.draw-number.locked { animation: lockPulse 0.6s ease-in-out 3; color: #fff; }
@keyframes winnerPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3) rotate(-5deg); }
  100% { transform: scale(1.05) rotate(0); }
}
.participant.popping { animation: winnerPop 0.8s ease-out; }
.move-to-top { animation: moveToTop 1s ease-out; }
@keyframes moveToTop { from { opacity: 0.3; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.draw-back-link { position: fixed; top: 12px; left: 12px; z-index: 200; }
.draw-back-link a { color: #cbd5e1; text-decoration: none; font-size: 0.85rem; padding: 6px 12px; background: rgba(0,0,0,0.4); border-radius: 999px; }

/* === 抽獎名單（含排名/跑馬燈/飛入動畫） === */
.participant {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
}
.participant .prank {
  font-size: 1.5rem; text-align: center; line-height: 1;
}
.participant .prank-num {
  font-family: monospace; color: #94a3b8; font-size: 0.95rem; font-weight: 700;
}
.participant .pmain { min-width: 0; }
.participant .pright { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.participant .pscore-orig {
  display: inline-block; font-size: 0.72rem; color: #94a3b8; font-family: monospace;
}
.participant.is-winner .prank { font-size: 2rem; }
.participant .pscore.boosted {
  color: #fbbf24; text-shadow: 0 0 12px rgba(251,191,36,0.7);
  animation: scoreBoost 0.8s ease-out;
}
@keyframes scoreBoost {
  0% { transform: scale(1); }
  40% { transform: scale(1.4); color: #fcd34d; }
  100% { transform: scale(1); }
}
.eb-tag {
  display: inline-block; background: rgba(251,191,36,0.22);
  color: #fde68a; padding: 1px 6px; border-radius: 6px;
  font-size: 0.78rem; font-weight: 700;
}
/* 開獎時，display_name 後方顯示帳號（小灰字） */
.participant .paccount {
  font-size: 0.72rem; color: #94a3b8; font-weight: 400;
  font-family: monospace; margin-left: 6px; letter-spacing: 0.3px;
}
.participant.is-winner .paccount {
  color: #7c2d12; opacity: 0.7;
}
.winner-banner .wb-account {
  font-size: 0.85rem; color: #7c2d12; opacity: 0.65;
  font-family: monospace; font-weight: 500;
  margin: 4px 0 8px; letter-spacing: 0.4px;
}

.participant-list.fading { opacity: 0.2; transition: opacity 0.3s; }

/* 垂直跑馬燈 */
.marquee-vertical {
  flex: 1; min-height: 0; overflow: hidden; position: relative;
  mask-image: linear-gradient(to bottom,
    transparent 0%, #000 8%, #000 92%, transparent 100%);
}
.marquee-track {
  display: flex; flex-direction: column; gap: 8px;
  animation: marqueeUp 28s linear infinite;
}
@keyframes marqueeUp {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

/* 飛入動畫元件 */
.eb-fly {
  position: fixed; z-index: 400;
  font-size: 2.4rem; font-weight: 900; color: #fbbf24;
  text-shadow: 0 0 24px rgba(251,191,36,0.9), 0 0 40px rgba(245,158,11,0.6);
  font-family: monospace; pointer-events: none;
  transition: transform 0.7s cubic-bezier(.55, -0.2, .25, 1.1), opacity 0.7s;
  width: 80px; text-align: center;
}

/* 早鳥揭示 overlay */
.eb-overlay {
  position: fixed; inset: 0; z-index: 350;
  background: radial-gradient(ellipse at center, rgba(245,158,11,0.55), rgba(0,0,0,0.85));
  display: flex; align-items: center; justify-content: center;
  animation: ebFadeIn 0.4s ease-out;
}
@keyframes ebFadeIn {
  from { opacity: 0; backdrop-filter: blur(0); }
  to   { opacity: 1; backdrop-filter: blur(4px); }
}
.eb-overlay.fade-out { opacity: 0; transition: opacity 0.4s; }
.eb-reveal {
  background: linear-gradient(135deg, #fef3c7, #fbbf24);
  color: #78350f; padding: 36px 48px; border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  min-width: 360px; max-width: 90vw; text-align: center;
  animation: ebPop 0.5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes ebPop {
  0%   { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.eb-title { font-size: 1.5rem; font-weight: 900; margin-bottom: 18px; letter-spacing: 1.5px; }
.eb-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.eb-row {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,0.55); padding: 10px 16px;
  border-radius: 10px; font-size: 1.1rem;
}
.eb-row .eb-name { font-weight: 700; }
.eb-row .eb-bonus {
  font-family: monospace; font-weight: 900; color: #b45309;
  background: #fff; padding: 2px 10px; border-radius: 999px;
}
.eb-countdown {
  font-size: 2.4rem; font-weight: 900; font-family: monospace;
  color: #b45309;
}

/* 得獎橫幅 */
.winner-banner {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1f2937; padding: 32px 56px; border-radius: 24px;
  font-size: 1.6rem; font-weight: 800; z-index: 300;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5); text-align: center;
  animation: bannerPop 0.6s cubic-bezier(.34,1.56,.64,1);
}
.winner-banner .wb-prize {
  display: inline-block; margin-top: 6px;
  font-size: 1.2rem; color: #7c2d12;
}
.winner-banner .wb-meta {
  font-size: 0.9rem; margin-top: 12px; color: #7c2d12;
  font-family: monospace; letter-spacing: 2px;
}
.winner-banner.fade-out { opacity: 0; transition: opacity 0.6s; transform: translate(-50%, -60%); }
@keyframes bannerPop {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
