:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #69758a;
  --line: #dce3ed;
  --surface: #ffffff;
  --page: #f5f7fb;
  --red: #e11d48;
  --rose: #fb7185;
  --orange: #f97316;
  --gold: #f6c453;
  --green: #16a34a;
  --blue: #2563eb;
  --teal: #0f766e;
  --shadow: 0 22px 54px rgba(23, 32, 51, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.draw-page {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.30) 0%, rgba(244, 249, 255, 0.72) 46%, rgba(240, 248, 252, 0.96) 100%),
    url("/assets/oppo-phone-bg.png") top center / min(1180px, 125vw) auto no-repeat fixed,
    linear-gradient(135deg, #6fa9df 0%, #eef7ff 48%, #f6fbff 100%);
}

.draw-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.22), transparent 35%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(239, 247, 252, 0.70) 68%, rgba(238, 247, 244, 0.98) 100%);
}

.draw-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.draw-backdrop span {
  position: absolute;
  display: block;
  width: 11px;
  height: 22px;
  border-radius: 2px;
  opacity: 0.42;
  transform: rotate(18deg);
}

.draw-backdrop span:nth-child(1) {
  left: 9%;
  top: 11%;
  background: var(--gold);
}

.draw-backdrop span:nth-child(2) {
  right: 12%;
  top: 17%;
  background: var(--blue);
  transform: rotate(-22deg);
}

.draw-backdrop span:nth-child(3) {
  left: 16%;
  bottom: 24%;
  background: var(--rose);
  transform: rotate(38deg);
}

.draw-backdrop span:nth-child(4) {
  right: 20%;
  bottom: 17%;
  background: var(--teal);
  transform: rotate(-35deg);
}

.draw-backdrop span:nth-child(5) {
  left: 49%;
  top: 7%;
  background: var(--orange);
  transform: rotate(52deg);
}

.draw-shell {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 24px 18px 34px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.event-head {
  padding: 4px 6px 0;
  text-align: center;
}

.event-kicker {
  margin: 0 0 8px;
  color: #0b5eab;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0;
  line-height: 1.14;
}

h1 {
  font-size: 34px;
  font-weight: 950;
}

h2 {
  font-size: 21px;
}

.event-description {
  min-height: 22px;
  margin: 9px 0 0;
  color: #34445c;
  font-size: 15px;
  font-weight: 700;
}

.wheel-stage {
  position: relative;
  z-index: 0;
  width: min(372px, calc(100vw - 36px));
  aspect-ratio: 1;
  margin: 2px auto 0;
  display: grid;
  place-items: center;
}

.wheel-stage::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -46px;
  z-index: -1;
  width: min(560px, 118%);
  height: 142px;
  transform: translateX(-50%);
  background: url("/assets/gift-stage.svg") center bottom / contain no-repeat;
  opacity: 0.58;
  pointer-events: none;
}

.stage-light {
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  background:
    conic-gradient(from 20deg, rgba(246, 196, 83, 0.18), rgba(225, 29, 72, 0.16), rgba(37, 99, 235, 0.12), rgba(22, 163, 74, 0.16), rgba(246, 196, 83, 0.18));
  filter: blur(8px);
}

.wheel-ring {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  padding: 12px;
  background:
    repeating-conic-gradient(from 0deg, #fff 0deg 8deg, #f6c453 8deg 16deg),
    #fff;
  box-shadow: var(--shadow);
}

.wheel {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--wheel-gradient);
  border: 9px solid #fffaf0;
  overflow: hidden;
  transform: rotate(0deg);
  transition: transform 4.1s cubic-bezier(0.12, 0.72, 0.12, 1);
}

.wheel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.34), transparent 34%),
    linear-gradient(295deg, rgba(0, 0, 0, 0.08), transparent 38%);
  pointer-events: none;
}

.wheel::after {
  content: "";
  position: absolute;
  inset: 17px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.66);
  pointer-events: none;
}

.wheel-label {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 88px;
  margin-left: -44px;
  transform-origin: 44px 0;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.24;
  text-align: center;
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.28);
  overflow-wrap: anywhere;
  pointer-events: none;
  transition: transform 4.1s cubic-bezier(0.12, 0.72, 0.12, 1);
}

.wheel-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 82px;
  height: 82px;
  margin: -41px 0 0 -41px;
  border: 6px solid #ffe7a3;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, #fffdf3, #fff4bf);
  color: var(--red);
  font-size: 30px;
  font-weight: 950;
  box-shadow:
    0 10px 24px rgba(15, 23, 42, 0.22),
    inset 0 -4px 8px rgba(246, 196, 83, 0.28);
}

.pointer {
  position: absolute;
  top: -2px;
  left: 50%;
  z-index: 5;
  width: 44px;
  height: 54px;
  transform: translateX(-50%);
  clip-path: polygon(50% 100%, 4% 0, 96% 0);
  background: linear-gradient(180deg, #172033, #e11d48);
  filter: drop-shadow(0 7px 10px rgba(15, 23, 42, 0.24));
}

.prize-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 33px;
}

