:root {
  --blue: #2c5de5;
  --blue-light: #7eb3ff;
  --blue-dark: #1a3ea8;
  --gold: #f5c400;
  --gold-light: #ffd54f;
  --bg: #080808;
  --surface: #0f0f0f;
  --surface2: #141414;
  --border: #1e1e1e;
  --border2: #252525;
  --text: #ffffff;
  --text-dim: #888888;
  --green: #4caf7d;
  --red: #e05555;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; }

.hidden { display: none !important; }

/* Auth Screen */
#auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-box { width: 100%; max-width: 340px; }

.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo .wordmark {
  font-family: 'Syne', sans-serif;
  font-size: 2.16rem;
  font-weight: 800;
  color: #fff;
}
.auth-logo .wordmark span { color: var(--blue); }
.auth-logo .tagline { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.3rem; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.6rem 1.4rem;
}

.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 1.4rem;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
}

.auth-tab.active { background: var(--surface2); color: #fff; }

.auth-form { display: flex; flex-direction: column; gap: 0.85rem; }

.field-group { display: flex; flex-direction: column; gap: 0.35rem; }

.field-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.field-input {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 10px;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 13px 14px;
  outline: none;
  width: 100%;
}

.field-input:focus { border-color: var(--blue); }
.field-input.error { border-color: var(--red); animation: shake 0.35s ease; }

.auth-error { font-size: 0.8rem; color: var(--red); text-align: center; min-height: 1rem; }

.auth-submit {
  width: 100%;
  padding: 14px;
  background: var(--blue);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 0.4rem;
}

.auth-submit:hover { background: #3a6af5; }
.auth-submit:disabled { opacity: 0.5; }

.auth-footer { text-align: center; margin-top: 1.1rem; font-size: 0.75rem; color: #555; }
.auth-footer a { color: var(--blue-light); cursor: pointer; }

/* Game Screen */
#game-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.topbar {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0 0.8rem;
}

.brand { font-family: 'Syne', sans-serif; font-size: 1.17rem; font-weight: 800; color: #fff; }
.brand span { color: var(--blue); }

.topbar-right { display: flex; align-items: center; gap: 0.55rem; }

.balance-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 16px 5px 6px;
}

.pfp {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #7b3fe4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: #fff;
  font-weight: 700;
}

.balance-text { font-size: 0.88rem; font-weight: 600; color: #fff; }
.balance-text .sym { color: var(--text-dim); margin-right: 1px; }

.deposit-btn {
  background: var(--surface2);
  border: 1px solid #2a2a2a;
  border-radius: 999px;
  color: var(--blue-light);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 13px;
}

.logout-btn {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 5px 10px;
}

/* Panel */
.panel { width: 100%; max-width: 420px; text-align: center; }

/* Coin Area */
.coin-area {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.8rem;
  position: relative;
}

.coin-wrap { width: 180px; height: 180px; position: relative; }
.coin-stage { width: 100%; height: 100%; perspective: 700px; display: flex; align-items: center; justify-content: center; }
.coin-3d { width: 160px; height: 160px; transform-style: preserve-3d; border-radius: 50%; position: relative; }

.face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heads-side {
  background: radial-gradient(circle at 35% 30%, #4a7fff 0%, #1a3ea8 60%, #0e2572 100%);
  border: 2.5px solid #3060e8;
}

.tails-side {
  background: radial-gradient(circle at 35% 30%, #4a7fff 0%, #1a3ea8 60%, #0e2572 100%);
  border: 2.5px solid #3060e8;
  transform: rotateY(180deg);
}

.face-letter {
  font-family: 'Syne', sans-serif;
  font-size: 4rem;
  font-weight: 800;
  color: rgba(255,255,255,0.12);
}

/* Coin Animation */
@keyframes flip-coin {
  0% { transform: rotateY(0deg) scale(1); }
  50% { transform: rotateY(900deg) scale(0.9); }
  100% { transform: rotateY(1800deg) scale(1); }
}

.coin-3d.flipping {
  animation: flip-coin 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

/* Coin Glow */
.coin-glow {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.coin-glow.visible { opacity: 1; }
.coin-glow.heads { background: radial-gradient(circle, rgba(44,93,229,0.45) 0%, transparent 70%); }
.coin-glow.tails { background: radial-gradient(circle, rgba(44,93,229,0.45) 0%, transparent 70%); }

/* Side Picker */
.side-picker { display: flex; gap: 0.6rem; width: 100%; margin-bottom: 0.8rem; }

.side-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: #444;
  font-size: 0.88rem;
  font-weight: 700;
  transition: all 0.2s;
}

.side-btn.active {
  background: rgba(44,93,229,0.18);
  border-color: var(--blue);
  color: var(--blue-light);
}

/* Stats Row (old pill style) */
.stats-row { display: flex; gap: 0.6rem; width: 100%; margin-bottom: 1.2rem; }
.stat-pill { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; text-align: center; }
.stat-label { font-size: 0.65rem; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: #555; margin-bottom: 3px; }
.stat-value { font-size: 0.95rem; font-weight: 700; color: #fff; }

/* Fair Link Button */
.fair-link-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.8rem;
  padding: 4px 8px;
  text-decoration: underline;
}
.fair-link-btn:hover { color: var(--blue-light); }

/* Result */
.result-wrap {
  min-height: 2rem;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.result { font-size: 1.08rem; font-weight: 700; color: #fff; transition: color 0.3s; }
.result.empty { color: #444; }
.result.win { color: var(--green); }
.result.lose { color: var(--red); }

.result-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0;
}

.result-dot.show { opacity: 1; }
.result-dot.heads { background: var(--blue); }
.result-dot.tails { background: var(--gold); }

/* Bet Section */
.bet-section {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.2rem;
  margin-bottom: 0.9rem;
  text-align: left;
}

.bet-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 0.6rem;
}

.bet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.bet-header .bet-label {
  margin-bottom: 0;
}

.bet-header .fair-link-btn {
  font-size: 0.65rem;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.bet-header .fair-link-btn:hover {
  color: var(--blue-light);
}

.bet-row { display: flex; gap: 0.5rem; align-items: center; }

.bet-input-wrap { flex: 1; position: relative; }

.bet-currency {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #444;
  font-weight: 600;
  font-size: 0.95rem;
}

.bet-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 10px;
  color: #fff;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 11px 13px 11px 30px;
  outline: none;
}

.bet-input:focus { border-color: #333; }

.preset-btns { display: flex; gap: 0.35rem; }

.preset {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: #555;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 9px 12px;
}

.preset:hover { background: #141414; color: #888; }

/* Flip Button */
.flip-btn {
  width: 100%;
  padding: 15px;
  background: var(--blue);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
}

.flip-btn:hover { background: #3a6af5; }
.flip-btn:disabled { opacity: 0.4; cursor: default; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 360px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.modal-header {
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.3rem;
}

.modal-tabs {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 1.4rem;
}

.modal-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 6px;
}

.modal-tab.active { background: var(--surface2); color: #fff; }

.modal-body { min-height: 220px; }
.modal-desc { font-size: 0.85rem; color: var(--text-dim); text-align: center; margin-bottom: 0.6rem; }
.modal-sub { font-size: 0.72rem; color: #555; text-align: center; }
.deposit-address {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: monospace;
  font-size: 0.75rem;
  word-break: break-all;
  text-align: center;
  margin: 0.8rem 0;
  color: var(--blue-light);
}

.btn-blue {
  width: 100%;
  padding: 13px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 0.8rem;
}

.btn-red {
  width: 100%;
  padding: 14px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  margin-top: 1.2rem;
}

.btn-ghost {
  width: 100%;
  margin-top: 1.3rem;
  padding: 11px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 10px;
  font-weight: 600;
}

/* Fair Content */
.fair-content { display: flex; flex-direction: column; gap: 0.85rem; }
.fair-item { display: flex; flex-direction: column; gap: 0.25rem; }
.fair-label { font-size: 0.62rem; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-dim); }
.fair-value { font-family: monospace; font-size: 0.7rem; color: var(--blue-light); word-break: break-all; }
.fair-hash { font-size: 0.6rem; color: #777; }
.fair-note { font-size: 0.7rem; color: #555; text-align: center; margin-top: 1rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ccc;
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
  z-index: 10000;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Animations */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes bal-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.balance-text.bump { animation: bal-bump 0.4s ease; }

.fair-link-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.8rem;
  padding: 4px 8px;
  text-decoration: underline;
}
.fair-link-btn:hover { color: var(--blue-light); }

/* Profile Card */
.profile-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem;
  margin-bottom: 1rem;
  text-align: center;
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.2rem;
}

.profile-pfp-lg {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #7b3fe4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.profile-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.profile-stats {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.profile-stat {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 0.8rem;
  text-align: center;
}

.profile-stat-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.profile-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--blue-light);
}

/* Profile Page */
.profile-page {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.profile-pfp-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #7b3fe4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  font-weight: 700;
  margin: 0 auto 1rem;
}

.profile-name {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.profile-stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}

.profile-stat-box .profile-stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.profile-stat-box .profile-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue-light);
}