:root {
  --bg-deep: #0b0e17;
  --bg-hero-2: #15233d;
  --surface: #f5f7fb;
  --card: #ffffff;
  --ink: #132238;
  --muted: #617187;
  --line: #dde4ee;
  --violet: #7c6bff;
  --cyan: #16b8cc;
  --gold: #a6823b;
  --gold-bg: #faf4e6;
  --gold-line: #e4cfa0;
  --green: #1e7356;
  --red: #b53f43;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

button, input {
  font: inherit;
  touch-action: manipulation;
}

.h5-shell {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding-bottom: calc(14px + var(--safe-bottom));
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

@media (min-width: 640px) {
  body {
    background: #0d1320;
    padding: 20px 12px;
  }
  .h5-shell {
    min-height: calc(100dvh - 40px);
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  }
}

/* 顶部深空脑机视觉头图（适配刘海屏与灵动岛） */
.h5-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(150deg, var(--bg-deep) 0%, var(--bg-hero-2) 100%);
  color: #f4f7fb;
  padding: calc(18px + var(--safe-top)) clamp(16px, 5vw, 22px) 22px;
}

.h5-hero-orb {
  position: absolute;
  width: 220px;
  height: 220px;
  right: -75px;
  top: -65px;
  border-radius: 50%;
  border: 1px solid rgba(140, 123, 255, 0.28);
  box-shadow: 0 0 0 22px rgba(24, 210, 230, 0.06), 0 0 48px rgba(140, 123, 255, 0.22);
  pointer-events: none;
}

.h5-hero-inner {
  position: relative;
  z-index: 1;
}

.h5-kicker {
  font-size: clamp(11.5px, 3.2vw, 13px);
  color: #9be7f2;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.h5-hero h1 {
  margin: 6px 0 4px;
  font-size: clamp(22px, 6.2vw, 26px);
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff3d2;
}

.h5-sub {
  margin: 0;
  font-size: clamp(12px, 3.4vw, 13.5px);
  color: #c2d0e2;
}

.h5-meta {
  margin-top: 10px;
  font-size: 12px;
  color: #8fa5c0;
}

/* 主体容器 */
.h5-main {
  flex: 1;
  padding: 14px clamp(12px, 4vw, 18px) 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.h5-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(14px, 4.2vw, 20px);
  box-shadow: 0 6px 24px rgba(16, 31, 54, 0.045);
}

.h5-loading {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}

/* 双模式切换条 */
.h5-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 4px;
  background: #e6ecf4;
  border-radius: 12px;
}

.h5-tab {
  border: 0;
  min-height: 40px;
  border-radius: 9px;
  background: transparent;
  color: #54667d;
  font-size: clamp(12.5px, 3.5vw, 14px);
  font-weight: 600;
  padding: 6px 8px;
}

.h5-tab.active {
  background: #13233d;
  color: #f8e5ba;
  box-shadow: 0 2px 10px rgba(15, 28, 48, 0.18);
}

/* 表单控件（严格 >= 16px 防止 iOS 微信自动放大页面） */
.h5-field {
  margin-bottom: 14px;
}

.h5-field label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.h5-field label em {
  color: var(--red);
  font-style: normal;
}

.h5-field label span {
  font-weight: 400;
  color: var(--muted);
  font-size: 13px;
}

.h5-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid #cfd8e4;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  appearance: none;
}

.h5-input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(124, 107, 255, 0.14);
}

.h5-input-code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-align: center;
  min-height: 52px;
}

.h5-help {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.h5-pass-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #edf3fa;
  border: 1px solid #d5e2f0;
  font-size: 12px;
  color: #3a5678;
  margin-bottom: 14px;
}

.h5-pass-bar.expired {
  background: #fff2ea;
  border-color: #f0ccb8;
  color: #9b4a26;
}

.h5-dup-alert {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff6e6;
  border: 1px solid #e7c98e;
  color: #74521e;
  font-size: 12.5px;
  line-height: 1.6;
  margin: -4px 0 14px;
}

.h5-dup-alert strong {
  display: block;
  margin-bottom: 3px;
  color: #5c3d11;
}

