/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #08090b;
  --bg-soft: #0d0f13;
  --panel: #101318;
  --panel-2: #151920;
  --line: #1e242d;
  --line-soft: #171c23;
  --text: #e7eaee;
  --text-dim: #98a1ad;
  --text-faint: #626c79;
  --accent: #3ddc97;
  --accent-dim: #1f8f63;
  --danger: #f2606a;
  --warn: #e2b04a;
  --info: #6aa9f5;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(61, 220, 151, 0.06), transparent 60%),
    radial-gradient(700px 400px at 90% 0%, rgba(106, 169, 245, 0.05), transparent 55%);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
::selection { background: rgba(61, 220, 151, 0.28); }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.pos { color: var(--accent); }
.neg { color: var(--danger); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }

/* ------------------------------------------------------------------ boot */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 100;
  transition: opacity 0.35s var(--ease);
}
.boot.gone { opacity: 0; pointer-events: none; }
.boot-mark { color: var(--accent); font-size: 28px; animation: pulse 1.2s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.94); } 50% { opacity: 1; transform: scale(1.06); } }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 24px;
  height: 58px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(8, 9, 11, 0.82);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; letter-spacing: -0.02em; }
.brand-mark { color: var(--accent); }
.brand-name { font-size: 15px; }

.nav { display: flex; gap: 2px; margin-left: 6px; }
.nav a {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  transition: color 0.15s, background 0.15s;
}
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a.active { color: var(--text); background: var(--panel-2); }

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.online {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.online .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.balance {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}
.balance-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-faint); }
.balance strong { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.balance.flash { animation: flash 0.6s var(--ease); }
@keyframes flash { 0% { background: rgba(61, 220, 151, 0.22); } 100% { background: var(--panel); } }

.lang-switch { position: relative; }
.lang-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-dim);
}
.lang-btn:hover { color: var(--text); border-color: #2a3341; }
.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 190px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 60;
}
.lang-menu li {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
}
.lang-menu li:hover { background: var(--panel-2); }
.lang-menu li[aria-selected="true"] { color: var(--accent); }
.lang-menu .lang-native { flex: 1; }
.lang-menu .lang-tag { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }

.user-slot { display: flex; align-items: center; gap: 8px; }

/* --------------------------------------------------------------- avatars */
.avatar {
  --hue: 150;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600;
  color: hsl(var(--hue) 70% 82%);
  background: linear-gradient(150deg, hsl(var(--hue) 45% 22%), hsl(var(--hue) 55% 13%));
  border: 1px solid hsl(var(--hue) 40% 30%);
  flex: none;
}
.avatar.lg { width: 54px; height: 54px; font-size: 20px; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }

/* ----------------------------------------------------------------- layout */
.view { flex: 1; width: 100%; max-width: 1220px; margin: 0 auto; padding: 26px 24px 60px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 5px 0 0; color: var(--text-dim); font-size: 14px; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
}
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.card-head h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); font-weight: 600; }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); }
.field .hint { font-size: 12px; color: var(--text-faint); }
.input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, select:focus, textarea:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.12);
}
.input.num { font-family: var(--mono); }
textarea { resize: vertical; min-height: 74px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: #1b2029; border-color: #2a3341; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #05140d; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #4ee9a6; border-color: #4ee9a6; }
.btn.admin {
  background: #d93c46;
  border-color: #d93c46;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 0 0 rgba(217, 60, 70, 0.5);
}
.btn.admin:hover:not(:disabled) { background: #ef5560; border-color: #ef5560; }
.btn.admin::before { content: "●"; font-size: 9px; opacity: 0.85; }
.btn.danger { background: transparent; border-color: rgba(242, 96, 106, 0.4); color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: rgba(242, 96, 106, 0.1); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.xl { padding: 15px 20px; font-size: 16px; }

.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; }
.seg button {
  padding: 5px 13px; border: 0; background: transparent; border-radius: 999px;
  color: var(--text-dim); cursor: pointer; font-size: 13px;
}
.seg button.active { background: var(--panel-2); color: var(--text); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); position: relative; cursor: pointer; transition: background 0.2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-faint); transition: transform 0.2s var(--ease), background 0.2s; }
.switch input:checked { background: rgba(61, 220, 151, 0.22); border-color: var(--accent-dim); }
.switch input:checked::after { transform: translateX(16px); background: var(--accent); }

