/* ---------------------------------------------------------------------
   $DELVE — dark mine aesthetic
   Near-black base, warm stone browns, lantern amber/gold, emerald accents,
   parchment text. Serif display for headings, clean sans for data.
--------------------------------------------------------------------- */

:root {
  --bg: #0D0B08;
  --bg-raised: #16130E;
  --bg-card: #1C1811;
  --stone: #2B2419;
  --stone-line: #3A2F1F;
  --amber: #E8A33D;
  --gold: #F6C453;
  --emerald: #3FBF7F;
  --parchment: #EFE3C8;
  --parchment-dim: #B8AC8E;
  --ember: #FF7A3D;
  --danger: #E0574C;

  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 10px;
  --shadow-lantern: 0 0 0 1px rgba(232, 163, 61, 0.25), 0 0 18px rgba(232, 163, 61, 0.15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--parchment);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(232, 163, 61, 0.07), transparent 60%);
  background-repeat: no-repeat;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--gold);
  margin: 0 0 0.5rem;
  font-weight: 600;
}

h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; color: var(--amber); }

p { color: var(--parchment-dim); margin: 0 0 0.75rem; }

a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--gold); text-decoration: underline; }

button { font-family: var(--font-sans); }

.vein-divider {
  height: 2px;
  margin: 2.5rem auto;
  max-width: 1100px;
  background: linear-gradient(90deg, transparent, var(--amber) 20%, var(--gold) 50%, var(--amber) 80%, transparent);
  opacity: 0.5;
}

/* ---------------------------- header ---------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 11, 8, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--stone-line);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--gold);
  text-decoration: none;
}
.brand:hover { color: var(--gold); text-decoration: none; }
.brand-mark { font-size: 1.3rem; }

.main-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  background: none;
  border: none;
  color: var(--parchment-dim);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.92rem;
}
.nav-link:hover { color: var(--parchment); background: var(--bg-raised); }
.nav-link.is-active { color: var(--gold); background: var(--stone); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.network-badge {
  font-size: 0.72rem;
  color: var(--parchment-dim);
  border: 1px solid var(--stone-line);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.wallet-address {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--emerald);
  border: 1px solid var(--stone-line);
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
}

/* ---------------------------- buttons ---------------------------- */

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
  color: var(--bg);
}
.btn:hover { filter: brightness(1.08); box-shadow: var(--shadow-lantern); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; box-shadow: none; }

.btn-amber { background: var(--amber); }
.btn-gold { background: var(--gold); }
.btn-emerald { background: var(--emerald); color: #06170F; }
.btn-large { padding: 0.85rem 1.75rem; font-size: 1.05rem; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn-ghost {
  background: transparent;
  color: var(--parchment);
  border: 1px solid var(--stone-line);
}
.btn-ghost:hover { border-color: var(--amber); color: var(--gold); box-shadow: none; }
.btn-danger { background: var(--danger); color: #1a0a08; }

/* ---------------------------- layout ---------------------------- */

main { max-width: 1100px; margin: 0 auto; padding: 0 1rem 4rem; }

.view { animation: fade-in 0.2s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--stone-line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.panel-sub { font-size: 0.85rem; margin-top: -0.25rem; }

/* ---------------------------- hero ---------------------------- */

.hero {
  padding: 4rem 1rem 2.5rem;
  text-align: center;
}
.hero-inner { max-width: 720px; margin: 0 auto; }
.wordmark {
  font-size: clamp(2.4rem, 8vw, 4rem);
  letter-spacing: 0.02em;
  text-shadow: 0 0 24px rgba(246, 196, 83, 0.35);
}
.tagline {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  color: var(--amber);
  margin-bottom: 1rem;
}
.mechanics-line { max-width: 560px; margin: 0 auto 1.75rem; }

/* ---------------------------- stats bar ---------------------------- */

.stats-bar, .mystats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .stats-bar { grid-template-columns: repeat(5, 1fr); }
  .mystats-grid { grid-template-columns: repeat(3, 1fr); }
}

.stat-tile {
  background: var(--bg-card);
  border: 1px solid var(--stone-line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--parchment-dim);
  margin-bottom: 0.3rem;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--parchment);
  word-break: break-word;
}
.stat-unit { font-size: 0.72rem; color: var(--parchment-dim); margin-top: 0.15rem; }

.stat-ember .stat-value { color: var(--ember); text-shadow: 0 0 10px rgba(255, 122, 61, 0.45); }

/* ---------------------------- tier table ---------------------------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--stone-line); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead { background: var(--stone); }
th, td { text-align: left; padding: 0.6rem 0.85rem; white-space: nowrap; }
th { color: var(--amber); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr { border-top: 1px solid var(--stone-line); }
tbody tr:hover { background: var(--bg-raised); }

/* ---------------------------- how it works ---------------------------- */

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 720px) {
  .steps { grid-template-columns: repeat(4, 1fr); }
}
.step {
  background: var(--bg-card);
  border: 1px solid var(--stone-line);
  border-radius: var(--radius);
  padding: 1rem;
  position: relative;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--stone);
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.referral-explainer {
  margin-top: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--stone-line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.referral-warning { color: var(--ember); }

/* ---------------------------- mine view ---------------------------- */

.mine-gate {
  text-align: center;
  padding: 4rem 1rem;
  max-width: 480px;
  margin: 0 auto;
}

.machine-grid, .shop-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}
@media (min-width: 640px) {
  .machine-grid, .shop-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
  .machine-grid, .shop-grid { grid-template-columns: repeat(3, 1fr); }
}

.machine-card, .shop-card {
  background: var(--bg-raised);
  border: 1px solid var(--stone-line);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.machine-card-head { display: flex; align-items: center; justify-content: space-between; }
.machine-tier-name { font-family: var(--font-display); color: var(--gold); font-size: 1.05rem; }
.gift-tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--emerald);
  border: 1px solid var(--emerald);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.status-line { font-size: 0.82rem; display: flex; align-items: center; gap: 0.4rem; }
.status-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; display: inline-block; }
.status-ok { background: var(--emerald); }
.status-overdue { background: var(--danger); box-shadow: 0 0 8px rgba(224, 87, 76, 0.6); }

