:root {
  --navy: #0b1220;
  --navy-2: #111a2e;
  --navy-3: #1a2640;
  --line: #243152;
  --text: #eef2fb;
  --muted: #9aa8c7;
  --green: #3ddc97;
  --purple: #8b7cf6;
  --danger: #ff6b6b;
  --radius: 16px;
  --radius-sm: 10px;
  --pad: 20px;
  --bottom-safe: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--navy);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--navy);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
  padding-bottom: var(--bottom-safe);
}

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0 12px;
  background: var(--navy);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--navy-3);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px;
  color: var(--green);
  flex: none;
}
.brand-name { margin: 0; font-weight: 800; letter-spacing: .02em; font-size: 15px; }
.brand-x { color: var(--purple); }
.brand-sub { margin: 0; color: var(--muted); font-size: 12px; }

.wallet-mount { flex: none; }
.wallet-mount #ton-connect-button button { border-radius: var(--radius-sm); }

/* Type */
h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; margin: 10px 0 8px; }
h2 { font-size: 17px; margin: 0 0 8px; letter-spacing: .01em; }
h3 { font-size: 18px; margin: 4px 0 8px; letter-spacing: .02em; }
p { margin: 8px 0; }
code, .address {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}
.eyebrow { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin: 18px 0 0; }
.lede { color: #c9d4ef; font-size: 15px; margin-top: 0; }

.status-banner {
  margin: 14px 0 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--navy-2);
  font-size: 13px;
}
.status-banner.preview { border-color: #b78a2e; background: #2a2113; color: #f3d9a4; }
.status-banner.live { border-color: #1f6b4a; background: #0f2b21; color: #b9f2d6; }

/* Cards */
.card {
  background: var(--navy-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-top: 14px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; }

.wallet-state {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 10px 0 12px;
  background: var(--navy-3);
  word-break: break-all;
}
.wallet-state.connected { border-color: #1f6b4a; color: #b9f2d6; }

.row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.row:last-of-type { border-bottom: none; }

.eligibility {
  margin: 12px 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-align: center;
  border: 1px solid var(--line);
}
.eligibility.ok { background: #0f2b21; border-color: #1f6b4a; color: #b9f2d6; }
.eligibility.no { background: #2b1317; border-color: #6b2230; color: #ffc9cc; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--navy-3);
}
.stat-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
input[type="text"], input[type="number"] {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--navy);
  color: var(--text);
  font-size: 16px; /* avoids iOS zoom */
}
input:focus { outline: 2px solid var(--purple); outline-offset: 1px; }

.error { color: var(--danger); font-size: 13px; }

.review-box {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--navy-3);
}

/* Buttons */
.btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
  min-height: 48px; /* tap target */
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #071018; }
.btn-secondary { background: var(--navy-3); color: var(--text); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn:active { transform: scale(.99); }
@media (prefers-reduced-motion: reduce) {
  .btn:active { transform: none; }
  * { transition: none !important; }
}

/* Rules table */
.rules { margin: 8px 0; padding-left: 20px; }
.rules li { margin: 4px 0; }
.table-wrap { overflow-x: auto; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(3, 6, 14, .72);
  display: grid; place-items: end center;
  padding: 12px;
  z-index: 50;
}
@media (min-width: 600px) {
  .modal-backdrop { place-items: center; }
}
.modal {
  width: 100%; max-width: 520px;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  background: var(--navy-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px var(--pad);
  padding-bottom: calc(var(--pad) + var(--bottom-safe));
}
.modal-kicker { color: var(--purple); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: 0; }
.modal-copy { color: #c9d4ef; font-size: 14px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.modal-field {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 10px;
  display: grid; gap: 4px;
  background: var(--navy-3);
}
.modal-actions { display: grid; gap: 10px; margin-top: 16px; }
@media (min-width: 480px) {
  .modal-actions { grid-template-columns: 1fr 1fr; }
  .modal-actions .btn { margin-top: 0; }
}

.preview-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed #b78a2e;
  border-radius: var(--radius-sm);
}

.tx-refs { display: block; margin-top: 10px; white-space: pre-wrap; }

.fineprint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 20px;
  word-break: break-all;
}

.toast {
  position: fixed; left: 50%; bottom: calc(16px + var(--bottom-safe));
  transform: translateX(-50%);
  background: var(--navy-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  z-index: 60;
  max-width: calc(100vw - 32px);
  font-size: 13px;
}

[hidden] { display: none !important; }
