/* musetrade — rainbow trading terminal.
   Fredoka for display type, Nunito for body. Muse is branding only. */

:root {
  --bg: #fffaf6;
  --ink: #3d3450;
  --ink-soft: #8a80a0;
  --card: #ffffff;

  --rb-red: #ff5c7a;
  --rb-orange: #ff9f43;
  --rb-yellow: #ffd23f;
  --rb-green: #4ee6a6;
  --rb-blue: #4fc3f7;
  --rb-indigo: #8b7cf6;
  --rb-violet: #e57bff;
  --rainbow: linear-gradient(90deg,
    var(--rb-red), var(--rb-orange), var(--rb-yellow),
    var(--rb-green), var(--rb-blue), var(--rb-indigo), var(--rb-violet), var(--rb-red));

  --code-bg: #f3effc;
  --green: #1e9e5a;
  --red: #d94f3d;
  --shadow: 0 10px 30px rgba(139, 124, 246, 0.16);
  --radius: 24px;
  --font-display: "Fredoka", "Baloo 2", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", "Avenir Next", Verdana, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ---------- playful rain background ---------- */
#rain { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.drop {
  position: absolute;
  top: -10vh;
  font-size: var(--sz, 18px);
  opacity: var(--op, 0.55);
  filter: drop-shadow(0 0 6px currentColor);
  animation: fall var(--dur, 12s) linear infinite;
  animation-delay: var(--delay, 0s);
  will-change: transform;
}
@keyframes fall {
  0% { transform: translate(0, -10vh) rotate(0deg); }
  50% { transform: translate(var(--sway, 20px), 55vh) rotate(180deg); }
  100% { transform: translate(0, 115vh) rotate(360deg); }
}
body > *:not(#rain):not(.boot-overlay):not(.wallet-modal-backdrop) { position: relative; z-index: 1; }

@keyframes shimmer { to { background-position: 300% 0%; } }
@keyframes glow-spin { to { background-position: 300% 0%; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes mascot-bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-9px) rotate(3deg); }
}
.live-dot {
  display: inline-block;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(30, 158, 90, 0.5);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(30, 158, 90, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(30, 158, 90, 0); }
  100% { box-shadow: 0 0 0 0 rgba(30, 158, 90, 0); }
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.mascot-stage {
  display: inline-block;
  will-change: transform;
  cursor: grab;
  touch-action: none;
  user-select: none;
  position: relative;
  z-index: 5;
  border-radius: 50%;
}
.mascot-stage::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: var(--rainbow);
  background-size: 300% 300%;
  filter: blur(10px);
  opacity: 0.5;
  animation: glow-spin 6s linear infinite;
  z-index: -1;
}
.mascot {
  width: 46px; height: 46px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 6px 10px rgba(139, 124, 246, 0.35));
  pointer-events: none;
}
.mascot-stage.idle .mascot { animation: mascot-bob 3.2s ease-in-out infinite; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  background: var(--rainbow);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 8s linear infinite;
}
.brand-sub { font-size: 11.5px; color: var(--ink-soft); font-weight: 700; }

/* wallet chip / connect button */
.wallet-chip-wrap { display: flex; align-items: center; }
.connect-chip, .wallet-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: var(--shadow);
}
.connect-chip {
  position: relative;
  border: none;
  cursor: pointer;
  overflow: hidden;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  transition: transform 0.15s ease;
}
.connect-chip:hover { transform: translateY(-1px) scale(1.02); }
.connect-chip-glow {
  position: absolute;
  inset: -60%;
  background: var(--rainbow);
  background-size: 300% 300%;
  opacity: 0.9;
  filter: blur(2px);
  animation: glow-spin 5s linear infinite;
  z-index: 0;
}
.connect-chip-label { position: relative; z-index: 1; }