.card-actions { display: flex; gap: 0.5rem; margin-top: auto; flex-wrap: wrap; }

.empty-note { color: var(--parchment-dim); font-style: italic; }

.rewards-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.rewards-amount { font-family: var(--font-mono); font-size: 1.6rem; color: var(--emerald); }
.rewards-amount .unit { font-size: 0.9rem; color: var(--parchment-dim); }

.boost-badge {
  background: rgba(63, 191, 127, 0.15);
  color: var(--emerald);
  border: 1px solid var(--emerald);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.inline-form input, .gift-form input, .gift-form select {
  background: var(--bg-raised);
  border: 1px solid var(--stone-line);
  color: var(--parchment);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.referral-block { margin-top: 0.5rem; }
.code-display { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.code-label { color: var(--parchment-dim); font-size: 0.8rem; }
.code-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--gold);
  background: var(--bg-raised);
  border: 1px solid var(--stone-line);
  border-radius: var(--radius);
  padding: 0.3rem 0.7rem;
}

.first-purchase-warning {
  color: var(--ember);
  font-size: 0.82rem;
  border: 1px dashed var(--ember);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  margin-top: 0.4rem;
}

/* ---------------------------- admin view ---------------------------- */

.gift-form { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.gift-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.78rem; color: var(--parchment-dim); }

.quota-grid, .admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .quota-grid { grid-template-columns: repeat(3, 1fr); }
  .admin-grid { grid-template-columns: repeat(2, 1fr); }
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  background: var(--bg-raised);
  border: 1px solid var(--stone-line);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  flex-wrap: wrap;
}
.admin-row input {
  width: 9rem;
  background: var(--bg);
  border: 1px solid var(--stone-line);
  color: var(--parchment);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-family: var(--font-mono);
}

.data-table tbody td { font-family: var(--font-mono); font-size: 0.82rem; }

.fund-status { font-size: 0.82rem; color: var(--parchment-dim); min-height: 1.2em; }

/* ---------------------------- footer ---------------------------- */

.site-footer {
  border-top: 1px solid var(--stone-line);
  margin-top: 2rem;
  padding: 1.5rem 1rem 2.5rem;
}
.footer-inner { max-width: 1100px; margin: 0 auto; text-align: center; }
.footer-links { display: flex; gap: 1.25rem; justify-content: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.footer-note { font-size: 0.8rem; color: var(--parchment-dim); }

/* ---------------------------- toasts ---------------------------- */

.toast-stack {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  left: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-end;
  pointer-events: none;
}
@media (min-width: 640px) {
  .toast-stack { left: auto; width: 360px; }
}

.toast {
  pointer-events: auto;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--stone-line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  font-size: 0.85rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.18s ease;
}
.toast a { color: var(--amber); }
.toast.toast-pending { border-left-color: var(--amber); }
.toast.toast-success { border-left-color: var(--emerald); }
.toast.toast-error { border-left-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------- misc ---------------------------- */

[hidden] { display: none !important; }
