:root {
  --bg: #06070d;
  --bg-2: #0a0c16;
  --panel: rgba(16, 19, 32, 0.72);
  --panel-solid: #0d1020;
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-strong: rgba(255, 255, 255, 0.14);
  --accent: #9945ff; /* Solana purple */
  --accent2: #14f195; /* Solana green */
  --accent-soft: rgba(153, 69, 255, 0.16);
  --text: #eef1f7;
  --muted: #8a93a8;
  --muted-2: #5b6478;
  --danger: #ff6b6b;
  --gold: #ffcc55;
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

#game { display: block; width: 100vw; height: 100vh; cursor: none; }
body.spectating #game { cursor: default; }

.hidden { display: none !important; }

kbd {
  font-family: var(--font-ui); font-size: 11px; font-weight: 600;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--stroke);
  border-radius: 5px; padding: 1px 6px; color: var(--text);
}

/* Shared "live" pulse dot */
.dot-live {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent2); box-shadow: 0 0 0 0 rgba(20, 241, 149, 0.6);
  animation: pulse 1.8s infinite; vertical-align: middle; margin-right: 5px;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(20, 241, 149, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(20, 241, 149, 0); }
  100% { box-shadow: 0 0 0 0 rgba(20, 241, 149, 0); }
}

/* ============ HUD ============ */
#hud { position: fixed; inset: 0; pointer-events: none; font-family: var(--font-ui); }

.panel {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 13px 16px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Top fee / reward dashboard */
#feeboard {
  top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 0; padding: 12px 8px;
}
.fee-item { display: flex; flex-direction: column; gap: 4px; padding: 2px 18px; text-align: center; }
.fee-label {
  font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted-2); white-space: nowrap; font-weight: 600;
}
.fee-value { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.fee-value b {
  font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--text);
}
.fee-value.accentv b {
  background: linear-gradient(135deg, var(--accent2), #8fffd0);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.fee-sep { width: 1px; background: var(--stroke); margin: 3px 0; }
.fee-mode {
  font-size: 8.5px; padding: 2px 6px; border-radius: 5px; letter-spacing: 0.1em;
  font-weight: 700; text-transform: uppercase;
  background: var(--accent-soft); color: #c9b3ff; vertical-align: middle;
}
.fee-mode.live { background: rgba(20, 241, 149, 0.16); color: var(--accent2); }

#round {
  top: 104px; left: 50%; transform: translateX(-50%);
  text-align: center; min-width: 230px;
}
.round-phase {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent2); font-weight: 600;
}
.round-timer {
  font-family: var(--font-display); font-size: 34px; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1.1; margin-top: 2px;
}
.round-pool { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.round-pool b { color: var(--text); font-variant-numeric: tabular-nums; }

#leaderboard { top: 14px; right: 16px; width: 224px; }
#alltime { top: 268px; right: 16px; width: 224px; }
.panel-title {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px; font-weight: 600; display: flex; align-items: center;
}
#lbList, #atList {
  margin: 0; padding: 0; list-style: none;
  font-size: 13.5px; display: flex; flex-direction: column; gap: 2px;
}
#lbList li, #atList li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px; border-radius: 8px; counter-increment: rank;
}
#lbList li::before, #atList li::before {
  content: counter(rank); color: var(--muted-2); font-variant-numeric: tabular-nums;
  font-size: 11px; min-width: 14px; margin-right: 8px; font-weight: 600;
}
#lbList, #atList { counter-reset: rank; }
#lbList li .nm, #atList li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lbList li.me, #atList li.me { color: var(--accent2); font-weight: 700; }
#lbList li.me::before, #atList li.me::before { color: var(--accent2); }
.lb-score { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
#atList .lb-score { color: var(--gold); }
/* Rows are inside #hud (pointer-events:none) — re-enable so they can be hovered. */
#lbList li[data-wallet], #atList li[data-wallet] { pointer-events: auto; cursor: pointer; }
#lbList li[data-wallet]:hover, #atList li[data-wallet]:hover { background: rgba(255, 255, 255, 0.06); }
#atList .at-empty, #lbList .lb-empty { color: var(--muted-2); font-size: 12px; padding: 4px 0; }
#atList .at-empty::before, #lbList .lb-empty::before { content: ""; margin: 0; min-width: 0; }

#mystats {
  bottom: 18px; left: 18px; display: flex; gap: 16px; align-items: center; font-size: 13px;
}
#mystats .ms-mass { font-weight: 500; color: var(--muted); }
#mystats .ms-mass b {
  font-family: var(--font-display); color: var(--text); font-size: 16px; margin-left: 4px;
  font-variant-numeric: tabular-nums;
}
#mystats .hint { color: var(--muted-2); font-size: 12px; display: flex; gap: 6px; align-items: center; }

