
  :root {
    --cream: #FBF5EA;
    --wine: #7B1E2E;
    --wine-deep: #561321;
    --gold: #D4B072;
    --gold-light: #F1DFB4;
    --gold-deep: #A9844A;
    --serif: "Noto Serif SC", "Songti SC", serif;
    --sans: "Noto Sans SC", -apple-system, "PingFang SC", system-ui, sans-serif;

    --title: "Lilita One", "Arial Black", sans-serif;
    --bg-ratio: 429 / 1192;

    /* 刮刮卡面板在背景图上的位置（相对整张图的百分比），按设计稿调整 */
    --panel-left: 4%;
    --panel-top: 50.5%;
    --panel-width: 92%;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { background: #061650; }
  body {
    font-family: var(--sans);
    overflow-x: hidden;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
  }
  button { font: inherit; border: 0; background: none; color: inherit; cursor: pointer; }

  /* 背景图按原比例铺满屏宽，刮刮区跟着图一起缩放，任何机型都对得上 */
  /* 只做手机视图：电脑上打开也固定手机宽度居中 */
  .viewport {
    position: relative;
    width: 100%;
    max-width: 430px;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0 auto;
    display: flex;
    align-items: center;
    overflow: hidden;
    background: #061650;
  }
  /* 整张图完整显示不裁切；屏幕比图更细长时，上下空位用同一张图的模糊版填满 */
  .viewport::before {
    content: "";
    position: absolute;
    inset: -40px;
    background: var(--bg-url, none) center / cover no-repeat;
    filter: blur(40px);
    opacity: .45;
  }
  .stage { position: relative; width: 100%; container-type: inline-size; }
  .stage > .bg {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    /* 上下边缘淡出，和填充色自然衔接 */
    -webkit-mask-image: linear-gradient(transparent, #000 4%, #000 96%, transparent);
    mask-image: linear-gradient(transparent, #000 4%, #000 96%, transparent);
  }
  .stage.no-bg {
    aspect-ratio: var(--bg-ratio);
    background: linear-gradient(180deg, #1B4FD8, #061650);
  }
  .stage.no-bg > .bg { display: none; }

  /* ---------- 刮刮卡面板 ---------- */
  .panel {
    position: absolute;
    left: var(--panel-left);
    top: var(--panel-top);
    width: var(--panel-width);
    container-type: inline-size;
    padding: 8cqw 6cqw 9cqw;
    border-radius: 7cqw;
    background:
      radial-gradient(120% 60% at 50% 0%, rgba(70,140,255,.45), transparent 70%),
      linear-gradient(180deg, #0F3AB8 0%, #0A2783 55%, #081D66 100%);
    border: 2px solid #6FB4FF;
    box-shadow:
      0 0 0 1px rgba(255,255,255,.35),
      0 0 18px 2px rgba(64,150,255,.85),
      0 0 40px 6px rgba(40,110,255,.45),
      inset 0 0 22px rgba(110,180,255,.55);
  }
  /* 底部橙色光带 */
  .panel::after {
    content: "";
    position: absolute;
    left: -6%; right: -6%;
    bottom: 2%;
    height: 26%;
    background:
      radial-gradient(60% 40% at 50% 70%, rgba(255,160,50,.55), transparent 70%),
      radial-gradient(90% 12% at 50% 78%, rgba(255,200,120,.9), transparent 70%);
    pointer-events: none;
  }
  /* 标题图（含礼物盒），略微超出面板上沿 */
  .title {
    position: relative;
    z-index: 2;
    margin: -9cqw -4cqw 6cqw;
  }
  .title img { display: block; width: 100%; height: auto; pointer-events: none; }

  .card {
    position: relative;
    z-index: 1;
    width: 100%;
    aspect-ratio: 335 / 205;
    border-radius: 5cqw;
    overflow: hidden;
    container-type: size;
    background: linear-gradient(160deg, #1A4FD6, #0A1F6E);
    box-shadow: 0 0 0 2px rgba(255,255,255,.9), 0 0 14px 2px rgba(130,195,255,.9);
  }
  .card::before {
    content: "";
    position: absolute;
    inset: 3cqw;
    border: 1.5px solid rgba(140,190,255,.5);
    border-radius: 3cqw;
    pointer-events: none;
  }
  .prize {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6cqh;
    color: #fff;
    text-align: center;
    visibility: hidden;
  }
  .card.ready .prize { visibility: visible; }
  .prize-label { font-size: max(11px, min(3.8cqw, 10cqh)); letter-spacing: .25em; color: #FFD27A; font-weight: 700; }
  .code {
    padding: min(2.4cqw, 5cqh) 6cqw;
    border-radius: 3cqw;
    border: 1.5px dashed #FFC13B;
    font-family: var(--title);
    /* 码越长字越小，保证一行放得下 */
    font-size: min(11cqw, 26cqh, calc(75cqw / var(--code-len, 6)));
    white-space: nowrap;
    line-height: 1.1;
    letter-spacing: .1em;
    background-image: linear-gradient(180deg, #FFF6D8, #FFC13B 60%, #F08A1C);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  .code-hint { font-size: max(10px, min(3.2cqw, 8cqh)); color: rgba(255,255,255,.75); }

  .cta {
    position: relative;
    z-index: 1;
    display: block;
    width: 78%;
    height: 14cqw;
    margin: 8cqw auto 0;
    border-radius: 999px;
    overflow: hidden;
    color: #fff;
    font-family: "Arial Rounded MT Bold", "Arial Rounded MT", "Nunito", "Arial Black", sans-serif;
    font-weight: 700;
    font-size: max(16px, 6.6cqw);
    letter-spacing: .01em;
    text-shadow: 0 2px 0 #B8500A, 0 0 6px rgba(150,60,0,.5);
    background: linear-gradient(180deg, #FFC765 0%, #FF9A2E 45%, #F2700F 75%, #D95A06 100%);
    box-shadow:
      0 0 0 2px #FFE7A8,
      0 0 0 4px rgba(200,100,10,.7),
      0 0 22px 4px rgba(255,150,40,.75),
      inset 0 2px 0 rgba(255,255,255,.55),
      inset 0 -3px 0 rgba(150,60,0,.35);
    /* 刮开前隐藏（保留占位，避免布局跳动），刮开后浮现 */
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity .4s ease .3s, transform .4s ease .3s;
  }
  .cta.show { opacity: 1; transform: none; pointer-events: auto; }
  .cta.show:active { transform: scale(.97); transition: transform .15s; }
  .cta::after {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    width: 40%;
    left: -60%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent);
    animation: shine 2.8s ease-in-out infinite;
  }
  @keyframes shine { 0%, 55% { left: -60%; } 100% { left: 130%; } }
  @media (prefers-reduced-motion: reduce) { .cta::after { animation: none; } }

  #scratch {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    transition: opacity .6s ease;
  }
  #scratch.gone { opacity: 0; pointer-events: none; }

  .toast {
    position: fixed;
    left: 50%;
    bottom: calc(40px + env(safe-area-inset-bottom));
    transform: translate(-50%, 12px);
    max-width: calc(100% - 32px);
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(8,24,90,.92);
    color: var(--cream);
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 20;
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }

  #confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }

  /* ---------- 用户名验证（盖在刮层上，验证通过后淡出） ---------- */
  .gate {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5cqh;
    padding: 6cqh 8cqw;
    background: rgba(8, 28, 100, .72);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    transition: opacity .4s ease, visibility .4s;
  }
  .gate.done { opacity: 0; visibility: hidden; pointer-events: none; }
  .gate-title {
    color: #fff;
    font-weight: 700;
    font-size: max(13px, min(4.6cqw, 10cqh));
    text-align: center;
  }
  .gate-input {
    width: 100%;
    height: max(40px, 20cqh);
    padding: 0 4cqw;
    border: 2px solid rgba(255,255,255,.85);
    border-radius: 999px;
    background: #fff;
    color: #0A1F6E;
    font: 600 16px/1 var(--sans); /* 16px：iPhone 不会自动放大页面 */
    text-align: center;
    outline: none;
    user-select: text;
    -webkit-user-select: text;
  }
  .gate-input:focus { border-color: #FFC13B; box-shadow: 0 0 0 3px rgba(255,193,59,.35); }
  .gate-btn {
    width: 60%;
    height: max(36px, 18cqh);
    border-radius: 999px;
    color: #fff;
    font-family: "Arial Rounded MT Bold", "Arial Rounded MT", "Nunito", "Arial Black", sans-serif;
    font-weight: 700;
    font-size: max(14px, min(4.8cqw, 9cqh));
    text-shadow: 0 1px 0 #B8500A;
    background: linear-gradient(180deg, #FFC765 0%, #FF9A2E 45%, #F2700F 75%, #D95A06 100%);
    box-shadow: 0 0 0 2px #FFE7A8, 0 0 14px 2px rgba(255,150,40,.6);
  }
  .gate-btn:disabled { opacity: .7; }
  .gate-msg {
    min-height: 1.2em;
    margin-top: -2cqh;
    color: #FFD27A;
    font-size: max(11px, min(3.4cqw, 7.5cqh));
    text-align: center;
  }

/* ---------- 切换语言按钮（右上角） ---------- */
.lang-btn {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  z-index: 15;
  min-width: 52px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(8,24,90,.72);
  border: 1px solid rgba(156,195,255,.7);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.lang-btn:active { transform: scale(.95); }
