:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b202b;
  --line: #2a3140;
  --text: #e9edf5;
  --muted: #8e9aae;
  --accent: #7c5cff;
  --accent-2: #21d4a1;
  --danger: #ff5c7a;
  --warn: #ffc857;
  --radius: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, .16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(33, 212, 161, .10), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

a { color: #b9a8ff; text-decoration: none; }
a:hover { text-decoration: underline; }
code { color: #c9d4ea; word-break: break-all; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5rem; }
h1 { font-size: clamp(2rem, 5vw, 3.6rem); letter-spacing: -.03em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  background: rgba(11, 13, 18, .82); backdrop-filter: blur(12px);
}
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 700; letter-spacing: -.02em; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  background: conic-gradient(from 20deg, #ff5c7a, #ffc857, #21d4a1, #4cc9f0, #7c5cff, #ff5c7a);
  box-shadow: 0 0 18px rgba(124, 92, 255, .55);
}
.nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: flex-end; }
.wallet-area { display: inline-flex; gap: .5rem; align-items: center; }

.banner {
  padding: .6rem clamp(1rem, 4vw, 3rem);
  background: rgba(255, 200, 87, .1);
  border-bottom: 1px solid rgba(255, 200, 87, .25);
  color: #ffe3a3; font-size: .88rem;
}
.banner strong { color: #fff0c7; }
.admin-banner { background: rgba(33, 212, 161, .09); border-color: rgba(33, 212, 161, .25); color: #c8ffe9; }

.wrap { width: min(1180px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2.2rem) clamp(1rem, 4vw, 2rem) 4rem; }

.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(1rem, 4vw, 3rem); align-items: center; padding: 1.5rem 0 2rem; }
.eyebrow { color: var(--accent-2); text-transform: uppercase; letter-spacing: .16em; font-size: .72rem; font-weight: 700; margin: 0 0 .4rem; }
.lede { color: #c3ccdd; font-size: 1.08rem; max-width: 42ch; }
.hero-actions { display: flex; gap: .7rem; flex-wrap: wrap; margin: 1.2rem 0 .6rem; }

.machine { display: flex; justify-content: center; }
.machine-glass {
  width: min(330px, 100%); aspect-ratio: .78;
  border-radius: 30px 30px 22px 22px;
  border: 2px solid rgba(255, 255, 255, .22);
  background: linear-gradient(160deg, rgba(255,255,255,.12), rgba(255,255,255,.02) 55%, rgba(124,92,255,.12));
  box-shadow: inset 0 0 60px rgba(255,255,255,.05), var(--shadow);
  padding: 1.2rem; position: relative; overflow: hidden;
}
.machine-glass::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.12) 45%, transparent 55%);
  pointer-events: none;
}
.balls { display: flex; flex-wrap: wrap; gap: .7rem; align-content: flex-start; height: 78%; }
.balls .ball { animation: float 4.5s ease-in-out infinite; }
.balls .ball:nth-child(2n) { animation-delay: -1.2s; }
.balls .ball:nth-child(3n) { animation-delay: -2.4s; }
.balls .ball:nth-child(4n) { animation-delay: -3.1s; }
@keyframes float { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-9px) rotate(8deg); } }
.machine-base { position: absolute; left: 8%; right: 8%; bottom: 2.4rem; height: .55rem; border-radius: 99px; background: rgba(255,255,255,.18); }
.blower { position: absolute; bottom: .7rem; left: 50%; transform: translateX(-50%); font-size: .62rem; letter-spacing: .2em; text-transform: uppercase; color: rgba(255,255,255,.45); }

