:root {
  --bg: #0f1827;
  --card: #1e2938;
  --field: #17212c;
  --line: #364152;
  --text: #ececec;
  --muted: #93a1b3;
  --blue: #5188c0;
  --blue-soft: rgba(81, 136, 192, 0.16);
  --red: #d9463f;
  --radius: 14px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 8px;
  background: var(--bg);
  max-width: 560px;
  margin: 0 auto;
}
.bar h1 { margin: 0; font-size: 17px; font-weight: 600; }

.close {
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.close:active { filter: brightness(1.3); }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 16px calc(96px + env(safe-area-inset-bottom));
}

.lede { margin: 2px 0 14px; font-size: 14px; color: var(--muted); }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: #8fbbe6;
  font-weight: 600;
  max-width: 62vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.banner {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(217, 70, 63, 0.14);
  color: #ffb4b0;
  font-size: 13px;
}

.prizes { display: flex; flex-direction: column; gap: 10px; }

.prize-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 92px 92px;
  gap: 10px;
}
.prize-card .cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.prize-card .cell.wide { grid-column: 1 / -1; }
.prize-card .head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: -2px;
}
.prize-card .head .tag { font-size: 12px; color: var(--muted); }
.prize-card .del {
  border: none;
  background: none;
  color: #7d8b9c;
  font-size: 15px;
  padding: 2px 4px;
  cursor: pointer;
}
.prize-card .del:active { color: var(--red); }

.label, .row-label { font-size: 13px; color: var(--muted); }
.label.grow { flex: 1; }

.section-title {
  margin: 22px 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

input, textarea, select {
  width: 100%;
  min-width: 0;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  min-height: 44px;
  transition: border-color 0.15s ease;
}

select { appearance: none; padding-right: 28px; }

input::placeholder, textarea::placeholder { color: #64748b; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--blue);
}

input:disabled, select:disabled, textarea:disabled {
  opacity: 0.45;
}

textarea { resize: vertical; min-height: 80px; }

input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.75);
  cursor: pointer;
}

.hint { font-size: 12px; color: #6f7f92; }

.field > .hint { display: block; margin-top: 7px; }

#conditionHint { margin: 12px 2px 0; line-height: 1.5; }

.totals { margin: 10px 2px 0; font-size: 12px; color: var(--muted); }

.add {
  width: 100%;
  margin-top: 10px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: none;
  color: #9db4cc;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 12px;
  cursor: pointer;
}
.add:active { background: rgba(255, 255, 255, 0.04); }
.add[disabled] { opacity: 0.4; }

.block {
  margin-top: 16px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 2px 14px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 50px;
  border-bottom: 1px solid rgba(54, 65, 82, 0.55);
}
.row:last-child { border-bottom: none; }
.row-label { color: var(--text); font-size: 14px; flex: 1 1 auto; min-width: 0; }

.field { display: block; margin-top: 16px; }
.field > .label { display: block; margin-bottom: 7px; }
.inline { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }

.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: #3a4757;
  cursor: pointer;
  padding: 0;
  transition: background 0.18s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}
.switch[aria-checked="true"] { background: var(--blue); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.mode {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-align: left;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.mode strong { display: block; font-size: 14px; margin-bottom: 4px; font-weight: 600; }
.mode small { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; }
.mode[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--blue-soft);
}
.mode[aria-pressed="true"] strong { color: #8fbbe6; }

footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(15, 24, 39, 0) 0%, var(--bg) 40%);
  max-width: 560px;
  margin: 0 auto;
}

.btn {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  min-height: 48px;
  cursor: pointer;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn:active { filter: brightness(0.93); }
.btn[disabled] { opacity: 0.55; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: min(88vw, 460px);
  padding: 10px 14px;
  border-radius: 12px;
  background: #23303f;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: pre-wrap;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #4a2320; color: #ffc9c5; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 16, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
}

.sheet {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 18px;
  padding: 22px 20px 18px;
  text-align: center;
}
.sheet h3 { margin: 0 0 8px; font-size: 17px; }
.sheet p { margin: 0 0 18px; font-size: 14px; color: var(--muted); line-height: 1.55; white-space: pre-wrap; }
.sheet .btn { width: 100%; }

@media (max-width: 360px) {
  .prize-card { grid-template-columns: 1fr 76px 76px; }
  .modes { grid-template-columns: 1fr; }
}