.wallet-chip {
  background: var(--card);
  border: 3px solid #fff;
  cursor: pointer;
  padding: 6px 8px 6px 10px;
}
.wallet-chip-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--rainbow);
  background-size: 300% 100%;
  animation: shimmer 6s linear infinite;
  border: 2px solid #fff;
}
.wallet-chip-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.wallet-chip-dot.wrong-net { background: var(--rb-orange); }
.wallet-chip-addr { font-family: var(--font-mono); font-weight: 700; font-size: 14px; }
.wallet-chip-copy, .wallet-chip-x {
  border: none; background: var(--bg); border-radius: 50%;
  width: 26px; height: 26px; cursor: pointer; font-size: 12px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.wallet-chip-copy:hover { background: var(--code-bg); }
.wallet-chip-x:hover { color: var(--rb-red); background: var(--code-bg); }

/* ---------- wallet picker modal (RainbowKit-style multi-wallet picker,
   built on EIP-6963 wallet discovery — no bundler/build step needed) ---------- */
.wallet-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(61, 52, 80, 0.35);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
  padding: 16px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.wallet-modal {
  background: var(--card);
  border-radius: 28px;
  padding: 26px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 30px 80px rgba(61, 52, 80, 0.35);
  position: relative;
  border: 3px solid #fff;
  animation: modalPop 0.25s cubic-bezier(.2,1.4,.4,1);
}
@keyframes modalPop { from { opacity: 0; transform: scale(0.92) translateY(10px); } to { opacity: 1; transform: none; } }
.wallet-modal::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  padding: 3px;
  background: var(--rainbow);
  background-size: 300% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.4;
  animation: shimmer 8s linear infinite;
  pointer-events: none;
}
.wallet-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.wallet-modal-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.wallet-modal-close {
  border: none; background: var(--bg); border-radius: 50%;
  width: 30px; height: 30px; cursor: pointer; font-size: 14px;
}
.wallet-modal-close:hover { color: var(--rb-red); }
.wallet-list { display: flex; flex-direction: column; gap: 8px; }
.wallet-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: var(--bg);
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 14.5px;
  color: var(--ink);
  transition: transform 0.12s ease, background 0.12s ease;
  text-align: left;
}
.wallet-option:hover { transform: translateX(2px); background: var(--code-bg); }
.wallet-option img, .wallet-option .wallet-option-fallback-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; object-fit: contain;
}
.wallet-option-fallback-icon {
  display: flex; align-items: center; justify-content: center;
  background: var(--rainbow); font-size: 15px;
}
.wallet-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 4px 2px;
  line-height: 1.5;
}
.wallet-empty a { color: var(--rb-indigo); }

/* ---------- price header ---------- */
.price-header {
  max-width: 1180px;
  margin: 6px auto 0;
  padding: 6px 22px 0;
}
.price-main { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.price-sym { font-family: var(--font-display); font-size: 20px; color: var(--rb-violet); font-weight: 600; }
.price-value { font-family: var(--font-display); font-size: 40px; font-weight: 600; }
.price-delta { padding: 4px 12px; border-radius: 999px; font-size: 15px; font-weight: 800; }
.price-delta.up { color: var(--green); background: rgba(78, 230, 166, 0.22); }
.price-delta.down { color: var(--red); background: rgba(255, 92, 122, 0.14); }
.price-meta { margin-top: 4px; font-size: 13.5px; color: var(--ink-soft); font-weight: 700; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dot-sep { opacity: 0.6; }

/* ---------- layout ---------- */
.trade-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 22px 30px;
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  align-items: start;
}
.col-main, .col-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: relative;
  border: 3px solid #fff;
}
.card::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  padding: 3px;
  background: var(--rainbow);
  background-size: 300% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.3;
  animation: shimmer 10s linear infinite;
  pointer-events: none;
  z-index: -1;
}
.card-head-sm {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 12px;
}

/* ---------- chart ---------- */
.chart-card { padding: 14px 16px 6px; }
.chart-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 8px; }
.chart-range { display: flex; gap: 6px; }
.range-opt {
  border: none;
  background: var(--code-bg);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
}
.range-opt.active { background: var(--rb-indigo); color: #fff; }
.chart-hover {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
}
#priceChart { width: 100%; height: 260px; display: block; cursor: crosshair; }
.chart-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 0 12px;
}

/* ---------- order form ---------- */
.order-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.order-tab {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  background: var(--bg);
  color: var(--ink-soft);
}
.order-tab.buy.active { background: rgba(78, 230, 166, 0.25); color: var(--green); }
.order-tab.sell.active { background: rgba(255, 92, 122, 0.18); color: var(--red); }

.order-label { font-size: 12.5px; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.4px; }
.order-amount-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 14px;
  padding: 10px 14px;
  margin: 6px 0 8px;
}
.order-amount {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  min-width: 0;
}
.order-amount-unit { font-weight: 800; color: var(--ink-soft); font-size: 13px; }

