:root{
  --sky-top:#0a0e26;
  --sky-mid:#1c1a45;
  --sky-bottom:#3c2c5c;
  --moon:#ffe9b8;
  --moon-core:#fff8e6;
  --moon-glow:rgba(255,207,122,.55);
  --jade:#4fae8e;
  --jade-bright:#7fe0b8;
  --jade-deep:#2b6b56;
  --lantern:#e6543f;
  --lantern-dark:#a92c1f;
  --osmanthus:#f2c14e;
  --moonsoil-dark:#241f3a;
  --moonsoil:#3a3358;
  --moonsoil-light:#554b7d;
  --cream:#fdf3e2;
  --cream-dim:rgba(253,243,226,.72);
  --card-bg:rgba(15,13,38,.6);
  --card-border:rgba(255,233,184,.16);
  --shadow:rgba(4,3,16,.55);
}

*{box-sizing:border-box;}

body{
  margin:0;

 
  align-items:center;
  justify-content:center;
  background:linear-gradient(180deg,var(--sky-top) 0%,var(--sky-mid) 55%,var(--sky-bottom) 100%);
  color:var(--cream);
  font-family:'Noto Sans SC',-apple-system,BlinkMacSystemFont,sans-serif;

  -webkit-tap-highlight-color:transparent;
  user-select:none;
  position:relative;
}

/* Don't rely solely on the Bootstrap CDN for positioning that the whole
   layout depends on — if that CDN fails to load, .position-relative and
   .position-absolute would silently do nothing and everything built on
   top of them collapses. These are defined directly as a guaranteed fallback. */
main.d-lg-flex > section{position:relative;}

/* ---------- game page: same d-lg-flex + section + #bg pattern as the
   login page — photo in normal flow gives the section its shape, the game
   card overlays on top of it ---------- */
.stage.position-absolute{
  position:absolute;
  left:50%; top:21%; transform:translateX(-50%);
  background:none; border:none; box-shadow:none; backdrop-filter:none;
  width:94%; max-width:420px;
}
/* ---------- login page: photo in normal flow gives the card its shape,
   the form overlays on top of it ---------- */

#bg{

  width:100%;
  height:auto;

}
/* title + login card now move together as one unit */
.login-group.position-absolute{
  position:absolute;
  left:50%; top:32%; transform:translate(-50%,-50%);
  width:90%; max-width:380px;
  display:flex; flex-direction:column; align-items:center;
  gap:16px;
  z-index:2;
}
.login-group .title-img{width:80%; display:block;}
.login-group .overlay-card{
  width:100%;
  aspect-ratio:964/716;
  box-sizing:border-box;
  background:url('image/frame.png') center/100% 100% no-repeat;
  justify-content:center;
  gap:6px;
  padding:11% 16% 9% 16%;
  text-align:center;
}
.login-group .overlay-card .sub{font-size:clamp(12px,3.2vw,15px); line-height:1.3;}
.login-group .overlay-card .field{
  max-width:320px;
  font-size:17px;
  padding:14px 18px;
}
.login-group .overlay-card .cta{
  background:none; box-shadow:none; padding:0;
  width:100%; display:flex; justify-content:center;
}
.login-group .overlay-card .cta img{
  width:min(220px,70%); display:block; margin:0 auto;
}
.login-group .overlay-card .cta.is-busy img{opacity:.6;}


@media (prefers-reduced-motion: reduce){
  *{animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important;}
}

/* ---------- stage ---------- */
.stage{
  position:relative; z-index:1;
  width:min(560px,92vw);
  max-height:94vh;
  background:var(--card-bg);
  border:1px solid var(--card-border);
  border-radius:28px;
  padding:clamp(14px,3vw,26px);
  backdrop-filter:blur(6px);
  box-shadow:0 30px 60px var(--shadow);
  display:flex; flex-direction:column; gap:clamp(10px,2vw,18px);
}

.hud{display:flex; align-items:center; justify-content:center; gap:10px;}
.brand{
  font-family:'Ma Shan Zheng',cursive; font-weight:400;
  font-size:clamp(20px,4.6vw,28px); color:var(--moon);
  margin:0; text-shadow:0 0 18px rgba(255,207,122,.4);
  text-wrap:balance;
}
.pill{
  display:flex; align-items:center; gap:6px;
  background:rgba(12,35,26,.85);
  border:1.5px solid rgba(127,224,184,.85);
  color:var(--cream);
  padding:8px 16px; border-radius:999px;
  font-weight:700; font-variant-numeric:tabular-nums;
  font-size:clamp(14px,3.8vw,18px);
  white-space:nowrap;
  box-shadow:0 4px 14px rgba(0,0,0,.5);
}
.pill .label{font-weight:500; color:var(--cream-dim); font-size:.85em;}
.pill.pulse{animation:pulse-pill .35s ease;}
@keyframes pulse-pill{0%{transform:scale(1);} 40%{transform:scale(1.14);} 100%{transform:scale(1);}}
.pill.time-low{background:rgba(230,84,63,.22); border-color:rgba(230,84,63,.5);}

