/* ============================================================================
   CoinForge — base design system (1b2t.xyz-inspired: Nunito, near-black
   layered surfaces, rounded panels, functionality-first dark UI).
   ========================================================================== */

/* The hidden attribute must ALWAYS win — component classes like .btn set
   display:inline-flex, which otherwise defeats it and leaves dead controls
   visible on screen (e.g. a cash-out button with no running round). */
[hidden] {
  display: none !important;
}

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-light: #1c1c1c;
  --surface-elev: #222222;
  --surface-hover: #282828;
  --border: #2a2a2a;
  --border-light: #333333;
  --text: #ffffff;
  --text-dim: #d1d5db;
  --text-muted: #9ca3af;
  --text-faint: #6a6a6a;
  --accent: #4263eb;
  --accent-soft: #6c8aff;
  --accent-dim: rgba(66, 99, 235, 0.16);
  --gold: #ffd43b;
  --gold-dim: rgba(255, 212, 59, 0.14);
  --green: #94d82d;
  --green-dim: rgba(148, 216, 45, 0.14);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.13);
  --orange: #f97316;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  --topbar-h: 60px;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  font-family: 'Nunito', -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

::selection { background: var(--accent); color: #fff; }

a { color: var(--accent-soft); text-decoration: none; }
a:hover { color: #8ba2ff; }

button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #333 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #333; border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------------------
   Layout
   --------------------------------------------------------------------------- */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-spacer { flex: 1; }

.nav-toggle { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.2px;
}
.brand-coin { color: var(--gold); display: flex; }
.brand:hover { color: var(--text); }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}

.main {
  padding: 22px 26px 40px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100%;
}

.footer {
  margin-top: auto;
  padding: 18px 0 6px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
   Sidebar nav
   --------------------------------------------------------------------------- */

.sidenav { display: flex; flex-direction: column; gap: 3px; }

.nav-section {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-faint);
  padding: 12px 10px 4px;
}
.nav-section:first-child { padding-top: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 14.5px;
  transition: background 0.14s, color 0.14s;
}
.nav-link svg { flex-shrink: 0; opacity: 0.85; }
.nav-link:hover { background: var(--surface-light); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent-soft); }
.nav-link .nav-badge {
  margin-left: auto;
  font-size: 11px;
  background: var(--surface-elev);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  color: var(--text-muted);
}

.sidebar-feed { margin-top: auto; min-height: 120px; }

.feed-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-faint);
  padding: 0 10px 8px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(148, 216, 45, 0.5); }
  55% { box-shadow: 0 0 0 5px rgba(148, 216, 45, 0); }
}

.feed-list { display: flex; flex-direction: column; gap: 4px; }

.feed-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--surface-light);
  animation: feedIn 0.3s ease;
}
@keyframes feedIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.feed-item .f-user { color: var(--text-dim); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .f-game { color: var(--text-faint); }
.feed-item .f-pay { margin-left: auto; font-weight: 800; white-space: nowrap; }
.feed-item .f-pay.win { color: var(--green); }
.feed-item .f-pay.loss { color: var(--text-faint); }

/* ---------------------------------------------------------------------------
   Balance chip
   --------------------------------------------------------------------------- */

.balance-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 8px 5px 12px;
}
.coin-icon { color: var(--gold); display: flex; }
.balance-value { font-weight: 800; font-size: 15px; }
.balance-usd { color: var(--text-faint); font-size: 12px; font-weight: 700; }
.balance-chip.bump { animation: balanceBump 0.45s ease; }
@keyframes balanceBump {
  0% { transform: scale(1); }
  35% { transform: scale(1.06); border-color: var(--gold); }
  100% { transform: scale(1); }
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 14.5px;
  padding: 9px 18px;
  cursor: pointer;
  transition: filter 0.13s, background 0.13s, transform 0.06s, box-shadow 0.13s;
  user-select: none;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); box-shadow: 0 4px 14px rgba(66, 99, 235, 0.35); }

.btn-gold { background: var(--gold); color: #221a00; }
.btn-gold:hover:not(:disabled) { filter: brightness(1.07); box-shadow: 0 4px 14px rgba(255, 212, 59, 0.3); }

.btn-green { background: var(--green); color: #142000; }
.btn-green:hover:not(:disabled) { filter: brightness(1.08); }

.btn-red { background: var(--red); color: #fff; }
.btn-red:hover:not(:disabled) { filter: brightness(1.1); }

.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border-light); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-light); color: var(--text); }

.btn-danger-ghost { background: transparent; color: var(--red); border-color: rgba(239, 68, 68, 0.4); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--red-dim); }