.order-quick { display: flex; gap: 6px; margin-bottom: 14px; }
.order-quick button {
  flex: 1;
  border: none;
  background: var(--code-bg);
  border-radius: 999px;
  padding: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--rb-indigo);
  cursor: pointer;
}
.order-quick button:hover { background: var(--rb-indigo); color: #fff; }

.order-estimate, .order-slippage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 8px 2px;
}
.order-estimate span:last-child { color: var(--ink); font-weight: 800; }
.slip-options { display: flex; gap: 6px; }
.slip-opt {
  border: none;
  background: var(--code-bg);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
}
.slip-opt.active { background: var(--rb-indigo); color: #fff; }

.submit-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 16px;
  margin-top: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(120deg, var(--rb-indigo), var(--rb-violet));
  box-shadow: 0 12px 24px rgba(139, 124, 246, 0.35);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.submit-btn:hover:not(:disabled) { transform: translateY(-2px); }
.submit-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.order-note { font-size: 12px; color: var(--ink-soft); text-align: center; margin: 10px 0 0; font-weight: 600; }

.tx-log { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.tx-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 700;
}
.tx-item a { color: var(--rb-indigo); text-decoration: none; }
.tx-item.pending { color: var(--rb-orange); }
.tx-item.success { color: var(--green); }
.tx-item.failed { color: var(--red); }

/* ---------- wallet card (sidebar) ---------- */
.wallet-rows { display: flex; flex-direction: column; gap: 8px; }
.wallet-row {
  display: flex;
  justify-content: space-between;
  background: var(--bg);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 800;
}
.wallet-row.total { background: rgba(139, 124, 246, 0.12); }
.wr-label { color: var(--ink-soft); font-size: 13px; }
.wr-value { font-variant-numeric: tabular-nums; }
.wallet-net { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin-top: 8px; text-align: center; }
.switch-net-btn {
  width: 100%;
  margin-top: 10px;
  border: none;
  border-radius: 999px;
  padding: 10px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  background: linear-gradient(120deg, var(--rb-orange), var(--rb-yellow));
  color: #573900;
}

/* ---------- agent card ---------- */
.agent-signal {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.agent-badge {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 999px;
  flex-shrink: 0;
}
.agent-badge.hold { background: var(--code-bg); color: var(--ink-soft); }
.agent-badge.buy { background: rgba(78, 230, 166, 0.3); color: var(--green); }
.agent-badge.sell { background: rgba(255, 92, 122, 0.2); color: var(--red); }
.agent-reason { font-size: 13px; font-weight: 700; color: var(--ink-soft); }

.agent-size-row label {
  font-size: 12.5px; font-weight: 800; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.4px;
}

.agent-execute { margin-top: 4px; }

.agent-auto-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  cursor: pointer;
}
.agent-auto-row input { margin-top: 2px; }

.agent-log { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-height: 160px; overflow-y: auto; }
.agent-log-item { font-size: 12px; font-weight: 700; color: var(--ink-soft); background: var(--bg); border-radius: 10px; padding: 6px 10px; }

.town-foot { text-align: center; color: var(--ink-soft); font-size: 13px; padding: 10px 22px 34px; font-weight: 600; max-width: 900px; margin: 0 auto; }

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 800;
  font-size: 13px;
}
.social-link:hover { color: var(--rb-violet); }

/* ---------- loading overlay ---------- */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: linear-gradient(160deg, #201a33, #2c2149);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #ece7f9;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.boot-overlay.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-mascot { width: 96px; height: 96px; object-fit: contain; animation: boot-bounce 0.9s ease-in-out infinite; filter: drop-shadow(0 10px 20px rgba(139,124,246,0.5)); }
@keyframes boot-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.04); }
}
.boot-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  background: var(--rainbow);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 3s linear infinite;
}
.boot-line { font-size: 13px; font-weight: 700; color: #b9aee6; min-height: 18px; }
.boot-bar { width: 200px; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.12); overflow: hidden; }
.boot-bar-fill { height: 100%; width: 0%; background: var(--rainbow); background-size: 300% 100%; animation: shimmer 2s linear infinite; transition: width 0.3s ease; }

/* ---------- cursor sparkle trail ---------- */
.cursor-spark {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 9999;
  font-size: 14px;
  will-change: transform, opacity;
  animation: sparkFade 0.7s ease-out forwards;
}
@keyframes sparkFade {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(50deg) translateY(-18px); }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .trade-wrap { grid-template-columns: 1fr; padding: 12px 14px 24px; }
  .price-header { padding: 4px 14px 0; }
  .price-value { font-size: 28px; }
  .topbar { padding: 14px 16px; gap: 10px; }
  .brand-sub { display: none; }
  .chart-toolbar { flex-wrap: wrap; gap: 8px; }
  #priceChart { height: 200px; }
  .card { padding: 16px; }
}

@media (max-width: 480px) {
  .wallet-chip-addr { display: none; }
  .connect-chip-label { font-size: 13px; }
  .order-tab { font-size: 13px; padding: 9px; }
  .price-value { font-size: 24px; }
  .price-meta { font-size: 12px; }
  .boot-mascot { width: 76px; height: 76px; }
}

@media (hover: none) {
  .cursor-spark { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mascot-stage.idle .mascot,
  .live-dot, .brand-name, .card::before, .connect-chip-glow, .mascot-stage::before,
  .wallet-chip-avatar, .wallet-modal::before, .boot-title, .boot-bar-fill, .boot-mascot,
  .drop { animation: none; }
  #rain { display: none; }
  .cursor-spark { display: none; }
}
