:root {
  color-scheme: dark;
  color: #fff3d7;
  background: #300b17;
  font: 16px/1.5 system-ui, sans-serif;
  --gold: #f8ce84;
  --muted: #eac7ba;
  --edge: #edbf7759;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; overflow-x: clip; background: radial-gradient(ellipse at 75% 40%, #8b2931 0, transparent 53%), radial-gradient(ellipse at 4% 100%, #551b32, transparent 70%), #300b17; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
:focus-visible { outline: 3px solid #ffdd93; outline-offset: 4px; }
.ambient { position: fixed; inset: 0; pointer-events: none; opacity: .2; background-image: radial-gradient(circle at center, #f3c386 1px, transparent 1.5px); background-size: 42px 42px; mask-image: linear-gradient(to right, transparent, #000); }
.shell { position: relative; width: min(74rem, 100% - 3rem); margin: auto; min-height: 100svh; display: flex; flex-direction: column; }
.top, footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .65rem 1rem; border-color: var(--edge); border-style: solid; border-width: 0; padding-block: 1rem; }
.top { border-bottom-width: 1px; }
.brand { display: inline-flex; gap: .55rem; align-items: center; color: inherit; text-decoration: none; font-weight: 850; letter-spacing: .09em; overflow-wrap: anywhere; }
.brand-mark { color: var(--gold); border: 1px solid var(--edge); border-radius: 50%; display: grid; place-items: center; width: 2rem; height: 2rem; flex: none; }
.audio { display: flex; flex-wrap: wrap; gap: .5rem; }
.audio button, .secondary { color: #fff0d4; border: 1px solid var(--edge); background: #471522; border-radius: 2rem; padding: .47rem .8rem; min-height: 2.75rem; font-weight: 650; }
.audio button { font-size: .9rem; }
.audio button[aria-pressed="true"] { background: #f9d48b; border-color: #f9d48b; color: #471522; }
.audio button span:first-child { margin-right: .18rem; }
.hero { flex: 1; display: grid; grid-template-columns: minmax(0,.92fr) minmax(0,1.08fr); grid-template-areas: "intro stage" "actions stage"; grid-template-rows: 1fr auto; align-items: center; gap: 0 clamp(1rem, 4vw, 4rem); padding-block: clamp(2.25rem, 6vw, 5rem); }
.intro { grid-area: intro; align-self: end; }
.kicker, .season { text-transform: uppercase; font-weight: 800; letter-spacing: .16em; color: var(--gold); font-size: .85rem; }
.kicker { margin: 0 0 1rem; }
.kicker span:first-child { margin-right: .35rem; }
h1, .result h2, .amount, .timer strong { font-family: Georgia, 'Times New Roman', serif; }
h1 { margin: 0; font-size: clamp(3rem, 6.4vw, 6.4rem); line-height: .98; letter-spacing: -.045em; overflow-wrap: anywhere; text-wrap: balance; }
h1 em { display: block; color: var(--gold); font-size: .82em; font-weight: inherit; padding-bottom: .12em; }
.lead { font-size: clamp(1rem, 1.8vw, 1.15rem); color: var(--muted); max-width: 38ch; margin: .85rem 0 1.2rem; overflow-wrap: anywhere; }
.countdown { margin-bottom: 1.4rem; }
.countdown h2 { margin: 0 0 .55rem; font-size: .9rem; font-weight: 650; color: #f6dcc4; }
.timer { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .42rem; max-width: 22rem; }
.timer div { display: flex; flex-direction: column; align-items: center; border: 1px solid var(--edge); background: #340b1b99; border-radius: .63rem; padding: .36rem .12rem; text-align: center; }
.timer strong { color: var(--gold); line-height: 1.15; font-size: clamp(1.15rem, 3.15vw, 1.75rem); font-variant-numeric: tabular-nums; }
.timer span { font-size: .82rem; color: #f7dec4; overflow-wrap: anywhere; max-width: 100%; }
#new-year { color: var(--gold); font-weight: 750; }
.stage { position: relative; isolation: isolate; grid-area: stage; display: grid; justify-items: center; align-content: center; justify-self: center; width: min(100%, 34rem); min-height: 0; aspect-ratio: 1; }
.halo { position: absolute; inset: 5%; z-index: -1; border-radius: 50%; border: 1px dashed #f6ce826e; box-shadow: 0 0 0 12px #ffcf7820, 0 0 75px #fa9e453d; animation: glow 3.5s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 0 12px #ffcf7809, 0 0 95px #fa9e4570; } }
.season { z-index: 2; margin: 0; position: absolute; top: 0; padding: .3rem .75rem; max-width: 80%; text-align: center; background: #451320; border: 1px solid var(--edge); border-radius: 2rem; overflow-wrap: anywhere; }
.wheel-frame { position: relative; width: 83%; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg,#fff0b2,#ca7b39 42%,#ffe4a1 67%,#a9582c); box-shadow: 0 9px 0 #6c281d, 0 18px 35px #260713aa; }
#wheel { display: block; width: 92%; height: 92%; border-radius: 50%; box-shadow: 0 0 0 2px #542312; }
#bulbs { position: absolute; inset: 0; pointer-events: none; }
#bulbs i { position: absolute; width: 2.1%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; background: #fff1b8; box-shadow: 0 0 8px 2px #ffc96ecc; animation: bulbs 1.8s ease-in-out infinite alternate; }
@keyframes bulbs { 40% { opacity: .4; } }
.pointer { position: absolute; z-index: 2; top: -6%; left: 50%; translate: -50%; width: 9%; aspect-ratio: .85; background: linear-gradient(135deg,#fff6c5,#ffc750 70%); clip-path: polygon(50% 100%, 0 20%, 10% 1%, 90% 1%, 100% 20%); }
.hub { position: absolute; width: 19%; aspect-ratio: 1; border: 3px solid #fff3b9; border-radius: 50%; color: #7f2331; background: radial-gradient(circle at 36% 30%, #fff4b9, #dfa451 80%); box-shadow: 0 3px 8px #2d071cc7; font: bold clamp(.8rem, 4vw, 2.7rem) Georgia, serif; overflow: hidden; }
.stage.is-spinning .hub { opacity: 1; }
.lantern { position: absolute; z-index: 1; top: 11%; width: 7.7%; aspect-ratio: .83; border-radius: 42% 42% 40% 40%; background: repeating-linear-gradient(0deg,#76282122 0 2px, transparent 3px 6px), radial-gradient(ellipse at center,#ff9a50,#ad273b 65%,#6d1733); box-shadow: 0 0 20px #ed65346a; transform-origin: top; animation: sway 3s ease-in-out infinite alternate; }
.lantern::before, .lantern::after { content: ''; position: absolute; left: 50%; translate: -50%; background: #e8ac62; }
.lantern::before { top: -6%; height: 9%; width: 50%; border-radius: 3px; }
.lantern::after { top: 97%; width: 9%; height: 30%; border-radius: 3px; }
.lantern.one { left: 2%; }
.lantern.two { right: 2%; top: 18%; width: 5.7%; animation-delay: -1.7s; }
@keyframes sway { from { rotate: -8deg; } to { rotate: 9deg; } }
.star { position: absolute; font-size: clamp(1.1rem,3vw,2.3rem); color: #ffdc94; }
.star.one { bottom: 17%; left: 3%; }
.star.two { bottom: 12%; right: 6%; }
.actions { grid-area: actions; align-self: start; }
.gold { border: 1px solid #ffe6a6; background: linear-gradient(128deg,#fff0b3,#e8a95a); color: #4a1720; border-radius: 2rem; min-height: 2.75rem; padding: .65rem 1.35rem; font-weight: 850; box-shadow: 0 3px 0 #9b542f; }
.gold:hover:not(:disabled) { background: #ffe7a7; }
#spin { padding-inline: 1.65rem; font-size: 1.12rem; min-height: 3.2rem; }
#spin span:first-child { margin-right: .2em; }
.status, .muted { color: var(--muted); font-size: .9rem; }
.status { margin: .7rem 0 0; min-height: 1.5em; }
footer { border-top-width: 1px; color: var(--muted); font-size: .85rem; }
footer p { margin: 0; }
.footer-brand { background: transparent; color: var(--gold); border: 0; padding: .35em .15em; min-height: 2.75rem; text-decoration: underline; text-underline-offset: .23em; font-weight: 850; }
.dialog { color: #fff3d7; border: 1px solid var(--edge); border-radius: 1.2rem; background: #4c1525; padding: 1.2rem; max-width: calc(100% - 1.25rem); max-height: calc(100% - 1.25rem); }
.dialog::backdrop { background: #220713d9; }
.result { width: 29rem; text-align: center; padding: 2rem 1rem; overflow: hidden; }
.result-content { position: relative; }
.envelope { margin: auto; display: grid; place-items: center; width: 3.9rem; aspect-ratio: .78; border: 1px solid #ffd288; border-radius: .35rem; background: linear-gradient(135deg,#c54845,#8c2237); box-shadow: 0 .45rem 1.1rem #260a17; rotate: -8deg; font: bold 1.8rem Georgia, serif; color: var(--gold); }
.result h2 { margin: 1rem 0 0; font-size: 1.7rem; }
.amount { margin: .25rem 0; line-height: 1.08; font-size: clamp(2.4rem, 10vw, 4.5rem); color: var(--gold); overflow-wrap: anywhere; }
.result .toolbar { justify-content: center; }
#confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.admin { width: 52rem; }
.admin h2 { margin: 0; font-size: 1.3rem; }
.admin-heading, .toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.admin-heading { justify-content: space-between; }
.admin label { display: block; font-size: .88rem; margin: .55rem 0 .2rem; }
.admin input { width: 100%; min-width: 0; border: 1px solid var(--edge); border-radius: .45rem; padding: .5rem; background: #350d1c; color: inherit; }
.admin input[type="color"] { height: 2.65rem; padding: .25rem; }
.admin input[type="password"] { max-width: 23rem; display: block; margin-bottom: .85rem; }
.admin details { margin: .9rem 0; border: 1px solid var(--edge); border-radius: .7rem; padding: .65rem; }
.admin summary { cursor: pointer; font-weight: 750; }
#copy-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .25rem .75rem; }
#slot-fields fieldset { min-width: 0; margin: .55rem 0; padding: .65rem; border: 1px solid var(--edge); border-radius: .55rem; }
.slot-grid { display: grid; grid-template-columns: 1fr 1.4fr .6fr .8fr; gap: .5rem; }
.slot-actions { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; }
#admin-status { color: #ffdc97; margin: .8rem 0 0; }
.sticky { position: sticky; top: -.2rem; background: #4c1525; padding-block: .55rem; z-index: 1; }
@media (max-width: 730px) {
  .shell { width: min(100% - 1.35rem, 33rem); }
  .hero { grid-template-columns: minmax(0,1fr); grid-template-rows: auto auto auto; grid-template-areas: "intro" "stage" "actions"; padding-block: 1.35rem 1.65rem; text-align: center; }
  h1 { font-size: clamp(2.55rem,9.9vw,4.75rem); }
  .lead, .timer { margin-inline: auto; }
  .kicker { margin-bottom: .6rem; }
  .countdown { margin-bottom: 1rem; }
  .stage { width: min(100%,25rem); }
  .actions { margin-top: .4rem; }
  .hub { font-size: clamp(1rem, 6.7vw, 2rem); }
  footer { justify-content: center; text-align: center; gap: 0 .65rem; }
}
@media (max-width: 540px) {
  .slot-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  #copy-fields { grid-template-columns: minmax(0,1fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }

/* Đêm giao thừa */
body {
  background: #26080f;
}
.ambient {
  position: absolute;
  opacity: 1;
  mask-image: none;
  min-height: 100svh;
  background:
    linear-gradient(90deg,#240710e8 0%,#270811a8 38%,#27081128 71%),
    linear-gradient(180deg,#26081042 0%,#26080f00 57%,#26080f 100%),
    #3d101d url('./dem-giao-thua.webp') center 42% / cover no-repeat;
}
.shell { width: min(79rem, 100% - 4rem); }
.top { padding-block: .9rem; }
.brand { text-transform: uppercase; }
.brand-mark { background: #f6cf83; color: #601625; border: 0; width: 2.1rem; height: 2.1rem; box-shadow: 0 0 16px #e6a6534f; }
.hero {
  grid-template-areas: "intro stage" "actions stage" "countdown stage";
  grid-template-rows: 1fr auto 1fr;
  grid-template-columns: minmax(0,.91fr) minmax(0,1.09fr);
  column-gap: clamp(1.5rem,6vw,6rem);
  padding: clamp(1.9rem,4vh,4rem) clamp(0rem,3vw,2.9rem);
}
.intro { align-self: end; }
.hero h1 { text-wrap: unset; }
.hero .lead { margin-bottom: 1.25rem; }
.hero .countdown { grid-area: countdown; align-self: start; margin: .35rem 0 0; }
.hero .timer { max-width: 21rem; }
.timer div { background: #2e101dcc; }
.stage { width: min(96%,34rem); }
.wheel-frame { background: linear-gradient(150deg,#fff4c7,#d78441 30%,#edbf76 59%,#fff0ad 74%,#a45125); box-shadow: 0 9px 0 #773628, 0 20px 38px #210008b5, 0 0 0 1px #f9d18b; }
.hub:disabled { opacity: 1; }
.actions { margin: 0; }
.status { margin: .62rem 0 .6rem; }
#spin, .preview-spin { min-height: 3.25rem; min-width: min(100%, 14rem); }
footer { padding-block: .65rem; }

.open-envelope {
  display: grid;
  justify-items: center;
  gap: 1.15rem;
  color: #fff2ca;
  font-weight: 800;
  width: min(100%, 20rem);
  padding: 1.2rem .9rem;
  border: 1px solid var(--edge);
  border-radius: 1rem;
  background: radial-gradient(ellipse at center,#a83b43,#5b172c 74%);
  margin: auto;
}
.envelope {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  width: 6.2rem;
  aspect-ratio: .76;
  border: 2px solid #ffd783;
  border-radius: .45rem;
  perspective: 20rem;
  background: linear-gradient(135deg,#cf5751,#7f1832);
  box-shadow: 0 10px 23px #310415b0;
  rotate: -7deg;
}
.dismiss-envelope { margin-top: .8rem; }
.envelope-lid {
  position: absolute;
  inset: 0 0 59%;
  background: linear-gradient(#ad283a,#e06456);
  transform-origin: top;
  clip-path: polygon(0 0,100% 0,100% 78%,50% 100%,0 78%);
}
.envelope-seal {
  z-index: 1;
  display: grid;
  place-items: center;
  color: #67172a;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: #ffdc8a;
  font-size: 1.05rem;
}
.open-envelope.opening .envelope-lid { animation: open-lid .28s ease forwards; }
.open-envelope.opening .envelope-seal { animation: release-seal .28s ease forwards; }
@keyframes open-lid { to { transform: rotateX(105deg); } }
@keyframes release-seal { to { opacity: 0; transform: translateY(-1rem); } }
#revealed:not([hidden]) { animation: reveal-result .28s ease both; }
@keyframes reveal-result { from { opacity: 0; translate: 0 .5rem; } }
#share-status:empty { display: none; }
.slot-actions { justify-content: flex-end; }
#simulation-counts { padding-left: 1.5rem; }
.phone-preview {
  max-width: 24rem;
  margin: .7rem auto .25rem;
  border: 5px solid #b38262;
  border-radius: 1rem;
  text-align: center;
  padding: .65rem;
  background: linear-gradient(#280e19aa,#220b14e3), #2e0b18 url('./dem-giao-thua.webp') 73% top / cover no-repeat;
  overflow-wrap: anywhere;
}
.phone-preview .intro { display: block; }
.phone-preview .kicker { margin-bottom: .35rem; font-size: .72rem; }
.phone-preview h1 { font-size: clamp(1.65rem,6vw,3.05rem); }
.phone-preview .lead { max-width: 29ch; margin: .45rem auto .7rem; font-size: .9rem; }
.phone-preview .stage { width: min(100%,17rem); margin: .2rem auto; }
.phone-preview .timer { margin-inline: auto; }
.phone-preview .status { margin-bottom: .6rem; }
.phone-preview .countdown { margin: .3rem auto .2rem; }
.preview-wheel { display: block; width: 92%; height: 92%; border-radius: 50%; }
.preview-spin, .phone-preview .hub { display: inline-grid; place-items: center; cursor: default; }
.phone-preview .hub { font-size: 1.15rem; }

@media (max-width: 730px) {
  .shell { width: min(34rem,100% - 1.4rem); }
  .top { padding-block: .56rem; }
  .ambient {
    background:
      linear-gradient(180deg,#290b17c2 0%,#320c186b 35%,#26080f 100%),
      #3d101d url('./dem-giao-thua.webp') right top / auto 94% no-repeat;
  }
  .hero { grid-template-columns: minmax(0,1fr); grid-template-areas: "intro" "stage" "actions" "countdown"; grid-template-rows: auto; padding: .9rem 0 1.15rem; gap: .15rem; }
  .hero h1 { font-size: clamp(2.2rem,9.6vw,4rem); }
  .hero .lead { margin: .35rem auto .75rem; max-width: min(34ch,100%); font-size: .93rem; }
  .kicker { margin-bottom: .43rem; font-size: .75rem; }
  .stage { width: min(90%,24rem); }
  .season { font-size: .73rem; padding: .23rem .62rem; }
  .actions { margin-top: .16rem; }
  .hero .countdown { margin-top: .25rem; }
  .hero .timer div { padding-block: .24rem; }
  footer { padding-block: .44rem; }
}