/* ------------------------------------------------------------------ table */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; padding: 9px 14px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); font-weight: 600;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.table td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
.table .right { text-align: right; }
.table .you td { background: rgba(61, 220, 151, 0.05); }
.table-wrap { overflow-x: auto; }

.empty { padding: 26px 14px; text-align: center; color: var(--text-faint); font-size: 13.5px; }

/* ------------------------------------------------------------------- game */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }

.stage {
  position: relative;
  background: linear-gradient(180deg, #0c0f14, #0a0c10);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 380px;
}
#crash-canvas { display: block; width: 100%; height: 380px; }
.stage-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; gap: 6px;
}
.multiplier {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(42px, 7vw, 76px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  text-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  transition: color 0.2s;
}
.multiplier.crashed { color: var(--danger); }
.multiplier.won { color: var(--accent); }
.stage-status { font-size: 13.5px; color: var(--text-dim); letter-spacing: 0.02em; }
.stage-badge {
  position: absolute; top: 14px; left: 14px;
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-family: var(--mono); color: var(--text-faint);
}
.countdown-track { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line-soft); }
.countdown-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.1s linear; }

/* ------------------------------------------------------------------- home */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.game-card {
  --game-accent: var(--accent);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.18s var(--ease), transform 0.18s var(--ease);
}
.game-card:hover { border-color: color-mix(in srgb, var(--game-accent) 45%, var(--line)); transform: translateY(-2px); }
.game-art {
  height: 132px;
  padding: 14px 18px;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--game-accent) 14%, transparent), transparent 70%),
    var(--bg-soft);
  border-bottom: 1px solid var(--line-soft);
}
.game-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.game-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-title h3 { font-size: 17px; }
.game-desc { margin: 0; color: var(--text-dim); font-size: 13.5px; flex: 1; }
.game-facts { display: flex; gap: 18px; flex-wrap: wrap; }
.game-facts > div { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.game-facts strong { font-size: 14px; }
.game-cta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.game-play { color: var(--game-accent); font-size: 13.5px; font-weight: 600; }
.game-play::after { content: " →"; }

/* ------------------------------------------------------------------- chat */
.chat-shell {
  display: flex; flex-direction: column;
  height: min(64vh, 620px);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.chat-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-row { display: flex; gap: 10px; align-items: flex-start; }
.chat-row.mine .chat-name { color: var(--accent); }
.chat-row.special .chat-body { color: var(--text); }
.chat-head { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
.chat-name { font-weight: 600; font-size: 13px; }
.chat-body { font-size: 14px; word-break: break-word; }
.chat-tip {
  border: 0; background: transparent; color: var(--text-faint);
  cursor: pointer; font-size: 11.5px; padding: 0 2px;
}
.chat-tip:hover { color: var(--accent); }
.chat-request {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; margin-top: 2px;
  border: 1px solid rgba(226, 176, 74, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(226, 176, 74, 0.08);
  font-size: 13.5px;
}
.chat-ask { font-weight: 600; color: var(--warn); }
.chat-gift {
  padding: 6px 10px; margin-top: 2px;
  border-radius: var(--radius-sm);
  background: rgba(61, 220, 151, 0.1);
  color: var(--accent);
  font-size: 13.5px;
}
.chat-composer {
  display: flex; gap: 8px; padding: 12px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-soft);
}
.chat-composer .input { flex: 1; }

/* ------------------------------------------------------------------ loans */
.loan-row { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.loan-row:last-child { border-bottom: 0; }

/* --------------------------------------------------------------- fairness */
.fair-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.fair-card .code { display: block; line-height: 1.5; }

/* ------------------------------------------------------------------ slots */
.slot-stage {
  min-height: 470px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 22px;
}
.slot-machine { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.slot-window {
  display: flex; gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(226, 176, 74, 0.07), transparent 65%),
    var(--bg-soft);
  max-width: 100%;
}
.slot-reel { display: flex; flex-direction: column; gap: 8px; }
.slot-reel.spinning .slot-cell { filter: blur(1.4px); opacity: 0.75; transform: translateY(-1px); }
.slot-reel.landed .slot-cell { animation: reel-stop 0.26s var(--ease); }
@keyframes reel-stop {
  0% { transform: translateY(-9px); }
  60% { transform: translateY(3px); }
  100% { transform: none; }
}
.slot-cell {
  width: clamp(44px, 9vw, 66px);
  height: clamp(44px, 9vw, 66px);
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--panel);
  font-size: clamp(20px, 4vw, 30px);
  transition: opacity 0.18s, border-color 0.18s, background 0.18s;
}
.slot-cell.win {
  border-color: var(--warn);
  background: rgba(226, 176, 74, 0.14);
  box-shadow: 0 0 16px -6px var(--warn);
}
.slot-cell.faded { opacity: 0.32; }
.slot-status { font-size: 14px; min-height: 22px; font-family: var(--mono); }

.paytable-grid {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 4px 12px;
  align-items: center;
  font-size: 12.5px;
}
.slot-symbol { display: flex; align-items: center; gap: 8px; }
.slot-glyph { font-size: 17px; }
.payline-mini { display: flex; flex-direction: column; gap: 3px; }
.payline-row { display: flex; gap: 3px; }
.payline-dot { width: 9px; height: 9px; border-radius: 2px; background: var(--panel-2); }
.payline-dot.on { background: var(--accent); }

/* ------------------------------------------------------------------ mines */
.mines-stage { min-height: 470px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 20px; }
.mines-status { display: flex; align-items: baseline; gap: 14px; font-family: var(--mono); }
.mines-status .num { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; }
.mines-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: min(400px, 100%); }
.mine-tile {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.14s, transform 0.08s, border-color 0.14s;
}
.mine-tile:hover:not(:disabled) { background: #1e242d; border-color: #2c3644; }
.mine-tile:active:not(:disabled) { transform: scale(0.96); }
.mine-tile:disabled { cursor: default; }
.mine-tile.safe { background: rgba(61, 220, 151, 0.16); border-color: var(--accent-dim); color: var(--accent); }
.mine-tile.bomb { background: rgba(217, 60, 70, 0.22); border-color: rgba(217, 60, 70, 0.6); color: #ff9aa0; }
.mine-tile.dim { opacity: 0.35; }

/* -------------------------------------------------------------- blackjack */
.bj-stage {
  min-height: 470px;
  display: flex; flex-direction: column; justify-content: center; gap: 30px;
  padding: 26px;
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(61, 220, 151, 0.05), transparent 70%),
    linear-gradient(180deg, #0c0f14, #0a0c10);
}
.felt { display: flex; flex-direction: column; gap: 28px; }
.hand { display: flex; flex-direction: column; gap: 10px; }
.hand-label { display: flex; align-items: center; gap: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.hand-label .num { color: var(--text); font-size: 15px; letter-spacing: 0; }
.cards { display: flex; gap: 8px; flex-wrap: wrap; }
.card-face {
  width: 54px; height: 76px;
  border-radius: 8px;
  background: #f2f4f7;
  color: #14181f;
  border: 1px solid #cdd4dd;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: var(--mono);
  box-shadow: 0 6px 14px -10px rgba(0, 0, 0, 0.9);
}
.card-face.red { color: #c02c39; }
.card-face.back {
  background: repeating-linear-gradient(45deg, #1a2029, #1a2029 5px, #222a36 5px, #222a36 10px);
  border-color: var(--line);
}
.card-rank { font-size: 17px; font-weight: 600; }
.card-suit { font-size: 15px; }

/* Only freshly dealt cards animate; a re-render must not shuffle the felt. */
.card-face.dealt { animation: deal 0.3s var(--ease) both; }
.card-face.flip { animation: flip 0.42s var(--ease) both; }
@keyframes deal {
  from { opacity: 0; transform: translate(22px, -26px) rotate(-8deg) scale(0.9); }
  to { opacity: 1; transform: none; }
}
@keyframes flip {
  0% { transform: rotateY(90deg) scale(0.94); background: #1a2029; }
  55% { transform: rotateY(0deg) scale(1.04); }
  100% { transform: none; background: #f2f4f7; }
}

.hands-row { display: flex; gap: 16px; flex-wrap: wrap; }
.hands-row.multi .hand-box {
  padding: 10px 12px;
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.015);
  transition: border-color 0.18s, background 0.18s;
}
.hands-row.multi .hand-box.active { border-color: var(--accent-dim); background: rgba(61, 220, 151, 0.06); }
.hands-row.multi .hand-box.won { border-color: rgba(61, 220, 151, 0.4); }
.hands-row.multi .hand-box.lost { opacity: 0.55; }
.hand-result { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; }
.bj-insurance { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.bj-result { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; animation: deal 0.3s var(--ease) both; }
.bj-outcome { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.bj-mult { font-size: 20px; font-weight: 600; }

/* ------------------------------------------------------------------ horses */
.track-stage { min-height: 470px; padding: 18px; display: flex; align-items: center; }
.track { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.race-banner {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 4px;
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--bg-soft);
  font-size: 13.5px;
}
.race-go { font-weight: 600; letter-spacing: 0.02em; animation: pulse 1s var(--ease) infinite; }
.lane { display: grid; grid-template-columns: 170px 1fr 74px; align-items: center; gap: 12px; }
.lane-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; min-width: 0; }
.lane-no {
  width: 20px; height: 20px; border-radius: 5px; flex: none;
  display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px;
}
.lane-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-odds { color: var(--text-faint); font-size: 11.5px; margin-left: auto; }
.lane-track {
  height: 22px; border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, transparent, transparent 26px, rgba(255, 255, 255, 0.035) 26px, rgba(255, 255, 255, 0.035) 27px),
    var(--bg-soft);
  border: 1px solid var(--line-soft);
  position: relative; overflow: hidden;
}
.lane-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, rgba(61, 220, 151, 0.1), rgba(61, 220, 151, 0.26));
  position: relative;
}
.finish-line {
  position: absolute; top: 0; bottom: 0; right: 3px; width: 3px;
  background: repeating-linear-gradient(180deg, #e7eaee, #e7eaee 3px, #1a2029 3px, #1a2029 6px);
  opacity: 0.5;
}
.runner {
  position: absolute; right: -2px; top: 50%;
  transform: translateY(-50%) scaleX(-1);
  font-size: 15px;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.6));
}
.lane.picked .lane-no { border-color: var(--accent-dim); color: var(--accent); }
.lane.picked .lane-fill { background: linear-gradient(90deg, rgba(61, 220, 151, 0.2), rgba(61, 220, 151, 0.5)); }
.lane.finished .lane-fill { filter: saturate(0.7); }
.lane.winner .lane-name { color: var(--accent); font-weight: 600; }
.lane.winner .lane-fill { background: linear-gradient(90deg, rgba(61, 220, 151, 0.3), rgba(61, 220, 151, 0.68)); filter: none; }
.lane.winner .lane-pos { color: var(--accent); }
.lane-result { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; }
.lane-time { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); }
.lane-pos { font-family: var(--mono); font-size: 12px; color: var(--text-faint); text-align: right; min-width: 12px; }

.horse-picker { display: flex; flex-direction: column; gap: 5px; max-height: 260px; overflow-y: auto; }
.horse-option {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-soft); color: var(--text);
  cursor: pointer; font-size: 13px;
  transition: border-color 0.14s, background 0.14s;
}
.horse-option:hover { background: var(--panel-2); }
.horse-option.active { border-color: var(--accent-dim); background: rgba(61, 220, 151, 0.1); }
.horse-name { flex: 1; text-align: left; }
.horse-odds { font-size: 12.5px; }
.horse-prob { font-size: 11px; width: 34px; text-align: right; }

/* ------------------------------------------------------------------ wheel */
.wheel-stage { min-height: 470px; display: grid; place-items: center; padding: 8px; }
#wheel-canvas { display: block; width: 100%; height: 470px; }

/* ----------------------------------------------------------------- plinko */
.plinko-stage { min-height: 460px; padding: 4px; }
#plinko-canvas { display: block; width: 100%; height: 460px; }

.payout-table { margin-top: 6px; }
.payout-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 4px 0; font-size: 12.5px;
}
.payout-chip {
  min-width: 62px; text-align: center;
  padding: 3px 8px; border-radius: 6px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
}

.history-strip {
  display: flex;
  gap: 6px;
  padding: 12px 2px 0;
  flex-wrap: nowrap;
  overflow: hidden;
  /* No scrollbar: chips past the edge simply fade out. */
  mask-image: linear-gradient(90deg, #000 88%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent 100%);
}
.history-strip .chip { flex: none; }
.chip {
  padding: 4px 9px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-dim);
  white-space: nowrap;
  cursor: pointer;
}
.chip.low { color: var(--danger); border-color: rgba(242, 96, 106, 0.28); }
.chip.mid { color: var(--warn); border-color: rgba(226, 176, 74, 0.26); }
.chip.high { color: var(--accent); border-color: rgba(61, 220, 151, 0.3); }

.bet-panel { display: flex; flex-direction: column; gap: 14px; }
.amount-row { display: flex; gap: 6px; }
.amount-row .btn { flex: 1; padding: 6px 0; font-size: 12px; }
.cash-btn { position: relative; overflow: hidden; }
.bet-state {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  font-size: 13px;
}

.players-list { max-height: 300px; overflow-y: auto; }
.player-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.player-row:last-child { border-bottom: 0; }
.player-row .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row.win { background: rgba(61, 220, 151, 0.06); }
.player-row.bust { opacity: 0.5; }
.player-row .mult { font-family: var(--mono); width: 62px; text-align: right; }
.player-row .amt { font-family: var(--mono); width: 84px; text-align: right; color: var(--text-dim); }

/* -------------------------------------------------------------------- KPI */
.kpi {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.kpi .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); }
.kpi .value { margin-top: 6px; font-family: var(--mono); font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .sub { margin-top: 3px; font-size: 12px; color: var(--text-faint); }

.level-bar { height: 5px; border-radius: 999px; background: var(--panel-2); overflow: hidden; margin-top: 8px; }
.level-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 78px 1fr 52px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-track { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.4s var(--ease); }
.bar-fill.bust { background: var(--danger); }

.spark { width: 100%; height: 130px; display: block; }
.mini-spark { width: 100%; height: 46px; display: block; }

/* --------------------------------------------------------------- friends */
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.list-row .meta { font-size: 12.5px; color: var(--text-faint); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: none; }
.status-dot.on { background: var(--accent); box-shadow: 0 0 7px var(--accent); }

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono);
}
.badge.accent { color: var(--accent); border-color: rgba(61, 220, 151, 0.3); }

