* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0e16;
  color: #e7ebf3;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}

#canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  outline: none;
  touch-action: none;
  background: #0a0e16;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(120% 120% at 50% 0%, rgb(67 209 139 / 10%), transparent 55%),
    radial-gradient(120% 120% at 50% 100%, rgb(255 91 118 / 10%), transparent 55%),
    #0a0e16;
  color: #e9eef7;
  transition: opacity 240ms ease, visibility 240ms ease;
}

.loading-overlay.ready {
  visibility: hidden;
  opacity: 0;
}

.brand {
  font-size: clamp(40px, 9vw, 96px);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}

.brand .up {
  color: #43d18b;
  text-shadow: 0 0 32px rgb(67 209 139 / 50%);
}

.brand .slash {
  margin: 0 0.12em;
  color: #4a5266;
}

.brand .down {
  color: #ff5b76;
  text-shadow: 0 0 32px rgb(255 91 118 / 50%);
}

.tag {
  margin-top: 14px;
  color: #7e8aa0;
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.status {
  min-height: 18px;
  margin-top: 26px;
  color: #aeb9cc;
  font-size: 13px;
}

.dots {
  display: inline-flex;
  gap: 6px;
  margin-top: 18px;
}

.dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #43d18b;
  animation: pulse 1s ease-in-out infinite;
}

.dots span:nth-child(2) {
  background: #f4c76a;
  animation-delay: 0.15s;
}

.dots span:nth-child(3) {
  background: #ff5b76;
  animation-delay: 0.3s;
}

.loading-overlay.fatal .dots {
  display: none;
}

.wallet-data-controls {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  top: max(72px, calc(env(safe-area-inset-top) + 12px));
  z-index: 5;
  width: min(310px, calc(100vw - 20px));
  border: 1px solid #313b50;
  border-radius: 10px;
  background: rgb(10 14 22 / 94%);
  color: #aeb9cc;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 12px 40px rgb(0 0 0 / 45%);
}

.wallet-data-controls[hidden] {
  display: none;
}

.wallet-data-header {
  display: flex;
  min-height: 40px;
  padding: 7px 8px 4px 12px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgb(49 59 80 / 65%);
}

.wallet-data-header h2 {
  color: #8f9bb0;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wallet-settings-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8f9bb0;
  cursor: pointer;
  font: inherit;
  font-size: 22px;
  line-height: 1;
}

.wallet-settings-close:hover,
.wallet-settings-close:focus-visible {
  background: rgb(143 155 176 / 12%);
  color: #e7ebf3;
  outline: 2px solid rgb(143 155 176 / 24%);
}

.wallet-data-body {
  display: grid;
  gap: 9px;
  padding: 11px 12px 12px;
}

.wallet-data-body label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: #e7ebf3;
}

.wallet-data-body input {
  margin-top: 2px;
  accent-color: #43d18b;
}

.wallet-data-body p {
  color: #7e8aa0;
}

