/* ============================================================================
   economy — design system
   Clean grayscale base with green/red money accents. Fun, animated, 2px borders,
   12px radius throughout.
   ============================================================================ */

:root {
  --bg:        hsl(0 0% 0%);
  --bg-elev:   hsl(0 0% 3%);
  --card:      hsl(0 0% 5%);
  --card-hover: hsl(0 0% 8%);
  --border:    hsl(0 0% 20%);
  --border-soft: hsl(0 0% 14%);
  --accent:    hsl(0 0% 20%);

  --text:      hsl(0 0% 90%);
  --subtext:   hsl(0 0% 70%);
  --muted:     hsl(0 0% 45%);

  --green:     hsl(145 63% 49%);
  --green-dim: hsl(145 40% 22%);
  --red:       hsl(0 72% 56%);
  --red-dim:   hsl(0 45% 24%);

  --radius:    12px;
  --radius-sm: 8px;
  --bw:        2px;

  --shadow:    0 8px 30px hsl(0 0% 0% / 0.6);
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle moving glow in the background for "fun" energy. */
body::before {
  content: '';
  position: fixed;
  inset: -50% -50% auto auto;
  width: 70vmax;
  height: 70vmax;
  background: radial-gradient(circle, hsl(145 63% 49% / 0.05), transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: drift 26s var(--ease) infinite alternate;
}

@keyframes drift {
  0%   { transform: translate(10%, -10%) rotate(0deg); }
  100% { transform: translate(-10%, 20%) rotate(40deg); }
}

h1, h2, h3 { margin: 0 0 0.4em; font-weight: 700; letter-spacing: -0.01em; }
a { color: inherit; }
.subtext { color: var(--subtext); }
.muted { color: var(--muted); }
.green { color: var(--green); }
.red { color: var(--red); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

/* ---- buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: var(--bw) solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease),
              border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s;
  user-select: none;
}
.btn:hover { background: var(--card-hover); border-color: hsl(0 0% 32%); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-green {
  background: var(--green-dim);
  border-color: var(--green);
  color: hsl(145 80% 85%);
}
.btn-green:hover { background: hsl(145 45% 28%); box-shadow: 0 0 20px hsl(145 63% 49% / 0.25); }

.btn-red {
  background: var(--red-dim);
  border-color: var(--red);
  color: hsl(0 80% 88%);
}
.btn-red:hover { background: hsl(0 50% 30%); box-shadow: 0 0 20px hsl(0 72% 56% / 0.25); }

.btn-ghost { background: transparent; border-color: var(--border-soft); }
.btn-ghost:hover { background: var(--card); }

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

/* ---- cards & surfaces ----------------------------------------------------- */
.card {
  background: var(--card);
  border: var(--bw) solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.field {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-elev);
  border: var(--bw) solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px hsl(145 63% 49% / 0.15);
}
.field::placeholder { color: var(--muted); }

label.lbl { display: block; font-size: 13px; color: var(--subtext); margin: 0 0 6px; }

/* ---- pills / badges ------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: var(--bw) solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--subtext);
  background: var(--bg-elev);
}
.pill.green { color: hsl(145 70% 75%); border-color: var(--green); background: var(--green-dim); }

/* ---- layout helpers ------------------------------------------------------- */
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; }
.wrap { position: relative; z-index: 1; }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: var(--bw) solid var(--border);
  object-fit: cover;
  background: var(--bg-elev);
}
.avatar.lg { width: 44px; height: 44px; }

/* ---- animations ----------------------------------------------------------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.96); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

.fade-up { animation: fadeUp 0.45s var(--ease) both; }
.fade-in { animation: fadeIn 0.4s var(--ease) both; }
.pop { animation: pop 0.25s var(--ease) both; }

/* stagger helper */
.stagger > * { animation: fadeUp 0.45s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 0.02s; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.10s; }
.stagger > *:nth-child(4) { animation-delay: 0.14s; }
.stagger > *:nth-child(5) { animation-delay: 0.18s; }
.stagger > *:nth-child(6) { animation-delay: 0.22s; }
.stagger > *:nth-child(n+7) { animation-delay: 0.26s; }

.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---- scrollbars ----------------------------------------------------------- */
.scroll { overflow-y: auto; }
.scroll::-webkit-scrollbar { width: 10px; }
.scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); }
.scroll::-webkit-scrollbar-thumb:hover { background: hsl(0 0% 30%); }

