:root {
  --bg: #04060c;
  --panel: rgba(8, 22, 40, 0.72);
  --panel-border: rgba(140, 210, 255, 0.18);
  --text: #e8f4ff;
  --muted: #8fb0c8;
  --accent: #ffd45a;
  --accent-2: #4fd8ff;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 14px/1.4 Inter, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
canvas#tank { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: grab; }
canvas#tank.dragging { cursor: grabbing; }
canvas#tank.over-fish { cursor: pointer; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

.glass {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius);
}

/* ── top HUD ─────────────────────────────── */
.hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: auto minmax(0, 560px) auto;
  justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 18px; pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 42px; height: 42px; display: block; filter: drop-shadow(0 4px 14px rgba(79,184,255,.35)); }
.brand h1 { margin: 0; font: 700 24px/1 Fredoka, sans-serif; letter-spacing: .4px; text-shadow: 0 2px 12px rgba(0,0,0,.5);
  background: linear-gradient(90deg, #c9a6ff, #7fd0ff 55%, #5ff5bd); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { color: var(--muted); font-size: 12px; }
.ticker { color: var(--accent); font: 600 13px Fredoka, sans-serif; }
.coin-logo { font-size: 22px; line-height: 1; }
.logo-img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: block; border: 2px solid rgba(255,212,90,.55); }
.badge { margin-left: 6px; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: #ff5a8a; color: #fff; vertical-align: 1px; }

.search { position: relative; display: flex; width: 100%; }
.search input {
  flex: 1; min-width: 0; height: 44px; padding: 0 16px;
  border-radius: 999px 0 0 999px; border: 1px solid var(--panel-border); border-right: 0;
  background: var(--panel); color: var(--text); outline: none;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font: 13px "JetBrains Mono", monospace;
}
.search input::placeholder { color: var(--muted); font-family: Inter, sans-serif; }
.search input:focus { border-color: var(--accent-2); }
.search button {
  height: 44px; padding: 0 20px; border: 0; border-radius: 0 999px 999px 0;
  background: linear-gradient(135deg, #4fd8ff, #2a8cff); color: #031424; font-weight: 600;
}
.suggest {
  position: absolute; top: 50px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: rgba(8, 22, 40, .95); border: 1px solid var(--panel-border); border-radius: var(--radius);
}
.suggest li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.suggest li:hover { background: rgba(79,216,255,.12); }
.suggest li span:last-child { color: var(--muted); }

.stats { display: flex; align-items: center; gap: 16px; }
.stat { display: flex; flex-direction: column; }
.stat b { font: 600 18px Fredoka, sans-serif; font-variant-numeric: tabular-nums; transition: color .4s; }
.stat span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; white-space: nowrap; }
.stat.mc { flex-direction: row; align-items: center; gap: 8px; }
.stat.mc > div { display: flex; flex-direction: column; }
.stat em { font-style: normal; font-weight: 600; letter-spacing: 0; }
.up { color: #3ee08f; }
.down { color: #ff6b81; }
.stat b.flash-up { color: #3ee08f; }
.stat b.flash-down { color: #ff6b81; }

.live-pill {
  display: flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px;
  font: 700 12px Inter, sans-serif; letter-spacing: 1px; color: #3ee08f;
  background: rgba(62, 224, 143, .12); border: 1px solid rgba(62, 224, 143, .45);
}
.live-pill i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: livePulse 1.6s ease-out infinite; }
.live-pill.stale { color: #ffb84d; background: rgba(255,184,77,.12); border-color: rgba(255,184,77,.45); }
.live-pill.stale i { animation: none; }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(62,224,143,.7); } 100% { box-shadow: 0 0 0 9px rgba(62,224,143,0); } }
@media (prefers-reduced-motion: reduce) { .live-pill i { animation: none; } }
.buy {
  padding: 10px 16px; border-radius: 999px; text-decoration: none; font-weight: 600;
  background: linear-gradient(135deg, #ffd45a, #ff9f43); color: #2a1600;
}

/* ── wallet ──────────────────────────────── */
.wallet { position: relative; }
.wallet-btn {
  padding: 10px 16px; border-radius: 999px; font-weight: 600; white-space: nowrap;
  background: linear-gradient(135deg, #8b5cff, #4f7bff); border: 0; color: #fff;
  box-shadow: 0 4px 18px rgba(110, 90, 255, .35);
}
.wallet-btn.connected { background: var(--panel); border: 1px solid var(--panel-border); box-shadow: none; font-family: "JetBrains Mono", monospace; font-size: 12px; }
.wallet-menu {
  position: absolute; right: 0; top: 46px; min-width: 210px; margin: 0; padding: 6px; list-style: none; text-align: left; z-index: 15;
  background: rgba(8, 22, 40, .96); border: 1px solid var(--panel-border); border-radius: var(--radius);
}
.wallet-menu { width: 290px; max-height: min(70vh, 560px); overflow-y: auto; }
.wallet-menu li { padding: 9px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.wallet-menu li:hover, .wallet-menu li:focus-visible { background: rgba(79,216,255,.12); outline: none; }
.wallet-menu .whead { cursor: default; padding: 10px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.wallet-menu .whead:hover, .wallet-menu .wnote:hover { background: none; }
.wallet-menu .witem { display: flex; align-items: center; gap: 10px; }
.wallet-menu .witem a { display: flex; align-items: center; gap: 10px; width: 100%; color: inherit; text-decoration: none; }
.wicon { width: 26px; height: 26px; border-radius: 7px; flex: none; object-fit: contain; }
.wicon-letter { display: grid; place-items: center; font: 700 13px Fredoka, sans-serif; background: linear-gradient(135deg, #8b5cff, #4f7bff); color: #fff; }
.wname { font-weight: 600; }
.wsub { margin-left: auto; font-size: 11px; color: var(--muted); }
.wallet-menu .wnote { cursor: default; white-space: normal; font-size: 11px; line-height: 1.45; color: var(--muted); border-top: 1px solid var(--panel-border); margin-top: 6px; padding-top: 10px; }
canvas#tank.controlling { cursor: crosshair; }
.control-hint {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 9;
  padding: 8px 16px; border-radius: 999px; font-size: 13px; white-space: nowrap; pointer-events: none;
  background: rgba(8, 22, 40, .8); border: 1px solid rgba(79,216,255,.5); color: var(--text);
}
.control-hint b { color: var(--accent-2); font-weight: 600; }
.you { margin-left: 8px; padding: 1px 7px; border-radius: 6px; font-size: 11px; vertical-align: 3px; background: #4fd8ff; color: #031424; }
.card-actions .primary.ctl { background: linear-gradient(135deg, #4fd8ff, #2a8cff); color: #031424; }

/* ── leaderboard ─────────────────────────── */
.leaders { position: fixed; left: 18px; top: 84px; z-index: 9; width: 250px; }
.leaders-toggle {
  width: 100%; text-align: left; padding: 10px 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--panel-border); font-weight: 600;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.leaders ol {
  margin: 6px 0 0; padding: 6px; list-style: none; max-height: 50vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.leaders.collapsed ol { display: none; }
.leaders li { display: grid; grid-template-columns: 22px 12px 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.leaders li:hover { background: rgba(79,216,255,.12); }
.leaders li .r { color: var(--muted); font-weight: 600; }
.leaders li .dot { width: 10px; height: 10px; border-radius: 50%; }
.leaders li .amt { color: var(--accent); font-weight: 600; }

/* ── activity feed ───────────────────────── */
.feed { position: fixed; left: 18px; bottom: 18px; z-index: 9; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; pointer-events: none; max-width: 70vw; }
.feed li {
  padding: 7px 12px; border-radius: 10px; font-size: 12px; width: fit-content;
  background: var(--panel); border: 1px solid var(--panel-border);
  animation: feedIn .35s ease-out, feedOut .6s ease-in 6s forwards;
}
.feed li b { color: var(--accent); font-weight: 600; }
@keyframes feedIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes feedOut { to { opacity: 0; transform: translateY(-4px); } }

/* ── zoom ─────────────────────────────────── */
.zoom { position: fixed; right: 18px; bottom: 18px; z-index: 9; display: flex; flex-direction: column; gap: 6px; }
.zoom button {
  width: 42px; height: 42px; border-radius: 12px; font-size: 20px;
  background: var(--panel); border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.zoom button:hover, .leaders-toggle:hover { border-color: var(--accent-2); }

/* ── fish card ───────────────────────────── */
.card {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 11;
  width: min(440px, calc(100vw - 32px)); padding: 16px 18px;
  background: rgba(8, 22, 40, .86); border: 1px solid var(--panel-border); border-radius: 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  animation: cardIn .3s ease-out;
}
@keyframes cardIn { from { opacity: 0; transform: translate(-50%, 16px); } }
.card-close { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: var(--muted); font-size: 16px; }
.card-head { display: flex; gap: 14px; align-items: center; }
.card-head canvas { width: 120px; height: 70px; flex: none; border-radius: 12px; background: radial-gradient(circle at 50% 40%, #145a85, #08263f); }
.card-title { font: 700 20px Fredoka, sans-serif; }
.card-title small { color: var(--accent); font-size: 14px; margin-left: 6px; }
.card-addr { font-size: 11px; color: var(--muted); word-break: break-all; margin-top: 2px; }
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 12px; }
.card-grid div { background: rgba(255,255,255,.05); border-radius: 10px; padding: 8px 10px; }
.card-grid b { display: block; font: 600 16px Fredoka, sans-serif; }
.card-grid span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-actions button, .card-actions a {
  flex: 1; text-align: center; padding: 9px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; text-decoration: none; color: var(--text);
  background: rgba(255,255,255,.07); border: 1px solid var(--panel-border);
}
.card-actions .primary { background: linear-gradient(135deg, #ffd45a, #ff9f43); color: #2a1600; border: 0; }
.card-empty { text-align: center; padding: 6px 4px 2px; }
.card-empty .big { font-size: 40px; }
.card-empty p { color: var(--muted); margin: 6px 0 12px; }

/* ── own card: mini pill while steering, opens on approach ── */
.card-mini-row { display: none; }
.card.mini { width: auto; max-width: calc(100vw - 32px); padding: 8px 14px 8px 8px; border-radius: 999px; transition: border-radius .2s; }
.card.mini .card-close { display: none; }
.card.mini:not(.peek):not(:focus-within) .card-full { display: none; }
.card.mini:not(.peek):not(:focus-within) .card-mini-row {
  display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; text-align: left; white-space: nowrap;
}
.card.mini.peek, .card.mini:focus-within { width: min(440px, calc(100vw - 32px)); padding: 16px 18px; border-radius: 18px; }
.card-mini-row canvas { width: 48px; height: 28px; border-radius: 999px; background: radial-gradient(circle at 50% 40%, #145a85, #08263f); }
.mini-text { font-size: 13px; }
.mini-text b { color: var(--accent-2); }
.mini-open { color: var(--muted); font-size: 12px; }

/* ── color editor ── */
.look { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
.swatch { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.swatch input { width: 36px; height: 28px; padding: 0; border: 1px solid var(--panel-border); border-radius: 8px; background: none; cursor: pointer; }
.pat { display: flex; gap: 4px; margin-left: auto; }
.pat button { padding: 5px 9px; font-size: 12px; border-radius: 8px; background: rgba(255,255,255,.06); border: 1px solid var(--panel-border); }
.pat button.on { border-color: var(--accent-2); background: rgba(79,216,255,.16); color: #fff; }
.look-save { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.look-save button { padding: 9px 10px; border-radius: 10px; font-weight: 600; border: 0; background: linear-gradient(135deg, #4fd8ff, #2a8cff); color: #031424; }
.look-save button:disabled { opacity: .6; cursor: wait; }
.look-msg { font-size: 11px; color: var(--muted); }
.look-msg.ok { color: #3ee08f; }
.look-msg.err { color: #ff8a9b; }

/* ── bubble on a clicked fish ── */
.pop {
  position: fixed; left: 0; top: 0; z-index: 12; min-width: 240px; max-width: 280px; padding: 10px 12px;
  background: rgba(8, 22, 40, .92); border: 1px solid var(--panel-border); border-radius: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgba(0,0,0,.4);
  will-change: transform;
}
.pop-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pop-head .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pop-rank { margin-left: auto; color: var(--muted); font-size: 12px; }
.pop-amt { margin: 4px 0 8px; color: var(--accent); font: 600 14px Fredoka, sans-serif; }
.pop-actions { display: flex; gap: 6px; }
.pop-actions button {
  flex: 1; padding: 7px 8px; border-radius: 9px; font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,.07); border: 1px solid var(--panel-border);
}
.pop-actions .primary { background: linear-gradient(135deg, #ffd45a, #ff9f43); color: #2a1600; border: 0; }

/* ── misc ─────────────────────────────────── */
.tooltip {
  position: fixed; z-index: 12; pointer-events: none; transform: translate(14px, 14px);
  padding: 6px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap;
  background: rgba(4, 14, 28, .92); border: 1px solid var(--panel-border);
}
.tooltip b { color: var(--accent); }
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 20;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px;
  background: #3a1020; border: 1px solid #ff5a8a; font-size: 13px;
}
.loading {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: var(--bg); font: 600 18px Fredoka, sans-serif; color: var(--muted); transition: opacity .6s;
}
.loading.done { opacity: 0; pointer-events: none; }
.spinner { font-size: 48px; animation: swim 1.4s ease-in-out infinite; }
@keyframes swim { 50% { transform: translateX(24px) scaleX(-1); } }

/* ── mobile ───────────────────────────────── */
@media (max-width: 760px) {
  .hud-top { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 12px 18px; gap: 10px;
    background: linear-gradient(to bottom, rgba(4,6,12,.96) 80%, rgba(4,6,12,0)); }
  .search { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  .search button { padding: 0 14px; }
  .card-grid b { font-size: 14px; }
  .brand h1 { font-size: 20px; }
  .brand-logo { width: 36px; height: 36px; }
  .stats { grid-column: 1 / -1; grid-row: 3; gap: 10px; min-width: 0; }
  .stat b { font-size: 15px; }
  .stat span { font-size: 10px; }
  .logo-img { width: 26px; height: 26px; }
  .live-pill { padding: 5px 9px; font-size: 11px; }
  .buy { display: none; }
  .wallet { margin-left: auto; }
  .wallet-btn { padding: 8px 12px; font-size: 12px; }
  .wallet-btn .wide { display: none; }
  .control-hint { top: 168px; font-size: 12px; white-space: normal; text-align: center; width: max-content; max-width: calc(100vw - 24px); border-radius: 14px; z-index: 11; }
  .leaders { top: 172px; left: 12px; width: 220px; }
  .feed { left: 12px; bottom: 12px; }
  .zoom { right: 12px; bottom: 12px; }
  .card { bottom: 12px; }
  body.has-card .feed, body.has-card .zoom { display: none; }
}
