:root {
  --red: #c8102e;
  --red-deep: #8e0614;
  --red-ink: #7a0010;
  --gold: #f3cd84;
  --gold-soft: #fbe3a6;
  --cream: #fff8ec;
  --paper: #fffdf8;
  --ink: #3a2418;
  --muted: #8a6b58;
  --line: #f0dcc0;
  --ok: #2f8f4e;
  --warn: #c77700;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #5a0610;
}
#app {
  max-width: 520px; margin: 0 auto; min-height: 100vh; position: relative;
  background:
    radial-gradient(circle at 20px 20px, rgba(243,205,132,.08) 12px, transparent 13px) 0 0/56px 56px,
    radial-gradient(120% 60% at 50% 0%, #d9182b 0%, var(--red) 40%, var(--red-deep) 100%);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.loading { color: var(--gold-soft); text-align: center; padding: 120px 0; }

/* ---------- tabbar ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; z-index: 20;
  display: flex; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(0,0,0,.12);
}
#tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 0 5px; font-size: 11px; color: var(--muted); }
#tabbar a i { font-style: normal; font-size: 20px; line-height: 26px; filter: grayscale(.6); }
#tabbar a.on { color: var(--red); font-weight: 600; }
#tabbar a.on i { filter: none; }
#tabbar a.primary i { background: var(--red); border-radius: 50%; width: 42px; height: 42px; line-height: 42px; text-align: center; margin-top: -18px; border: 3px solid var(--gold); filter: none; box-shadow: 0 4px 10px rgba(200,16,46,.4); }

/* ---------- common ---------- */
.page { padding: 14px 14px 20px; }
.card { background: var(--cream); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 6px 18px rgba(80,0,10,.18); }
.card h2 { margin: 0 0 10px; font-size: 17px; color: var(--red-ink); display: flex; align-items: center; gap: 8px; }
.card h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: linear-gradient(var(--red), #e8553e); }
.card p { margin: 0 0 8px; }
.card ul { margin: 0; padding-left: 20px; }
.card li { margin: 4px 0; }
.muted { color: var(--muted); font-size: 13px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 20px; border-radius: 22px; background: linear-gradient(180deg, #e8273d, var(--red)); color: #fff; font-weight: 600; box-shadow: 0 4px 10px rgba(200,16,46,.3); }
.btn.gold { background: linear-gradient(180deg, #fde9b8, #eec06b); color: var(--red-ink); box-shadow: 0 4px 10px rgba(120,60,0,.25); }
.btn.ghost { background: transparent; color: var(--red); border: 1px solid var(--red); box-shadow: none; }
.btn.block { display: flex; width: 100%; }
.btn.small { height: 32px; padding: 0 14px; font-size: 13px; border-radius: 16px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #fde7d0; color: var(--red-ink); }
.tag.ok { background: #e3f4e8; color: var(--ok); }
.tag.warn { background: #fff1d6; color: var(--warn); }
.tag.bad { background: #fde2e2; color: #c0392b; }
.tag.gray { background: #eee; color: #777; }
.empty { text-align: center; color: var(--gold-soft); padding: 60px 20px; }
.empty.dark { color: var(--muted); }

/* ---------- home ---------- */
.hero { text-align: center; color: var(--gold-soft); padding: 26px 16px 8px; position: relative; overflow: hidden; }
.hero .year { font-size: 13px; letter-spacing: 6px; opacity: .9; }
.hero h1 { margin: 6px 0 4px; font-size: 30px; line-height: 1.25; letter-spacing: 2px; color: #fff3cf; text-shadow: 0 2px 0 #8e0614, 0 0 18px rgba(255,200,120,.35); font-family: "Songti SC", "STSong", serif; font-weight: 900; }
.hero .sub { font-size: 14px; opacity: .95; }
.hero-stage { position: relative; height: 270px; margin: 14px auto 4px; max-width: 360px; }
.hero-stage .env { position: absolute; display: block; width: 104px; top: 6px; filter: drop-shadow(0 10px 18px rgba(60,0,0,.45)); transition: transform .3s; }
.hero-stage .env:nth-child(1) { left: 6%; transform: rotate(-12deg); top: 34px; }
.hero-stage .env:nth-child(2) { left: 50%; margin-left: -60px; width: 120px; z-index: 2; }
.hero-stage .env img { width: 100%; }
.hero-stage .env:nth-child(3) { right: 6%; transform: rotate(12deg); top: 34px; }
.hero-stage .sheep { position: absolute; bottom: -22px; right: -6px; width: 104px; z-index: 3; transform: rotate(6deg); filter: drop-shadow(0 6px 8px rgba(80,0,0,.35)); }
.hero-stage .sheep.lamb { right: auto; left: -8px; width: 84px; transform: rotate(-8deg); }
.stats { display: flex; justify-content: center; gap: 26px; margin: 10px 0 4px; }
.stats b { display: block; font-size: 24px; color: #fff3cf; font-family: "DIN Alternate", "Helvetica Neue", sans-serif; }
.stats span { font-size: 12px; opacity: .85; }
.phase { display: flex; gap: 8px; margin: 14px 0; }
.phase div { flex: 1; position: relative; background: rgba(255,248,236,.12); border: 1px solid rgba(243,205,132,.4); border-radius: 12px; padding: 8px 10px; color: var(--gold-soft); font-size: 12px; }
.phase div b { display: block; font-size: 14px; color: #fff3cf; }
.phase div.now { background: rgba(243,205,132,.2); border-color: var(--gold); }
.phase div.now::after { content: "进行中"; position: absolute; top: -8px; right: 8px; font-size: 10px; line-height: 16px; background: var(--gold); color: var(--red-ink); border-radius: 8px; padding: 0 6px; font-weight: 600; }
.cta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.cta .btn:first-child { grid-column: span 2; height: 50px; font-size: 17px; border-radius: 25px; }
table.groups { width: 100%; border-collapse: collapse; font-size: 14px; }
table.groups th, table.groups td { border-bottom: 1px solid var(--line); padding: 8px 4px; text-align: left; }
table.groups th { color: var(--muted); font-weight: 500; font-size: 12px; }
.tpl-row { display: flex; gap: 12px; align-items: stretch; }
.tpl-row a { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; font-size: 13px; }
.tpl-row img { height: 120px; margin: 0 auto 6px; object-fit: contain; }
.foot { text-align: center; color: var(--gold-soft); font-size: 12px; opacity: .8; padding: 10px 0 20px; }
.demo-bar { background: rgba(0,0,0,.25); color: var(--gold-soft); font-size: 12px; text-align: center; padding: 6px 10px; }
.demo-bar button { background: var(--gold); color: var(--red-ink); border-radius: 10px; padding: 1px 8px; font-size: 12px; margin-left: 6px; }

/* ---------- gallery ---------- */
.gtabs { display: flex; gap: 6px; padding: 12px 14px 0; position: sticky; top: 0; z-index: 10; background: linear-gradient(var(--red) 70%, transparent); }
.gtabs button { flex: 1; padding: 8px 2px 6px; border-radius: 12px 12px 0 0; background: rgba(255,248,236,.15); color: var(--gold-soft); font-size: 13px; line-height: 1.25; }
.gtabs button small { display: block; font-size: 11px; opacity: .85; }
.gtabs button.on { background: var(--cream); color: var(--red-ink); font-weight: 700; }
.gbar { background: var(--cream); margin: 0 14px; padding: 10px 12px; border-radius: 0 0 12px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gbar .left { flex: 1 1 100%; font-size: 13px; color: var(--red-ink); }
.gbar .left b { color: var(--red); }
.gbar input { flex: 1; min-width: 0; height: 34px; border: 1px solid var(--line); border-radius: 17px; padding: 0 14px; background: #fff; }
.seg { display: inline-flex; background: #f4e3cc; border-radius: 17px; padding: 2px; }
.seg button { height: 30px; padding: 0 12px; border-radius: 15px; background: none; font-size: 13px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--red); font-weight: 600; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 14px; }
.work { background: var(--cream); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 12px rgba(60,0,0,.2); display: flex; flex-direction: column; }
.work .pic { background: linear-gradient(#fff6e6, #f6e2c4); padding: 10px 18px 4px; position: relative; }
.work .pic img { aspect-ratio: var(--env-ratio, 70/144.5); width: 100%; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(80,0,0,.25)); }
.work .rank { position: absolute; left: 0; top: 8px; background: var(--red); color: #fff3cf; font-size: 11px; padding: 1px 8px 1px 6px; border-radius: 0 10px 10px 0; }
.work .rank.top { background: linear-gradient(90deg, #d39b2a, #f2c66a); color: var(--red-ink); font-weight: 700; }
.work .meta { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.work .t { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work .a { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work .row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.work .v { color: var(--red); font-weight: 700; font-size: 15px; }
.work .v small { font-weight: 400; font-size: 11px; color: var(--muted); margin-left: 2px; }
.vote-btn { height: 30px; padding: 0 14px; border-radius: 15px; background: linear-gradient(180deg, #e8273d, var(--red)); color: #fff; font-size: 13px; font-weight: 600; }
.vote-btn.done { background: #f1e2cd; color: var(--muted); }
.more { text-align: center; padding: 6px 0 16px; }

/* ---------- detail ---------- */
.detail-stage { padding: 18px 0 4px; text-align: center; }
.detail-stage img { width: 44%; max-width: 210px; margin: 0 auto; filter: drop-shadow(0 14px 22px rgba(40,0,0,.5)); cursor: zoom-in; }
.detail-stage img.art { width: 52%; max-width: 240px; border-radius: 4px; border: 6px solid #fff; }
.toggle { display: flex; justify-content: center; margin-top: 14px; }
.toggle .seg { background: rgba(255,248,236,.2); }
.toggle .seg button { color: var(--gold-soft); }
.toggle .seg button.on { background: var(--cream); color: var(--red); }
.dinfo h3 { margin: 0; font-size: 20px; color: var(--red-ink); }
.dinfo .kv { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0 12px; font-size: 13px; color: var(--muted); }
.dinfo .big { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 0; border-top: 1px dashed var(--line); }
.dinfo .big b { font-size: 30px; color: var(--red); font-family: "DIN Alternate", "Helvetica Neue", sans-serif; }
.dinfo .actions { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

/* ---------- submit ---------- */
.steps-tip { color: var(--gold-soft); font-size: 13px; padding: 4px 4px 12px; }
.upload-zone { border: 2px dashed #e5b97a; border-radius: 14px; background: #fff; padding: 28px 16px; text-align: center; color: var(--muted); cursor: pointer; }
.upload-zone b { display: block; color: var(--red); font-size: 17px; margin: 8px 0 4px; }
.editor { display: flex; gap: 14px; align-items: flex-start; }
.env-preview { position: relative; width: 52%; flex: none; aspect-ratio: var(--env-ratio); background: var(--env-bg) center/100% 100% no-repeat; filter: drop-shadow(0 8px 14px rgba(80,0,0,.3)); user-select: none; }
.env-preview .frame { position: absolute; left: calc(var(--ax) - 4px); top: calc(var(--ay) - 4px); width: calc(var(--aw) + 8px); height: calc(var(--ah) + 8px); pointer-events: none; z-index: 3;
  /* 虚线用渐变画：iOS 微信里 dashed 边框在 drop-shadow 父元素、非整像素尺寸下会丢竖边 */
  --dash: #ffe9c2;
  background:
    repeating-linear-gradient(90deg, var(--dash) 0 6px, transparent 6px 10px) left top / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, var(--dash) 0 6px, transparent 6px 10px) left bottom / 100% 2px no-repeat,
    repeating-linear-gradient(180deg, var(--dash) 0 6px, transparent 6px 10px) left top / 2px 100% no-repeat,
    repeating-linear-gradient(180deg, var(--dash) 0 6px, transparent 6px 10px) right top / 2px 100% no-repeat; }
.env-preview .frame span { position: absolute; left: 0; right: 0; top: -17px; text-align: center; font-size: 9px; color: #ffe9c2; letter-spacing: .5px; white-space: nowrap; }
.env-preview .ghost-clip { position: absolute; top: 0; right: 0; bottom: 0; left: 0; overflow: hidden; z-index: 1; pointer-events: none; }
.env-preview .ghost { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; opacity: 0; pointer-events: none; z-index: 1; transition: opacity .15s; }
.env-preview.dragging .ghost { opacity: .5; }
.env-preview .vp-empty { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #ffe9c2; text-align: center; gap: 2px; font-family: "Songti SC", serif; }
.env-preview .vp-empty[hidden] { display: none; }
.env-preview .vp-empty i { font-style: normal; font-size: 22px; }
.env-preview .vp-empty b { font-size: 13px; font-family: -apple-system, "PingFang SC", sans-serif; background: rgba(255,233,194,.18); border: 1px solid rgba(255,233,194,.6); border-radius: 12px; padding: 1px 10px; margin: 4px 0 10px; }
.env-preview .vp-empty span { font-size: 17px; letter-spacing: 2px; }
.env-preview .vp-empty small { font-size: 11px; }
.env-preview .vp { position: absolute; z-index: 2; left: var(--ax); top: var(--ay); width: var(--aw); height: var(--ah); overflow: hidden; touch-action: none; background: #fff repeating-linear-gradient(45deg, #fbeee0 0 8px, #fff 8px 16px); cursor: grab; }
.env-preview .vp.empty { background: transparent; cursor: pointer; }
.env-preview .vp img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; pointer-events: none; }
.env-preview .sig { position: absolute; right: 3%; bottom: 1.6%; background: rgba(179,0,15,.86); border: 1px solid var(--gold); color: var(--gold-soft); border-radius: 20px; font-size: 9px; padding: 0 6px; line-height: 16px; white-space: nowrap; pointer-events: none; font-weight: 600; }
.editor-side { flex: 1; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.editor-side .tools { display: flex; flex-direction: column; gap: 10px; }
.editor-side .tools[hidden] { display: none; }
.editor-side .hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.editor-side input[type=range] { width: 100%; accent-color: var(--red); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field label em { color: var(--red); font-style: normal; margin-left: 2px; }
.field label small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.field input, .field select { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; appearance: none; -webkit-appearance: none; }
.field select { background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a6b58' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") right 14px center no-repeat; }
.field input:focus, .field select:focus { outline: 2px solid rgba(200,16,46,.25); border-color: var(--red); }
.field .tip { font-size: 12px; color: var(--muted); margin-top: 4px; }
.age-result { background: #fff1dc; border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--red-ink); margin-top: 6px; }
.guardian { background: #fff6ea; border: 1px solid #f4d9b0; border-radius: 12px; padding: 12px 12px 2px; margin-bottom: 14px; }
.guardian .gt { font-size: 13px; color: var(--warn); margin-bottom: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.proof-pick { display: flex; align-items: center; gap: 10px; }
.proof-pick img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; }
.agree { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.agree:last-child { border: 0; }
.agree input { width: 20px; height: 20px; accent-color: var(--red); flex: none; margin-top: 1px; }
.agree a { color: var(--red); text-decoration: underline; }
.progress { height: 8px; background: #f3e1c8; border-radius: 4px; overflow: hidden; margin: 14px 0 6px; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, #e8273d, #f2a33a); transition: width .2s; }
.success { text-align: center; }
.success .ok-icon { font-size: 48px; }
.success img { width: 46%; margin: 14px auto; filter: drop-shadow(0 8px 14px rgba(80,0,0,.3)); }

/* ---------- my ---------- */
.mine { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.mine:last-child { border: 0; }
.mine img { width: 70px; flex: none; }
.mine .info { flex: 1; min-width: 0; font-size: 13px; }
.mine .info b { font-size: 15px; display: block; }
.mine .reason { background: #fde8e8; color: #b03030; padding: 6px 8px; border-radius: 8px; margin: 6px 0; font-size: 12px; }
.quota { display: flex; gap: 8px; margin-bottom: 10px; }
.quota div { flex: 1; text-align: center; background: #fff; border-radius: 10px; padding: 8px 4px; border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.quota b { display: block; font-size: 18px; color: var(--red); }
.myvote { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.myvote img { width: 34px; }
.myvote span { flex: 1; }

/* ---------- results ---------- */
.res-group h2 { color: var(--gold-soft); font-size: 18px; text-align: center; margin: 18px 0 10px; font-family: "Songti SC", serif; }
.res-group h2::before, .res-group h2::after { content: " ✦ "; color: var(--gold); }
.badge { display: inline-block; font-size: 11px; border-radius: 8px; padding: 0 6px; margin-bottom: 2px; }
.badge.public { background: #ffe6b3; color: #8a4b00; }
.badge.jury { background: #e2ecff; color: #2c4f9e; }

/* ---------- overlays ---------- */
#toast { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); background: rgba(30,10,5,.88); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 80%; text-align: center; }
#toast.show { opacity: 1; }
#modal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(20,0,0,.72); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
#modal[hidden] { display: none; }
.sheet { background: var(--cream); border-radius: 16px; max-width: 480px; width: 100%; max-height: 82vh; overflow: auto; padding: 18px; position: relative; }
.sheet h3 { margin: 0 0 10px; color: var(--red-ink); }
.sheet pre { white-space: pre-wrap; font: inherit; font-size: 14px; margin: 0 0 14px; }
.viewer { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.92); z-index: 60; overflow: auto; display: flex; align-items: center; justify-content: center; }
.viewer img { max-height: 96vh; max-width: 96vw; }
.share-tip { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.8); z-index: 60; color: #fff; text-align: right; padding: 16px 24px; font-size: 16px; }
.share-tip .arrow { font-size: 44px; line-height: 1; }
.poster img { width: 100%; border-radius: 10px; }
.vote-pop { text-align: center; }
.vote-pop .big { font-size: 44px; }
@media (min-width: 521px) { body { padding: 0; } }

/* 老内核（iOS 14 / 旧安卓 X5）不支持 aspect-ratio：用 padding 撑出红包比例 */
@supports not (aspect-ratio: 1) {
  .env-preview { height: 0; padding-top: calc(100% * var(--env-h) / var(--env-w)); }
  .work .pic img { height: auto; }
}
