/* Card stage: one full-screen card that tilts, flips and morphs between portrait and landscape. */
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden;overscroll-behavior:none}
/* iOS enlarges text on rotation unless told not to; that pushed card text out of place. */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
html{--page-bg:#0b0b0e;--ui-fg:#fff;--ui-bg:rgba(255,255,255,.1);--ui-bd:rgba(255,255,255,.18)}
body{background:var(--page-bg);color:var(--ui-fg);font-family:"Inter Tight","Noto Sans SC",system-ui,sans-serif;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent;transition:background-color .8s}
button{font:inherit;color:inherit}

/* Stage: rotated by --stage-rot when the phone is sideways but the OS did not rotate (rotation lock). */
.stage{position:fixed;left:50%;top:50%;width:100vw;height:100vh;height:100dvh;transform:translate(-50%,-50%) rotate(var(--stage-rot,0deg));container-type:size;display:grid;grid-template-rows:minmax(0,1fr) auto;justify-items:center;padding:calc(env(safe-area-inset-top,0px) + 12px) env(safe-area-inset-right,0px) calc(env(safe-area-inset-bottom,0px) + 14px) env(safe-area-inset-left,0px);transition:transform .8s cubic-bezier(.25,.9,.3,1)}
.stage.virtual{width:100vh;height:100vw;width:100dvh}
.scene{width:100%;height:100%;min-height:0;display:grid;place-items:center;perspective:1500px;touch-action:none;cursor:grab;user-select:none;-webkit-user-select:none}
.scene:active{cursor:grabbing}
.enter,.tilt{transform-style:preserve-3d}
.tilt{transform:rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg));will-change:transform}
.flipper{position:relative;transform:rotateY(var(--flip,0deg));transform-style:preserve-3d;width:min(86cqw,66cqh * .6308);aspect-ratio:54/85.6}
.land .flipper{width:min(76cqw,86cqh * 1.5852);aspect-ratio:85.6/54}
.land .stage{grid-template-rows:minmax(0,1fr);grid-template-columns:minmax(0,1fr) auto;align-items:center}
/* Measuring: take the 3D transforms out so boxes come back exact (the stage rotation is undone in JS). */
.stage.measuring .enter,.stage.measuring .tilt,.stage.measuring .flipper,.stage.measuring .face,.stage.measuring .scene{transform:none!important}

/* Faces. .box is the size container for content (cqmin = the card's short edge); .lay holds the grid. */
.face{position:absolute;inset:0;container-type:size;overflow:hidden;backface-visibility:hidden;-webkit-backface-visibility:hidden;border-radius:6% / 3.79%;--px:50%;--py:35%}
.land .face{border-radius:3.79% / 6%}
/* The faces sit half a pixel apart so Safari never treats them as one plane while turning. */
.face.front{transform:translateZ(.5px)}
.face.back{transform:rotateY(180deg) translateZ(.5px)}
/* The face turned away (set from JS): not painted, its loops paused. */
.face.off{visibility:hidden}
.face.off,.face.off *,.face.off ::before,.face.off ::after{animation-play-state:paused!important}
/* Safari (WebKit) can paint blend-mode layers black while a card turns in 3D: drop them mid-turn. */
.webkit .stage.turning .face::after,.webkit .stage.turning :is(.n-glint,.h-lines,.h-band,.a-curtain,.a-grain){visibility:hidden}
.webkit .stage.turning .w-n{mix-blend-mode:normal}
/* iOS Safari does not clip animated layers (Aurora's light) to the rounded corners, so the faces are
   clipped explicitly. That also cuts off their outer shadow, redrawn just behind them (runtime.js). */
