:root {
  /* Palette taken from the logo: black, electric blue glow, ice white. */
  --bg: #020308;
  --panel: rgba(8, 11, 20, .86);
  --panel-2: #101727;
  --line: #18233d;
  --text: #edf3ff;
  --muted: #8192b3;
  --accent: #2f7bff;
  --accent-ink: #ffffff;
  --up: #2fe0b0;
  --down: #f23d2e;
  --gold: #a9ccff; /* highlight colour: the logo's ice blue (was gold) */
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
/* Whole-page backdrop: the logo's blue glow over a faint grid, fixed behind everything. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 10% -10%, rgba(47, 123, 255, .26), transparent 62%),
    radial-gradient(760px 520px at 102% 6%, rgba(47, 123, 255, .14), transparent 60%),
    radial-gradient(1000px 620px at 50% 118%, rgba(47, 123, 255, .16), transparent 60%),
    linear-gradient(rgba(90, 150, 255, .04) 1px, transparent 1px) 0 0 / 100% 44px,
    linear-gradient(90deg, rgba(90, 150, 255, .04) 1px, transparent 1px) 0 0 / 44px 100%,
    var(--bg);
}
.top, .ticker { background: rgba(2, 3, 8, .72); backdrop-filter: blur(8px); }
.panel { box-shadow: 0 0 0 1px rgba(47, 123, 255, .05), 0 12px 40px rgba(0, 0, 0, .4); }
.brand-name { text-transform: uppercase; letter-spacing: .06em; font-style: italic; text-shadow: 0 0 18px rgba(47, 123, 255, .65); }
.btn.primary { box-shadow: 0 0 18px rgba(47, 123, 255, .45); }
.brand-name { background: linear-gradient(90deg, #ffffff, #8fbaff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel { border-color: rgba(47, 123, 255, .22); }
.panel h2 { color: #dbe8ff; }
.countdown div { background: linear-gradient(180deg, rgba(47, 123, 255, .16), rgba(47, 123, 255, .04)); border: 1px solid rgba(47, 123, 255, .25); }
.countdown b { color: #fff; text-shadow: 0 0 16px rgba(47, 123, 255, .9); }
.prize b, .winner-banner b, .winner-dialog h2 { text-shadow: 0 0 18px rgba(47, 123, 255, .7); }
.tabs button.on { text-shadow: 0 0 12px rgba(47, 123, 255, .8); }
.input:focus-within { box-shadow: 0 0 0 3px rgba(47, 123, 255, .18); }
::selection { background: rgba(47, 123, 255, .45); }
* { scrollbar-color: #1d3566 transparent; }
.logo-img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 16px rgba(47, 123, 255, .55); }

h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: 400; }
.up { color: var(--up); }
.down { color: var(--down); }
b, dd, .tick-price, .feed, #board { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: .01em; }
.tag { color: var(--muted); font-size: 12px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.logo { display: inline-flex; align-items: flex-end; gap: 3px; height: 22px; }
.logo i { width: 5px; border-radius: 2px; background: var(--up); }
.logo i:nth-child(1) { height: 10px; background: var(--down); }
.logo i:nth-child(2) { height: 16px; }
.logo i:nth-child(3) { height: 22px; background: #fff; }
.top-right { display: flex; align-items: center; gap: 8px; }
.wallet-info { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 7px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }

.btn {
  font: inherit; font-weight: 600; color: var(--text); cursor: pointer;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2);
  transition: filter .12s, background .12s;
}
.btn:hover { filter: brightness(1.15); }
.btn:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; }

/* ---------- ticker ---------- */
.ticker {
  display: flex; align-items: center; gap: 28px; padding: 12px 20px;
  border-bottom: 1px solid var(--line); overflow-x: auto; white-space: nowrap;
}
.pair { display: flex; flex-direction: column; }
.pair b { font-size: 15px; }
.pair span, .stat span { color: var(--muted); font-size: 11px; }
.tick-price { font-size: 24px; font-weight: 700; font-family: var(--mono); min-width: 120px; }
.mc { display: flex; flex-direction: column; }
.mc span { color: var(--muted); font-size: 11px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 13px; font-weight: 600; }

/* ---------- layout ---------- */
.grid {
  display: grid; gap: 12px; padding: 12px 20px 20px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  max-width: 1600px; margin: 0 auto;
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.chart-panel { grid-column: span 9; padding: 10px; }
.order-panel { grid-column: span 3; }
.comp-panel { grid-column: span 3; }
.account-panel { grid-column: span 4; }
.feed-panel { grid-column: span 5; }
.board-panel { grid-column: span 12; }

/* ---------- chart ---------- */
.chart-bar { display: flex; align-items: center; gap: 14px; padding: 2px 4px 8px; flex-wrap: wrap; }
.tfs { display: inline-flex; background: var(--panel-2); border-radius: 8px; padding: 2px; }
.tfs button { font: inherit; font-size: 12px; color: var(--muted); background: none; border: 0; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.tfs button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.legend { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.legend b { color: var(--text); font-weight: 500; margin-right: 8px; }
.chart-wrap { position: relative; height: 440px; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.chart-hint { margin: 6px 4px 0; font-size: 11px; color: var(--muted); }

/* ---------- order form ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); margin: -4px -4px 12px; }
.tabs button { flex: 1; font: inherit; font-weight: 600; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 4px; cursor: pointer; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--panel-2); padding: 3px; border-radius: 9px; margin-bottom: 12px; }
.sides button { font: inherit; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 8px; border-radius: 7px; cursor: pointer; }
.sides button.on.buy { background: var(--up); color: #04150e; }
.sides button.on.sell { background: var(--down); color: #1c0306; }

.field { display: block; margin-bottom: 10px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; margin-bottom: 5px; }
.input { display: flex; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; }
.input:focus-within { border-color: var(--accent); }
.input em { font-style: normal; color: var(--muted); font-size: 12px; margin-right: 6px; }
.input input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: 15px var(--mono); padding: 10px 0; }
.pcts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.pcts button { font: inherit; font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 0; cursor: pointer; }
.pcts button:hover { color: var(--text); }
.est { margin: 0 0 10px; }
.est div, .acct-grid div { display: flex; justify-content: space-between; padding: 3px 0; font-size: 12.5px; }
dt { color: var(--muted); } dd { margin: 0; font-family: var(--mono); }
.order-note { min-height: 18px; margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.submit { width: 100%; padding: 12px; font-size: 15px; border: 0; }
.submit.buy { background: var(--up); color: #04150e; }
.submit.sell { background: var(--down); color: #1c0306; }

/* ---------- competition ---------- */
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-left: auto; }
.badge.live { color: var(--up); border-color: color-mix(in srgb, var(--up) 45%, transparent); }
.badge.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--up); margin-right: 5px; vertical-align: 1px; }
.countdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 14px; }
.countdown div { background: var(--panel-2); border-radius: 10px; padding: 10px 4px; text-align: center; }
.countdown b { display: block; font: 700 26px var(--mono); }
.countdown span { font-size: 11px; color: var(--muted); }
.prize { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); background: color-mix(in srgb, var(--gold) 7%, transparent); }
.prize b { font: 700 22px var(--mono); color: var(--gold); }

