:root {
  --text: #0d3557;
  --muted: #64809c;
  --brand: #0068e5;
  --brand2: #10b981;
  --sky: #00a4ff;
  --teal: #00c4b3;
  --danger: #e11d48;
  --line: rgba(0, 82, 217, .14);
  --card: rgba(255, 255, 255, .82);
  --touch: 56px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 12% -10%, #d3e9ff 0%, transparent 55%),
    radial-gradient(900px 600px at 95% 8%, #d5f7e8 0%, transparent 50%),
    linear-gradient(160deg, #f2f8ff 0%, #ffffff 45%, #ecfbf3 100%);
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(0, 82, 217, .07);
}

/* ================= 大屏 ================= */
.screen-wrap {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  gap: 20px;
  padding: 22px 26px;
  height: 100vh;
  height: 100dvh;
}

.screen-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.screen-head h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #0052d9, #00a4ff 55%, #10b981);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.screen-head .sub { color: var(--muted); font-size: 15px; }
.screen-head .spacer { flex: 1; }

.powered-by {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 6px 13px 6px 11px;
  border: 1px solid rgba(16, 185, 129, .24);
  border-radius: 18px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 5px 16px rgba(16, 185, 129, .09);
  color: #176b5c;
  white-space: nowrap;
}

.powered-label {
  color: #6b8292;
  font-size: 13px;
  letter-spacing: .2px;
}

.powered-logo {
  width: 28px;
  height: 28px;
  display: block;
  object-fit: cover;
  border-radius: 8px;
}

.powered-name {
  color: #087f68;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .1px;
}

.host-powered-by {
  width: fit-content;
  margin: -8px 0 18px auto;
}

.page-powered-by {
  width: fit-content;
  margin: 24px auto 0;
}

.qr-powered-by {
  position: absolute;
  right: 28px;
  bottom: 58px;
}

.pill {  
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 14px;
  background: rgba(0, 104, 229, .08);
  border: 1px solid rgba(0, 104, 229, .22);
  color: #0a5bb5;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; }
.dot.off { background: #e11d48; }

.panel-title {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px 6px;
  font-size: 19px;
  font-weight: 600;
}

.panel-title .tag {
  margin-left: auto;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.cloud-panel { display: flex; flex-direction: column; overflow: hidden; position: relative; }
.cloud-panel .empty { position: absolute; left: 0; right: 0; top: 44px; bottom: 20px; pointer-events: none; }
#cloudCanvas { flex: 1; width: 100%; min-height: 0; display: block; }

.empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 15px;
}

/* 开放题滚动区 */
.barrage {
  height: 150px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  position: relative;
  padding: 0 20px;
}

.barrage-inner { transition: transform .5s ease; }
.barrage-item {
  padding: 8px 0;
  font-size: 16px;
  color: #2c5f8a;
  border-bottom: 1px dashed rgba(0, 82, 217, .12);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ================= 主持人 ================= */
.host-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 60px;
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
}

.host-wrap h1 {
  font-size: 26px;
  margin: 0 0 4px;
  background: linear-gradient(90deg, #0052d9, #10b981);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}
.host-wrap .desc { color: var(--muted); margin-bottom: 22px; font-size: 14px; }

.host-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, auto));
  gap: 18px;
  align-items: stretch;
}

.card {
  min-width: 0;
  padding: 20px;
}
.card h3 { margin: 0 0 14px; font-size: 17px; }

.btn {
  padding: 13px 20px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: .15s;
  min-height: 46px;
}

.btn:hover { background: #f2f8ff; }
.btn.primary { background: linear-gradient(90deg, #0068e5, #00a4ff); border: none; color: #ffffff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: rgba(225, 29, 72, .07); border-color: rgba(225, 29, 72, .35); color: #d61f4c; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.qr-box { display: flex; gap: 18px; align-items: center; }
.qr-box .qr {
  width: 168px; height: 168px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  flex: none;
}
.qr-box .qr img, .qr-box .qr svg { width: 100%; height: 100%; display: block; }
.qr-meta { font-size: 14px; color: var(--muted); line-height: 1.9; word-break: break-all; }
.qr-meta b { color: var(--text); font-weight: 600; font-size: 16px; }

/* ================= 全屏二维码 ================= */
.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 16%, rgba(0, 164, 255, .22), transparent 30%),
    radial-gradient(circle at 84% 76%, rgba(16, 185, 129, .18), transparent 32%),
    linear-gradient(135deg, #eff8ff 0%, #ffffff 48%, #effbf6 100%);
}

.qr-showcase {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 760px);
  padding: 28px 30px 24px;
  border: 1px solid rgba(0, 104, 229, .14);
  border-radius: 28px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 24px 80px rgba(0, 82, 217, .16), 0 2px 8px rgba(0, 82, 217, .06);
  backdrop-filter: blur(18px);
}

.qr-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #087f68;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
}

.qr-kicker-line {
  display: block;
  width: 34px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #10b981);
}

.qr-kicker-line:last-child { background: linear-gradient(90deg, #10b981, transparent); }

.qr-showcase h2 {
  margin: 14px 0 6px;
  color: #0b3555;
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.3;
  letter-spacing: 1px;
  text-align: center;
}

.qr-lead {
  margin: 0 0 18px;
  color: #64809c;
  font-size: 15px;
}

.qr-frame {
  width: min(56vh, 500px);
  height: min(56vh, 500px);
  padding: 18px;
  border: 1px solid rgba(0, 82, 217, .12);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 14px 36px rgba(0, 82, 217, .13);
}

.qr-frame svg,
.qr-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.qr-url {
  margin-top: 14px;
  color: #176b5c;
  font-size: 15px;
  letter-spacing: .2px;
}

.qr-steps {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-top: 18px;
  color: #64809c;
  font-size: 13px;
}

.qr-steps span { display: inline-flex; align-items: center; gap: 7px; }
.qr-steps b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  color: #ffffff;
  background: linear-gradient(135deg, #0068e5, #10b981);
  font-size: 12px;
}

.qr-close {
  position: absolute;
  top: 22px;
  right: 28px;
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(0, 82, 217, .15);
  border-radius: 14px;
  color: #4c7190;
  background: rgba(255, 255, 255, .72);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 82, 217, .08);
}

.qr-close:hover { color: #0052d9; background: #ffffff; }
.qr-close:focus-visible { outline: 3px solid rgba(0, 164, 255, .35); outline-offset: 3px; }

.qr-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  z-index: 2;
  color: rgba(13, 53, 87, .55);
  font-size: 13px;
  text-align: center;
}

.qr-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}

.qr-orb-a {
  width: 220px;
  height: 220px;
  top: -90px;
  left: -70px;
  background: rgba(0, 164, 255, .14);
}

.qr-orb-b {
  width: 260px;
  height: 260px;
  right: -80px;
  bottom: -120px;
  background: rgba(16, 185, 129, .12);
}

@media (max-width: 720px) {
  .qr-showcase { padding: 22px 18px 20px; border-radius: 22px; }
  .qr-showcase h2 { font-size: 25px; }
  .qr-lead { font-size: 14px; text-align: center; }
  .qr-frame { width: min(72vw, 360px); height: min(72vw, 360px); padding: 14px; border-radius: 20px; }
  .qr-steps { gap: 8px 12px; font-size: 12px; }
  .qr-close { top: 14px; right: 14px; width: 40px; height: 40px; }
  .qr-footer { bottom: 12px; font-size: 12px; }
}

.stat-row { display: flex; gap: 22px; margin-top: 12px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.stat-row b { color: var(--text); font-size: 22px; }

select, .input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
}

/* ================= 手机端 ================= */
.m-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

.m-head { text-align: center; margin-bottom: 18px; }
.m-head h1 {
  font-size: 25px;
  line-height: 1.35;
  margin: 0 0 8px;
  background: linear-gradient(90deg, #0052d9, #10b981);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}
.m-head p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }

/* 进度提示 */
.progress {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 82, 217, .08);
  font-size: 15px;
  color: var(--muted);
}

.progress b { color: var(--brand); font-size: 19px; }
.progress .bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 82, 217, .12);
  overflow: hidden;
}
.progress .bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #0068e5, #00a4ff 55%, #10b981);
  transition: width .25s ease;
}