.h5-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin: 12px 0 14px;
}

.h5-check input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: #13233d;
}

.h5-error {
  padding: 10px 12px;
  border-radius: 9px;
  background: #fff0ef;
  border: 1px solid #f0c9c6;
  color: var(--red);
  font-size: 13px;
  margin-bottom: 12px;
}

/* 按钮（大触控热区 >= 48px） */
.h5-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.h5-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.h5-btn-full {
  width: 100%;
}

.h5-btn-primary {
  background: linear-gradient(135deg, #132542 0%, #1d355a 100%);
  color: #fff;
  border-color: #132542;
}

.h5-btn-gold {
  background: linear-gradient(120deg, #ecd8a9 0%, #d4b475 100%);
  color: #212e42;
  border-color: #cfb071;
}

.h5-link {
  border: 0;
  background: transparent;
  padding: 2px 0;
  color: #275e99;
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* 电子编号凭证票与中奖卡片 */
.h5-ticket {
  background: #fff;
  border: 1px solid #dce3ed;
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
}

.h5-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eaf2fa;
  color: #29598f;
}

.h5-badge.gold {
  background: var(--gold-bg);
  color: #876528;
  border: 1px solid var(--gold-line);
}

.h5-ticket-no {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: clamp(38px, 12vw, 52px);
  font-weight: 700;
  letter-spacing: 0.14em;
  padding-left: 0.14em;
  color: #12233c;
  margin: 8px 0;
}

.h5-award {
  background: linear-gradient(160deg, #fffaf0 0%, #ffffff 70%);
  border: 1px solid var(--gold-line);
  border-radius: 16px;
  padding: 22px 16px;
  text-align: center;
}

.h5-award h2 {
  margin: 8px 0 6px;
  font-size: clamp(20px, 5.5vw, 24px);
  color: #70531f;
}

.h5-prize-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
}

.h5-claim-box {
  background: linear-gradient(145deg, #fffdf8, #f3ebda);
  border: 1px solid #d7be88;
  border-radius: 13px;
  padding: 14px 12px;
  margin: 14px 0;
}

.h5-claim-box span {
  display: block;
  font-size: 12px;
  color: #7d673c;
}

.h5-claim-box strong {
  display: block;
  margin: 6px 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: clamp(28px, 8.5vw, 36px);
  letter-spacing: 0.18em;
  padding-left: 0.18em;
  color: #19304d;
}

.h5-kv {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 13.5px;
}

.h5-kv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.h5-kv-row span {
  color: var(--muted);
}

.h5-kv-row b {
  text-align: right;
  word-break: break-word;
}

.h5-tip-box {
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--gold-bg);
  border: 1px solid var(--gold-line);
  color: #745723;
  font-size: 12.5px;
  line-height: 1.65;
}

.h5-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.h5-footer {
  text-align: center;
  padding: 10px 16px 4px;
  font-size: 12px;
  color: #7b8a9f;
}

.h5-footer p {
  margin: 2px 0;
}

.h5-footer-sub {
  font-size: 11px;
  color: #95a3b5;
}

.h5-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(14px);
  opacity: 0;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 10px;
  background: #12233d;
  color: #fff;
  font-size: 13.5px;
  z-index: 100;
  transition: opacity 0.2s, transform 0.2s;
  text-align: center;
}

.h5-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.h5-modal {
  width: calc(100vw - 28px);
  max-width: 440px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  background: #fff;
  color: var(--ink);
}

.h5-modal::backdrop {
  background: rgba(10, 18, 32, 0.56);
}

.h5-modal-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.h5-modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.h5-icon-btn {
  border: 0;
  background: transparent;
  font-size: 18px;
  min-width: 36px;
  min-height: 36px;
  color: var(--muted);
}

.h5-modal-body {
  padding: 16px 18px;
  max-height: 58dvh;
  overflow-y: auto;
  font-size: 13.5px;
  color: #46576d;
  line-height: 1.75;
}

.h5-modal-foot {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
}

@media (max-width: 340px) {
  .h5-main {
    padding: 10px;
  }
  .h5-card {
    padding: 12px;
  }
  .h5-tab {
    font-size: 12px;
  }
}