/* ---------- account ---------- */
.empty { color: var(--muted); padding: 18px 4px; text-align: center; font-size: 13px; }
.acct-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.acct-top div { display: flex; flex-direction: column; }
.acct-top div:last-child { text-align: right; }
.acct-top b { font-family: var(--mono); font-size: 15px; }
.acct-top b.big { font-size: 26px; }
.acct-grid { margin: 0; display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
.orders { list-style: none; margin: 0; padding: 0; max-height: 132px; overflow: auto; }
.orders li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 12.5px; font-family: var(--mono); }
.orders li.none { color: var(--muted); font-family: inherit; border: 0; }
.orders button { font: inherit; font-size: 11px; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.orders button:hover { color: var(--down); border-color: var(--down); }

/* ---------- feed + leaderboard ---------- */
.rows, .feed > div, #board > div { display: grid; grid-template-columns: 1.4fr .6fr 1fr 1fr .9fr; gap: 8px; align-items: center; padding: 6px 4px; font-size: 12.5px; }
.rows.head { color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
.rows span:nth-child(n+3), .feed span:nth-child(n+3), #board span:nth-child(n+3) { text-align: right; }
.feed > div.empty, #board > div.empty { display: block; border: 0; font-family: inherit; }
.feed { max-height: 250px; overflow: auto; font-family: var(--mono); }
.feed > div.new { animation: flash .9s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--accent) 22%, transparent); } to { background: transparent; } }
.feed span:first-child, #board span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "Segoe UI", system-ui, sans-serif; }
.rows.board-row, #board > div { grid-template-columns: 48px 2fr 1.2fr 1fr .7fr; }
#board > div { border-top: 1px solid var(--line); font-family: var(--mono); padding: 9px 4px; }
#board > div:first-child { border-top: 0; }
#board > div.me { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 6px; }
#board .r1 span:first-child { color: var(--gold); font-weight: 700; }