.prize-chip {
  max-width: 150px;
  min-height: 31px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background: color-mix(in srgb, var(--chip-color) 18%, #ffffff);
  color: #172033;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.08);
  font-size: 12px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draw-form {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 38px rgba(23, 32, 51, 0.11);
  backdrop-filter: blur(14px);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.primary-button,
.secondary-button,
.danger-button,
.link-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  background: linear-gradient(135deg, var(--red), var(--orange));
  box-shadow: 0 12px 24px rgba(225, 29, 72, 0.24);
}

.primary-button:disabled {
  background: #a8b1c0;
  box-shadow: none;
  cursor: not-allowed;
}

.secondary-button,
.link-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 0 6px 14px rgba(23, 32, 51, 0.06);
}

.danger-button {
  background: #fff;
  border-color: #fecaca;
  color: #dc2626;
}

.message {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.message.error {
  color: #dc2626;
}

.message.success {
  color: var(--green);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.50);
}

.modal-panel {
  width: min(340px, 100%);
  padding: 28px 20px 20px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #ffffff, #fff7ed);
  text-align: center;
  box-shadow: var(--shadow);
}

.modal-kicker {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 13px;
  font-weight: 950;
}

.result-prize {
  margin: 12px 0 20px;
  color: var(--blue);
  font-size: 28px;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.admin-page {
  min-height: 100dvh;
  background:
    linear-gradient(135deg, #f8fafc, #eef5ff 52%, #f7fbf7);
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.login-copy {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.admin-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
  display: grid;
  gap: 18px;
}

.admin-head,
.section-title,
.action-row,
.section-actions,
.header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(30, 41, 59, 0.06);
}

.section-title {
  margin-bottom: 14px;
}

.section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.section-title p.probability-ok {
  color: var(--green);
}

.section-title p.probability-error {
  color: #dc2626;
}

.inline-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
}

.inline-message.error {
  color: #dc2626;
}

.inline-message.success {
  color: var(--green);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-grid .wide,
.project-grid .wide {
  grid-column: 1 / -1;
}

.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: end;
}

.project-switcher,
.new-project-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(180px, 0.5fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid #e5eaf3;
  border-radius: 8px;
  background: #f8fafc;
}

.new-project-card {
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.5fr) auto minmax(150px, 0.45fr);
}

.link-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.project-share {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 16px;
  align-items: end;
  padding: 14px;
  border: 1px solid #e5eaf3;
  border-radius: 8px;
  background: #f8fafc;
}

.prize-total-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px);
  gap: 12px;
  margin-bottom: 12px;
}

.qr-code {
  width: 148px;
  height: 148px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.qr-code canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.qr-meta {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.qr-meta p {
  max-width: 100%;
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  margin-top: 20px;
}

.switch-line input {
  width: 18px;
  min-height: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}

td input {
  min-height: 38px;
}

.calculated-input {
  background: #f8fafc;
  color: #334155;
  font-weight: 900;
}

.prize-table input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
}

.table-check {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-check span {
  display: none;
  color: var(--ink);
  font-size: 14px;
}

.prize-table input[type="color"] {
  width: 46px;
  padding: 3px;
}

.prize-table {
  min-width: 700px;
  table-layout: fixed;
}

.prize-table th:nth-child(1),
.prize-table td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 178px;
  background: #fff;
  box-shadow: 8px 0 12px rgba(23, 32, 51, 0.04);
}

.prize-table th:nth-child(1) {
  z-index: 2;
  background: #f8fafc;
}

.prize-table th:nth-child(2),
.prize-table td:nth-child(2) {
  width: 88px;
}

.prize-table th:nth-child(3),
.prize-table td:nth-child(3),
.prize-table th:nth-child(4),
.prize-table td:nth-child(4) {
  width: 94px;
}

.prize-table th:nth-child(5),
.prize-table td:nth-child(5) {
  width: 66px;
}

.prize-table th:nth-child(6),
.prize-table td:nth-child(6) {
  width: 60px;
}

.prize-table th:nth-child(7),
.prize-table td:nth-child(7) {
  width: 50px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #dc2626;
  font-size: 18px;
  font-weight: 950;
}

.action-row {
  justify-content: flex-end;
  margin-top: 14px;
}

.records-wrap {
  max-height: 380px;
}

@media (max-width: 720px) {
  h1 {
    font-size: 28px;
  }

  .draw-shell {
    padding-inline: 14px;
  }

  .wheel-label {
    width: 78px;
    margin-left: -39px;
    transform-origin: 39px 0;
    font-size: 12px;
  }

  .admin-head,
  .section-title,
  .action-row,
  .section-actions,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .project-grid,
  .project-switcher,
  .new-project-card,
  .link-field {
    grid-template-columns: 1fr;
  }

  .project-share {
    grid-template-columns: 1fr;
  }

  .prize-total-row {
    grid-template-columns: 1fr;
  }

  .admin-shell {
    width: min(100% - 24px, 1160px);
    padding-top: 18px;
  }

  .admin-section {
    padding: 12px;
  }

  .admin-page label,
  .field-label {
    font-size: 14px;
  }

  th,
  td {
    padding: 7px 6px;
    font-size: 14px;
  }

  th {
    font-size: 13px;
  }

  td input {
    min-height: 34px;
    padding: 0 8px;
  }

  .prize-table {
    min-width: 660px;
  }

  .prize-table th:nth-child(1),
  .prize-table td:nth-child(1) {
    width: 154px;
  }

  .prize-table th:nth-child(2),
  .prize-table td:nth-child(2) {
    width: 82px;
  }

  .prize-table th:nth-child(3),
  .prize-table td:nth-child(3),
  .prize-table th:nth-child(4),
  .prize-table td:nth-child(4) {
    width: 84px;
  }

  .prize-table th:nth-child(5),
  .prize-table td:nth-child(5) {
    width: 60px;
  }

  .table-check span {
    display: none;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }
}
