/* ============================================================
   仁愛眼鏡 × 酷酷馬 2026 聖誕遊戲 — 共用樣式
   視覺語言：跟酷酷馬插畫一致的「深棕粗描邊貼紙風」
   ============================================================ */
:root {
  --red: #D7263D;
  --red-dark: #A11A2C;
  --green: #1E6B4F;
  --green-dark: #11452F;
  --gold: #F4B942;
  --gold-dark: #C4860F;
  --snow: #FFFBF5;
  --cream: #FFF1DC;
  --ink: #3B2418;          /* 酷酷馬的描邊色 */
  --ink-soft: #7A5A48;
  --navy: #142140;
  --navy-2: #1F3363;
  --sky: #CFE6F5;
  --radius: 22px;
  --stroke: 3px solid var(--ink);
  --pop: 0 5px 0 rgba(59, 36, 24, .28);
  --font: 'Huninn', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #2B4A8A 0%, transparent 60%),
    linear-gradient(180deg, var(--navy) 0%, #0B1428 100%);
  display: grid;
  place-items: center;
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
img { -webkit-user-drag: none; user-select: none; }
button { font-family: inherit; }

/* ---------- 手機外框（桌機看時模擬手機；手機上全螢幕） ---------- */
.stage {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--sky);
  isolation: isolate;
  touch-action: none;
}
@media (min-width: 520px) {
  .stage {
    width: 410px;
    height: min(860px, calc(100dvh - 32px));
    border-radius: 34px;
    box-shadow: 0 0 0 10px #0A0F1E, 0 0 0 12px #2A3554, 0 30px 80px rgba(0,0,0,.55);
  }
}

/* ---------- 頂部列 ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 12px 8px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.icon-btn {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; border: var(--stroke);
  background: var(--snow); color: var(--ink);
  box-shadow: 0 3px 0 rgba(59,36,24,.3);
  cursor: pointer; font-size: 20px; line-height: 1; text-decoration: none;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(59,36,24,.3); }
.icon-btn svg { width: 22px; height: 22px; }
.topbar .title-pill {
  flex: 1; text-align: center;
  font-size: 17px; font-weight: 700; letter-spacing: .04em;
  padding: 8px 12px; border-radius: 999px;
  background: rgba(255,251,245,.92); border: var(--stroke);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute; left: 12px; right: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 54px);
  z-index: 25; display: flex; gap: 8px; align-items: center; pointer-events: none;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--snow); border: var(--stroke);
  font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 0 rgba(59,36,24,.25);
}
.pill .lbl { font-size: 12px; color: var(--ink-soft); font-weight: 400; }
.pill.warn { background: var(--red); color: #fff; animation: pulse .5s ease-in-out infinite alternate; }
.pill.warn .lbl { color: #ffd9dd; }
@keyframes pulse { to { transform: scale(1.08); } }

.bar {
  flex: 1; height: 22px; border-radius: 999px; border: var(--stroke);
  background: var(--snow); overflow: hidden; position: relative;
  box-shadow: 0 3px 0 rgba(59,36,24,.25);
}
.bar > i {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: repeating-linear-gradient(-45deg, var(--red) 0 10px, #E8475B 10px 20px);
  transition: width .25s ease;
}
.bar.done > i { background: repeating-linear-gradient(-45deg, var(--green) 0 10px, #2C8A66 10px 20px); }
.bar > span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--ink); mix-blend-mode: normal;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 200px; padding: 14px 30px;
  font-size: 20px; font-weight: 700; letter-spacing: .08em;
  color: #fff; background: var(--red);
  border: var(--stroke); border-radius: 999px;
  box-shadow: 0 6px 0 var(--ink);
  cursor: pointer; text-decoration: none;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn.green { background: var(--green); }
.btn.gold { background: var(--gold); color: var(--ink); }
.btn.ghost { background: var(--snow); color: var(--ink); }
.btn.sm { min-width: 0; padding: 10px 20px; font-size: 16px; box-shadow: 0 4px 0 var(--ink); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.shine { position: relative; overflow: hidden; }
.btn.shine::after {
  content: ''; position: absolute; top: -50%; left: -60%; width: 40%; height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  transform: rotate(20deg); animation: shine 2.4s ease-in-out infinite;
}
@keyframes shine { 0%, 55% { left: -60%; } 100% { left: 130%; } }

/* ---------- 浮層 ---------- */
.ov {
  position: absolute; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 20px;
  background: rgba(20, 33, 64, .55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fadeIn .25s ease;
}
.ov.clear { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.ov.hide { display: none; }
@keyframes fadeIn { from { opacity: 0; } }

.card {
  position: relative; width: 100%; max-width: 340px;
  background: var(--snow); border: var(--stroke); border-radius: 28px;
  box-shadow: 0 8px 0 rgba(59,36,24,.35);
  padding: 22px 20px 24px; text-align: center;
  animation: popIn .4s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }
.card h2 { margin: 4px 0 6px; font-size: 26px; letter-spacing: .06em; }
.card p { margin: 6px 0; font-size: 15px; line-height: 1.6; color: var(--ink-soft); }
.card .big { font-size: 46px; font-weight: 700; color: var(--red); line-height: 1.1; font-variant-numeric: tabular-nums; }
.card .actions { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-top: 18px; }

/* 帽子緞帶標題 */
.ribbon {
  display: inline-block; position: relative;
  padding: 8px 26px; margin-top: -42px; margin-bottom: 6px;
  background: var(--red); color: #fff; font-weight: 700; font-size: 18px; letter-spacing: .12em;
  border: var(--stroke); border-radius: 12px;
  box-shadow: 0 4px 0 var(--ink);
}

/* 規則列表 */
.rules { list-style: none; padding: 0; margin: 12px 0 4px; text-align: left; }
.rules li {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 10px; margin: 6px 0;
  background: var(--cream); border-radius: 14px; font-size: 15px; line-height: 1.45;
}
.rules li img { width: 34px; height: 34px; object-fit: contain; flex: none; }
.rules li .emo { width: 34px; text-align: center; font-size: 24px; flex: none; }
.rules b { color: var(--red); }

.demo-tag {
  position: absolute; z-index: 60; right: -34px; bottom: 18px; transform: rotate(-45deg);
  background: var(--gold); color: var(--ink); font-size: 11px; font-weight: 700;
  padding: 3px 40px; letter-spacing: .1em; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  pointer-events: none;
}

/* ---------- 下雪 ---------- */
.snow-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
.flake {
  position: absolute; top: -20px; color: #fff; line-height: 1;
  animation: fall linear infinite;
  text-shadow: 0 0 4px rgba(255,255,255,.7);
}
@keyframes fall {
  0% { transform: translate3d(0, -20px, 0) rotate(0deg); }
  100% { transform: translate3d(var(--drift, 30px), 110dvh, 0) rotate(360deg); }
}

/* ---------- 彩帶 ---------- */
.confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 70; }
.confetti {
  position: absolute; top: -20px; border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translate3d(0, -20px, 0) rotate(0) rotateY(0); opacity: 1; }
  100% { transform: translate3d(var(--dx), 105%, 0) rotate(720deg) rotateY(540deg); opacity: .9; }
}

/* ---------- 浮動文字（+1、-2秒…） ---------- */
.float-txt {
  position: absolute; z-index: 40; pointer-events: none;
  font-weight: 700; font-size: 26px; color: #fff;
  -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--ink);
  animation: floatUp .9s ease-out forwards;
  transform: translate(-50%, -50%);
}
@keyframes floatUp { to { transform: translate(-50%, -150%); opacity: 0; } }