/* ---- toasts --------------------------------------------------------------- */
#toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 1000; align-items: center;
}
.toast {
  background: var(--card); border: var(--bw) solid var(--border);
  border-radius: var(--radius); padding: 11px 16px; box-shadow: var(--shadow);
  animation: pop 0.25s var(--ease) both; max-width: 90vw;
}
.toast.err { border-color: var(--red); }
.toast.ok { border-color: var(--green); }

/* ---- modal ---------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: hsl(0 0% 0% / 0.7);
  display: flex; align-items: center; justify-content: center; z-index: 900;
  animation: fadeIn 0.2s var(--ease) both; padding: 20px;
}
.modal {
  background: var(--card); border: var(--bw) solid var(--border);
  border-radius: var(--radius); padding: 24px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow); animation: pop 0.25s var(--ease) both;
}

.hidden { display: none !important; }

/* full-screen status pages (no access / not found / loading) */
.fullscreen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 24px;
}
.fullscreen .big { font-size: 56px; }

/* ============================================================================
   Blackjack
   ============================================================================ */
.bj { max-width: 820px; margin: 0 auto; }
.bj-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.bj-bal { font-weight: 800; font-size: 18px; }

/* lobby */
.room-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border: var(--bw) solid var(--border); border-radius: var(--radius);
  background: var(--card); margin-bottom: 10px; transition: border-color 0.2s var(--ease), transform 0.15s var(--ease);
}
.room-row:hover { border-color: hsl(0 0% 30%); transform: translateY(-1px); }
.room-row .rinfo { display: flex; flex-direction: column; gap: 2px; }
.room-phase { font-size: 12px; color: var(--muted); text-transform: capitalize; }

/* table */
.felt {
  border: var(--bw) solid var(--border); border-radius: var(--radius);
  background:
    radial-gradient(120% 90% at 50% -10%, hsl(145 40% 12% / 0.6), transparent 60%),
    var(--card);
  padding: 22px; margin-bottom: 18px;
}
.dealer-area { text-align: center; padding-bottom: 18px; border-bottom: 2px dashed var(--border-soft); margin-bottom: 18px; }
.area-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 10px; }

.hand { display: flex; gap: 8px; justify-content: center; min-height: 92px; align-items: center; flex-wrap: wrap; }
.bj-card {
  width: 64px; height: 90px; border-radius: 8px; border: var(--bw) solid var(--border);
  background: hsl(0 0% 96%); color: hsl(0 0% 10%); position: relative; flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px;
  box-shadow: 0 4px 12px hsl(0 0% 0% / 0.4); animation: dealIn 0.3s var(--ease) both;
}
.bj-card.red { color: hsl(0 72% 45%); }
.bj-card .corner { position: absolute; font-size: 12px; line-height: 1; }
.bj-card .tl { top: 6px; left: 7px; }
.bj-card .br { bottom: 6px; right: 7px; transform: rotate(180deg); }
.bj-card .pip { font-size: 22px; }
.bj-card.back {
  background: repeating-linear-gradient(45deg, hsl(145 40% 22%), hsl(145 40% 22%) 6px, hsl(145 45% 28%) 6px, hsl(145 45% 28%) 12px);
  color: transparent; border-color: var(--green);
}
@keyframes dealIn { from { opacity: 0; transform: translateY(-16px) rotate(-6deg); } to { opacity: 1; transform: none; } }

.total-badge {
  display: inline-block; margin-top: 10px; padding: 3px 12px; border-radius: 999px;
  border: var(--bw) solid var(--border); background: var(--bg-elev); font-weight: 700; font-variant-numeric: tabular-nums;
}
.total-badge.bust { border-color: var(--red); color: var(--red); }
.total-badge.bj { border-color: var(--green); color: var(--green); }