/* Wallet address popover (hover a leaderboard row) */
#walletPop {
  position: fixed; z-index: 50; display: flex; align-items: center; gap: 8px;
  background: var(--panel-solid); border: 1px solid var(--stroke-strong);
  border-radius: 12px; padding: 9px 11px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55); pointer-events: auto;
}
#walletPop code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  color: var(--text); white-space: nowrap;
}
#walletPop button {
  cursor: pointer; font-size: 12px; font-weight: 700; color: #06070d;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-radius: 8px; padding: 6px 11px;
}
#walletPop button.copied { background: var(--accent2); }

#spectateBar {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--stroke);
  border-radius: 999px; padding: 9px 9px 9px 18px; backdrop-filter: blur(16px);
  font-size: 13px; pointer-events: auto; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
#spectateBar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 10px var(--danger); }
#spectateBar b { color: var(--accent2); letter-spacing: 0.12em; font-size: 12px; }
#spectateBar button {
  pointer-events: auto; cursor: pointer; font-size: 12px; font-weight: 700;
  color: #06070d; background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-radius: 999px; padding: 7px 16px;
}

/* ============ Entry overlay ============ */
#overlay { position: fixed; inset: 0; background: var(--bg); }
#bgfx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.overlay-inner {
  position: relative; z-index: 2;
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  /* vignette + brand glow over the animated cell field */
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(153, 69, 255, 0.22), transparent 60%),
    radial-gradient(900px 500px at 50% 120%, rgba(20, 241, 149, 0.12), transparent 60%),
    radial-gradient(120% 120% at 50% 50%, transparent 40%, rgba(3, 4, 9, 0.72) 100%);
}

.card {
  width: min(430px, 92vw);
  background: linear-gradient(180deg, rgba(20, 24, 40, 0.86), rgba(11, 13, 24, 0.9));
  border: 1px solid var(--stroke-strong);
  border-radius: 22px;
  padding: 30px 30px 26px;
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(153, 69, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: cardIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }

.brand-row { margin-bottom: 16px; }
.solana-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: #c9d2e3;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--stroke);
  border-radius: 999px; padding: 5px 11px 5px 9px;
}
.sol-mark {
  width: 13px; height: 13px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent) 0%, #c77dff 45%, var(--accent2) 100%);
  box-shadow: 0 0 10px rgba(153, 69, 255, 0.5);
}

.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 60px; height: 60px; border-radius: 16px; display: block;
  filter: drop-shadow(0 6px 20px rgba(153, 69, 255, 0.45));
  animation: logoIn 0.7s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}
@keyframes logoIn { from { opacity: 0; transform: scale(0.7) rotate(-8deg); } to { opacity: 1; transform: none; } }