/* ---------- 抽獎：讀取中 ---------- */
.loader-box { text-align: center; color: #fff; }
.loader-box .spin {
  width: 86px; height: 86px; margin: 0 auto 14px;
  animation: wobble .9s ease-in-out infinite;
}
@keyframes wobble { 0%, 100% { transform: rotate(-10deg) scale(1); } 50% { transform: rotate(10deg) scale(1.08); } }
.loader-box .msg { font-size: 20px; font-weight: 700; letter-spacing: .08em; text-shadow: 0 2px 0 var(--ink); }
.loader-box .dev {
  margin-top: 14px; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #CFE0FF; opacity: .85; text-align: left; display: inline-block;
  background: rgba(0,0,0,.25); padding: 8px 12px; border-radius: 10px; max-width: 320px;
}

/* ---------- 抽獎：選禮物 ---------- */
.pick-title {
  color: #fff; font-size: 28px; font-weight: 700; letter-spacing: .1em; margin-bottom: 6px;
  text-shadow: 0 3px 0 var(--ink), 0 0 18px rgba(244,185,66,.6);
}
.pick-sub { color: #E4ECFF; font-size: 15px; margin-bottom: 26px; }
.gifts { display: flex; gap: 10px; justify-content: center; align-items: flex-end; width: 100%; }
.gift {
  width: 31%; max-width: 116px; cursor: pointer; position: relative;
  animation: bob 1.6s ease-in-out infinite; transition: opacity .3s, transform .3s;
}
.gift:nth-child(2) { animation-delay: .25s; }
.gift:nth-child(3) { animation-delay: .5s; }
.gift img { width: 100%; display: block; filter: drop-shadow(0 6px 0 rgba(0,0,0,.25)); }
.gift img[src*="gold"] { transform: scale(1.3); transform-origin: 50% 85%; } /* 金禮物圖含閃光，盒子本體較小 */
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.gift.dim { opacity: .25; transform: scale(.85); animation: none; }
.gift.chosen { animation: shake .12s linear infinite; z-index: 2; }
.gift.chosen::before {
  content: ''; position: absolute; inset: -40%; z-index: -1;
  background: radial-gradient(circle, rgba(255,226,140,.95) 0%, rgba(255,226,140,0) 65%);
  animation: glowGrow .9s ease-out forwards;
}
@keyframes shake { 0% { transform: rotate(-6deg) scale(1.15); } 50% { transform: rotate(6deg) scale(1.15); } 100% { transform: rotate(-6deg) scale(1.15); } }
@keyframes glowGrow { from { transform: scale(.3); opacity: 0; } to { transform: scale(1.3); opacity: 1; } }
.flash { position: absolute; inset: 0; background: #fff; z-index: 80; pointer-events: none; animation: flash .6s ease-out forwards; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* ---------- 抽獎：獎品券 ---------- */
.rays {
  position: absolute; left: 50%; top: 42%; width: 900px; height: 900px; margin: -450px 0 0 -450px;
  background: repeating-conic-gradient(from 0deg, rgba(255,230,160,.22) 0 10deg, transparent 10deg 20deg);
  border-radius: 50%; animation: spin 18s linear infinite; pointer-events: none;
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 62%); mask: radial-gradient(circle, #000 20%, transparent 62%);
}
@keyframes spin { to { transform: rotate(360deg); } }
.ticket {
  position: relative; width: 100%; max-width: 320px;
  background: var(--snow); border: var(--stroke); border-radius: 26px;
  box-shadow: 0 10px 0 rgba(0,0,0,.3);
  animation: ticketIn .6s cubic-bezier(.2, 1.5, .4, 1);
  overflow: visible;
}
@keyframes ticketIn { from { transform: translateY(40px) scale(.5) rotate(-8deg); opacity: 0; } }
.ticket .t-head {
  position: relative; height: 150px; border-radius: 23px 23px 0 0; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 100%, #FFE7A8 0%, #F4B942 45%, #D7263D 100%);
}
.ticket .t-head .snowdots {
  position: absolute; inset: 0; opacity: .7;
  background-image: radial-gradient(#fff 1.2px, transparent 1.5px), radial-gradient(#fff 1px, transparent 1.3px);
  background-size: 26px 26px, 17px 17px; background-position: 0 0, 9px 11px;
}
.ticket .t-head img { position: absolute; left: 50%; bottom: -18px; height: 170px; transform: translateX(-50%); }
.ticket .t-head .congrats {
  position: absolute; left: 12px; top: 12px; z-index: 2;
  background: var(--snow); border: var(--stroke); border-radius: 12px; padding: 4px 10px;
  font-weight: 700; font-size: 15px; letter-spacing: .1em; transform: rotate(-6deg);
}
.ticket .t-body { padding: 16px 18px 6px; text-align: center; }
.ticket .off { display: flex; align-items: baseline; justify-content: center; gap: 4px; color: var(--red); line-height: 1; }
.ticket .off b { font-size: 76px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
.ticket .off small { font-size: 30px; font-weight: 700; -webkit-text-stroke: 1.2px var(--ink); paint-order: stroke fill; }
.ticket .off .pre { font-size: 26px; font-weight: 700; }
.ticket .ttl { font-size: 22px; font-weight: 700; margin-top: 8px; letter-spacing: .06em; }
.ticket .note { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
.ticket .grand { display: inline-block; margin-bottom: 8px; padding: 3px 12px; border-radius: 999px; background: var(--red); color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .15em; }
.ticket .perf {
  position: relative; height: 26px; margin: 10px 0 0;
  background: radial-gradient(circle at 0 50%, transparent 12px, transparent 12px) ;
}
.ticket .perf::before {
  content: ''; position: absolute; left: 16px; right: 16px; top: 50%;
  border-top: 3px dashed #E2CDB4;
}
.ticket .perf .n { position: absolute; top: 50%; width: 26px; height: 26px; margin-top: -13px; border-radius: 50%; background: rgba(20,33,64,.92); border: var(--stroke); }
.ticket .perf .n.l { left: -15px; clip-path: inset(0 0 0 50%); }
.ticket .perf .n.r { right: -15px; clip-path: inset(0 50% 0 0); }
.ticket .t-foot { padding: 6px 18px 20px; text-align: center; }
.ticket .meta { font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 14px; }
.ticket .meta b { color: var(--green); }
.below-ticket { margin-top: 18px; display: flex; gap: 10px; }
.link-btn { background: none; border: 0; color: #E4ECFF; font-size: 14px; text-decoration: underline; cursor: pointer; padding: 6px; }

/* 吐司訊息 */
.toast {
  position: absolute; left: 50%; bottom: 28px; z-index: 90; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 14px;
  font-size: 14px; line-height: 1.5; width: max-content; max-width: 86%;
  animation: toastIn .3s ease, fadeOut .4s ease 2.6s forwards;
}
@keyframes toastIn { from { transform: translate(-50%, 20px); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }

/* 螢幕震動 */
.shake-screen { animation: screenShake .35s linear; }
@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-7px, 3px); } 40% { transform: translate(6px, -4px); }
  60% { transform: translate(-5px, 2px); } 80% { transform: translate(4px, -2px); }
}

@media (prefers-reduced-motion: reduce) {
  .flake, .gift, .rays, .btn.shine::after { animation: none !important; }
}