.seats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.seat {
  border: var(--bw) solid var(--border); border-radius: var(--radius); padding: 12px;
  background: var(--bg-elev); transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.seat.turn { border-color: var(--green); box-shadow: 0 0 0 3px hsl(145 63% 49% / 0.15); }
.seat.me { background: hsl(145 63% 49% / 0.05); }
.seat .seat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.seat .seat-name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .seat-bet { font-size: 12px; color: var(--subtext); }
.result-badge { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.result-badge.win, .result-badge.blackjack { background: var(--green-dim); color: hsl(145 70% 80%); border: 1px solid var(--green); }
.result-badge.lose, .result-badge.bust { background: var(--red-dim); color: hsl(0 70% 82%); border: 1px solid var(--red); }
.result-badge.push { background: var(--bg-elev); color: var(--subtext); border: 1px solid var(--border); }

.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; padding: 16px; border: var(--bw) solid var(--border); border-radius: var(--radius); background: var(--card); }
.controls .bet-input { width: 120px; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--green); min-width: 28px; text-align: center; }
.status-line { color: var(--subtext); }

/* ============================================================================
   Roulette
   ============================================================================ */
.rl { max-width: 880px; margin: 0 auto; }

/* result / wheel reel */
.rl-result { text-align: center; margin-bottom: 16px; }
.rl-number {
  display: inline-flex; align-items: center; justify-content: center;
  width: 92px; height: 92px; border-radius: 50%; font-size: 40px; font-weight: 800;
  border: var(--bw) solid var(--border); background: var(--bg-elev); color: var(--text);
  font-variant-numeric: tabular-nums; transition: transform 0.2s var(--ease);
}
.rl-number.red { background: hsl(0 60% 32%); border-color: var(--red); color: #fff; }
.rl-number.black { background: hsl(0 0% 12%); border-color: hsl(0 0% 40%); color: #fff; }
.rl-number.green { background: var(--green-dim); border-color: var(--green); color: #fff; }
.rl-number.spin { animation: rlspin 0.5s linear infinite; }
@keyframes rlspin { 0% { transform: scale(1); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }
.rl-number.land { animation: pop 0.4s var(--ease) both; }

/* board */
.rl-board {
  display: grid;
  grid-template-columns: 0.7fr repeat(12, 1fr) 0.85fr;
  grid-template-rows: repeat(3, 52px) 38px 38px;
  gap: 4px; margin-bottom: 16px;
}
.rl-cell {
  position: relative; border: 2px solid hsl(0 0% 30%); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; cursor: pointer; user-select: none; color: #fff;
  transition: transform 0.1s var(--ease), box-shadow 0.15s var(--ease), filter 0.15s;
}
.rl-cell:hover { filter: brightness(1.25); }
.rl-board.locked .rl-cell { cursor: default; }
.rl-board.locked .rl-cell:hover { filter: none; }
.rl-cell.red { background: hsl(0 60% 32%); }
.rl-cell.black { background: hsl(0 0% 13%); }
.rl-cell.green { background: var(--green-dim); }
.rl-cell.outside { background: hsl(0 0% 9%); font-size: 12px; letter-spacing: 0.02em; color: var(--subtext); }
.rl-cell.outside.red { background: hsl(0 60% 32%); color: #fff; }
.rl-cell.outside.black { background: hsl(0 0% 13%); color: #fff; }
.rl-cell.win { box-shadow: 0 0 0 3px var(--green), 0 0 18px hsl(145 63% 49% / 0.6); z-index: 2; }

/* token chips on a cell */
.rl-token {
  position: absolute; bottom: 2px; right: 2px;
  min-width: 20px; height: 20px; padding: 0 4px; border-radius: 999px;
  background: hsl(0 0% 0% / 0.78); border: 2px solid #fff; color: #fff;
  font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums; animation: pop 0.18s var(--ease) both;
}
.rl-dots { position: absolute; top: 2px; left: 3px; display: flex; gap: 2px; }
.rl-dot { width: 7px; height: 7px; border-radius: 50%; border: 1px solid hsl(0 0% 0% / 0.5); }

/* players */
.rl-players { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.rl-player {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  border: var(--bw) solid var(--border); border-radius: 999px; background: var(--bg-elev); font-size: 13px;
}
.rl-chip { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.rl-player.ready { border-color: var(--green); }
.rl-net.pos { color: var(--green); font-weight: 700; }
.rl-net.neg { color: var(--red); font-weight: 700; }

/* ============================================================================
   Duck Race
   ============================================================================ */
.dr { max-width: 880px; margin: 0 auto; }
.dr-banner {
  text-align: center; font-size: 18px; font-weight: 800; padding: 12px; margin-bottom: 14px;
  border: var(--bw) solid var(--border); border-radius: var(--radius); background: var(--bg-elev);
}
.dr-banner.win { border-color: var(--green); color: hsl(145 70% 80%); animation: pop 0.3s var(--ease) both; }

.dr-lanes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.dr-lane {
  display: flex; align-items: stretch; gap: 10px;
  border: var(--bw) solid var(--border); border-radius: var(--radius); background: var(--card);
  overflow: hidden; transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.dr-lane.clickable { cursor: pointer; }
.dr-lane.clickable:hover { border-color: hsl(0 0% 35%); }
.dr-lane.mine { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green), 0 0 16px hsl(145 63% 49% / 0.12); background: hsl(145 63% 49% / 0.05); }
.dr-lane.win { border-color: var(--green); box-shadow: 0 0 18px hsl(145 63% 49% / 0.4); }

.dr-info {
  display: flex; align-items: center; gap: 10px; width: 180px; flex: none; padding: 12px 14px;
  border-right: var(--bw) solid var(--border-soft); background: var(--bg-elev);
}
.dr-chip { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.dr-name { font-weight: 700; font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-count {
  min-width: 26px; height: 24px; padding: 0 7px; border-radius: 999px; flex: none;
  background: var(--card); border: var(--bw) solid var(--border); color: var(--subtext);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.dr-lane.mine .dr-count { border-color: var(--green); color: hsl(145 70% 80%); }

.dr-track { position: relative; flex: 1; min-height: 48px; overflow: hidden; }
.dr-track::after {
  content: ''; position: absolute; right: 6px; top: 6px; bottom: 6px; width: 0;
  border-right: 3px dashed var(--border);
}
.dr-duck {
  position: absolute; top: 50%; left: 2%; transform: translate(-50%, -50%);
  font-size: 26px; transition: left 0.15s linear; will-change: left;
}
.dr-duck.bob { animation: bob 0.4s var(--ease) infinite alternate; }
@keyframes bob { from { transform: translate(-50%, -58%); } to { transform: translate(-50%, -42%); } }

/* ============================================================================
   Rocket / Crash
   ============================================================================ */
.crash { max-width: 940px; margin: 0 auto; }
.crash-main { display: flex; gap: 16px; align-items: stretch; }
.crash-stage { flex: 1; min-width: 0; }
.crash-graph {
  position: relative; border: var(--bw) solid var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, hsl(0 0% 6%), hsl(0 0% 3%)); overflow: hidden; height: 340px;
}
.crash-graph canvas { display: block; width: 100%; height: 100%; }
.crash-mult {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.crash-mult .m { font-size: 60px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; text-shadow: 0 2px 20px hsl(0 0% 0% / 0.6); }
.crash-mult .m.up { color: var(--green); }
.crash-mult .m.crashed { color: var(--red); }
.crash-mult .m.idle { color: var(--subtext); }
.crash-mult .sub { color: var(--subtext); margin-top: 4px; }
.crash-mult .sub.crashed { color: var(--red); }

.crash-controls { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.btn-cashout { font-size: 17px; padding: 14px 22px; }
.crash-cash-amt { font-variant-numeric: tabular-nums; }

/* live feed */
.crash-feed { width: 250px; flex: none; border: var(--bw) solid var(--border); border-radius: var(--radius); background: var(--card); display: flex; flex-direction: column; }
.crash-feed h3 { margin: 0; padding: 12px 14px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: var(--bw) solid var(--border-soft); }
.crash-feed ul { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 5px; overflow-y: auto; max-height: 300px; }
.feed-item { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-elev); font-size: 13px; display: flex; align-items: center; gap: 7px; animation: fadeUp 0.3s var(--ease) both; }
.feed-item .who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .amt { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.feed-item.win { border-left: 3px solid var(--green); }
.feed-item.loss { border-left: 3px solid var(--red); }
.feed-empty { color: var(--muted); font-size: 13px; padding: 14px; text-align: center; }

@media (max-width: 720px) { .crash-main { flex-direction: column; } .crash-feed { width: auto; } }
