:root {
  color-scheme: dark;
  --bg: #08050c;
  --panel: rgba(18, 11, 25, .96);
  --border: #493552;
  --border-soft: #33243d;
  --text: #eee3f0;
  --muted: #a99cad;
  --gold: #e1bd73;
  --gold-2: #f4dda7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(
      180deg,
      rgba(8, 5, 12, .54) 0%,
      rgba(8, 5, 12, .70) 52%,
      rgba(8, 5, 12, .92) 100%
    ),
    url("./referrals-eclipse-background.webp");
  background-position: center top, center top;
  background-size: cover, cover;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
}

button, input { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--gold-2);
  color: #171019;
  font-weight: 800;
}
.skip-link:focus { top: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgba(225, 189, 115, .22);
  background: rgba(8, 5, 12, .92);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}
.brand img {
  filter: drop-shadow(0 0 12px rgba(225, 189, 115, .3));
}
.brand small, .eyebrow {
  display: block;
  margin: 0;
  color: #a995ae;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.brand strong {
  display: block;
  margin-top: 2px;
  color: var(--gold-2);
  font-family: Georgia, serif;
  font-size: 1.05rem;
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.layout {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 50px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(34, 21, 43, .93), rgba(13, 8, 19, .98));
  box-shadow: 0 18px 52px rgba(0, 0, 0, .35);
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 28px;
  padding: clamp(24px, 5vw, 54px);
  overflow: hidden;
}

h1, h2 { font-family: Georgia, serif; }
h1 {
  max-width: 720px;
  margin: 10px 0 12px;
  color: var(--gold-2);
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.02;
}
h2 {
  margin: 4px 0 0;
  color: #f0d69e;
  font-size: 1.25rem;
}

.hero-copy {
  max-width: 760px;
  margin: 0;
  color: #c6b8ca;
  line-height: 1.65;
}