.ball { width: 2.35rem; height: 2.35rem; border-radius: 50%; display: inline-block; box-shadow: inset -6px -7px 12px rgba(0,0,0,.35), 0 4px 12px rgba(0,0,0,.35); }
.ball-red { background: radial-gradient(circle at 32% 28%, #ff9aa9, #e11d48 55%, #8b0f2c); }
.ball-blue { background: radial-gradient(circle at 32% 28%, #9fd0ff, #2563eb 55%, #123a8a); }
.ball-green { background: radial-gradient(circle at 32% 28%, #a7f3cf, #10b981 55%, #08664a); }
.ball-yellow { background: radial-gradient(circle at 32% 28%, #fff3a8, #f5c518 55%, #8a6a00); }
.ball-purple { background: radial-gradient(circle at 32% 28%, #d8c4ff, #7c3aed 55%, #3a1a80); }
.ball-orange { background: radial-gradient(circle at 32% 28%, #ffd2a8, #f97316 55%, #8a3a06); }
.ball-pink { background: radial-gradient(circle at 32% 28%, #ffd0ec, #ec4899 55%, #861657); }
.ball-cyan { background: radial-gradient(circle at 32% 28%, #c8fbff, #06b6d4 55%, #055b6b); }

.grid { display: grid; gap: 1rem; margin: 1rem 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .6rem; }
.pill { display: inline-block; padding: .18rem .55rem; border-radius: 99px; background: rgba(255,255,255,.08); color: #c8d2e6; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.pill.play { background: rgba(33, 212, 161, .14); color: #8ff5d4; }
.round-timer { display: flex; align-items: baseline; justify-content: space-between; padding: .8rem 0; border-bottom: 1px dashed var(--line); }
.round-timer strong { font-size: 1.9rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.result-row { display: flex; gap: .45rem; flex-wrap: wrap; padding: .9rem 0; min-height: 3.2rem; }
.result-row .ball { width: 1.9rem; height: 1.9rem; }
.fairness { margin-top: .5rem; color: var(--muted); }
.fairness summary { cursor: pointer; }
.fairness code { font-size: .72rem; }

.bet-form, .stack { display: grid; gap: .7rem; }
label { display: grid; gap: .3rem; color: #c7d0e1; font-size: .85rem; }
input, select, button { font: inherit; }
input, select {
  width: 100%; padding: .65rem .7rem; border-radius: 10px;
  border: 1px solid var(--line); background: #0e121a; color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(124, 92, 255, .55); outline-offset: 1px; }
.btn {
  border: 1px solid var(--line); background: #1a2030; color: var(--text);
  padding: .62rem 1rem; border-radius: 10px; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: #3b4763; background: #20283b; }
.btn.primary { background: linear-gradient(135deg, #7c5cff, #5b3df0); border-color: transparent; box-shadow: 0 8px 22px rgba(124, 92, 255, .28); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: rgba(255, 92, 122, .12); border-color: rgba(255, 92, 122, .35); color: #ffb3c1; }
.btn.tiny { padding: .35rem .65rem; font-size: .78rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.odds-line { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: .4rem .7rem; align-items: center; padding: .6rem .7rem; border-radius: 10px; background: rgba(255,255,255,.04); font-size: .86rem; }
.odds-line span { color: var(--muted); }
.odds-line strong { font-variant-numeric: tabular-nums; }

.market-pane { display: grid; gap: .5rem; }
.order-output { min-height: 2.2rem; display: flex; gap: .35rem; flex-wrap: wrap; padding: .4rem; border: 1px dashed var(--line); border-radius: 10px; }
.order-output .ball { width: 1.55rem; height: 1.55rem; }
.color-picker { display: flex; gap: .35rem; flex-wrap: wrap; }
.color-picker button { border: 1px solid var(--line); background: #0e121a; border-radius: 99px; padding: .25rem .55rem; color: var(--text); cursor: pointer; font-size: .76rem; display: inline-flex; align-items: center; gap: .35rem; }
.color-picker .ball { width: 1rem; height: 1rem; }

.notice { padding: .8rem; border-radius: 10px; background: rgba(255, 200, 87, .08); border: 1px solid rgba(255, 200, 87, .2); color: #ffe3a3; font-size: .88rem; }

.recent-list { display: grid; gap: .5rem; }
.recent-item { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .5rem .6rem; border-radius: 10px; background: rgba(255,255,255,.03); }
.recent-item .ball { width: 1.45rem; height: 1.45rem; }
.recent-item .seq { color: var(--muted); font-size: .78rem; min-width: 3.6rem; }

.account-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.balance-card { display: grid; gap: .15rem; text-align: right; padding: 1rem 1.2rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.balance-card strong { font-size: 2rem; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stats .stat { padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.03); display: grid; gap: .25rem; }
.stats .stat span { color: var(--muted); font-size: .78rem; }
.stats .stat strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th, .table td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
.table td.win { color: var(--accent-2); }
.table td.loss { color: var(--danger); }

.wallet-list, .mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.wallet-list li, .mini-list li { padding: .5rem .6rem; border-radius: 9px; background: rgba(255,255,255,.03); font-size: .86rem; word-break: break-all; }
.mini-list.audit li { font-size: .78rem; }

.prose { max-width: 78ch; }
.prose h1 { font-size: 2.2rem; }
.prose h2 { margin-top: 1.5rem; }
.prose ul { padding-left: 1.2rem; }

.footer { border-top: 1px solid var(--line); padding: 1.5rem clamp(1rem, 4vw, 3rem); color: var(--muted); font-size: .82rem; max-width: 1180px; margin: 0 auto; }

.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: #20283b; border: 1px solid #3b4763; color: var(--text); padding: .6rem 1rem; border-radius: 10px; transition: .2s ease; z-index: 50; max-width: min(92vw, 38rem); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(255,92,122,.5); color: #ffc2ce; }

.admin-body .wrap { padding-top: 1.2rem; }
.admin-form, .inline-form { margin-top: .6rem; }
.inline-form { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.inline-form input { width: auto; flex: 1 1 8rem; }
.queue-item { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.queue-item:last-child { border-bottom: 0; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .machine { order: -1; }
  .machine-glass { width: min(280px, 80%); }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .account-head { align-items: flex-start; }
  .balance-card { text-align: left; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .balls .ball { animation: none; }
}