.search-results { margin-top: 10px; }

/* ----------------------------------------------------------------- auth */
.auth-wrap { max-width: 400px; margin: 6vh auto 0; }
.auth-wrap .card { padding: 26px; }
.auth-wrap h1 { font-size: 21px; }
.auth-wrap p.sub { margin: 6px 0 20px; color: var(--text-dim); font-size: 14px; }
.auth-alt { margin-top: 16px; text-align: center; font-size: 13.5px; color: var(--text-dim); }
.auth-alt a { color: var(--accent); }
.form-error {
  margin-bottom: 14px; padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(242, 96, 106, 0.1);
  border: 1px solid rgba(242, 96, 106, 0.28);
  color: #ffb4b9; font-size: 13px;
}

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  padding: 11px 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  min-width: 220px;
  animation: slide-in 0.25s var(--ease);
}
.toast.ok { border-left-color: var(--accent); }
.toast.err { border-left-color: var(--danger); }
.toast.fade { opacity: 0; transform: translateX(8px); transition: all 0.25s var(--ease); }
@keyframes slide-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4, 5, 7, 0.72);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade 0.16s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(640px, 100%);
  max-height: 86vh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { font-size: 18px; flex: 1; }

/* ---------------------------------------------------------------- footer */
.footer {
  padding: 18px 24px 26px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  border-top: 1px solid var(--line-soft);
}
.footer a { color: var(--text-dim); }
.footer a:hover { color: var(--accent); }
.footer-sep { margin: 0 8px; }

.prose p { color: var(--text-dim); font-size: 14px; margin: 0 0 12px; }
.prose code, .code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  padding: 2px 6px; border-radius: 6px;
  word-break: break-all;
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 940px) {
  .game-layout { grid-template-columns: 1fr; }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .topbar { gap: 10px; padding: 0 14px; overflow-x: auto; }
  .nav { order: 3; }
  .brand-name { display: none; }
  .view { padding: 18px 14px 48px; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .balance-label { display: none; }
  #crash-canvas, .stage { min-height: 300px; height: 300px; }
  .plinko-stage, #plinko-canvas { min-height: 360px; height: 360px; }
  .wheel-stage, #wheel-canvas { min-height: 340px; height: 340px; }
  .mines-stage, .bj-stage, .track-stage { min-height: auto; height: auto; }
  .lane { grid-template-columns: 120px 1fr 22px; }
  .card-face { width: 46px; height: 66px; }
}
