:root{
  --bg: radial-gradient(circle at 12% 0%, #3b0d63 0%, #260144 40%, #16002a 100%);
  --text:#f5f3ff;
  --muted:#a5addf;

  /* Monad vibes: purple primary, indigo secondary */
  --accent:#a855f7;   /* core monad purple */
  --accent2:#4f46e5;  /* deep indigo */

  --ok:#22c55e;
  --warn:#f59e0b;
  --err:#ef4444;

  --bd: rgba(129,140,248,.45);

  --header-h:64px;
  --footer-h:56px;
}

/* ============= Base Reset ============= */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--text);
  background:var(--bg);
  background-attachment:fixed;
  min-height:100vh;
}

/* ============= Back Button Wrapper ============= */
.back-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 18px 0;
}

/* ===== Back Button ===== */
.btn-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent2);
  background: rgba(38,0,79,.94);
  border: 1px solid rgba(148,163,255,.55);
  box-shadow: 0 10px 26px rgba(3,7,18,.95);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: all .25s ease;
}

.btn-back .icon {
  width: 22px;
  height: 22px;
  stroke: var(--accent2);
  transition: transform .25s ease;
}

.btn-back:hover {
  color: #f9fafb;
  background: linear-gradient(
    105deg,
    rgba(126,34,206,.7),
    rgba(79,70,229,.7),
    rgba(30,64,175,.7)
  );
  box-shadow:
    0 0 18px rgba(129,140,248,.7),
    0 0 30px rgba(79,70,229,.6);
  transform: translateY(-2px);
}
.btn-back:hover .icon {
  transform: translateX(-4px);
}

/* ============= Header ============= */
header.app-hd{
  position:sticky;
  top:0;
  z-index:50;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 16px;
  background:
    radial-gradient(circle at 0 0, rgba(168,85,247,.24) 0%, transparent 60%),
    linear-gradient(115deg, #28004e 0%, #3d0072 52%, #5b0da8 100%);
  border-bottom:1px solid rgba(148,163,255,.55);
  backdrop-filter:saturate(160%) blur(16px);
  box-shadow:0 18px 46px rgba(0,0,0,.8);
}

.brand{
  position:relative;
  font-weight:800;
  letter-spacing:.2px;
  display:flex;
  align-items:center;
  gap:.5rem;
  text-transform:uppercase;
}

.brand::before{
  content:"";
  width:34px;
  height:34px;
  border-radius:12px;
  background: url("../assets/rancer-logo.jpg") center/cover no-repeat;
  border:1px solid rgba(191,219,254,.8);
  box-shadow:
    0 0 18px rgba(168,85,247,.9),
    0 0 28px rgba(79,70,229,.9);
  flex-shrink:0;
  animation:glowPulse 3.2s ease-in-out infinite;
}

@keyframes glowPulse{
  0%,100%{
    box-shadow:
      0 0 18px rgba(168,85,247,.9),
      0 0 28px rgba(79,70,229,.8);
  }
  50%{
    box-shadow:
      0 0 26px rgba(192,132,252,1),
      0 0 40px rgba(99,102,241,.9);
  }
}

.brand span{
  background:linear-gradient(120deg,#e5e7ff,#c4b5fd,#6366f1);
  -webkit-background-clip:text;
  color:transparent;
}

.wallet{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:10px;
}

/* ============= Layout ============= */
main{
  max-width:1100px;
  margin:0 auto;
  padding:22px 16px calc(var(--footer-h) + 20px);
}

.wrap{
  position:relative;
  border:1px solid var(--bd);
  border-radius:18px;
  padding:18px;
  background:
    radial-gradient(circle at 10% 0%, rgba(79,70,229,.32) 0%, transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(55,48,163,.22) 0%, transparent 55%),
    rgba(148,163,255,.55);
  box-shadow:
  0 0 24px rgba(168,85,247,.5),
  0 0 40px rgba(232,121,249,.35);
  backdrop-filter:blur(12px);
  overflow:hidden;
}

.grid{
  display:grid;
  gap:16px;
}

.g-2{
  grid-template-columns:1fr;
}

/* ============= Card (Monad style) ============= */
.card {
  position: relative;
  border-radius: 16px;
  padding: 16px;
  background:
    radial-gradient(circle at 0% 0%, rgba(129,140,248,.26), transparent 56%),
    linear-gradient(182deg, rgba(38,0,79,.94), rgba(192,132,252,1));
  border:1px solid rgba(148,163,255,.6);
  box-shadow:
    0 14px 34px rgba(3,7,18,.95),
    inset 0 1px 0 rgba(248,250,252,.06);
  backdrop-filter:blur(10px);
  overflow:hidden;
  transition:transform .18s ease, box-shadow .18s ease, border .18s ease;
}

.card::after {
  content: "";
  position: absolute;
  top: -140%;
  left: -50%;
  width: 200%;
  height: 150%;
  background: linear-gradient(130deg,
    rgba(255,255,255,0) 0%,
    rgba(148,163,255,.28) 45%,
    rgba(255,255,255,0) 80%);
  transform: rotate(3deg);
  animation: cardScan 11s linear infinite;
  pointer-events: none;
  opacity: 0;
}
@keyframes cardScan{
  0%{ transform:translateY(0) rotate(3deg); opacity:0;}
  12%{ opacity:.85; }
  40%{ transform:translateY(140%) rotate(3deg); opacity:0;}
  100%{ opacity:0; }
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(191,219,254,.98);
  box-shadow: 0 22px 52px rgba(15,23,42,1);
}

/* ============= Typography ============= */
h1{margin:10px 0 8px; font-size:1.6rem}
h2{margin:0 0 10px; font-size:1.2rem}
.mono{font-family:ui-monospace,Menlo,Consolas,monospace}

/* ============= Stats (fluid) ============= */
.stats{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap:10px;
}
.stat{
  background:
  radial-gradient(circle at 10% 0%, rgba(168,85,247,.32) 0%, transparent 55%),
  rgba(38,0,79,.94);
  border:1px solid rgba(129,140,248,.8);
  border-radius:12px;
  padding:12px;
  box-shadow:
    0 0 16px rgba(76,81,191,.45),
    inset 0 0 10px rgba(3,7,18,.96);
}
.stat .lbl{
  color:var(--muted);
  font-size:.78rem;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:6px;
}
.stat .val{
  margin-top:6px;
  font-weight:800;
  word-break:break-word;
}

/* ============= Form ============= */
.row{display:flex; gap:10px; align-items:center; flex-wrap:wrap}
.field{display:flex; flex-direction:column; gap:8px; margin:8px 0}
.field input{
  padding:12px;
  border-radius:10px;
  background:#050317;
  border:1px solid var(--bd);
  color:var(--text);
}
.helper{color:var(--muted); font-size:.8rem}
.sep{
  height:1px;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.15),transparent);
  margin:12px 0;
}