.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 4px 20px 28px; max-width: 760px; margin: 0 auto; }

/* ---------- dialogs + toasts ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(380px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(4, 6, 12, .7); }
dialog h2 { font-size: 17px; }
dialog p { margin: 0 0 14px; font-size: 13px; }
.wallet-list { display: grid; gap: 8px; margin-bottom: 12px; }
.wallet-list button { display: flex; justify-content: space-between; align-items: center; text-align: left; }
.wallet-name { display: inline-flex; align-items: center; gap: 10px; }
.wallet-name img { border-radius: 6px; }
.wallet-list p { margin: 0; }
.wallet-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wallet-links a { text-align: center; text-decoration: none; font-size: 13px; }
.addr-form { border-top: 1px solid var(--line); padding-top: 4px; margin-bottom: 12px; }
.addr-form h3 { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); margin-top: 12px; }
.addr-form p { font-size: 12px; margin-bottom: 10px; }
.addr-row { display: flex; gap: 8px; }
.addr-row .input { flex: 1; min-width: 0; }
.addr-row input { font-size: 12px; }
.addr-error { color: var(--down); min-height: 16px; margin: 8px 0 0 !important; }
.unv { font-size: 10px; color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); border-radius: 999px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.unv.bad { color: var(--down); border-color: color-mix(in srgb, var(--down) 40%, transparent); }
.unv.botTag { color: var(--muted); border-color: var(--line); }
.winner-banner {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; justify-content: center; text-align: center;
  padding: 12px 20px; border-bottom: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--gold) 14%, transparent), transparent);
}
.winner-banner b { font-size: 17px; color: var(--gold); }
.winner-dialog { text-align: center; border-color: color-mix(in srgb, var(--accent) 50%, transparent); box-shadow: 0 0 60px rgba(47, 123, 255, .35); }
.winner-dialog img { border-radius: 50%; box-shadow: 0 0 28px rgba(47, 123, 255, .6); margin-bottom: 8px; }
.winner-dialog h2 { display: block; font-size: 24px; color: var(--gold); margin: 0 0 8px; }
.winner-dialog p { margin: 0 0 6px; }
.winner-dialog .btn { margin-top: 12px; }
.rules-panel { grid-column: span 12; }
.rules-panel ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.rules-panel li b { color: var(--text); font-weight: 600; }
.entry-req { color: var(--gold); }
#authDialog .tabs { margin: -6px -4px 16px; }
#authDialog p { font-size: 12px; margin: 0 0 8px; }
#authDialog p:empty { display: none; }
#authDialog .addr-error:empty { display: block; }
#authWallet { font-size: 12px; }
.fair { display: block; margin-top: 8px; font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; }
.wallet-list small { color: var(--muted); font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(360px, calc(100vw - 32px)); }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.toast.err { border-left-color: var(--down); }
.toast.ok { border-left-color: var(--up); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .chart-panel, .order-panel, .board-panel { grid-column: span 12; }
  .comp-panel, .account-panel { grid-column: span 6; }
  .feed-panel { grid-column: span 12; }
}
@media (max-width: 680px) {
  .top, .ticker, .grid { padding-left: 16px; padding-right: 16px; }
  .tag, .chart-hint { display: none; }
  .comp-panel, .account-panel { grid-column: span 12; }
  .chart-wrap { height: 320px; }
  .ticker { gap: 18px; }
  .tick-price { font-size: 20px; min-width: 100px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
