:root {
  --bg: #05070d;
  --panel: rgba(14, 22, 38, 0.92);
  --panel-2: rgba(22, 34, 56, 0.9);
  --line: #2b4a6e;
  --line-hi: #4c86c2;
  --text: #d6e2f0;
  --muted: #7f93ab;
  --gold: #f2b84b;
  --gold-hi: #ffd98a;
  --gold-dk: #8a5a12;
  --copper: #c26a2a;
  --ec: #7fc4ff;
  --gpl: #f2c14b;
  --win: #69e07a;
  --lose: #ff6a5a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  font-size: 14px;
}

body { display: flex; justify-content: center; padding: 16px; }

.stars {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 34%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 35% 76%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 82%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 10%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 20% 55%, #fff4 50%, transparent 51%),
    radial-gradient(ellipse at 30% 20%, #1a2a55 0%, transparent 55%),
    radial-gradient(ellipse at 80% 90%, #3a1a10 0%, transparent 50%),
    var(--bg);
  background-size: 300px 300px, 400px 400px, 350px 350px, 500px 500px, 280px 280px, 330px 330px, 100% 100%, 100% 100%, 100% 100%;
}

.window {
  width: min(1240px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 0 0 1px #000, 0 20px 60px #000c, inset 0 1px 0 #ffffff10;
  overflow: hidden;
}

.titlebar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px;
  background: linear-gradient(#1f3556, #12223a);
  border-bottom: 2px solid var(--gold-dk);
}
.titlebar .title {
  font-weight: 800; letter-spacing: 6px; font-size: 20px;
  color: var(--gold);
  text-shadow: 0 0 12px #f2b84b66;
}
.titlebar .subtitle { color: var(--muted); font-size: 12px; flex: 1; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 4px; cursor: pointer; padding: 2px 8px; font-size: 14px; }

.content { display: grid; grid-template-columns: 1fr 380px; }

.wheel-wrap {
  position: relative;
  padding: 16px;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 50%, #2a1b0c 0%, #0b0d14 70%);
}
#wheel { width: 100%; max-width: 780px; height: auto; display: block; user-select: none; }

.slot-hit { cursor: pointer; }
.slot-hit:hover .slot-face { filter: brightness(1.35); }
.slot-house { cursor: not-allowed; }

.banner {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: none;
  font-size: clamp(36px, 8vw, 96px); font-weight: 900; letter-spacing: 4px;
  color: var(--gold-hi);
  text-shadow: 0 0 20px #ffb000, 0 0 40px #ff7a00, 0 4px 0 #6b3a00;
  white-space: nowrap; text-align: center;
  animation: pop 2.6s ease-out forwards;
}
.banner small { display: block; font-size: 0.32em; letter-spacing: 2px; color: #fff; text-shadow: 0 0 10px #000, 0 2px 0 #000; }
.banner.hidden { display: none; }
@keyframes pop {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  12% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.05); opacity: 0; }
}

.panel {
  border-left: 1px solid var(--line);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(#101a2c, #0b1220);
}

.box {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
}
.box-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--gold); margin-bottom: 8px;
  border-bottom: 1px solid var(--line); padding-bottom: 4px;
}

.wallet-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; padding: 3px 0; }
.wallet-row b { font-size: 16px; font-variant-numeric: tabular-nums; }
.cur { font-size: 10px; font-weight: 800; text-align: center; border-radius: 3px; padding: 2px 0; color: #000; }
.cur.ec { background: var(--ec); }
.cur.gpl { background: var(--gpl); }
#ecAmt { color: var(--ec); }
#gplAmt { color: var(--gpl); }
.flash-up { animation: flashUp 1.2s; }
@keyframes flashUp { 0% { text-shadow: 0 0 14px var(--win); color: #fff; } 100% { text-shadow: none; } }

.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; }
.row label { color: var(--muted); font-size: 12px; }
.row small { color: var(--muted); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 5px 10px; cursor: pointer; font: inherit; font-size: 12px; }
.seg button.on { background: var(--line); color: #fff; }

.bet-input { display: flex; align-items: center; gap: 4px; }
.bet-input input {
  width: 120px; text-align: right;
  background: #060b14; color: #fff;
  border: 1px solid var(--line); border-radius: 3px; padding: 5px 8px;
  font: inherit; font-variant-numeric: tabular-nums;
}
.bet-input input:focus { outline: none; border-color: var(--gold); }
button.sm { width: 26px; height: 26px; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 3px; cursor: pointer; }

.presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.presets button {
  background: #0c1626; border: 1px solid var(--line); color: var(--text);
  padding: 4px 0; border-radius: 3px; cursor: pointer; font-size: 12px;
}
.presets button:hover { border-color: var(--gold); color: var(--gold); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 26px; padding: 0 8px;
  border-radius: 13px; font-weight: 800;
  background: radial-gradient(circle at 35% 30%, var(--gold-hi), var(--gold) 50%, var(--gold-dk));
  color: #2a1700; border: 1px solid #3b2400; cursor: pointer;
}
.chip:hover { filter: brightness(1.15); }
.muted { color: var(--muted); font-size: 12px; }

.total-row b { font-variant-numeric: tabular-nums; }

.actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 8px; }
.btn {
  border-radius: 3px; padding: 10px; font: inherit; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
}
.btn:hover { border-color: var(--line-hi); }
.btn.primary {
  background: linear-gradient(#ffcf6a, #e39a25 55%, #a8650f);
  color: #2a1700; border-color: #5b3605;
  text-shadow: 0 1px 0 #ffe7b0;
  font-size: 16px; letter-spacing: 4px;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.6); }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.danger:hover { border-color: var(--lose); color: var(--lose); }

.msg { min-height: 18px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.msg.win { color: var(--win); font-weight: 700; }
.msg.lose { color: var(--lose); }
.msg.err { color: var(--lose); }

.tabs { display: flex; gap: 2px; margin-bottom: -10px; }
.tabs button {
  flex: 1; background: #0c1626; border: 1px solid var(--line); border-bottom: 0;
  color: var(--muted); padding: 6px 0; cursor: pointer; font: inherit; font-size: 12px;
  border-radius: 4px 4px 0 0;
}
.tabs button.on { background: var(--panel-2); color: var(--gold); }
.tab-body { border-top-left-radius: 0; height: 290px; overflow: auto; }

.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 6px 0; border-bottom: 1px solid #ffffff10; font-size: 12px; }
.history .spin-head { display: flex; justify-content: space-between; color: var(--muted); }
.history .line { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.history .line .slotno { width: 28px; color: var(--gold); font-weight: 700; }
.history .line .mini { display: inline-flex; gap: 2px; }
.history .line .mini svg { width: 20px; height: 20px; background: #050a12; border-radius: 3px; }
.history .line .res { flex: 1; text-align: right; }
.history .w { color: var(--win); font-weight: 700; }
.history .l { color: var(--lose); }

.paytable { width: 100%; border-collapse: collapse; font-size: 12px; }
.paytable td { padding: 5px 4px; border-bottom: 1px solid #ffffff10; vertical-align: middle; }
.paytable td:last-child { text-align: right; color: var(--gold); font-weight: 700; white-space: nowrap; }
.paytable .pname { color: #fff; font-weight: 600; }
.paytable .pdesc { color: var(--muted); font-size: 11px; }
.paytable .picons { white-space: nowrap; }
.paytable .picons svg { width: 22px; height: 22px; background: #050a12; border-radius: 3px; margin-right: 2px; }
.paytable tr.hit td { background: #f2b84b22; }

.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 0; font-size: 12px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.rules p, .rules ul { margin: 0 0 8px; font-size: 12px; line-height: 1.5; }
.rules ul { padding-left: 18px; }

.ticker {
  border-top: 1px solid var(--line);
  padding: 7px 14px; font-size: 12px; color: var(--gold);
  background: #0a1220; font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 960px) {
  .content { grid-template-columns: 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 480px) {
  body { padding: 0; }
  .titlebar .subtitle { display: none; }
  .wheel-wrap { padding: 6px; }
  .bet-input input { width: 96px; }
}

/* ---------- multiplayer ---------- */

.conn { font-size: 11px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.conn.on { color: var(--win); border-color: #2f6b3a; }
.conn.off { color: var(--lose); border-color: #6b2f2f; }

.you-row { display: flex; align-items: center; gap: 8px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 11px; text-decoration: underline; margin-left: auto; }

.phase { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; }
.phase-top { display: flex; justify-content: space-between; font-weight: 700; letter-spacing: 1px; color: var(--gold); font-size: 13px; text-transform: uppercase; }
.phase-top #phaseTime { font-variant-numeric: tabular-nums; color: #fff; }
.phase-bar { height: 6px; background: #060b14; border-radius: 3px; margin-top: 6px; overflow: hidden; }
#phaseFill { height: 100%; width: 0; background: linear-gradient(90deg, #a8650f, var(--gold-hi)); transition: width .2s linear; }
.phase.closed .phase-top { color: var(--muted); }
.phase.closed #phaseFill { background: var(--line-hi); }

.badge { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--lose); color: #fff; font-size: 10px; line-height: 16px; }

.players { width: 100%; border-collapse: collapse; font-size: 12px; }
.players th { text-align: left; color: var(--muted); font-weight: 400; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.players td { padding: 5px 4px; border-bottom: 1px solid #ffffff10; font-variant-numeric: tabular-nums; }
.players td.n, .players th.n { text-align: right; }
.players tr.me td { background: #f2b84b18; }
.players tr.offline td { opacity: .45; }
.players .tag { font-size: 9px; padding: 0 4px; border-radius: 3px; background: #2b4a6e; color: #cde; margin-left: 4px; vertical-align: middle; }
.players .online-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: var(--win); margin-right: 5px; vertical-align: middle; }
.players tr.offline .online-dot { background: #555; }

.chat-pane { display: flex; flex-direction: column; height: 100%; }
.chat { list-style: none; margin: 0; padding: 0; flex: 1; overflow: auto; font-size: 12px; }
.chat li { padding: 3px 0; line-height: 1.4; word-wrap: break-word; }
.chat .who { font-weight: 700; margin-right: 4px; }
.chat li.system { color: var(--gold); font-style: italic; }
.chat li.bot .text { color: #b9c7d6; }
.chat-form { display: flex; gap: 6px; margin-top: 6px; }
.chat-form input { flex: 1; background: #060b14; color: #fff; border: 1px solid var(--line); border-radius: 3px; padding: 6px 8px; font: inherit; }
.chat-form input:focus { outline: none; border-color: var(--gold); }
.chat-form .btn { padding: 6px 12px; }

.history .winners { color: var(--text); margin-top: 3px; }
.history .big { color: var(--gold-hi); font-weight: 700; }

.modal { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--gold-dk); border-radius: 6px; padding: 20px; box-shadow: 0 20px 60px #000; }
.modal-title { font-size: 20px; font-weight: 800; color: var(--gold); letter-spacing: 2px; margin-bottom: 6px; }
.modal-box input { width: 100%; margin-top: 10px; background: #060b14; color: #fff; border: 1px solid var(--line); border-radius: 3px; padding: 10px; font: inherit; font-size: 16px; }
.modal-box input:focus { outline: none; border-color: var(--gold); }
.modal-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 12px; }
.modal-actions .btn.primary { font-size: 14px; letter-spacing: 2px; }

.tabs button { font-size: 11px; }
