:root{
  --bg:#000;
  --panel:#171717;
  --panel2:#252525;
  --white:#fff;
  --muted:#d7d7d7;
  --gold:#d7aa3b;
  --gold2:#f7d76c;
}
*{box-sizing:border-box}
html,body{margin:0;background:#000;color:#fff;min-height:100%;font-family:Inter,Arial,sans-serif}
body{display:flex;justify-content:center}
a{color:inherit;text-decoration:none}
.splash{position:fixed;inset:0;z-index:100;background:#000;display:flex;align-items:center;justify-content:center;transition:opacity .55s ease,visibility .55s ease}
.splash.hide{opacity:0;visibility:hidden}
.splash-logo{display:block;width:min(78vw,390px);height:auto;max-height:72dvh;object-fit:contain;border-radius:24px;opacity:0;transform:scale(.92);filter:drop-shadow(0 0 24px rgba(215,170,59,.18));animation:splashLogoIn 2.5s ease forwards}
@keyframes splashLogoIn{0%{opacity:0;transform:scale(.92)}24%{opacity:1;transform:scale(1)}78%{opacity:1;transform:scale(1.025)}100%{opacity:.98;transform:scale(1)}}
.app{width:min(100%,480px);min-height:100vh;background:#000;padding:max(44px,env(safe-area-inset-top)) 22px calc(48px + env(safe-area-inset-bottom));position:relative;overflow:hidden}
.app-hidden{opacity:0}
.app.ready{opacity:1;transition:opacity .35s ease}
.topbar{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-top:2px}
.topbar h1{font:400 clamp(31px,8vw,42px)/1 "Berkshire Swash",Georgia,serif;margin:0;color:#fff;letter-spacing:.2px}
.tagline{font-size:10px;letter-spacing:3px;margin-top:12px;color:#ddd;white-space:nowrap}
.history-link{display:flex;align-items:center;justify-content:center;width:48px;height:48px;margin-top:-5px;flex:0 0 auto}
.history-icon{width:43px;height:43px;overflow:visible}
.history-ring,.history-arrow,.history-hand{fill:none;stroke:#fff;stroke-width:3.4;stroke-linecap:round;stroke-linejoin:round}
.history-arrow{stroke-width:3.8}
.market-row{display:flex;justify-content:space-between;gap:12px;margin:40px 0 8px}
.market-item{font-size:18px;font-weight:700;display:flex;gap:8px;align-items:baseline}
.market-item span{color:var(--gold2)}
.market-item strong{color:#fff;font-size:18px}
.market-right{justify-content:flex-end;text-align:right}
.live-wrap{display:flex;justify-content:center;margin:10px 0 4px}
.poker-chip{width:min(66vw,300px);aspect-ratio:1;border-radius:50%;position:relative;border:2px solid var(--gold);background:repeating-conic-gradient(#f6f4ee 0deg 22deg,#070707 22deg 45deg);box-shadow:0 0 24px rgba(215,170,59,.25)}
.poker-chip::before{content:"";position:absolute;inset:17%;border-radius:50%;background:#f8f7f2;border:3px solid #080808;box-shadow:0 0 0 4px var(--gold),inset 0 0 0 2px rgba(0,0,0,.15)}
.chip-center{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#050505;font:500 clamp(72px,20vw,118px)/1 "Playfair Display",Georgia,serif;font-style:italic;z-index:2;transform:translateY(-2px)}
.status-pill{width:max-content;max-width:100%;margin:6px auto 20px;border:1px solid rgba(215,170,59,.9);border-radius:999px;padding:10px 16px;color:#fff;font-size:14px;white-space:nowrap;background:#050505}
.status-pill b{color:var(--gold2)}
.cards-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px 12px;margin-top:6px}
.result-card{position:relative;aspect-ratio:.78;border-radius:10px;border:1px solid rgba(215,170,59,.78);background:linear-gradient(145deg,#2d2d2d,#171717);overflow:hidden;display:flex;flex-direction:column;align-items:center;justify-content:space-between;padding:12px 8px;color:#fff}
.result-card.revealed .number{align-self:flex-start;font:700 26px/1 "Playfair Display",Georgia,serif}
.result-card.revealed .suit{font-size:52px;line-height:1;margin-top:-2px}
.result-card .time{font:600 15px/1 "Playfair Display",Georgia,serif;margin-bottom:4px}
.result-card.active{box-shadow:0 0 11px rgba(247,215,108,.85),inset 0 0 9px rgba(247,215,108,.15);border-color:var(--gold2)}
.card-back{background:radial-gradient(circle at center,#161616,#060606);padding:7px}
.card-back::before{content:"";position:absolute;inset:6px;border:1px solid var(--gold);border-radius:6px;background:repeating-linear-gradient(45deg,transparent 0 7px,rgba(215,170,59,.08) 7px 9px),repeating-linear-gradient(-45deg,transparent 0 7px,rgba(215,170,59,.08) 7px 9px)}
.card-back::after{content:"";position:absolute;inset:19%;border:1px solid rgba(215,170,59,.75);transform:rotate(45deg);border-radius:8px}
.back-mark{font-size:44px;color:var(--gold);z-index:2;margin:auto;opacity:.8}
.confetti{position:absolute;width:7px;height:12px;background:#e03d3d;transform:rotate(28deg);border-radius:1px}.c1{right:14%;top:12%}.c2{left:8%;bottom:28%;background:#e6ba49;transform:rotate(-25deg)}.c3{right:8%;bottom:12%;background:#f4cc5e;transform:rotate(60deg)}
.closed-note{text-align:center;margin:66px 0 6px;font:italic 500 17px/1.3 "Playfair Display",Georgia,serif;color:#f7f7f7}

.history-page{padding-top:max(34px,env(safe-area-inset-top));}
.history-topbar{display:grid;grid-template-columns:44px minmax(0,1fr);grid-template-areas:"back title" "brand brand";align-items:center;column-gap:12px;row-gap:10px;margin-bottom:34px}
.back-link{grid-area:back;font:300 58px/1 Georgia,serif;color:var(--gold2);transform:translateY(-3px);justify-self:start}
.history-topbar h1{grid-area:title;font:400 clamp(34px,10vw,56px)/1 "Berkshire Swash",Georgia,serif;margin:0;color:#fff;min-width:0}
.history-brand{grid-area:brand;font:400 clamp(17px,4.8vw,22px)/1 "Berkshire Swash",Georgia,serif;color:var(--gold2);white-space:nowrap;border-bottom:1px solid rgba(215,170,59,.35);padding:0 0 10px 0;justify-self:end;width:min(100%,330px);text-align:right}
.history-day{margin-bottom:40px}
.history-day h2{display:grid;grid-template-columns:minmax(32px,1fr) auto minmax(32px,1fr);gap:12px;align-items:center;text-align:center;margin:0 0 22px;font:500 clamp(24px,7.2vw,34px)/1 "Playfair Display",Georgia,serif;color:#fff}
.history-day h2 span{height:1px;background:linear-gradient(90deg,transparent,var(--gold),transparent)}
.history-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(108px,108px));justify-content:center;gap:16px 14px}
.history-card{width:108px;aspect-ratio:.82;border-radius:12px;border:1px solid rgba(215,170,59,.6);background:linear-gradient(145deg,#2f2f2f,#191919);display:grid;grid-template-rows:auto 1fr auto;padding:13px 10px 14px;box-shadow:0 4px 14px rgba(0,0,0,.2);margin:0 auto}
.history-card b{font:700 25px/1 "Playfair Display",Georgia,serif;align-self:start}
.history-card i{font-style:normal;font-size:48px;display:flex;align-items:center;justify-content:center}
.history-card small{text-align:center;font:500 16px/1 "Playfair Display",Georgia,serif}
@media (max-width:390px){
  .app{padding-left:16px;padding-right:16px}
  .tagline{letter-spacing:2px;font-size:9px}
  .market-row{margin-top:34px}
  .market-item,.market-item strong{font-size:16px}
  .status-pill{font-size:12px;padding:9px 12px}
  .cards-grid,.history-grid{gap:12px 10px}
  .history-brand{font-size:16px}
}


/* =========================================================
   RESPONSIVE HOME CANVAS — phone + tablet
   The Home design keeps one consistent proportion and scales
   to the *actual visible browser viewport* without overflow.
   ========================================================= */
.home-body{
  width:100%;
  height:100dvh;
  min-height:100dvh;
  overflow:hidden;
  overscroll-behavior:none;
  background:#000;
  position:relative;
}
.home-body .splash{
  width:100vw;
  height:100dvh;
  min-height:100dvh;
}
.home-body .app{
  /* Virtual design canvas. app.js scales this canvas to fit both
     width and height, so the same layout works on phones/tablets. */
  width:390px;
  height:720px;
  min-height:720px;
  max-height:720px;
  padding:12px 16px 10px;
  position:fixed;
  top:0;
  left:50%;
  transform-origin:top center;
  transform:translateX(-50%) scale(var(--home-scale,1));
  display:flex;
  flex-direction:column;
  overflow:hidden;
  background:#000;
}
.home-body .topbar{
  flex:0 0 48px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  margin:0;
}
.home-body .topbar h1{
  font-size:31px;
  line-height:.96;
  white-space:nowrap;
}
.home-body .tagline{
  margin-top:7px;
  font-size:7.8px;
  letter-spacing:2.15px;
  white-space:nowrap;
}
.home-body .history-link{
  width:42px;
  height:42px;
  margin-top:-1px;
  flex:0 0 42px;
}
.home-body .history-icon{width:39px;height:39px}
.home-body .market-row{
  flex:0 0 29px;
  margin:14px 0 2px;
  gap:8px;
  align-items:center;
}
.home-body .market-item,
.home-body .market-item strong{font-size:16px}
.home-body .market-item{gap:6px}
.home-body .live-wrap{
  flex:0 0 208px;
  height:208px;
  display:flex;
  align-items:center;
  justify-content:center;
  margin:0;
}
.home-body .poker-chip{
  width:202px;
  height:202px;
  aspect-ratio:auto;
  border-width:1.8px;
  box-shadow:0 0 18px rgba(215,170,59,.22);
}
.home-body .poker-chip::before{inset:17%}
.home-body .chip-center{font-size:80px}
.home-body .status-pill{
  flex:0 0 auto;
  margin:2px auto 9px;
  padding:6px 12px;
  font-size:11.5px;
  line-height:1.05;
}
.home-body .cards-grid{
  flex:0 0 294px;
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  grid-template-rows:repeat(2,143px);
  gap:8px 10px;
  margin:0;
}
.home-body .result-card{
  width:100%;
  height:143px;
  aspect-ratio:auto;
  border-radius:8px;
  padding:9px 7px 8px;
}
/* Revealed cards match the reference: plain charcoal, white details,
   without the decorative gold frame used in the previous version. */
.home-body .result-card.revealed{
  border:1px solid #454545;
  background:#303030;
  box-shadow:none;
}
.home-body .result-card.revealed.active{
  border-color:#454545;
  box-shadow:none;
}
.home-body .result-card.revealed .number{
  font-size:23px;
  line-height:1;
}
.home-body .result-card.revealed .suit{
  font-size:44px;
  line-height:1;
  margin-top:-2px;
}
.home-body .result-card .time{
  font-size:13px;
  margin-bottom:1px;
}
/* Use the exact black/grey doodle card-back look from the user's reference. */
.home-body .result-card.card-back{
  border:0;
  border-radius:0;
  padding:0;
  background:#2e2e2e url('assets/card-back-reference.png') center/100% 100% no-repeat;
  box-shadow:none;
}
.home-body .result-card.card-back::before,
.home-body .result-card.card-back::after{display:none}
.home-body .card-back .back-mark{display:none}
.home-body .confetti{width:6px;height:10px}
.home-body .closed-note{
  flex:1 1 auto;
  min-height:27px;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  margin:0;
  padding:8px 0 0;
  font-size:14px;
  white-space:nowrap;
}

/* History stays scrollable and scales naturally on both phones/tablets. */
.history-body{
  overflow-y:auto;
  overflow-x:hidden;
  min-height:100%;
  background:#000;
}
.history-body .app{
  width:min(100%,720px);
  min-height:100vh;
  overflow:visible;
  padding-left:clamp(16px,4vw,30px);
  padding-right:clamp(16px,4vw,30px);
}
@media (min-width:700px){
  .history-topbar{grid-template-columns:54px 1fr auto;grid-template-areas:"back title brand";margin-bottom:46px}
  .history-topbar h1{font-size:46px}
  .history-brand{font-size:22px;padding-left:14px;width:auto}
  .history-day h2{font-size:31px}
  .history-grid{grid-template-columns:repeat(auto-fit,minmax(126px,126px));gap:18px 20px}
  .history-card{width:126px}
  .history-card b{font-size:30px}
  .history-card i{font-size:58px}
  .history-card small{font-size:19px}
}
@media (max-width:390px){
  .history-body .app{padding-left:14px;padding-right:14px}
  .history-topbar{column-gap:10px;row-gap:8px;margin-bottom:28px}
  .history-brand{font-size:15px;width:min(100%,260px)}
  .history-grid{grid-template-columns:repeat(auto-fit,minmax(96px,96px));gap:11px 9px}
  .history-card{width:96px;padding:11px 9px 12px}
  .history-card b{font-size:22px}
  .history-card i{font-size:42px}
  .history-card small{font-size:14px}
}


/* Random-circle home variant */
.open-note{width:100%;margin:6px auto 16px;text-align:center;color:#fff;font:500 13px/1.35 "Playfair Display",Georgia,serif;white-space:nowrap}
.home-body .live-wrap{flex:0 0 222px;height:222px}
.home-body .poker-chip{width:214px;height:214px;border:0;background:repeating-conic-gradient(#f2f0ea 0deg 20deg,#111111 20deg 45deg);box-shadow:none}
.home-body .poker-chip::before{inset:17%;border:0;background:#f3f2ee;box-shadow:none}
.home-body .poker-chip::after{content:"";position:absolute;inset:26%;border-radius:50%;border:2.5px dashed rgba(255,255,255,.85);z-index:1}
.home-body .chip-center{font-size:84px;letter-spacing:-3px}
.home-body .cards-grid{flex:0 0 318px;grid-template-rows:repeat(2,154px);gap:12px 10px}
.home-body .result-card{height:154px;border-radius:0}
.home-body .result-card.card-back{background:#2e2e2e url('assets/card-back-reference.png') center/100% 100% no-repeat;border:0;border-radius:0}
.home-body .closed-note{padding-top:10px;font-size:13px}
@media (max-width:390px){
  .open-note{font-size:12px}
}

/* =========================================================
   RANDOM CHIP — match the original Mega Burma reference
   6 white rounded blocks on a dark ring + inner dashed ring.
   ========================================================= */
.home-body .poker-chip{
  width:202px !important;
  height:202px !important;
  position:relative;
  border:2px solid rgba(255,255,255,.14) !important;
  border-radius:50%;
  background:#2a2528 !important;
  box-shadow:
    0 0 0 2px rgba(215,170,59,.10),
    0 0 16px rgba(255,255,255,.045),
    0 8px 20px rgba(0,0,0,.32) !important;
  overflow:hidden;
}
.home-body .poker-chip::before{
  content:"";
  position:absolute;
  inset:22%;
  border-radius:50%;
  background:#f7f7f5;
  border:0 !important;
  box-shadow:none !important;
  z-index:1;
}
.home-body .poker-chip::after{
  content:"";
  position:absolute;
  inset:17.5%;
  border-radius:50%;
  border:2px dashed rgba(255,255,255,.92);
  z-index:2;
  pointer-events:none;
}
.home-body .chip-seg{
  position:absolute;
  left:50%;
  top:50%;
  width:23%;
  height:12%;
  margin-left:-11.5%;
  margin-top:-6%;
  background:#fff;
  border-radius:5px;
  z-index:3;
  transform-origin:50% 50%;
}
.home-body .chip-seg.s1{ transform:rotate(30deg) translateY(-76px); }
.home-body .chip-seg.s2{ transform:rotate(90deg) translateY(-76px); }
.home-body .chip-seg.s3{ transform:rotate(150deg) translateY(-76px); }
.home-body .chip-seg.s4{ transform:rotate(210deg) translateY(-76px); }
.home-body .chip-seg.s5{ transform:rotate(270deg) translateY(-76px); }
.home-body .chip-seg.s6{ transform:rotate(330deg) translateY(-76px); }

.home-body .chip-center{
  z-index:4;
  font-family:Georgia, "Times New Roman", serif !important;
  font-style:italic !important;
  font-weight:400 !important;
  font-size:70px !important;
  letter-spacing:-3px;
  transform:none !important;
}

/* Final Random ?? font fix */
.home-body .chip-center{
  font-family:"Times New Roman", Times, serif !important;
  font-style:italic !important;
  font-weight:400 !important;
  font-size:74px !important;
  line-height:1 !important;
  letter-spacing:-5px !important;
  transform:translateY(-1px) !important;
}

/* =========================================================
   ROTATING OUTER RING
   Outer dark ring + six white blocks rotate continuously.
   Center white circle + random number stay still.
   1 full turn = 14 seconds.
   ========================================================= */
.home-body .poker-chip{
  background:#2a2528 !important;
}
.home-body .chip-rotor{
  position:absolute;
  inset:0;
  border-radius:50%;
  z-index:3;
  animation:megaChipSpin 14s linear infinite;
  transform-origin:50% 50%;
  will-change:transform;
}
@keyframes megaChipSpin{
  from{transform:rotate(0deg)}
  to{transform:rotate(360deg)}
}

/* Keep the random number and inner white circle above the rotating ring */
.home-body .poker-chip::before{z-index:4}
.home-body .poker-chip::after{z-index:5}
.home-body .chip-center{z-index:6}

/* Segment positions live inside the rotating rotor */
.home-body .chip-rotor .chip-seg{z-index:1}

/* Respect devices that explicitly request reduced motion */
@media (prefers-reduced-motion: reduce){
  .home-body .chip-rotor{animation-duration:28s}
}

/* =========================================================
   LIVE NUMBER FEEL
   - subtle breathing glow all the time
   - quick pop when the 8-second number changes
   ========================================================= */
.home-body .chip-center{
  animation:liveNumberBreath 1.8s ease-in-out infinite;
  text-shadow:
    0 0 2px rgba(0,0,0,.18),
    0 0 10px rgba(215,170,59,.12);
  will-change:transform,filter,text-shadow;
}
@keyframes liveNumberBreath{
  0%,100%{
    filter:brightness(1);
    text-shadow:
      0 0 2px rgba(0,0,0,.18),
      0 0 8px rgba(215,170,59,.10);
  }
  50%{
    filter:brightness(1.08);
    text-shadow:
      0 0 2px rgba(0,0,0,.14),
      0 0 14px rgba(215,170,59,.20);
  }
}
.home-body .chip-center.number-change{
  animation:
    liveNumberPop .46s cubic-bezier(.2,.9,.2,1),
    liveNumberBreath 1.8s ease-in-out .46s infinite;
}
@keyframes liveNumberPop{
  0%{transform:scale(.80);opacity:.25}
  45%{transform:scale(1.14);opacity:1}
  72%{transform:scale(.97);opacity:1}
  100%{transform:scale(1);opacity:1}
}

/* =========================================================
   MYANMAR NIGHT STYLE — LIVE 2D FLASH
   Same number flashes in place only.
   NO jump, NO bounce, NO scaling, NO movement.
   ========================================================= */
.home-body .chip-center{
  opacity:1;
  transform:none !important;
  text-shadow:none !important;
}

.home-body .chip-center.mn-flash{
  animation:mnLiveFlash 1.65s steps(1,end) 1 !important;
}

@keyframes mnLiveFlash{
   0% {opacity:1}
  12% {opacity:0}
  24% {opacity:1}
  36% {opacity:0}
  48% {opacity:1}
  60% {opacity:0}
  72% {opacity:1}
  84% {opacity:0}
 100% {opacity:1}
}

/* =========================================================
   PURE BLINK FIX
   Force the live number to ONLY appear/disappear in place.
   No bounce, no scale, no breathing, no transform.
   ========================================================= */
.home-body .chip-center,
.home-body .chip-center.number-change,
.home-body .chip-center.number-blink,
.home-body .chip-center.mn-flash{
  transform:none !important;
  filter:none !important;
  text-shadow:none !important;
  will-change:opacity !important;
}

.home-body .chip-center{
  animation:none !important;
  opacity:1 !important;
}

.home-body .chip-center.mn-flash{
  animation:mnPureBlink 1.6s step-end 1 !important;
}

@keyframes mnPureBlink{
  0%   { opacity:1; }
  12%  { opacity:0; }
  24%  { opacity:1; }
  36%  { opacity:0; }
  48%  { opacity:1; }
  60%  { opacity:0; }
  72%  { opacity:1; }
  84%  { opacity:0; }
  100% { opacity:1; }
}


/* =========================================================
   TRUE BLINK ONLY
   JS will control opacity directly.
   No jump, no scale, no movement.
   ========================================================= */
.home-body .chip-center,
.home-body .chip-center.number-change,
.home-body .chip-center.number-blink,
.home-body .chip-center.mn-flash{
  animation:none !important;
  transform:none !important;
  filter:none !important;
  text-shadow:none !important;
  opacity:1;
}


/* =========================================================
   CONTINUOUS LIVE BLINK
   JS controls visibility only.
   No transform / bounce / scale / opacity animation.
   ========================================================= */
.home-body .chip-center,
.home-body .chip-center.number-change,
.home-body .chip-center.number-blink,
.home-body .chip-center.mn-flash{
  animation:none !important;
  transform:none !important;
  filter:none !important;
  text-shadow:none !important;
  opacity:1 !important;
}


/* =========================================================
   FINAL SERVER-SYNC LIVE MODE
   ========================================================= */
.home-body .chip-rotor{
  animation-play-state:paused !important;
}
.home-body.live-open .chip-rotor{
  animation-play-state:running !important;
}
.home-body .chip-center{
  animation:none !important;
  transform:none !important;
  filter:none !important;
  text-shadow:none !important;
  opacity:1 !important;
  will-change:auto !important;
}
.home-body .open-note{
  min-height:18px;
}
.home-body .result-card.card-back::after{
  content:attr(data-slot);
  display:block !important;
  position:absolute;
  left:50%;
  bottom:5px;
  transform:translateX(-50%) !important;
  inset:auto !important;
  border:0 !important;
  border-radius:0 !important;
  color:rgba(255,255,255,.74);
  background:rgba(0,0,0,.50);
  padding:2px 6px;
  font:600 10px/1.2 Inter,Arial,sans-serif;
  letter-spacing:.2px;
  z-index:4;
  white-space:nowrap;
}


/* =========================================================
   RESULT FLIP TEST MODE
   Six cards reveal one by one with fast spin + stop + confetti.
   ========================================================= */
.home-body.live-open .chip-rotor{animation-play-state:running !important;}
.home-body.spin-fast .chip-rotor{animation-duration:1.1s !important;}
.home-body.spin-stop .chip-rotor{animation-play-state:paused !important;}
.home-body .result-card.flip-card{
  perspective:1000px;
  overflow:visible;
  background:transparent;
  border:0;
  padding:0;
}
.home-body .card-flip-shell{
  position:relative;
  width:100%;
  height:100%;
  transform-style:preserve-3d;
  transition:transform .82s cubic-bezier(.2,.85,.2,1);
}
.home-body .result-card.revealed .card-flip-shell{transform:rotateY(180deg);}
.home-body .card-face{
  position:absolute;
  inset:0;
  backface-visibility:hidden;
  -webkit-backface-visibility:hidden;
}
.home-body .card-back-face{
  border:0;
  border-radius:0;
  background:#2e2e2e url('assets/card-back-reference.png') center/100% 100% no-repeat;
}
.home-body .card-front-face{
  transform:rotateY(180deg);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:space-between;
  padding:9px 7px 8px;
  border:1px solid #454545;
  border-radius:0;
  background:#303030;
  color:#fff;
}
.home-body .card-front-face .number{
  align-self:flex-start;
  font:700 23px/1 "Playfair Display",Georgia,serif;
}
.home-body .card-front-face .suit{
  font-size:44px;
  line-height:1;
  margin-top:-2px;
}
.home-body .card-front-face .time{
  font:600 13px/1 "Playfair Display",Georgia,serif;
  margin-bottom:1px;
}
.home-body .result-card.active .card-flip-shell,
.home-body .result-card.revealed.active .card-flip-shell{
  filter:drop-shadow(0 0 10px rgba(255,221,115,.55));
}
.home-body .result-card.flip-card.card-back::after,
.home-body .result-card.flip-card.card-back::before{display:none !important;}
.home-body .confetti-layer{
  position:absolute;
  left:0;
  right:0;
  top:205px;
  bottom:0;
  height:auto;
  pointer-events:none;
  overflow:hidden;
  z-index:40;
}
.home-body .confetti-piece{
  position:absolute;
  width:8px;
  height:14px;
  border-radius:2px;
  opacity:0;
}
.home-body .confetti-layer.show .confetti-piece{
  animation:megaConfettiFall var(--fall-duration,11s) linear forwards;
}
@keyframes megaConfettiFall{
  0%{opacity:0; transform:translate3d(0,-24px,0) rotate(0deg) scale(.9);}
  6%{opacity:1; transform:translate3d(calc(var(--drift-mid, 0px) * .25),18px,0) rotate(60deg) scale(1);}
  30%{opacity:1; transform:translate3d(var(--drift-mid, 0px),170px,0) rotate(180deg) scale(1);}
  58%{opacity:1; transform:translate3d(calc(var(--drift-x, 0px) * .55),340px,0) rotate(320deg) scale(1);}
  84%{opacity:1; transform:translate3d(var(--drift-x, 0px),500px,0) rotate(500deg) scale(1);}
  100%{opacity:0; transform:translate3d(calc(var(--drift-x, 0px) * .7),650px,0) rotate(660deg) scale(1);}
}

/* =========================================================
   iPhone / Safari 3D flip reliability fix
   Keep visual glow off the 3D shell because CSS filters can
   flatten preserve-3d on WebKit and leave the card back visible.
   ========================================================= */
.home-body .result-card.flip-card{
  -webkit-perspective:1000px;
  perspective:1000px;
}
.home-body .card-flip-shell{
  -webkit-transform-style:preserve-3d;
  transform-style:preserve-3d;
  -webkit-transition:-webkit-transform .82s cubic-bezier(.2,.85,.2,1);
  transition:transform .82s cubic-bezier(.2,.85,.2,1);
  will-change:transform;
}
.home-body .card-face{
  -webkit-backface-visibility:hidden !important;
  backface-visibility:hidden !important;
}
.home-body .card-back-face{
  -webkit-transform:rotateY(0deg) translateZ(.1px);
  transform:rotateY(0deg) translateZ(.1px);
}
.home-body .card-front-face{
  -webkit-transform:rotateY(180deg) translateZ(.1px);
  transform:rotateY(180deg) translateZ(.1px);
}
.home-body .result-card.revealed .card-flip-shell{
  -webkit-transform:rotateY(180deg) !important;
  transform:rotateY(180deg) !important;
}
.home-body .result-card.active .card-flip-shell,
.home-body .result-card.revealed.active .card-flip-shell{
  filter:none !important;
  -webkit-filter:none !important;
}
.home-body .result-card.flip-card.active{
  box-shadow:0 0 12px rgba(255,221,115,.58);
}

.history-empty{padding:60px 12px;text-align:center;color:#aaa;font:500 16px/1.4 Inter,Arial,sans-serif;}


/* History always keeps the full six-card board for the active date. */
.history-grid-six{grid-template-columns:repeat(3,108px);justify-content:center;}
.history-card-back{
  padding:0 !important;
  border:0 !important;
  border-radius:0 !important;
  background:#2e2e2e url('assets/card-back-reference.png') center/100% 100% no-repeat !important;
  box-shadow:none !important;
}
@media (min-width:700px){
  .history-grid-six{grid-template-columns:repeat(3,126px);}
}
@media (max-width:390px){
  .history-grid-six{grid-template-columns:repeat(3,96px);}
}

/* FINAL status readability on phones */
.home-body .open-note{
  font-size:14px !important;
  line-height:1.35;
}


/* =========================================================
   PWA INSTALL PROMPT
   Shows after the splash screen when the site is not already installed.
   Android/Chromium uses the native install prompt; iOS shows A2HS steps.
   ========================================================= */
.pwa-install-prompt{
  position:fixed;
  inset:0;
  z-index:140;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  padding:18px max(14px,env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left));
  background:rgba(0,0,0,.56);
  backdrop-filter:blur(4px);
  -webkit-backdrop-filter:blur(4px);
}
.pwa-install-prompt[hidden]{display:none!important}
.pwa-install-card{
  position:relative;
  width:min(100%,420px);
  border:1px solid rgba(247,215,108,.42);
  border-radius:22px;
  padding:18px 18px 14px;
  background:linear-gradient(155deg,#222,#0d0d0d 72%);
  box-shadow:0 18px 48px rgba(0,0,0,.62),0 0 22px rgba(215,170,59,.12);
  text-align:center;
  animation:pwaInstallRise .32s ease-out both;
}
@keyframes pwaInstallRise{
  from{opacity:0;transform:translateY(24px) scale(.97)}
  to{opacity:1;transform:translateY(0) scale(1)}
}
.pwa-install-close{
  position:absolute;
  right:10px;
  top:8px;
  width:34px;
  height:34px;
  border:0;
  background:transparent;
  color:#aaa;
  font:300 30px/32px Arial,sans-serif;
}
.pwa-install-icon{
  width:74px;
  height:74px;
  border-radius:18px;
  object-fit:cover;
  margin:0 auto 10px;
  box-shadow:0 5px 18px rgba(0,0,0,.35),0 0 12px rgba(247,215,108,.15);
}
.pwa-install-title{
  color:#fff;
  font:700 20px/1.2 Inter,Arial,sans-serif;
  margin-bottom:7px;
}
.pwa-install-text{
  color:#ddd;
  font:500 13px/1.45 Inter,Arial,sans-serif;
  min-height:38px;
  padding:0 4px;
}
.pwa-install-button{
  width:100%;
  margin-top:14px;
  border:1px solid #f1c94c;
  border-radius:14px;
  padding:12px 14px;
  background:linear-gradient(180deg,#f8dc75,#d7aa3b);
  color:#111;
  font:700 15px/1 Inter,Arial,sans-serif;
  box-shadow:0 5px 15px rgba(215,170,59,.18);
}
.pwa-install-later{
  width:100%;
  margin-top:7px;
  border:0;
  background:transparent;
  color:#aaa;
  padding:9px 10px 5px;
  font:600 13px/1 Inter,Arial,sans-serif;
}
@media (min-width:700px){
  .pwa-install-prompt{align-items:center}
}