.webkit .face:not(.c-pop){clip-path:inset(0 round 6% / 3.79%)}
.webkit.land .face:not(.c-pop){clip-path:inset(0 round 3.79% / 6%)}
.webkit .flipper::after{content:"";position:absolute;inset:0;border-radius:6% / 3.79%;box-shadow:var(--card-shadow,none);transform:translateZ(-1px);pointer-events:none}
.webkit.land .flipper::after{border-radius:3.79% / 6%}
.face > .fx{position:absolute;inset:0;pointer-events:none}
.face > .box{position:absolute;inset:0;container-type:size}
.box > .lay{position:absolute;inset:0}
.face [data-m]{position:relative}
.face::after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;z-index:30;background:radial-gradient(circle at var(--px) var(--py),rgba(255,255,255,var(--sa,.28)),transparent 46%);mix-blend-mode:var(--sb,soft-light)}
.face img{display:block}
/* The square SVG sets the height: aspect-ratio plus padding came out tall in Safari. */
.b-qr{overflow:hidden;background:var(--qr-bg,#fff)}
.b-qr svg{display:block;width:100%;height:auto}
/* The owner's own QR picture (WeChat, or WhatsApp's own code): shown as is, on white so it scans. */
.b-qr:has(.qr-img){background:#fff}
.b-qr .qr-img{display:block;width:100%;aspect-ratio:1;object-fit:cover}

/* Action bar */
.actions{display:flex;gap:10px;align-items:center;justify-content:center;flex-wrap:wrap;padding:6px 12px 0;position:relative;z-index:5}
.actions,.hint{-webkit-user-select:none;user-select:none}
.act{display:inline-flex;align-items:center;gap:7px;border:1px solid var(--ui-bd);background:var(--ui-bg);color:var(--ui-fg);border-radius:999px;padding:10px 16px;font-size:14px;font-weight:600;cursor:pointer;text-decoration:none;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);transition:transform .15s,opacity .3s}
.act:active{transform:scale(.95)}
.act svg{width:17px;height:17px;flex:none}
.act.icon{padding:10px;width:42px;height:42px;justify-content:center}
.act:focus-visible{outline:2px solid var(--ui-fg);outline-offset:3px}
.act .i-off,.act.off .i-on{display:none}
.act.off .i-off{display:inline}
.act.off{opacity:.6}
.act .i-out,.immersive .act .i-in{display:none}
.immersive .act .i-out{display:inline}
.land .actions{flex-direction:column;align-items:stretch;padding:0 16px 0 0}
.land .act{padding:8px 14px;font-size:13px}
.land .act.icon{width:38px;height:38px;padding:8px;align-self:center}

/* Desktop: the buttons stay in a column on the right in both layouts, so the mouse never chases them. */
@media (hover:hover) and (pointer:fine) and (min-width:700px){
  .stage{grid-template-rows:minmax(0,1fr);grid-template-columns:minmax(0,1fr) auto;align-items:center}
  .flipper{width:min(76cqw,80cqh * .6308)}
  .actions{flex-direction:column;align-items:stretch;padding:0 16px 0 0}
  .act{padding:8px 14px;font-size:13px}
  .act.icon{width:38px;height:38px;padding:8px;align-self:center}
}

/* Full screen (mostly for phones): no chrome, the card as large as the screen allows. */
.immersive .stage,.immersive.land .stage{padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);grid-template-rows:minmax(0,1fr);grid-template-columns:minmax(0,1fr)}
.immersive .flipper{width:min(92cqw,93cqh * .6308)}
.immersive.land .flipper{width:min(92cqw,90cqh * 1.5852)}
.immersive .actions,.immersive.land .actions{position:absolute;right:10px;bottom:10px;flex-direction:column;gap:8px;padding:0;opacity:.55}
.immersive .act:not(.icon){display:none}
.immersive .act.icon{width:36px;height:36px;padding:8px}
.immersive .hint{display:none}

.toast{position:fixed;left:50%;bottom:calc(env(safe-area-inset-bottom,0px) + 84px);transform:translateX(-50%);background:rgba(20,20,24,.92);color:#fff;font-size:13.5px;padding:9px 16px;border-radius:999px;pointer-events:none;opacity:0;transition:opacity .25s;z-index:50;white-space:nowrap}
.toast.show{opacity:1}
.hint{position:fixed;left:50%;top:calc(env(safe-area-inset-top,0px) + 14px);transform:translateX(-50%);font-size:12.5px;letter-spacing:.04em;color:var(--ui-fg);opacity:.6;pointer-events:none;white-space:nowrap;z-index:6;transition:opacity .6s}
.hint.gone{opacity:0}

/* POW stickers spawned by the pop physics */
.pow{position:absolute;z-index:40;pointer-events:none;font-family:Bungee,"ZCOOL KuaiLe",sans-serif;font-size:7cqmin;color:#fff;background:#ff3d7f;padding:1.4cqmin 2.6cqmin;border:.8cqmin solid #141414;box-shadow:1cqmin 1cqmin 0 #141414;clip-path:polygon(0 12%,12% 0,30% 9%,50% 0,68% 10%,88% 0,100% 15%,93% 50%,100% 85%,85% 100%,62% 90%,40% 100%,18% 90%,0 100%,7% 50%);white-space:nowrap}
.grain-dot{position:absolute;z-index:25;pointer-events:none;width:1.6cqmin;height:1.6cqmin;border-radius:50%}

@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){
  .stage{transition:none}
}