/* ============= Buttons ============= */
.btn{
  position: relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 18px;
  border-radius:12px;
  font-weight:700;
  cursor:pointer;
  background:transparent;
  color:var(--accent2);
  border:1px solid var(--accent2);
  transition: all .25s ease;
}
.btn:disabled{opacity:.6; cursor:not-allowed}

/* primary = pure monad purple/indigo */
.btn.primary{
  background: linear-gradient(135deg, #7e22ce 0%, #8b5cf6 45%, #4f46e5 100%);
  color: #020617;
  border: 1px solid rgba(191,219,254,0.75);
  box-shadow:
    0 0 18px rgba(129,140,248,.7),
    0 0 32px rgba(79,70,229,.55),
    inset 0 0 6px rgba(255,255,255,.15);
  overflow: hidden;
}
.btn.primary:hover{
  transform: translateY(-1px);
  box-shadow:
    0 0 22px rgba(167,139,250,.85),
    0 0 42px rgba(79,70,229,.7),
    inset 0 0 10px rgba(255,255,255,.25);
}
.btn.primary:active{
  transform: scale(.97);
  box-shadow: 0 0 10px rgba(55,48,163,.5);
}

/* outline futuristik */
.btn.primary::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius:inherit;
  border:2px solid transparent;
  background: linear-gradient(60deg, #a855f7, #6366f1, #4f46e5) border-box;
  mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  -webkit-mask-composite: destination-out;
  pointer-events:none;
  opacity:.7;
  filter: blur(1px);
}

/* state connected */
.btn.connected{
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color:#020617;
  border:none;
  box-shadow: 0 0 14px rgba(167,139,250,.7), 0 0 20px rgba(79,70,229,.55);
  cursor: default;
}

/* ============= Spinner / Loading ============= */
.spinner {
  display: none;
  width:25px;
  height:25px;
  border-radius:50%;
  border:8px solid rgba(255,255,255,.15);
  border-top-color:var(--accent);
  animation:spin .8s linear infinite;
}

@keyframes spin {
  to { transform:rotate(360deg); }
}

.btn[aria-busy="true"]{
  position:relative;
  pointer-events:none;
  opacity:.85;
}
.btn[aria-busy="true"]::before{
  content:"";
  position:absolute;
  left:10px;
  top:50%;
  transform: translateY(-50%);
  width:16px; height:16px; border-radius:50%;
  border:2px solid rgba(255,255,255,.35); border-top-color:#fff;
  animation: spin .8s linear infinite;
}
.btn.primary[aria-busy="true"]::before{
  border: 2px solid rgba(0,0,0,.3); border-top-color: rgba(0,0,0,.85);
}

/* ============= Hint Tooltip ============= */
.hint {
  display: inline-block;
  width: 16px; height: 16px;
  line-height: 15px;
  text-align: center;
  font-weight: 700;
  border-radius: 50%;
  color: var(--accent2);
  background: rgba(79,70,229,.18);
  border: 1px solid rgba(129,140,248,.5);
  margin-left: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s ease;
  position: relative;
}
.hint:hover {
  background: rgba(79,70,229,.32);
  box-shadow: 0 0 8px rgba(129,140,248,.6);
}

/* tooltip text */
.hint::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(9,9,24,.98);
  color: #eaf2ff;
  font-size: 0.75rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(136,160,255,.3);
  box-shadow: 0 8px 24px rgba(0,0,0,.55);
  opacity: 0;
  pointer-events: none;
  width: max-content;
  max-width: 220px;
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 200;
}
.hint:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ============= Address Chip ============= */
#addrChip{
  min-width: 90px;
  text-align: center;
  border: 1px solid rgba(129,140,248,.7);
  background: rgba(5,7,24,.96);
  color: var(--accent2);
  font-weight: 600;
  border-radius: 999px;
  padding: 6px 10px;
}

