:root {
  --bg: #0b0b0e;
  --panel: #141418;
  --panel2: #1a1a20;
  --line: #2a2a33;
  --text: #f3f3f5;
  --muted: #8b8b98;
  --green: #22c55e;
  --green2: #16a34a;
  --gold: #e8c56a;
  --danger: #ef4444;
  --radius: 12px;
  --rail: 220px;
  --chat: 300px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Space Grotesk", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: var(--rail) 1fr var(--chat);
  min-height: 100vh;
  background:
    radial-gradient(900px 400px at 20% -10%, rgba(34,197,94,0.12), transparent 60%),
    radial-gradient(700px 300px at 80% 0%, rgba(232,197,106,0.08), transparent 55%),
    var(--bg);
}

/* Rail */
.rail {
  border-right: 1px solid var(--line);
  background: rgba(10,10,12,0.9);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.logo { display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0.5rem 1rem; font-family: var(--display); font-weight: 700; font-size: 1.2rem; }
.logo img { width: 32px; height: 32px; border-radius: 8px; }
.rail-label { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; padding: 0 0.65rem; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; overflow: auto; flex: 1; }
.rail-nav button, .rail-nav a {
  display: flex; align-items: center; gap: 0.65rem;
  background: transparent; border: 0; color: #c9c9d2;
  padding: 0.65rem 0.7rem; border-radius: 10px; cursor: pointer; text-align: left;
}
.rail-nav button:hover, .rail-nav a:hover { background: var(--panel2); color: #fff; }
.rail-nav button.active { background: rgba(34,197,94,0.15); color: #fff; }
.rail-nav svg { width: 18px; height: 18px; opacity: 0.85; }
.rail-foot { padding: 0.75rem 0.5rem 0; border-top: 1px solid var(--line); font-size: 0.78rem; color: var(--muted); }
.bot-chip { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.35rem; }
.bot-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #666; }
.bot-chip.online .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.bot-chip.offline .dot { background: #a1a1aa; }

/* Stage */
.stage { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--line);
  background: rgba(12,12,14,0.75); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5;
}
.top-links { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.top-links a {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.45rem 0.7rem; border-radius: 999px; color: #d4d4dc; font-size: 0.82rem; font-weight: 600;
}
.top-links a:hover { background: var(--panel2); }
.top-links a.gold { color: var(--gold); }
.top-links svg { width: 15px; height: 15px; }
.wallet-bar, #guest-actions, #user-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.bal {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.4rem 0.75rem; font-weight: 700;
}
.user-menu { display: flex; align-items: center; gap: 0.4rem; }
.avatar { width: 28px; height: 28px; border-radius: 8px; image-rendering: pixelated; }

.main { padding: 1.25rem; max-width: 1100px; }
.banner {
  display: grid; grid-template-columns: 1.4fr 0.6fr; gap: 1rem; align-items: center;
  background: linear-gradient(120deg, #163222, #1a1a20 55%, #2a2110);
  border: 1px solid var(--line); border-radius: 18px; padding: 1.5rem 1.75rem; margin-bottom: 1.5rem;
  overflow: hidden;
}
.banner h1 { font-family: var(--display); margin: 0 0 0.5rem; font-size: clamp(1.6rem, 3vw, 2.2rem); }
.banner p { color: #d5d5de; margin: 0 0 1rem; max-width: 38ch; }
.banner-art { width: min(180px, 100%); justify-self: end; filter: drop-shadow(0 12px 30px rgba(0,0,0,0.45)); }
.section-title { font-family: var(--display); margin: 1.25rem 0 0.5rem; font-size: 1.15rem; }
.tiny { font-size: 0.8rem; margin-top: -0.2rem; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.85rem;
}
.tile {
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel);
  padding: 0; cursor: pointer; color: #fff; text-align: left;
  transition: transform 0.15s ease, border-color 0.15s;
}
.tile:hover { transform: translateY(-2px); border-color: #3f3f4a; }
.tile span { display: block; padding: 0.65rem 0.75rem 0.8rem; font-weight: 700; font-size: 0.92rem; }
.tile-art { height: 120px; background: #222; }
.tile .tag {
  position: absolute; margin: 0.5rem; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.06em;
  background: var(--danger); color: #fff; padding: 0.2rem 0.4rem; border-radius: 4px;
}
.tile-wrap { position: relative; }
.t-bj { background: linear-gradient(160deg,#0f3d2e,#1c1c24); }
.t-mines { background: linear-gradient(160deg,#4a1d1d,#1c1c24); }
.t-roulette { background: linear-gradient(160deg,#3b1d4a,#1c1c24); }
.t-limbo { background: linear-gradient(160deg,#1d3a4a,#1c1c24); }
.t-plinko { background: linear-gradient(160deg,#1d4a3a,#1c1c24); }
.t-dice { background: linear-gradient(160deg,#3a4a1d,#1c1c24); }
.t-cases { background: linear-gradient(160deg,#4a3a1d,#1c1c24); }
.t-chicken { background: linear-gradient(160deg,#4a2a1d,#1c1c24); }
.t-keno { background: linear-gradient(160deg,#1d2a4a,#1c1c24); }
.t-slot { background: linear-gradient(160deg,#204020,#2a1f10); }

.live-table { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel); }
.live-head, .live-row {
  display: grid; grid-template-columns: 1.1fr 1.2fr 1fr 0.7fr 1fr;
  gap: 0.5rem; padding: 0.7rem 0.9rem; font-size: 0.85rem;
}
.live-head { color: var(--muted); border-bottom: 1px solid var(--line); font-weight: 600; }
.live-row { border-bottom: 1px solid rgba(255,255,255,0.04); }
.win { color: var(--green); }
.lose { color: #f87171; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem;
}
.play-layout { max-width: 720px; }
.back-link {
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.35rem; margin-bottom: 0.75rem;
}
.label { display: block; color: var(--muted); font-size: 0.8rem; margin: 0.75rem 0 0.35rem; }
.field {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); color: #fff;
  border-radius: 10px; padding: 0.7rem 0.8rem;
}
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.btn {
  border: 0; border-radius: 10px; padding: 0.65rem 1rem; cursor: pointer; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; color: #fff;
}
.btn-primary { background: var(--green); color: #04140a; }
.btn-primary:hover { background: #4ade80; }
.btn-ghost { background: var(--panel2); border: 1px solid var(--line); color: #e7e7ee; }
.btn-danger { background: #7f1d1d; }
.btn-sm { padding: 0.45rem 0.7rem; font-size: 0.85rem; border-radius: 999px; }
.btn-block { width: 100%; margin-top: 0.85rem; }
.active-dir { outline: 2px solid var(--green); }
.result-box {
  min-height: 88px; border-radius: 12px; background: #0f0f12; border: 1px solid var(--line);
  display: grid; place-items: center; text-align: center; margin-bottom: 0.5rem;
}
.result-box .big { font-family: var(--display); font-size: 2rem; font-weight: 700; }
.result-box.win { border-color: rgba(34,197,94,0.5); }
.result-box.lose { border-color: rgba(239,68,68,0.4); }
.mines-grid, .keno-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.35rem; margin-top: 0.6rem;
}
.keno-grid { grid-template-columns: repeat(8, 1fr); }
.mine-cell, .keno-cell {
  aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2);
  cursor: pointer; color: #ddd;
}
.mine-cell.picked, .keno-cell.picked { background: rgba(34,197,94,0.25); border-color: var(--green); }
.mine-cell.boom { background: #7f1d1d; }
.mine-cell.safe { background: #14532d; }

.slots-machine {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem;
  background: linear-gradient(180deg, #1a2418, #0e100f); border: 2px solid #3f5a3a;
  border-radius: 14px; padding: 0.75rem; margin-top: 0.75rem; min-height: 180px;
}
.reel {
  background: #0a0c0a; border-radius: 8px; overflow: hidden; border: 1px solid #2a3328;
  display: flex; flex-direction: column;
}
.sym {
  flex: 1; display: grid; place-items: center; font-size: 1.6rem; border-bottom: 1px solid #1c221b;
  min-height: 52px;
}
.fair-box { margin-top: 1rem; color: var(--muted); font-size: 0.8rem; }
.fair-box pre {
  white-space: pre-wrap; word-break: break-all; background: #0f0f12; border-radius: 8px;
  padding: 0.75rem; border: 1px solid var(--line); color: #b7b7c2;
}

/* Chat */
.chat {
  border-left: 1px solid var(--line); background: rgba(10,10,12,0.92);
  display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0;
}
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.9rem 1rem; border-bottom: 1px solid var(--line);
}
.online { color: var(--muted); font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.35rem; }
.online .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.discord-pill {
  margin: 0.75rem 1rem 0; background: #5865F2; color: #fff; border-radius: 10px;
  padding: 0.65rem 0.8rem; font-weight: 700; text-align: center; font-size: 0.9rem;
}
.chat-msgs { flex: 1; overflow: auto; padding: 0.85rem 1rem; display: flex; flex-direction: column; gap: 0.65rem; }
.chat-line { font-size: 0.86rem; line-height: 1.35; }
.chat-line strong { color: #fff; margin-right: 0.35rem; }
.chat-form { display: flex; gap: 0.4rem; padding: 0.75rem; border-top: 1px solid var(--line); }
.chat-form .field { flex: 1; }

/* Modals */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: grid; place-items: center;
  z-index: 50; padding: 1rem;
}
.modal {
  width: min(440px, 100%); background: #16161c; border: 1px solid var(--line);
  border-radius: 16px; padding: 1.25rem;
}
.modal h3, .modal h4 { font-family: var(--display); margin: 0 0 0.5rem; }
.signin-kicker { font-size: 0.7rem; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 0.35rem; }
.signin-legal { font-size: 0.82rem; line-height: 1.45; }
.wait-box { text-align: center; padding: 0.85rem; }
.wait-pulse { color: var(--gold); font-weight: 700; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; margin: 0 auto 0.5rem;
  border: 3px solid #333; border-top-color: var(--green); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.cmd {
  background: #0f0f12; border: 1px solid var(--line); border-radius: 10px; padding: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 0.5rem 0;
}
.error { color: #fca5a5; font-size: 0.85rem; }
.ok { color: #86efac; }
.muted { color: var(--muted); }

@media (max-width: 1100px) {
  .app { grid-template-columns: 72px 1fr; }
  .chat { display: none; }
  .rail-nav button span, .logo span, .rail-label, .rail-foot .edge { display: none; }
  .rail-nav button { justify-content: center; }
  .banner { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; overflow: auto; width: 100%; }
  .rail-nav { flex-direction: row; }
  .top { flex-direction: column; align-items: stretch; }
}
