:root {
  --bg: #0b1013;
  --panel: #151b20;
  --panel-2: #1c242a;
  --panel-3: #232d34;
  --line: rgba(255, 255, 255, 0.06);
  --text: #e8eef0;
  --muted: #8b989f;
  --green: #3ddc84;
  --green-d: #22a862;
  --orange: #f2892b;
  --blue: #4c8dff;
  --red: #ff5c6c;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% 100%, rgba(61, 220, 132, 0.12), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(61, 220, 132, 0.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font-size: 14px;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.row-gap { display: flex; gap: 8px; align-items: center; }
.row-gap.end { justify-content: flex-end; margin-top: 14px; }
.wide { width: 100%; }

/* buttons */
.btn { border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 700; transition: filter .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-green { background: var(--green); color: #062313; }
.btn-green:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--panel-3); }
.btn-ghost:hover { background: #2b363e; }
.btn.big { padding: 13px 16px; font-size: 15px; }
.icon-btn { background: var(--panel-3); border: 0; border-radius: 10px; width: 38px; height: 38px; }
.pill { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-weight: 700; }
.link { color: var(--green); font-weight: 600; text-decoration: none; font-size: 13px; }
.link:hover { text-decoration: underline; }

.chip-ico { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--green); box-shadow: inset 0 0 0 3px #1a7a46; vertical-align: -2px; flex: none; }

/* coin badges */
.coin { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-weight: 800; color: #fff; flex: none; }
.coin.h { background: radial-gradient(circle, var(--green) 55%, #17824a 56%); box-shadow: 0 0 0 3px rgba(61,220,132,.25); }
.coin.t { background: radial-gradient(circle, var(--orange) 55%, #a85410 56%); box-shadow: 0 0 0 3px rgba(242,137,43,.25); }
.coin.b { background: radial-gradient(circle, var(--blue) 55%, #2350a8 56%); box-shadow: 0 0 0 3px rgba(76,141,255,.25); }
.coin.sm { width: 20px; height: 20px; font-size: 10px; box-shadow: none; }

/* topbar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; margin: 10px; padding: 10px 16px; background: rgba(18, 24, 28, 0.9); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--radius); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--green); text-decoration: none; font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.brand span { color: var(--text); }
.brand b { color: var(--green); }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: flex; gap: 8px; align-items: center; padding: 9px 14px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); background: rgba(61,220,132,.08); border-color: rgba(61,220,132,.45); }
.tabs .ico { color: var(--green); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-area { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; background: transparent; border: 0; padding: 4px 6px; border-radius: 10px; font-weight: 700; }
.user-chip:hover { background: var(--panel-3); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-3); object-fit: cover; flex: none; }
.avatar.lg { width: 40px; height: 40px; }
.avatar.init { display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #08130d; }
.chat-toggle { display: none; }

/* layout */
.layout { display: grid; grid-template-columns: 330px 1fr; gap: 12px; padding: 0 10px 10px; height: calc(100vh - 90px); }
.main { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; min-width: 0; padding-bottom: 20px; }

/* chat */
.chat { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-height: 0; }
.chat-head { display: flex; justify-content: space-between; align-items: center; font-size: 15px; margin-bottom: 12px; }
.online { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.online i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.drop { display: grid; grid-template-columns: 70px 1fr; gap: 6px 12px; padding: 14px; background: var(--panel-2); }
.drop-art { display: grid; place-items: center; font-size: 34px; color: var(--green); background: rgba(61,220,132,.08); border-radius: 12px; }
.drop-amount { display: flex; align-items: center; gap: 6px; font-size: 20px; }
.drop .wide { grid-column: 1 / -1; margin-top: 6px; }
.messages { list-style: none; margin: 10px 0; padding: 0 4px 0 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.msg { display: grid; grid-template-columns: 36px 1fr; gap: 10px; }
.msg .avatar { width: 36px; height: 36px; }
.msg-name { font-weight: 700; color: #7fb2ff; font-size: 13px; }
.msg-name.you { color: var(--green); }
.msg-text { overflow-wrap: anywhere; }
.chat-form { display: flex; background: var(--panel-2); border-radius: 10px; padding: 4px 4px 4px 12px; }
.chat-form input { flex: 1; background: transparent; border: 0; outline: 0; padding: 8px 0; }
.chat-form button { background: transparent; border: 0; color: var(--muted); padding: 0 10px; }
.chat-note { margin: 8px 2px 0; }

/* banner */
.banner { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; border-radius: var(--radius); background: linear-gradient(90deg, rgba(61,220,132,.14), rgba(61,220,132,.03)); border: 1px solid rgba(61,220,132,.25); border-left: 3px solid var(--green); }
.banner b { color: var(--green); font-size: 15px; }

/* coinflip */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 20px; display: flex; align-items: center; gap: 6px; }
.stat span:not(.chip-ico) { color: var(--muted); }
.lobby { padding: 14px; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.last100 { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.last100 b { color: var(--text); }
.games { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.game { display: grid; grid-template-columns: 1.6fr 1fr 80px auto; align-items: center; gap: 12px; padding: 14px 18px; background: var(--panel-2); border-radius: 12px; animation: in .3s ease; }
.game.mine { box-shadow: inset 0 0 0 1px rgba(61,220,132,.4); }
.vs { display: flex; align-items: center; gap: 10px; min-width: 0; }
.slot { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; }
.slot .avatar { width: 44px; height: 44px; }
.slot .coin.sm { position: absolute; left: -4px; bottom: -4px; }
.slot-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.slot.empty .avatar { border: 2px dashed #3a464e; background: transparent; }
.game-val { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 16px; justify-content: center; }
.game-state { display: grid; place-items: center; }
.game .btn { min-width: 76px; }
@keyframes in { from { opacity: 0; transform: translateY(-4px); } }

.side-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.side { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 700; }
.side.on { border-color: var(--green); background: rgba(61,220,132,.08); }

.flip-players { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0 18px; }
.fp { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; min-width: 110px; }
.fp .avatar { width: 56px; height: 56px; }
.fp.win .avatar { box-shadow: 0 0 0 3px var(--green); }
.coin3d-wrap { perspective: 800px; height: 140px; display: grid; place-items: center; }
.coin3d { width: 120px; height: 120px; position: relative; transform-style: preserve-3d; transition: transform 2.6s cubic-bezier(.2,.75,.25,1); }
.coin3d .face { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; font-size: 46px; font-weight: 800; backface-visibility: hidden; color: #fff; }
.coin3d .face.h { background: radial-gradient(circle, var(--green) 58%, #17824a 59%); }
.coin3d .face.t { background: radial-gradient(circle, var(--orange) 58%, #a85410 59%); transform: rotateY(180deg); }
.flip-result { min-height: 24px; font-weight: 800; font-size: 18px; }
.flip-result.win { color: var(--green); }
.flip-result.lose { color: var(--red); }

/* jackpot */
.jp-wrap { position: relative; width: min(420px, 80vw); aspect-ratio: 1; margin: 20px auto 10px; }
.jp-ring { position: absolute; inset: 0; border-radius: 50%; background: var(--panel-2); -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%); mask: radial-gradient(circle, transparent 62%, #000 63%); }
.jp-ring.spin { transition: transform 6s cubic-bezier(.15,.8,.2,1); }
.jp-pointer { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 14px solid transparent; border-right: 14px solid transparent; border-top: 24px solid #fff; z-index: 2; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.jp-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 6px; }
.jp-pot { font-size: 34px; font-weight: 800; display: flex; align-items: center; gap: 10px; justify-content: center; }
.jp-pot .chip-ico { width: 22px; height: 22px; box-shadow: inset 0 0 0 5px #1a7a46; }
.jp-controls { display: flex; gap: 10px; justify-content: center; }
.jp-controls input, .field { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; outline: 0; width: 100%; }
.jp-controls input { width: 180px; }
.jp-controls input:focus, .field:focus { border-color: rgba(61,220,132,.5); }
.jp-slots { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.jp-slot { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; border-top: 3px solid var(--c, var(--line)); animation: in .3s ease; }
.jp-slot .avatar { width: 48px; height: 48px; }
.jp-slot b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.jp-slot.win { box-shadow: 0 0 0 2px var(--green); }

/* roulette */
.rl-window { position: relative; overflow: hidden; height: 120px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); -webkit-mask: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.rl-marker { position: absolute; left: 50%; top: 8px; bottom: 8px; width: 3px; margin-left: -1px; background: #fff; border-radius: 2px; z-index: 2; box-shadow: 0 0 10px rgba(255,255,255,.6); }
.rl-strip { position: absolute; top: 15px; left: 0; display: flex; gap: 10px; will-change: transform; }
.rl-strip .coin { width: 90px; height: 90px; font-size: 32px; }
.rl-strip.spin { transition: transform 5s cubic-bezier(.12,.8,.2,1); }
.rl-status { text-align: center; font-weight: 700; }
.rl-recent { display: flex; justify-content: center; align-items: center; gap: 20px; flex-wrap: wrap; }
.rl-recent-list, .rl-counts { display: flex; gap: 6px; align-items: center; }
.rl-counts b { margin-right: 8px; }
.bet-bar { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; flex-wrap: wrap; max-width: 900px; width: 100%; margin: 0 auto; }
.bet-bar.inner { background: var(--panel-2); border-radius: 10px; margin: 0 0 14px; padding: 6px 6px 6px 12px; }
.bet-bar input { flex: 1; min-width: 120px; background: transparent; border: 0; outline: 0; padding: 8px 0; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { background: var(--panel-3); border: 0; border-radius: 8px; padding: 7px 11px; font-weight: 700; font-size: 13px; }
.quick button:hover { background: #2f3b44; }
.rl-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 900px; width: 100%; margin: 0 auto; }
.rl-col { display: flex; flex-direction: column; gap: 8px; }
.bet-btn { display: flex; align-items: center; gap: 10px; border: 0; border-radius: 12px; padding: 14px; font-weight: 800; font-size: 15px; }
.bet-btn em { margin-left: auto; font-style: normal; opacity: .8; }
.bet-btn.h { background: #1c4a33; }
.bet-btn.b { background: #1f3560; }
.bet-btn.t { background: #5a3418; }
.bet-btn:hover { filter: brightness(1.15); }
.bet-btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.bet-sum { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--muted); }
.bet-sum > span:last-child { display: flex; align-items: center; gap: 6px; color: var(--text); font-weight: 700; }
.bet-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.bet-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.02); font-size: 13px; }
.bet-list li.you { background: rgba(61,220,132,.1); }
.bet-list li.won { color: var(--green); }

/* upgrader */
.up-grid { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 20px; align-items: center; }
.up-panel { padding: 18px; }
.lbl { display: block; font-weight: 700; margin: 0 0 8px; }
.mults { margin: 10px 0 16px; }
.up-info { display: flex; justify-content: space-between; margin-bottom: 14px; color: var(--muted); }
.up-info b { color: var(--text); }
.up-dial-wrap { position: relative; width: min(380px, 80vw); aspect-ratio: 1; margin: 0 auto; }
.up-dial { position: absolute; inset: 0; border-radius: 50%; -webkit-mask: radial-gradient(circle, transparent 64%, #000 65%); mask: radial-gradient(circle, transparent 64%, #000 65%); }
.up-needle { position: absolute; inset: 0; transition: transform 3s cubic-bezier(.15,.8,.2,1); }
.up-needle::before { content: ""; position: absolute; left: 50%; top: -6px; transform: translateX(-50%); border-left: 10px solid transparent; border-right: 10px solid transparent; border-top: 22px solid #fff; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.up-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.up-center b { font-size: 34px; }
.up-center b.win { color: var(--green); }
.up-center b.lose { color: var(--red); }

/* modals */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(4, 8, 10, 0.7); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal-card { position: relative; width: min(460px, 100%); max-height: 90vh; overflow-y: auto; background: #182026; border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.modal-card.center { text-align: center; }
.modal-card h2 { margin: 0 0 14px; font-size: 18px; }
.modal-card h3 { font-size: 14px; margin: 18px 0 8px; font-weight: 600; }
.x { position: absolute; top: 14px; right: 14px; background: transparent; border: 0; color: var(--muted); font-size: 16px; }
.x:hover { color: var(--text); }
#loginForm { display: flex; flex-direction: column; gap: 10px; }
.who { display: flex; gap: 8px; align-items: baseline; }
.phrase { display: flex; gap: 8px; align-items: center; background: var(--panel-2); border-radius: 10px; padding: 10px 10px 10px 14px; margin: 6px 0 10px; }
.phrase code { flex: 1; font-family: ui-monospace, Consolas, monospace; color: var(--green); font-size: 14px; overflow-wrap: anywhere; user-select: all; }
.err { color: var(--red); min-height: 18px; margin: 10px 0 0; font-weight: 600; }
.bal-box { display: flex; align-items: center; justify-content: space-between; background: var(--panel-2); border-radius: 12px; padding: 18px; }
.bal-box b { font-size: 26px; display: flex; align-items: center; gap: 8px; }
.tx { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tx li { display: flex; justify-content: space-between; align-items: center; background: var(--panel-2); border-radius: 10px; padding: 10px 14px; }
.tx li div { display: flex; flex-direction: column; }
.tx .pos { color: var(--green); font-weight: 700; }
.tx .neg { color: var(--text); font-weight: 700; }
.tx .empty { justify-content: center; color: var(--muted); }

.menu { position: absolute; top: 58px; right: 10px; background: #182026; border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 160px; z-index: 30; }
.menu button { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 10px 12px; border-radius: 8px; font-weight: 600; }
.menu button:hover { background: var(--panel-3); }

/* toasts */
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #1f2a31; border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 10px; padding: 12px 16px; font-weight: 600; max-width: 320px; animation: in .2s ease; }
.toast.bad { border-left-color: var(--red); }

/* responsive */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .main { overflow: visible; }
  .chat { position: fixed; z-index: 40; inset: 76px 10px 10px; display: none; }
  .chat.open { display: flex; }
  .chat-toggle { display: inline-block; }
  .up-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; margin: 8px; padding: 10px 12px; }
  .tabs { order: 3; width: 100%; }
  .top-right { gap: 6px; }
  #refillBtn { display: none; }
  .user-chip .uname { display: none; }
  .layout { padding: 0 8px 8px; }
  .stats { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat b { font-size: 16px; }
  .game { grid-template-columns: 1fr auto; row-gap: 10px; padding: 12px; }
  .game .game-state { justify-self: start; }
  .slot-name { max-width: 70px; }
  .rl-cols { grid-template-columns: 1fr; }
  .rl-strip .coin { width: 70px; height: 70px; font-size: 24px; }
  .rl-window { height: 100px; }
  .chat { inset: 120px 8px 8px; }
}