/* ============= Toast (top-center) ============= */
.toast-stack{
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}
.toast{
  position: relative;
  pointer-events: auto;
  min-width: 260px;
  max-width: 92vw;
  padding: 12px 16px 12px 20px;
  border-radius: 14px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  background: radial-gradient(circle at 5% 10%, rgba(24,27,64,.96) 0%, rgba(7,11,32,.98) 60%);
  border: 1px solid rgba(148,163,255,.35);
  box-shadow:
    0 4px 16px rgba(0,0,0,.7),
    0 0 20px rgba(129,140,248,.35),
    0 0 28px rgba(79,70,229,.3);
  backdrop-filter: blur(7px);
  opacity: 0;
  transform: translateY(-14px) scale(.97);
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show{ opacity:1; transform: translateY(0) scale(1); }
.toast.leaving{ opacity:0; transform: translateY(-10px) scale(.97); }

.toast::before{
  content:"";
  position:absolute;
  left:0;
  top:0;
  bottom:0;
  width:4px;
  border-radius:14px 0 0 14px;
  background: linear-gradient(180deg,#a855f7,#4f46e5);
  box-shadow: 0 0 12px rgba(167,139,250,.8), 0 0 22px rgba(79,70,229,.7);
}
.toast.info::before   { background: linear-gradient(180deg,#6366f1,#4f46e5); }
.toast.success::before{ background: linear-gradient(180deg,#34d399,#10b981); }
.toast.warn::before   { background: linear-gradient(180deg,#fbbf24,#f59e0b); }
.toast.error::before  { background: linear-gradient(180deg,#f87171,#ef4444); }

/* ============= Modal ============= */
.modal{position:fixed; inset:0; display:none; z-index:1400;}
.modal.show{display:block;}
.modal__backdrop{
  position:absolute; inset:0; background:rgba(0,0,0,.6);
  backdrop-filter: blur(5px);
  opacity:0; transition:opacity .2s ease;
}
.modal.show .modal__backdrop{opacity:1;}
.modal__panel{
  position:absolute;
  inset:auto 0 0 0;
  margin:auto;
  top:15%;
  width:min(520px, 92vw);
  background:rgba(7,12,32,.98);
  border:1px solid rgba(148,163,255,.45);
  border-radius:14px;
  box-shadow:0 20px 50px rgba(0,0,0,.6);
  transform:translateY(-8px) scale(.98);
  opacity:0; transition:transform .2s ease, opacity .2s ease;
}
.modal.show .modal__panel{transform:translateY(0) scale(1); opacity:1;}
.modal__header{display:flex; align-items:center; justify-content:space-between; padding:14px 14px 8px;}
.modal__body{padding:2px 14px 8px; color:var(--text);}
.modal__footer{display:flex; gap:10px; justify-content:flex-end; padding:12px 14px 14px;}
.modal__x{
  width:34px; height:34px; border-radius:8px; cursor:pointer;
  background:transparent; color:var(--text); border:1px solid rgba(148,163,255,.45);
}
.modal__x:hover{background:rgba(255,255,255,.06);}

/* ============= Skeleton ============= */
.skeleton {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid rgba(148,163,255,.14);
  border-radius: 10px;
  box-shadow: inset 0 0 4px rgba(255,255,255,.05);
}
.skeleton::after { content: none; }

.skel-line { height: 12px; margin: 6px 0; background: rgba(255,255,255,.05); border-radius: 4px; }
.skel-box  { height: 64px; background: rgba(255,255,255,.05); border-radius: 8px; }

/* ===== Futuristic My Wallet Panel ===== */

.wallet-panel {
  position: relative;
  margin-top: 18px;
  padding: 16px 14px 18px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 0% 0%, rgba(168,85,247,0.28) 0%, transparent 45%),
    radial-gradient(circle at 100% 100%, rgba(79,70,229,0.22) 0%, transparent 40%),
    linear-gradient(135deg, rgba(38,0,79,.94), rgba(38,0,79,.94));
  border: 1px solid rgba(148,163,255,0.55);
  box-shadow:
    0 0 24px rgba(15,23,42,0.92),
    0 0 26px rgba(88,28,135,0.55),
    0 0 36px rgba(79,70,229,0.4);
  overflow: hidden;
}

.wallet-panel::before,
.wallet-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.wallet-panel::before {
  border: 1px solid rgba(129,140,248,0.38);
  mix-blend-mode: screen;
  opacity: 0.7;
}

.wallet-panel::after {
  background:
    linear-gradient(90deg, rgba(168,85,247,0.26), transparent 40%, rgba(79,70,229,0.22) 60%, transparent 100%);
  opacity: 0.6;
  mask-image: radial-gradient(circle at 50% 0, black 0%, transparent 60%);
}

.wallet-panel__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  z-index: 1;
}

.wallet-panel__header h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.wallet-panel__tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,255,0.8);
  background: radial-gradient(circle at 0 0, rgba(129,140,248,0.4), rgba(38,0,79,.94));
  color: #e0e7ff;
  box-shadow:
    0 0 10px rgba(129,140,248,0.7),
    0 0 18px rgba(79,70,229,0.6);
}

.wallet-panel__addr {
  position: relative;
  margin: 4px 0 10px;
  font-size: 0.8rem;
  z-index: 1;
}
.wallet-panel__addr span {
  color: #e5e7eb;
}

.wallet-panel__stats {
  position: relative;
  z-index: 1;
  margin-top: 6px;
}
.wallet-panel .stat {
  background: radial-gradient(circle at 0 0, rgba(148,163,248,0.2) 0%, rgba(38,0,79,.94) 55%);
  border: 1px solid rgba(129,140,248,0.7);
  box-shadow:
    0 0 14px rgba(76,81,191,0.35),
    inset 0 0 8px rgba(38,0,79,.94);
}
.wallet-panel .stat .val.mono{
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

/* claim & refresh buttons */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: .85;
}
.btn-loading::after {
  content: "";
  position: absolute;
  right: 10px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  animation: spinBtn .6s linear infinite;
}
@keyframes spinBtn {
  to { transform: rotate(360deg); }
}

/* footer */
footer.site-footer{
  position:fixed;
  inset:auto 0 0 0;
  height:var(--footer-h);
  z-index:40;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:10px 16px;
  background:linear-gradient(0deg, #020017f2, #020617);
  border-top:1px solid rgba(79,70,229,.7);
  backdrop-filter:blur(11px);
  color:var(--muted);
  font-size:.7rem;
}

/* ===== RESPONSIVE ===== */
@media(max-width:768px){
  .wallet{margin-left:unset}
  main{
    padding:calc(var(--header-h) + 14px) 14px calc(var(--footer-h) + 18px);
  }
}

@media (min-width: 960px) {
  main{ max-width:1200px; }
  .card{ padding:18px 20px; }
}

@media (prefers-reduced-motion: reduce){
  .card, .skeleton::after{ animation: none; transition: none; }
  .btn[aria-busy="true"]::before { animation: none; }
  .hint::after, .hint::before { transition:none; }
}