:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --text: #172033;
  --muted: #70798a;
  --line: #dce2eb;
  --line-strong: #c5cedb;
  --navy: #07356f;
  --navy-strong: #032b5f;
  --navy-soft: #edf4ff;
  --gold: #c98716;
  --danger: #d84646;
  --success: #16a05d;
  --shadow: 0 -8px 28px rgba(17, 40, 77, 0.09);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.hidden { display: none !important; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--surface);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 58px;
  padding: env(safe-area-inset-top) 8px 0;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  text-align: center;
  letter-spacing: 0.01em;
}

.topbar-spacer { width: 44px; }

/* Keep the title centered before the back button becomes available. */
.topbar .icon-button.hidden {
  display: inline-grid !important;
  visibility: hidden;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: currentColor;
  cursor: pointer;
}

.icon-button svg,
.outline-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-screen {
  display: flex;
  min-height: calc(100dvh - 58px);
  padding: 72px 28px 40px;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 24px;
  background: var(--navy-soft);
  color: var(--navy);
}

.auth-mark svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-screen h2,
.success-screen h2 {
  margin: 24px 0 8px;
  font-size: 23px;
}

.auth-screen p,
.success-screen > p {
  max-width: 340px;
  margin: 0 0 28px;
  color: var(--muted);
}

.identity-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px;
  border-bottom: 1px solid var(--line);
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}

.identity-row strong { display: block; font-size: 16px; }
.identity-row span:not(.avatar) {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}
.identity-row svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--success);
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.form-section {
  padding: 24px 18px;
  border-bottom: 9px solid var(--surface-soft);
}

.section-heading { margin-bottom: 18px; }
.section-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}
.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}
em { color: var(--danger); font-style: normal; }

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

.venue-option {
  min-height: 58px;
  padding: 10px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
}

.venue-option[aria-checked="true"] {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
  box-shadow: 0 6px 16px rgba(7, 53, 111, 0.14);
}

.field-grid,
.placement-fields { display: grid; gap: 16px; }

.field { display: block; min-width: 0; }
.field > span {
  display: block;
  margin-bottom: 7px;
  color: #354054;
  font-size: 14px;
  font-weight: 600;
}

input,
select {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input::placeholder { color: #a0a8b5; }
input:focus,
select:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(7, 53, 111, 0.1);
}
input[aria-invalid="true"],
select[aria-invalid="true"] { border-color: var(--danger); }

.input-suffix { position: relative; }
.input-suffix input { padding-right: 46px; }
.input-suffix > span {
  position: absolute;
  right: 14px;
  top: 50%;
  color: var(--muted);
  transform: translateY(-50%);
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.text-button {
  justify-self: start;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--navy);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.placement-list { display: grid; gap: 14px; }
.placement-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.placement-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 13px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}
.placement-card > header > div { display: flex; align-items: center; gap: 8px; }
.place-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  font-weight: 750;
}
.place-label { font-size: 16px; }
.placement-fields { padding: 16px 14px; }

.danger-button {
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 13px;
  cursor: pointer;
}

.prize-block {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}
.prize-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.prize-heading strong { font-size: 14px; }
.prize-heading label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.prize-heading input { width: 18px; min-height: 18px; accent-color: var(--navy); }
.prize-list { display: grid; gap: 10px; }
.prize-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 66px 38px;
  gap: 7px;
  align-items: end;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.prize-row .field > span { font-size: 12px; font-weight: 500; }
.prize-row input { min-height: 44px; padding: 9px 8px; font-size: 14px; }
.remove-prize { margin-bottom: 1px; color: var(--danger); }

.outline-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 50px;
  border: 1px dashed #97aac3;
  border-radius: 9px;
  background: #fff;
  color: var(--navy);
  font-weight: 650;
  cursor: pointer;
}
.add-placement { margin-top: 14px; }

.sticky-action {
  position: sticky;
  bottom: 0;
  z-index: 15;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.primary-button {
  width: 100%;
  min-height: 54px;
  padding: 13px 18px;
  border: 0;
  border-radius: 9px;
  background: var(--navy);
  color: #fff;
  font-weight: 720;
  cursor: pointer;
  box-shadow: 0 7px 18px rgba(7, 53, 111, 0.18);
}
.primary-button:active { background: var(--navy-strong); }
.primary-button:disabled { opacity: 0.55; cursor: not-allowed; }
.auth-screen .primary-button { width: min(100%, 320px); margin-top: 4px; }

.form-error,
.status-text {
  min-height: 22px;
  margin: 0;
  padding: 0 18px 10px;
  color: var(--danger);
  font-size: 13px;
}

.review-screen { padding-bottom: 0; }
.review-group { padding: 22px 18px; border-bottom: 1px solid var(--line); }
.review-group h2 { margin: 0 0 14px; font-size: 17px; }
.review-list { display: grid; gap: 12px; margin: 0; }
.review-list > div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
}
.review-list dt { color: var(--muted); font-size: 14px; }
.review-list dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.review-placement {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.review-placement:first-of-type { border-top: 0; padding-top: 0; }
.review-placement h3 { margin: 0 0 12px; font-size: 16px; }
.review-warning {
  margin: 0;
  padding: 18px;
  color: var(--gold);
  font-size: 13px;
  background: #fffaf0;
}

.success-screen {
  padding: 50px 18px calc(32px + env(safe-area-inset-bottom));
  text-align: center;
}
.success-check {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 50%;
  background: #e8f8ef;
  color: var(--success);
}
.success-check svg {
  width: 42px;
  height: 42px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.success-details {
  margin: 30px 0 22px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: left;
}
.success-details > div {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.success-details > div:last-child { border-bottom: 0; }
.success-details dt { color: var(--muted); }
.success-details dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

@media (min-width: 521px) {
  body { background: #edf1f6; }
  .app-shell { box-shadow: 0 0 40px rgba(17, 40, 77, 0.1); }
}

@media (max-width: 370px) {
  .prize-row { grid-template-columns: minmax(0, 1fr) 64px 38px; }
  .prize-row .compact:nth-of-type(3) { display: none; }
  .review-list > div { grid-template-columns: 92px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