.brand {
  font-family: var(--font-display); margin: 0; font-size: 60px; font-weight: 700;
  letter-spacing: 0.02em; line-height: 0.95;
  background: linear-gradient(120deg, #ffffff 10%, #d7c4ff 45%, var(--accent2) 110%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 24px rgba(153, 69, 255, 0.35));
}
.tag { margin: 12px 0 16px; color: var(--muted); font-size: 14.5px; line-height: 1.55; }

/* Contract address pill — follows env TOKEN_MINT, click to copy */
.ca-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--stroke);
  border-radius: 12px; padding: 9px 11px; margin-bottom: 20px; cursor: pointer;
  font-family: var(--font-ui); transition: border-color 0.15s ease, background 0.15s ease;
}
.ca-row:hover { border-color: var(--accent2); background: rgba(20, 241, 149, 0.06); }
.ca-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: var(--accent2);
  background: rgba(20, 241, 149, 0.12); border-radius: 6px; padding: 3px 7px;
}
.ca-addr {
  flex: 1; text-align: left; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ca-copy { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.ca-row.copied { border-color: var(--accent2); }
.ca-row.copied .ca-copy { color: var(--accent2); }

.pool-banner {
  position: relative; overflow: hidden;
  background:
    linear-gradient(135deg, rgba(153, 69, 255, 0.18), rgba(20, 241, 149, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px; padding: 16px 18px; margin-bottom: 22px;
}
.pool-banner::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(400px 120px at 100% 0%, rgba(20, 241, 149, 0.18), transparent 70%);
  pointer-events: none;
}
.pool-head { display: flex; align-items: center; justify-content: space-between; }
.pool-label { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.pool-live { font-size: 11px; color: var(--accent2); font-weight: 600; }
.pool-value {
  font-family: var(--font-display); font-size: 38px; font-weight: 700; line-height: 1.1; margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.pool-value span { font-size: 22px; color: var(--muted); font-weight: 600; }
.split-note { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

.field { display: block; margin-bottom: 15px; }
.field-label { display: block; font-size: 12px; letter-spacing: 0.02em; color: var(--muted); margin-bottom: 7px; font-weight: 500; }
.field input {
  width: 100%; padding: 13px 14px; font-size: 14.5px; font-family: var(--font-ui);
  background: rgba(0, 0, 0, 0.28); color: var(--text);
  border: 1px solid var(--stroke-strong); border-radius: 12px; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.field input::placeholder { color: var(--muted-2); }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(153, 69, 255, 0.18); background: rgba(0, 0, 0, 0.4); }
.field input:disabled { opacity: 0.5; cursor: not-allowed; }
.gate-note { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; min-height: 14px; }
.gate-note.checking { color: var(--accent2); }
.gate-note.ok { color: var(--accent2); }
.gate-note.bad { color: var(--danger); }

#playBtn {
  position: relative; width: 100%; padding: 15px; font-size: 15.5px; font-weight: 700;
  font-family: var(--font-display); letter-spacing: 0.01em;
  color: #06070d; cursor: pointer; overflow: hidden;
  background: linear-gradient(135deg, var(--accent) 0%, #b06bff 40%, var(--accent2) 100%);
  border: none; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(153, 69, 255, 0.35);
  transition: transform 0.08s ease, box-shadow 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}
#playBtn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(153, 69, 255, 0.45); filter: brightness(1.05); }
#playBtn:active:not(:disabled) { transform: translateY(0); }
#playBtn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.ghost-btn {
  width: 100%; padding: 12px; margin-top: 11px; font-size: 13.5px; font-weight: 600;
  color: var(--text); cursor: pointer; font-family: var(--font-ui);
  background: transparent; border: 1px solid var(--stroke-strong); border-radius: 14px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.ghost-btn:hover { border-color: var(--accent2); background: rgba(20, 241, 149, 0.07); color: var(--accent2); }

.join-error { margin-top: 13px; color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }
.ov-footer { color: var(--muted-2); font-size: 12px; letter-spacing: 0.02em; }

/* ============ Round-end toast ============ */
#toast {
  position: fixed; top: 120px; left: 50%; transform: translateX(-50%);
  background: var(--panel-solid); border: 1px solid var(--stroke-strong);
  border-radius: 18px; padding: 18px 22px; text-align: center; z-index: 60;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease; max-width: 90vw;
}
#toast.hidden { opacity: 0; transform: translate(-50%, -8px); }
#toast .toast-title {
  font-family: var(--font-display); font-size: 13px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent2); font-weight: 600;
}
#toast .winner-row { font-size: 15px; margin-top: 8px; }
#toast .winner-row b { color: var(--text); }
#toast .payout { color: var(--gold); font-weight: 700; }
#toast .dq-row { font-size: 12px; margin-top: 7px; color: #ff8f8f; opacity: 0.85; }
#toast .paysig { color: var(--accent2); font-size: 12px; text-decoration: none; margin-left: 6px; }
#toast .paysig:hover { text-decoration: underline; }
#toast .payfail { color: var(--danger); font-size: 12px; margin-left: 6px; }
#toast .paysim { color: var(--muted); font-size: 12px; margin-left: 6px; }

@media (max-width: 560px) {
  .brand { font-size: 52px; }
  #feeboard { flex-wrap: wrap; max-width: 94vw; }
  #leaderboard, #alltime { width: 180px; }
}