.btn-sm { padding: 6px 13px; font-size: 13px; }
.btn-xs { padding: 3px 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 14px 26px; font-size: 17px; border-radius: 12px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 8px;
  padding: 7px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-light); color: var(--text); }

/* ---------------------------------------------------------------------------
   Cards / panels
   --------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.card-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.panel {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-side { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-muted); }

.input, .select, .textarea {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14.5px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input::placeholder { color: var(--text-faint); font-weight: 600; }
.input:disabled { opacity: 0.5; }
.input.invalid { border-color: var(--red); }

.input-group { display: flex; gap: 6px; align-items: stretch; }
.input-group .input { flex: 1; }
.input-suffix { display: flex; align-items: center; padding: 0 12px; background: var(--surface-elev); border-radius: var(--radius); color: var(--text-muted); font-size: 13px; font-weight: 800; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--surface-elev);
  border: 1px solid var(--border-light);
  color: var(--text-dim);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-soft); }
.chip.on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-soft); }

.range-wrap { display: flex; align-items: center; gap: 12px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-elev);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 3px solid var(--surface);
}

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--surface-elev);
  border: 1px solid var(--border-light); border-radius: var(--radius-pill);
  transition: 0.18s; cursor: pointer;
}
.switch .track::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px;
  background: var(--text-muted); border-radius: 50%; transition: 0.18s;
}
.switch input:checked + .track { background: var(--accent-dim); border-color: var(--accent); }
.switch input:checked + .track::before { transform: translateX(20px); background: var(--accent-soft); }

/* ---------------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 480px; }
.table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-faint);
  background: var(--surface-light);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255, 255, 255, 0.018); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }

.pos { color: var(--green); font-weight: 800; }
.neg { color: var(--red); font-weight: 800; }
.gold { color: var(--gold); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }

.win-pill, .loss-pill {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 800;
}
.win-pill { background: var(--green-dim); color: var(--green); }
.loss-pill { background: var(--red-dim); color: var(--red); }

/* ---------------------------------------------------------------------------
   Toasts & modal
   --------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  max-width: 340px;
}
.toast {
  background: var(--surface-elev);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-dim);
  box-shadow: var(--shadow);
  animation: toastIn 0.22s ease;
}
.toast.win { border-left-color: var(--green); color: var(--green); }
.toast.error { border-left-color: var(--red); color: var(--red); }
.toast.gold { border-left-color: var(--gold); color: var(--gold); }
.toast.out { animation: toastOut 0.25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

.modal-root {
  position: fixed; inset: 0; z-index: 900;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(3px);
  padding: 18px;
}
.modal-root.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  font-weight: 800; font-size: 16px;
}
.modal-body { padding: 18px; }

/* ---------------------------------------------------------------------------
   Misc
   --------------------------------------------------------------------------- */

.announcement {
  background: var(--gold-dim);
  border: 1px solid rgba(255, 212, 59, 0.35);
  color: var(--gold);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 700;
  font-size: 13.5px;
  display: flex;
  gap: 9px;
  align-items: center;
}

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat-box {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat-box .s-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-faint); }
.stat-box .s-value { font-size: 21px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }

.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--surface-elev);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-screen {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
}

.hidden { display: none !important; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 800;
  font-size: 14px;
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-soft); border-bottom-color: var(--accent); }

.code-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 12.5px;
  color: var(--text-dim);
  word-break: break-all;
  user-select: all;
}

.copy-btn { cursor: pointer; }

/* User dropdown */
.user-menu { position: relative; }
.user-menu-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; text-transform: uppercase;
}
.dropdown {
  position: absolute; right: 0; top: calc(100% + 7px);
  background: var(--surface-elev);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  min-width: 190px;
  box-shadow: var(--shadow);
  padding: 5px;
  z-index: 60;
  animation: modalIn 0.14s ease;
}
.dropdown-item {
  display: block; width: 100%;
  background: none; border: none; text-align: left;
  color: var(--text-dim);
  padding: 9px 11px;
  border-radius: 8px;
  font-weight: 700; font-size: 14px;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-hover); color: var(--text); }
.dropdown-sep { border: none; border-top: 1px solid var(--border); margin: 5px 8px; }

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 1000px) {
  .grid-side { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: var(--topbar-h); bottom: 0;
    width: min(78vw, 300px);
    z-index: 80;
    transform: translateX(-104%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop {
    position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 75;
  }
  .main { padding: 16px 14px 30px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .balance-usd { display: none; }
  .brand-name { display: none; }
}

@media (max-width: 520px) {
  #loginBtn { display: none; }
  .toasts { left: 14px; right: 14px; max-width: none; }
}