.q-card { padding: 20px; margin-bottom: 16px; }
.q-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 6px;
}
.q-hint { font-size: 14px; color: var(--muted); margin-bottom: 16px; }

/* 选项：大触摸区 + 自定义选中圈 */
.opt {
  position: relative;
  display: block;
  padding: 16px 18px 16px 56px;
  margin-bottom: 12px;
  min-height: var(--touch);
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #ffffff;
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color .18s, background .18s, transform .1s;
}

.opt:last-child { margin-bottom: 0; }
.opt:active { transform: scale(.985); }

.opt input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.opt::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(0, 82, 217, .28);
  background: #fff;
  transition: .18s;
}

.opt.on {
  border-color: #00a4ff;
  background: linear-gradient(90deg, rgba(0, 104, 229, .09), rgba(16, 185, 129, .09));
}

.opt.on::before {
  border-color: transparent;
  background: linear-gradient(135deg, #0068e5, #10b981);
}

.opt.on::after {
  content: '';
  position: absolute;
  left: 27px;
  top: 50%;
  width: 7px;
  height: 12px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: translateY(-62%) rotate(45deg);
}

/* 提交按钮：常驻底部 */
.submit {
  position: sticky;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 20;
  width: 100%;
  padding: 18px;
  margin-top: 20px;
  border: none;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffffff;
  background: linear-gradient(90deg, #0068e5, #00a4ff 55%, #10b981);
  box-shadow: 0 10px 26px rgba(0, 104, 229, .3);
  cursor: pointer;
  transition: .15s;
}

.submit:active { transform: scale(.985); }
.submit:disabled { opacity: .45; box-shadow: none; }

/* 提交成功页 */
.done { text-align: center; padding: 40px 22px; }
.done .ico {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  color: #fff;
  background: linear-gradient(135deg, #0068e5, #10b981);
  box-shadow: 0 12px 30px rgba(16, 185, 129, .3);
  animation: popIn .45s cubic-bezier(.2, 1.4, .5, 1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(.5); }
  to { opacity: 1; transform: scale(1); }
}

.done h2 { margin: 0 0 10px; font-size: 23px; }
.done p { color: var(--muted); font-size: 16px; line-height: 1.6; margin: 0 0 6px; }

/* 手机成功页词云：向两侧出血铺满整屏宽度，字号才有足够空间体现票数差异 */
.mini-cloud {
  margin: 24px -22px 0;
  padding: 18px 12px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}
.mini-cloud .t { font-size: 16px; margin-bottom: 10px; font-weight: 600; }
.mini-cloud canvas { width: 100%; height: 340px; display: block; }

.toast {
  position: fixed;
  left: 50%;
  top: calc(20px + env(safe-area-inset-top));
  transform: translateX(-50%);
  max-width: 88vw;
  padding: 13px 22px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: 0 12px 34px rgba(0, 82, 217, .18);
  font-size: 16px;
  z-index: 999;
  animation: pop .25s ease;
}

/* ================= 小屏适配 ================= */
@media (max-width: 900px) {
  .screen-wrap {
    height: auto;
    min-height: 100dvh;
    padding: 16px;
    gap: 14px;
  }
  .screen-head h1 { font-size: 24px; letter-spacing: 1px; }
  .screen-head .sub { font-size: 13px; }
  .screen-head .spacer { display: none; }
  .pill { font-size: 13px; padding: 6px 12px; }
  .cloud-panel { min-height: 62vh; }
  .cloud-panel .empty { bottom: 110px; }
  .barrage { height: 108px; }
  .barrage-item { font-size: 15px; }
}

@media (max-width: 720px) {
  .host-grid { grid-template-columns: 1fr; }
  .host-wrap { padding: 18px 14px 40px; }
  .host-powered-by { margin: -2px auto 16px; }
  .qr-powered-by { right: 14px; bottom: 48px; transform: scale(.9); transform-origin: right bottom; }
  .qr-box { flex-direction: column; align-items: flex-start; gap: 14px; }
  .qr-box .qr { width: 200px; height: 200px; align-self: center; }
  .qr-meta { text-align: center; width: 100%; }
  .btn-row { width: 100%; }
  .btn-row .btn { flex: 1 1 45%; justify-content: center; display: inline-flex; align-items: center; }
}

@media (max-width: 400px) {
  .m-head h1 { font-size: 22px; }
  .q-title { font-size: 18px; }
  .opt { font-size: 16px; padding: 15px 15px 15px 52px; }
  .opt::before { left: 15px; width: 24px; height: 24px; }
  .opt.on::after { left: 23px; }
}
