:root {
  --bg: #0b0e11;
  --panel: #12161b;
  --line: #232b33;
  --green: #3ddc84;
  --gold: #f4b93e;
  --red: #ff5a5a;
  --text: #e8e6de;
  --text-dim: #7d8791;
  --font-display: 'JetBrains Mono', monospace;
  --font-ui: 'Space Grotesk', sans-serif;
}
* { box-sizing: border-box; }
input[type="text"], input[type="number"] { font-size: 16px; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-ui); overflow-y: auto; overflow-x: hidden; }
.hidden { display: none !important; }
.screen { min-height: 100vh; width: 100vw; display: flex; align-items: center; justify-content: center; padding: 16px 0; box-sizing: border-box; }

.card { text-align: center; padding: 48px 56px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); max-width: 460px; width: 100%; }
@media (max-width: 480px) {
  .card { padding: 32px 24px; }
}
.wordmark { font-family: var(--font-display); font-size: 28px; letter-spacing: 0.08em; margin: 0 0 12px; font-weight: 700; }
.wordmark span { color: var(--gold); }
.tagline { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin-bottom: 28px; }

.btn {
  display: block; width: 100%; padding: 12px; background: var(--green); color: #06120b;
  border: none; border-radius: 3px; font-family: var(--font-display); font-weight: 700;
  letter-spacing: 0.08em; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: #4fe89a; }
.btn-small {
  padding: 10px 16px; background: var(--green); color: #06120b; border: none; border-radius: 3px;
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0.05em; cursor: pointer; font-size: 12px;
}
.btn-small:hover { background: #4fe89a; }

.error-text { min-height: 18px; color: var(--red); font-size: 13px; margin: 10px 0 0; }
.meta { margin-top: 24px; font-size: 12px; color: var(--text-dim); font-family: var(--font-display); }
.meta .dot { margin: 0 8px; }

#lobby-share.hidden, #lobby-create.hidden { display: none; }
.share-label { font-family: var(--font-display); font-size: 12px; color: var(--text-dim); margin: 20px 0 8px; text-align: left; }
.share-row { display: flex; gap: 8px; }
.share-row input {
  flex: 1; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); color: var(--green);
  font-family: var(--font-display); font-size: 12px; border-radius: 3px;
}
.overlay-sub { color: var(--text-dim); font-size: 12px; margin-top: 10px; }
.qr-wrap { display: flex; justify-content: center; margin: 16px 0; padding: 12px; background: #fff; border-radius: 6px; width: fit-content; margin-left: auto; margin-right: auto; }

.divider { display: flex; align-items: center; margin: 24px 0; color: var(--text-dim); font-family: var(--font-display); font-size: 11px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.divider span { padding: 0 12px; }

.join-row { display: flex; gap: 8px; }
.join-row input {
  flex: 1; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font-family: var(--font-display); letter-spacing: 0.15em; text-align: center; border-radius: 3px; outline: none;
}
.join-row input:focus { border-color: var(--green); }

#game-screen { flex-direction: column; padding: 12px 16px; min-height: 100vh; }
.hud { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.hud-player { display: flex; flex-direction: column; gap: 2px; min-width: 160px; }
.hud-player--right { align-items: flex-end; text-align: right; }
.hud-label { font-family: var(--font-display); font-size: 11px; color: var(--text-dim); letter-spacing: 0.1em; }
.hud-name { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pot-display { display: flex; align-items: baseline; gap: 6px; }
.pot-label { font-family: var(--font-display); font-size: 12px; color: var(--gold); letter-spacing: 0.1em; }
.pot-amount { font-family: var(--font-display); font-size: 34px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.pot-unit { font-family: var(--font-display); font-size: 12px; color: var(--text-dim); }
.stake-row { display: flex; gap: 8px; margin-bottom: 10px; }
.stake-btn {
  flex: 1; padding: 10px 0; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font-family: var(--font-display); font-size: 13px; border-radius: 3px; cursor: pointer;
}
.stake-btn:hover { border-color: var(--green); }
.stake-btn.active { background: var(--green); color: #06120b; border-color: var(--green); font-weight: 700; }
#stake-custom {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font-family: var(--font-display); border-radius: 3px; outline: none;
}
#stake-custom:focus { border-color: var(--green); }
.stake-display { font-family: var(--font-display); font-size: 11px; color: var(--text-dim); }

.rally-display { font-family: var(--font-display); font-size: 12px; color: var(--text-dim); letter-spacing: 0.1em; }
.rally-display span { color: var(--text); font-weight: 700; }

.court-wrap { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; margin: 16px 0; min-height: 0; }
#court { background: #05070a; border: 1px solid var(--line); border-radius: 4px; max-width: 100%; max-height: 100%; }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(5,7,10,0.72); font-family: var(--font-display); text-align: center; gap: 6px;
}
#start-overlay { cursor: pointer; touch-action: manipulation; }
kbd { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 2px 8px; font-family: var(--font-display); }

.touch-controls { display: flex; gap: 16px; justify-content: center; padding: 8px 0 4px; flex-shrink: 0; }
.touch-btn {
  width: 68px; height: 68px; border-radius: 50%; background: var(--panel); border: 2px solid var(--line);
  color: var(--green); font-size: 22px; cursor: pointer; touch-action: none; user-select: none;
  -webkit-tap-highlight-color: transparent; display: flex; align-items: center; justify-content: center;
}
.touch-btn:active { background: var(--green); color: #06120b; border-color: var(--green); }

@media (min-width: 800px) and (pointer: fine) {
  .touch-controls { opacity: 0.6; }
}

.ledger { border-top: 1px solid var(--line); padding-top: 10px; height: 120px; flex-shrink: 0; }
.ledger-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.ledger-title { font-family: var(--font-display); font-size: 11px; letter-spacing: 0.12em; color: var(--green); }
.ledger-sub { font-family: var(--font-display); font-size: 11px; color: var(--text-dim); }
.ledger-lines { font-family: var(--font-display); font-size: 12px; line-height: 1.9; color: var(--green); height: 86px; overflow: hidden; display: flex; flex-direction: column-reverse; }
.ledger-line { white-space: nowrap; opacity: 0.85; }
.ledger-line .amt { color: var(--gold); }
.ledger-line .dim { color: var(--text-dim); }

.modal { position: fixed; inset: 0; background: rgba(5,7,10,0.85); display: flex; align-items: center; justify-content: center; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 40px 44px; min-width: 380px; max-width: 90vw; text-align: center; }
#winner-heading { font-family: var(--font-display); color: var(--gold); letter-spacing: 0.08em; margin: 0 0 20px; }
.modal-row { display: flex; justify-content: space-between; font-family: var(--font-display); font-size: 13px; color: var(--text-dim); margin: 8px 0; }
.modal-row span:last-child { color: var(--text); }
.modal-txid span:last-child { color: var(--green); font-size: 11px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.board-heading { font-family: var(--font-display); font-size: 12px; letter-spacing: 0.1em; color: var(--text-dim); margin: 28px 0 10px; text-align: left; }
.leaderboard-list { list-style: none; padding: 0; margin: 0 0 24px; font-family: var(--font-display); font-size: 13px; text-align: left; max-height: 180px; overflow-y: auto; }
.leaderboard-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.leaderboard-list li:first-child { color: var(--gold); }