.reward-seal {
  display: grid;
  place-items: center;
  width: 154px;
  aspect-ratio: 1;
  border: 2px solid #c69b55;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(88, 54, 24, .92), rgba(20, 11, 25, .96) 68%);
  box-shadow:
    inset 0 0 0 6px rgba(8, 5, 12, .82),
    inset 0 0 0 8px rgba(225, 189, 115, .3),
    0 0 38px rgba(225, 189, 115, .2);
  text-align: center;
}
.reward-seal strong {
  display: block;
  color: var(--gold-2);
  font-family: Georgia, serif;
  font-size: 3rem;
  line-height: 1;
}
.reward-seal span {
  display: block;
  margin-top: 5px;
  color: #d8c7dc;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.status-panel, .history-panel, .rules-panel,
.content-grid > .panel {
  padding: 20px;
}
.status-panel { margin-top: 14px; }
.section-copy { margin: -2px 0 16px; color: var(--muted); font-size: .78rem; line-height: 1.55; }

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.status-dot {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}
.status-dot::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.notice {
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #0d0813;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.5;
}
.notice-info { border-color: #38536d; color: #b9d6ef; background: #0d1720; }
.notice-success { border-color: #376247; color: #b8e3c6; background: #0d1b12; }
.notice-warning { border-color: #755c31; color: #ead49e; background: #21190c; }
.notice-danger { border-color: #713f47; color: #efb9bd; background: #241014; }
.notice-muted { color: var(--muted); }

.login-actions { margin-top: 12px; }
.workspace { display: grid; gap: 14px; margin-top: 14px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(16, 10, 23, .96);
}
.metric-card span, .metric-card small {
  display: block;
  color: var(--muted);
  font-size: .7rem;
}
.metric-card strong {
  display: block;
  margin: 7px 0 5px;
  color: var(--gold-2);
  font-family: Georgia, serif;
  font-size: 2rem;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid #56415e;
  border-radius: 999px;
  background: #160e1d;
  color: #cdbfd1;
  font-size: .68rem;
  font-weight: 800;
  white-space: nowrap;
}
.badge-success { border-color: #3f7350; color: #aee0bd; background: #102118; }
.badge-warning { border-color: #745d35; color: #e6d093; background: #21180c; }
.badge-danger { border-color: #75414a; color: #eab0b5; background: #241015; }
.badge-info { border-color: #486785; color: #b7d6f2; background: #0f1b26; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
}
.button:disabled { cursor: not-allowed; opacity: .52; }
.button-primary {
  border-color: #c49851;
  background: linear-gradient(180deg, #d6ad68, #9c6e32);
  color: #170e09;
}
.button-secondary {
  border-color: #5a4364;
  background: #17101e;
  color: #e0d3e3;
}

.code-box, .share-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.code-box code {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  overflow: auto;
  border: 1px solid #6a4b72;
  border-radius: 10px;
  background: #09060d;
  color: var(--gold-2);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: .08em;
  white-space: nowrap;
}

label {
  display: grid;
  gap: 7px;
  color: #d5c7d8;
  font-size: .76rem;
  font-weight: 800;
}
input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #5b4265;
  border-radius: 9px;
  outline: none;
  background: #0a0710;
  color: var(--text);
}
input:focus {
  border-color: #c49851;
  box-shadow: 0 0 0 3px rgba(196, 152, 81, .15);
}

.share-field { margin-top: 13px; }
.share-row input { min-width: 0; color: #b8abbc; font-size: .76rem; }
.fine-print { margin: 12px 0 0; color: #93869a; font-size: .72rem; }

#linkForm { display: grid; gap: 12px; }
#referralCodeInput {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 800;
}
.confirmation-check {
  grid-template-columns: auto 1fr;
  align-items: flex-start;
  font-weight: 500;
  line-height: 1.45;
}
.confirmation-check input {
  width: 18px;
  min-height: 18px;
  margin: 2px 0 0;
}
#linkNotice { margin-top: 12px; }

.linked-state {
  padding: 15px;
  border: 1px solid #3f7350;
  border-radius: 11px;
  background: #0c1a12;
}
.linked-state span, .linked-state small {
  display: block;
  color: #9fbea9;
  font-size: .72rem;
}
.linked-state strong {
  display: block;
  margin: 7px 0;
  color: #c9efd5;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .08em;
}

.history-table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 700px; border-collapse: collapse; }
th, td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  font-size: .76rem;
}
th {
  color: #9f91a5;
  font-size: .65rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
td { color: #ddd0e0; }
.reward-value { color: var(--gold-2); font-weight: 900; }

.empty-state {
  padding: 22px;
  border: 1px dashed #4a3653;
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  font-size: .8rem;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.rules-grid > div {
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: #0c0812;
}
.rules-grid strong { color: #ead4a5; font-family: Georgia, serif; }
.rules-grid p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.5;
}


.allies-panel { padding: 20px; }
.allies-list { display: grid; gap: 10px; }
.ally-card {
  padding: 15px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(12, 8, 18, .94);
}
.ally-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.ally-head strong { display: block; color: #ead4a5; font-family: Georgia, serif; font-size: 1rem; }
.ally-head small { display: block; margin-top: 4px; color: #918596; font-size: .68rem; }
.ally-head time { color: var(--muted); font-size: .68rem; text-align: right; }
.ally-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 13px;
}
.ally-metrics > div {
  padding: 10px 11px;
  border: 1px solid #3f3048;
  border-radius: 9px;
  background: #09060d;
}
.ally-metrics span { display: block; color: var(--muted); font-size: .65rem; }
.ally-metrics strong { display: block; margin-top: 4px; color: var(--gold-2); font-size: 1.15rem; }
.ally-last-reward { margin: 11px 0 0; color: #9e91a3; font-size: .68rem; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 15px;
  border: 1px solid #3f7350;
  border-radius: 10px;
  background: #102118;
  color: #c9efd5;
  box-shadow: 0 18px 45px rgba(0,0,0,.42);
  font-size: .78rem;
  font-weight: 800;
}
.toast-danger { border-color: #75414a; background: #241015; color: #eab0b5; }

footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 22px;
  border-top: 1px solid rgba(225, 189, 115, .15);
  background: rgba(8, 5, 12, .9);
  color: #8f8394;
  font-size: .7rem;
}

@media (max-width: 850px) {
  .hero, .content-grid { grid-template-columns: 1fr; }
  .reward-seal { width: 122px; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rules-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  body {
    background-position: center top, 38% top;
    background-attachment: scroll, scroll;
  }
  .topbar { position: static; align-items: flex-start; padding: 13px 16px; }
  .topbar-actions .badge { display: none; }
  .topbar-actions .button { min-height: 36px; padding: 0 10px; font-size: .72rem; }
  .layout { width: min(100% - 20px, 1180px); padding-top: 10px; }
  .hero, .status-panel, .history-panel, .rules-panel, .allies-panel,
  .content-grid > .panel { padding: 16px; border-radius: 13px; }
  .ally-head { flex-direction: column; }
  .ally-head time { text-align: left; }
  .code-box, .share-row { align-items: stretch; flex-direction: column; }
  .code-box .button, .share-row .button { width: 100%; }
}