/* the wooden "你还有 X 次机会" sign, positioned like the reference art */
.chance-sign{
  position:absolute; left:50%; top:68%; transform:translate(-50%,-50%);
  width:72%; max-width:340px;
  display:flex; align-items:center; justify-content:center;
  z-index:3;
}
/* don't let it show through the semi-transparent overlays behind it */
section:has(.overlay:not(.hidden)) .chance-sign,
section:has(.overlay:not(.hidden)) .stage.position-absolute,
section:has(.overlay:not(.hidden)) .claim-btn-wrap{display:none;}
.chance-sign-bg{
  width:100%; display:block;
  filter:drop-shadow(0 8px 14px rgba(0,0,0,.45));
}
.chance-sign-text{
  position:absolute; left:50%; top:48%; transform:translate(-50%,-50%);
  color:#fff4dd; font-weight:900;
  font-size:clamp(15px,4.2vw,21px);
  text-shadow:0 2px 3px rgba(0,0,0,.6);
  white-space:nowrap;
}
.chance-sign-text b{color:var(--osmanthus); font-size:1.25em;}
.chance-sign.time-low .chance-sign-text b{color:#ff8b78;}
/* already played today — a quieter two-line status instead of "X 次机会" */
.chance-sign.done .chance-sign-text{
  white-space:normal; width:82%; text-align:center;
  font-size:clamp(12px,3.4vw,16px);
  line-height:1.35;
}
.chance-sign.done .chance-sign-text b{font-size:1.15em;}

/* "领取奖励" button shown below the sign once today's scenario is done */
.claim-btn-wrap{
  position:absolute; left:50%; top:84%; transform:translate(-50%,-50%);
  width:60%; max-width:220px;
  z-index:3;
}
.claim-btn-wrap.hidden{display:none;}
.claim-btn-wrap .cta.secondary img{width:100%;}

/* Sits over the whole photo; each .hole is placed at its own {left,top} %
   (set inline by game.html) matching a grass wreath in the reference art,
   so the board itself doesn't lay out its children — it's just an anchor. */
.board{
  position:absolute; inset:0;
  pointer-events:none;
}

.hole{
  position:absolute;
  transform:translate(-50%,-50%);
  width:27%;
  aspect-ratio:1/1;
  border:none; padding:0; margin:0; background:none; cursor:pointer;
  border-radius:16px;
  outline-offset:4px;
  pointer-events:auto;
}
.hole:focus-visible{outline:2px solid var(--jade-bright);}

.hole-img{
  position:absolute; inset:0;
  width:100%; height:100%;
  object-fit:contain;
  pointer-events:none; user-select:none;
  z-index:1;
}

.peek-mask{
  position:absolute; left:0; right:0; bottom:28%; height:68%;
  overflow:hidden; z-index:2;
}

.rise{
  position:absolute; left:50%; bottom:-30px;
  width:90%; max-width:108px; aspect-ratio:1/1;
  transform:translate(-50%,130%);
  opacity:0;
  transition:transform .3s cubic-bezier(.32,1.6,.56,1), opacity .25s ease;
}
/* waiting to be caught: the whole ear photo clears the opening */
.hole.active .rise{transform:translate(-50%,-18%); opacity:1;}
/* caught: ears duck away, the prize modal takes over */
.hole.active.revealed .rise{
  transform:translate(-50%,130%); opacity:0;
  transition:transform .22s ease-in, opacity .18s ease-in;
}

.bob{position:relative; width:100%; height:100%; transform-origin:50% 100%;}
.hole.active:not(.revealed) .bob{animation:ear-pulse 1.1s ease-in-out .25s infinite;}
@keyframes ear-pulse{0%,100%{transform:scale(1);} 50%{transform:scale(1.1);}}

.ear-img{
  width:100%; height:100%; object-fit:contain; display:block;
  pointer-events:none; user-select:none;
}

/* ---------- prize reveal ---------- */
.prize-modal .overlay-card{gap:16px;}
.prize-modal-img{
  width:min(220px,58vw); display:block;
  filter:drop-shadow(0 16px 24px rgba(4,3,16,.55));
  animation:prize-pop .4s cubic-bezier(.34,1.56,.64,1);
}
.prize-modal-score{
  background:linear-gradient(180deg,var(--jade-bright),var(--jade-deep));
  color:#0c231b; font-weight:900; font-size:clamp(20px,5.5vw,28px);
  padding:6px 28px; border-radius:999px;
  box-shadow:0 10px 22px rgba(4,3,16,.4);
  font-variant-numeric:tabular-nums;
  animation:prize-pop .4s cubic-bezier(.34,1.56,.64,1);
}
.overlay.jackpot .prize-modal-img{filter:drop-shadow(0 0 24px rgba(127,224,184,.9)) drop-shadow(0 16px 24px rgba(4,3,16,.55));}
.overlay.jackpot .prize-modal-score{background:linear-gradient(180deg,var(--osmanthus),#c98f1f); color:#3a2504;}

/* the final "恭喜你赢得了 RM..." card, picked to match the exact session total */
.final-prize-img {
    width: 76%;
    display: block;
    filter: drop-shadow(0 16px 28px rgba(4, 3, 16, .55));
    animation: prize-pop .45s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes prize-pop{0%{transform:scale(.4); opacity:0;} 65%{transform:scale(1.08); opacity:1;} 100%{transform:scale(1); opacity:1;}}

.sparkle-wrap{position:absolute; inset:0; z-index:9; pointer-events:none;}
.spark{position:absolute; left:50%; top:44%; width:6px; height:6px; border-radius:50%; background:var(--jade-bright); opacity:0; animation:spark-fly .5s ease-out forwards;}
@keyframes spark-fly{
  0%{opacity:1; transform:translate(-50%,-50%) translate(0,0) scale(1);}
  100%{opacity:0; transform:translate(-50%,-50%) translate(var(--dx),var(--dy)) scale(.3);}
}

.hint{
  margin:0; text-align:center; color:var(--cream-dim);
  font-size:clamp(12px,3vw,14px); line-height:1.5;
  text-shadow:0 1px 4px rgba(0,0,0,.8);
}

/* ---------- overlays ---------- */
.overlay{
  position:absolute; inset:0; z-index:10;
  display:flex; align-items:center; justify-content:center;
  background:rgba(8,7,24,.72);
  border-radius:28px;
  text-align:center;
}
.overlay.hidden{display:none;}
.overlay-card{display:flex; flex-direction:column; align-items:center; gap:14px; padding:0 22px;}
.overlay-card h1{
  font-family:'Ma Shan Zheng',cursive; font-weight:400;
  font-size:clamp(34px,9vw,52px); margin:0; color:var(--moon);
  text-shadow:0 0 26px rgba(255,207,122,.5);
}
.sub{margin:0; color:white; font-size:20px; max-width:34ch; line-height:1.6;}
.stat-row{display:flex; gap:10px; margin:2px 0;}
.stat{
  background:rgba(79,174,142,.14); border:1px solid rgba(127,224,184,.3);
  border-radius:14px; padding:8px 18px; min-width:84px;
}
.stat .n{display:block; font-size:22px; font-weight:900; font-variant-numeric:tabular-nums; color:var(--jade-bright);}
.stat .l{display:block; font-size:11px; color:var(--cream-dim); margin-top:2px;}
.cta{
  appearance:none; border:none; cursor:pointer;
  background:linear-gradient(180deg,var(--jade-bright),var(--jade-deep));
  color:#0c231b; font-weight:900; font-size:16px;
  padding:12px 34px; border-radius:999px;
  box-shadow:0 10px 22px rgba(43,107,86,.45);
  transition:transform .15s ease, box-shadow .15s ease;
  font-family:'Noto Sans SC',sans-serif;
}
.cta:hover{transform:translateY(-2px); box-shadow:0 14px 26px rgba(43,107,86,.55);}
.cta:active{transform:translateY(0);}
.cta:focus-visible{outline:2px solid var(--cream);}
.cta:disabled{opacity:.45; cursor:not-allowed; transform:none; box-shadow:none;}
.cta.secondary{
  background:none; box-shadow:none; padding:0;
  width:100%; display:flex; justify-content:center;
}
.cta.secondary img {
    width: 60%;
    display: block;
    margin: 0 auto;
}

.field{
  width:100%;
  max-width:240px;
  background:rgba(255,255,255,.07);
  border:1px solid rgba(255,233,184,.28);
  border-radius:12px;
  padding:11px 16px;
  color:var(--cream);
  font-size:15px;
  font-family:'Noto Sans SC',sans-serif;
  outline:none;
  text-align:center;
}
.field::placeholder{color:var(--cream-dim);}
.field:focus{border-color:var(--jade-bright);}
.error-msg{color:#ff9686; font-size:13px; min-height:18px; margin:0;}
.error-msg.is-info{color:var(--cream-dim);}

@media (max-width:380px){
  .stage{border-radius:20px;}
}

@media(min-width:992px){

  #bg{

    height:100vh;
  }
}