.wallet-data-body button {
  min-height: 34px;
  border: 1px solid #ff5b76;
  border-radius: 7px;
  background: rgb(255 91 118 / 9%);
  color: #ff879b;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.wallet-data-body button:hover,
.wallet-data-body button:focus-visible {
  background: rgb(255 91 118 / 16%);
  outline: 2px solid rgb(255 91 118 / 28%);
  outline-offset: 1px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dots span {
    animation: none;
  }
}

/* Privy embedded-wallet iframe: functional only, never visible. Kept in the layout
   (not display:none) so the secure context loads and can post messages. */
.topk-privy-frame {
  position: fixed;
  width: 1px;
  height: 1px;
  border: 0;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* Sign-in / funding / withdraw overlay. Same dark, rounded, monospace-ish idiom as
   the trading-settings popover above. */
.topk-auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px;
}

.topk-auth-overlay[hidden] {
  display: none;
}

.topk-auth-scrim {
  position: absolute;
  inset: 0;
  background: rgb(4 7 12 / 68%);
}

.topk-auth-dialog {
  position: relative;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border: 1px solid #313b50;
  border-radius: 12px;
  background: rgb(10 14 22 / 98%);
  color: #aeb9cc;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 24px 70px rgb(0 0 0 / 55%);
}

.topk-auth-header {
  display: flex;
  min-height: 44px;
  padding: 9px 8px 7px 14px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgb(49 59 80 / 65%);
}

.topk-auth-title {
  color: #8f9bb0;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topk-auth-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8f9bb0;
  cursor: pointer;
  font: inherit;
  font-size: 22px;
  line-height: 1;
}

.topk-auth-close:hover,
.topk-auth-close:focus-visible {
  background: rgb(143 155 176 / 12%);
  color: #e7ebf3;
  outline: 2px solid rgb(143 155 176 / 24%);
}

.topk-auth-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.topk-auth-stage {
  display: grid;
  gap: 10px;
}

.topk-auth-stage[hidden] {
  display: none;
}

.topk-auth-field {
  display: grid;
  gap: 5px;
}

.topk-auth-field-label {
  color: #8f9bb0;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topk-auth-input {
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid #313b50;
  border-radius: 8px;
  background: rgb(6 9 15 / 90%);
  color: #e7ebf3;
  font: inherit;
}

.topk-auth-input:focus-visible {
  outline: 2px solid rgb(67 209 139 / 40%);
  outline-offset: 1px;
  border-color: #43d18b;
}

.topk-auth-primary {
  min-height: 38px;
  border: 1px solid #43d18b;
  border-radius: 8px;
  background: rgb(67 209 139 / 12%);
  color: #7ee7b4;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.topk-auth-primary:hover,
.topk-auth-primary:focus-visible {
  background: rgb(67 209 139 / 20%);
  outline: 2px solid rgb(67 209 139 / 30%);
  outline-offset: 1px;
}

.topk-auth-secondary {
  min-height: 38px;
  border: 1px solid #313b50;
  border-radius: 8px;
  background: rgb(143 155 176 / 8%);
  color: #e7ebf3;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.topk-auth-secondary:hover,
.topk-auth-secondary:focus-visible {
  background: rgb(143 155 176 / 16%);
  outline: 2px solid rgb(143 155 176 / 24%);
  outline-offset: 1px;
}

.topk-auth-primary:disabled,
.topk-auth-secondary:disabled {
  opacity: 0.55;
  cursor: default;
}

.topk-auth-link {
  border: 0;
  background: transparent;
  color: #8f9bb0;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  justify-self: start;
}

.topk-auth-link:hover,
.topk-auth-link:focus-visible {
  color: #e7ebf3;
}

.topk-auth-or {
  color: #6d788c;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

.topk-auth-hint {
  color: #7e8aa0;
}

.topk-auth-address {
  display: block;
  padding: 9px 11px;
  border: 1px solid #313b50;
  border-radius: 8px;
  background: rgb(6 9 15 / 90%);
  color: #e7ebf3;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}

.topk-auth-error {
  color: #ff879b;
  font-size: 12px;
}

.topk-auth-success {
  color: #7ee7b4;
  font-size: 12px;
}

.topk-auth-qr {
  align-self: center;
  width: 168px;
  height: 168px;
  max-width: 100%;
  border-radius: 8px;
  image-rendering: pixelated;
}

.topk-auth-divider {
  height: 1px;
  margin: 2px 0;
  background: rgb(49 59 80 / 65%);
}

.topk-auth-subhead {
  color: #e7ebf3;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.topk-auth-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.topk-auth-preset {
  flex: 1 1 auto;
  min-height: 32px;
  border: 1px solid #313b50;
  border-radius: 7px;
  background: rgb(143 155 176 / 8%);
  color: #e7ebf3;
  cursor: pointer;
  font: inherit;
}

.topk-auth-preset:hover,
.topk-auth-preset:focus-visible {
  background: rgb(143 155 176 / 16%);
  outline: 2px solid rgb(143 155 176 / 24%);
  outline-offset: 1px;
}

.topk-auth-input:disabled {
  opacity: 0.6;
}
