/* Christmas theme draw — mobile first */

:root {
  --bg0: #140c0a;
  --bg1: #2c1510;
  --gold: #e8c56b;
  --gold-soft: #f3d98a;
  --gold-dim: #b8943e;
  --cream: #f7f0e4;
  --ink: #2a1810;
  --ink-soft: #5c4638;
  --red: #c12a32;
  --red-deep: #8e1c24;
  --green: #1f4d32;
  --pine: #0d2418;
  --safe-top: max(16px, env(safe-area-inset-top));
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
  --font-sans: "Noto Sans TC", "PingFang TC", "Hiragino Sans CNS", "Microsoft JhengHei", sans-serif;
  --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg0);
  color: var(--cream);
  font-family: var(--font-sans);
  -webkit-text-size-adjust: 100%;
}
body {
  min-height: 100dvh;
  overflow: hidden;
}
button {
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:disabled { cursor: default; opacity: 0.6; }

.scene {
  position: relative;
  height: 100dvh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(193, 42, 50, 0.22), transparent 55%),
    radial-gradient(800px 500px at 80% 110%, rgba(31, 77, 50, 0.28), transparent 50%),
    linear-gradient(180deg, #1a0e0c 0%, #140c0a 55%, #0d0a08 100%);
}

.glow {
  position: absolute;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  filter: blur(40px);
  opacity: 0.55;
}
.glow-a {
  width: 180px; height: 180px;
  left: -40px; top: 80px;
  background: radial-gradient(circle, rgba(232, 197, 107, 0.35), transparent 70%);
}
.glow-b {
  width: 220px; height: 220px;
  right: -50px; bottom: 80px;
  background: radial-gradient(circle, rgba(193, 42, 50, 0.28), transparent 70%);
}

/* Snow */
.snow { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.flake {
  position: absolute;
  top: -12px;
  width: 6px; height: 6px;
  background: #fff;
  border-radius: 50%;
  opacity: 0.7;
  animation: fall linear infinite;
  box-shadow: 0 0 6px rgba(255,255,255,0.6);
}
@keyframes fall {
  0% { transform: translate3d(0, -10px, 0); opacity: 0; }
  10% { opacity: 0.75; }
  100% { transform: translate3d(var(--drift, 20px), 110dvh, 0); opacity: 0.15; }
}

/* Lights */
.lights {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 56px;
  z-index: 3;
  pointer-events: none;
}
.lights .wire {
  position: absolute;
  inset: 8px 0 auto 0;
  width: 100%;
  height: 40px;
  overflow: visible;
}
.bulbs {
  position: absolute;
  inset: 0 2% auto 2%;
  height: 52px;
}
.bulb {
  position: absolute;
  top: var(--y, 18px);
  width: 10px;
  height: 14px;
  border-radius: 50% 50% 45% 45%;
  background: var(--c, #e8c56b);
  box-shadow:
    0 0 8px var(--c, #e8c56b),
    0 0 16px var(--c, #e8c56b);
  animation: twinkle 1.8s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
.bulb::before {
  content: "";
  position: absolute;
  top: -4px; left: 2px;
  width: 6px; height: 4px;
  background: #6a5420;
  border-radius: 1px;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.55; filter: brightness(0.85); }
  50% { opacity: 1; filter: brightness(1.25); }
}

/* Header */
.top {
  position: relative;
  z-index: 4;
  text-align: center;
  padding: calc(var(--safe-top) + 44px) 24px 0;
}
.kicker {
  margin: 0;
  letter-spacing: 0.28em;
  font-size: 0.72rem;
  color: var(--gold);
  text-indent: 0.28em;
}
h1 {
  margin: 6px 0 8px;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  letter-spacing: 0.08em;
  text-shadow: 0 2px 16px rgba(0,0,0,0.4);
}
.remain {
  margin: 0;
  font-size: 0.95rem;
  color: rgba(247, 240, 228, 0.75);
}

.icon-btn {
  position: absolute;
  top: calc(var(--safe-top) + 8px);
  right: max(12px, env(safe-area-inset-right));
  z-index: 6;
  width: 44px; height: 44px;
  border: 1px solid rgba(232, 197, 107, 0.35);
  border-radius: 50%;
  background: rgba(20, 12, 10, 0.55);
  color: var(--gold);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}
.icon-btn .icon-off { display: none; }
.icon-btn.is-muted .icon-on { display: none; }
.icon-btn.is-muted .icon-off { display: inline; }

/* Stage */
.stage {
  position: relative;
  z-index: 4;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  min-height: 0;
}

/* Gift box */
.box-wrap {
  width: min(220px, 58vw);
  height: 200px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.box-wrap.is-hidden {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
  position: absolute;
}

.gift {
  position: relative;
  width: 150px;
  height: 150px;
  transform-origin: 50% 80%;
}
.gift.is-shaking { animation: shake 0.7s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: rotate(0) translateY(0); }
  15% { transform: rotate(-11deg) translateY(-6px); }
  30% { transform: rotate(10deg) translateY(-2px); }
  45% { transform: rotate(-8deg) translateY(-8px); }
  60% { transform: rotate(8deg) translateY(-1px); }
  75% { transform: rotate(-5deg) translateY(-4px); }
  90% { transform: rotate(4deg); }
}

.gift-body {
  position: absolute;
  left: 8px; right: 8px; bottom: 10px;
  height: 86px;
  background:
    linear-gradient(180deg, #e14a4f 0%, var(--red) 40%, var(--red-deep) 100%);
  border-radius: 6px 6px 10px 10px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.2),
    0 10px 20px rgba(0,0,0,0.35);
  overflow: hidden;
}
.body-ribbon-v {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 22px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #c9a24a, var(--gold-soft), #c9a24a);
}
.body-ribbon-h {
  position: absolute;
  top: 38%; left: 0; right: 0;
  height: 22px;
  background: linear-gradient(180deg, #c9a24a, var(--gold-soft), #c9a24a);
}
.body-shine {
  position: absolute;
  inset: 8px auto auto 8px;
  width: 28px; height: 50px;
  background: linear-gradient(180deg, rgba(255,255,255,0.22), transparent);
  border-radius: 8px;
  pointer-events: none;
}

.gift-lid {
  position: absolute;
  left: 0; right: 0; top: 28px;
  height: 34px;
  background: linear-gradient(180deg, #ef6a6a, #d0343c 60%, var(--red-deep));
  border-radius: 6px;
  box-shadow:
    0 4px 0 rgba(80, 10, 12, 0.35),
    0 8px 16px rgba(0,0,0,0.25);
  transform-origin: 12% 50%;
  z-index: 2;
  transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.gift.is-open .gift-lid {
  transform: translate(-18px, -42px) rotate(-28deg);
}
.lid-ribbon {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 22px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #c9a24a, var(--gold-soft), #c9a24a);
  border-radius: 2px;
}

.bow-knot {
  position: absolute;
  left: 50%; top: -8px;
  width: 22px; height: 18px;
  transform: translateX(-50%);
  background: radial-gradient(circle at 40% 30%, #f3d98a, #b8943e);
  border-radius: 50%;
  z-index: 3;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}
.bow-loop {
  position: absolute;
  top: -22px;
  width: 36px; height: 28px;
  background: radial-gradient(circle at 35% 35%, #f8e7b0, #d4af4a 60%, #a67c2a);
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px rgba(138, 90, 20, 0.25);
}
.bow-loop.left { left: 28px; transform: rotate(-28deg); }
.bow-loop.right { right: 28px; transform: rotate(28deg); }

.gift-shadow {
  position: absolute;
  left: 16px; right: 16px; bottom: 0;
  height: 12px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.45), transparent 70%);
  filter: blur(2px);
}

/* Card */
.card, .done {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  background:
    linear-gradient(180deg, #fffaf1 0%, var(--cream) 100%);
  color: var(--ink);
  border-radius: 20px;
  padding: 22px 22px 20px;
  text-align: center;
  box-shadow:
    0 0 0 1px #eed9a4,
    0 0 0 6px rgba(232, 197, 107, 0.18),
    0 18px 40px rgba(0,0,0,0.35);
  animation: cardIn 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(28px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.card-label, .tip-label {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--gold-dim);
}
.card-title {
  margin: 10px 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(1.45rem, 5.6vw, 1.9rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--red-deep);
}
.card-line {
  margin: 0 0 16px;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--ink-soft);
}
.tip {
  background: #fbf3de;
  border-radius: 14px;
  padding: 12px 14px 14px;
  text-align: left;
}
.tip-text {
  margin: 6px 0 0;
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--ink);
}

.done h2 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  color: var(--red-deep);
  font-size: 1.5rem;
}
.done p { margin: 0 0 12px; color: var(--ink-soft); }
.done-list {
  margin: 0;
  padding: 0 0 0 1.2em;
  text-align: left;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.7;
}
.done-list li { margin: 0 0 4px; }

/* Actions */
.actions {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 24px calc(var(--safe-bottom) + 12px);
}
.btn {
  appearance: none;
  border: 0;
  min-height: 54px;
  min-width: min(320px, 86vw);
  padding: 0 22px;
  border-radius: 999px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.btn.primary {
  background: linear-gradient(180deg, #e8c56b, #c9a24a);
  color: #3a240c;
  box-shadow: 0 8px 20px rgba(201, 162, 74, 0.28);
}
.btn.primary:active { transform: translateY(1px); }
.btn.ghost {
  min-height: 44px;
  background: transparent;
  color: rgba(247, 240, 228, 0.7);
  border: 1px solid rgba(247, 240, 228, 0.22);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 4, 3, 0.62);
  display: grid;
  place-items: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(360px, 100%);
  background: var(--cream);
  color: var(--ink);
  border-radius: 18px;
  padding: 22px 20px 18px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}
.modal-card h3 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 1.2rem;
}
.modal-card p {
  margin: 0 0 16px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.modal-actions .btn { min-width: 0; flex: 1; letter-spacing: 0.06em; }

@media (min-width: 768px) {
  .gift { width: 180px; height: 180px; }
  .gift-body { height: 104px; }
  .box-wrap { width: 260px; height: 240px; }
  .card, .done { padding: 28px 30px 24px; }
}
