:root {
  color-scheme: dark;
  --bg: #12131a;
  --panel: #171922;
  --panel-2: #1f222d;
  --line: #343845;
  --muted: #9ba1b4;
  --text: #f5f5f7;
  --green: #10d06f;
  --red: #ff3e55;
  --gold: #ffc700;
  --blue: #4a9cff;
  --purple: #8b5cf6;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
button:disabled,
input:disabled {
  cursor: not-allowed;
}
.app-shell { height: 100vh; display: grid; grid-template-rows: 70px 1fr; }
.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 460px) auto 42px;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  background: #12131a;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand img { width: 48px; height: 30px; object-fit: contain; }
.brand span { font-weight: 900; letter-spacing: .02em; font-size: 21px; }
.top-status {
  justify-self: center;
  min-width: 260px;
  max-width: 460px;
  width: 100%;
  min-height: 40px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid #2d3342;
  border-radius: 999px;
  background: linear-gradient(180deg, #1b1e29, #11131b);
  color: #cbd2de;
  font-weight: 900;
}
.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(16, 208, 111, .1), 0 0 14px rgba(16, 208, 111, .7);
}
.top-status strong {
  color: var(--gold);
  font-size: 15px;
}
.connect-btn {
  justify-self: end;
  width: 98px;
  height: 38px;
  border: 2px solid #e7dfbd;
  border-left-color: var(--blue);
  border-bottom-color: var(--blue);
  border-radius: 999px;
  background: #171a24;
  font-weight: 900;
  box-shadow: 0 3px 0 #07080d;
}
body[data-wallet="connected"] .connect-btn {
  width: 128px;
  border-color: #5ff0a4;
  background: #0b6139;
}
.menu-btn { justify-self: end; width: 42px; height: 42px; background: transparent; display: grid; place-items: center; gap: 4px; }
.menu-btn span { display: block; width: 19px; height: 2px; background: #e5e7ef; }

.terminal { display: grid; grid-template-columns: 320px 1fr; min-height: 0; }
.rail { border-right: 1px solid var(--line); background: #151720; min-height: 0; }
.chat-panel { display: grid; grid-template-rows: auto auto 1fr auto auto; }
.panel-head {
  height: 66px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid #2b2f3d;
}
.status-dot { width: 10px; height: 10px; background: var(--green); border-radius: 999px; }
.panel-head strong { color: #b7bdd1; }
.winner-card {
  margin: 16px 12px 12px;
  min-height: 100px;
  border-radius: var(--radius);
  padding: 16px 18px;
  background:
    linear-gradient(90deg, rgba(202, 137, 15, .95), rgba(104, 67, 12, .75)),
    repeating-linear-gradient(120deg, transparent 0 12px, rgba(255,255,255,.07) 12px 14px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
  text-transform: lowercase;
}
.winner-card small, .winner-card span { display: block; font-weight: 900; }
.winner-card small { font-size: 18px; }
.winner-card span { font-size: 12px; text-transform: uppercase; }
.winner-card strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1;
  color: white;
  text-shadow: 3px 3px 0 #111;
}
.chat-list { list-style: none; margin: 0; padding: 0 8px; overflow: auto; }
.chat-list li {
  min-height: 56px;
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  gap: 10px;
  border-radius: 7px;
  padding: 4px 2px;
  animation: chatIn .28s ease-out;
}
.chat-list li.hot { background: rgba(255, 199, 0, .05); }
.chat-list li.win { background: rgba(16, 208, 111, .05); }
.chat-list li.salt { background: rgba(255, 62, 85, .045); }
.badge {
  display: grid;
  place-items: center;
  width: 50px;
  height: 28px;
  border-radius: 5px;
  background: #322628;
  font-size: 12px;
}
.badge.blue { background: #12344d; }
.badge.green { background: #113d2a; }
.badge.cyan { background: #0d4650; }
.badge.gold { background: #5b4814; color: #ffe389; }
.badge.red { background: #4b1e27; color: #ff9baa; }
.chat-list p { margin: 0; min-width: 0; }
.chat-list strong { display: block; font-weight: 900; }
.chat-list span { display: block; color: #b3b8c6; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-compose {
  padding: 10px 12px 12px;
  display: grid;
  gap: 8px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.chat-lock { text-align: center; color: #b9bdca; font-weight: 900; font-size: 15px; }
.chat-compose input {
  width: 100%;
  height: 38px;
  border: 1px solid #323746;
  border-radius: 7px;
  background: #10121a;
  color: #dfe4ef;
  padding: 0 12px;
  font-weight: 800;
}
body[data-wallet="connected"] .chat-lock { color: #77efad; }
body[data-wallet="connected"] .chat-compose input {
  border-color: #245a3b;
  background: #121a18;
}
.rules-row { height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 22px; color: #aab0c1; }
.rules-row button { margin-right: auto; background: transparent; color: var(--gold); font-weight: 900; }
.rules-row span { font-size: 10px; font-weight: 900; }

.game-panel { padding: 14px 16px 18px; overflow: auto; min-width: 0; }
.market-tape {
  height: 32px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}
.market-tape span {
  min-width: 0;
  border: 1px solid #303544;
  border-radius: 6px;
  background: linear-gradient(180deg, #1d202b, #151720);
  color: #d3d8e6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-strip { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: center; margin-bottom: 14px; }
.last-100 { display: flex; align-items: center; gap: 8px; color: #c2c8d8; font-weight: 900; }
.last-100 span { white-space: nowrap; }
.last-100 strong { color: var(--gold); font-size: 12px; }
.last-100 em { font-style: normal; font-size: 22px; color: white; }
.coin {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #4d5365;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.38);
}
.coin.gold { background: #7a6a25; }
.coin.yellow { background: #a58a00; }
.tile-track { display: grid; grid-template-columns: repeat(9, minmax(58px, 1fr)); gap: 7px; }
.result-tile {
  height: 66px;
  border-radius: 5px;
  background: #181b23;
  border: 2px solid #333846;
  position: relative;
  overflow: hidden;
  padding: 8px;
  box-shadow: inset 0 -18px 34px rgba(0,0,0,.16);
}
.result-tile svg { width: 100%; height: 42px; display: block; }
.result-tile b { position: absolute; left: 10px; bottom: 6px; color: #7fc495; font-size: 13px; }
.result-tile.loss b { color: var(--red); }

.chart-card {
  border: 4px solid #526073;
  border-radius: 16px;
  background: #171a23;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0,0,0,.2);
}
.chart-top {
  height: 34px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 12px;
  color: #cbd2de;
  font-size: 12px;
}
.chart-top .latency { justify-self: center; color: #9399a9; font-weight: 900; }
.chart-top #roundId { justify-self: end; }
.chart-grid {
  position: relative;
  height: clamp(250px, 31vw, 370px);
  background:
    linear-gradient(#2b2f3a 1px, transparent 1px) 0 0 / 100% calc(100% / 7),
    linear-gradient(90deg, rgba(255,255,255,.052) 1px, transparent 1px) 0 0 / 12.5% 100%,
    #171a23;
}
.chart-grid::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 58% 48%, rgba(16, 208, 111, .14), transparent 24%),
    linear-gradient(180deg, rgba(255,255,255,.03), transparent 40%);
}
.round-hud {
  position: absolute;
  top: 18px;
  left: 46%;
  z-index: 4;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 10px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(16, 18, 26, .72);
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 28px rgba(0,0,0,.24);
}
.round-hud span,
.round-hud em {
  color: #aeb5c7;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: .05em;
}
.round-hud strong { font-size: 20px; line-height: 1; }
.round-hud b { color: var(--gold); font-size: 12px; }
.round-hud em { color: #77efad; grid-column: span 2; }
body[data-round="waiting"] .round-hud {
  border-color: rgba(255, 62, 85, .38);
  background: rgba(38, 14, 20, .8);
}
body[data-round="waiting"] .round-hud em,
body[data-round="waiting"] .round-hud strong {
  color: #ff8da0;
}
.axis {
  position: absolute;
  z-index: 3;
  inset: 0 auto 0 16px;
  width: 48px;
  pointer-events: none;
  color: white;
  font-weight: 900;
  font-size: 12px;
  text-shadow: 2px 2px 0 #07080d;
}
.axis span {
  position: absolute;
  left: 0;
  transform: translateY(-50%);
}
.target-line {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--current-line, 52%);
  border-top: 1px dashed rgba(255,255,255,.7);
  box-shadow: 0 0 16px rgba(255,255,255,.13);
}
.live-multiple {
  position: absolute;
  left: calc(var(--current-x, 50%) + 22px);
  top: calc(var(--current-line, 52%) - 22px);
  z-index: 2;
  font-size: 22px;
  text-shadow: 2px 2px 0 #000;
  white-space: nowrap;
}
.trap-token {
  position: absolute;
  left: 30px;
  bottom: 42px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #9a5935;
  border: 5px solid #f5861f;
  font-weight: 900;
  box-shadow: 0 0 0 3px rgba(0,0,0,.4);
}
#candleChart { position: absolute; inset: 0; width: 100%; height: 100%; }
#candleChart .wick { filter: drop-shadow(0 0 2px rgba(255,255,255,.2)); }
#candleChart .candle.green { filter: drop-shadow(0 0 10px rgba(16,208,111,.56)); }
#candleChart .candle.red { filter: drop-shadow(0 0 10px rgba(255,62,85,.46)); }
.chart-x-axis {
  position: absolute;
  left: 150px;
  right: 240px;
  bottom: 8px;
  display: flex;
  justify-content: space-between;
  color: #6f7585;
  font-size: 10px;
  font-weight: 900;
  pointer-events: none;
}
.top-players {
  position: absolute;
  top: 32px;
  right: 28px;
  width: min(230px, 28%);
  display: grid;
  gap: 8px;
  font-size: 12px;
  font-weight: 900;
  z-index: 5;
  padding: 8px 10px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(23, 26, 35, .62), rgba(23, 26, 35, .2));
  backdrop-filter: blur(4px);
}
.top-players p { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 10px; color: #b8becd; }
.top-players small { color: #737b8e; font-size: 10px; grid-column: 1 / -1; }
.top-players b { color: var(--green); }
.round-tape {
  height: 34px;
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.round-tape span {
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #303544;
  border-radius: 6px;
  background: #1b1e28;
  color: #cfd5e4;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bet-toolbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-top: 14px; }
.tool-tabs, .quick-buttons { display: flex; gap: 5px; }
.tool-tabs button, .quick-buttons button {
  min-width: 37px;
  height: 35px;
  border-radius: 5px;
  background: #252938;
  color: #d8deeb;
  font-weight: 900;
}
.friendly-tabs button {
  min-width: 58px;
  padding: 0 10px;
}
.tool-tabs .is-active { background: #3d2854; box-shadow: inset 0 0 0 1px #8e4fd3; }
.wallet-gate {
  justify-self: center;
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid #51431a;
  border-radius: 6px;
  background: rgba(255, 199, 0, .1);
  color: var(--gold);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .02em;
}
body[data-wallet="connected"] .wallet-gate {
  border-color: #214b35;
  background: rgba(16, 208, 111, .1);
  color: #77efad;
}
body[data-wallet="locked"] [data-play-control],
body[data-wallet="locked"] .stake-box,
body[data-wallet="locked"] .leverage-row,
body[data-wallet="locked"] .trade-actions {
  filter: grayscale(.2) brightness(.65);
}
body[data-wallet="locked"] [data-play-control] {
  opacity: .52;
}
.stake-box {
  min-height: 45px;
  margin-top: 12px;
  border: 1px solid #303544;
  border-radius: var(--radius);
  background: #1b1e28;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
}
.currency, .amount { display: inline-flex; align-items: center; gap: 12px; font-weight: 900; }
.sol {
  color: #55e3dc;
  font-size: 12px;
  letter-spacing: .05em;
  padding: 4px 7px;
  border-radius: 5px;
  background: rgba(85, 227, 220, .08);
}
.stake-box > button { background: transparent; color: #d7ddeb; font-size: 22px; }
.amount { height: 34px; padding: 0 12px; border-radius: 6px; background: #2a2e3e; }
.amount b { color: var(--gold); }
.leverage-row {
  margin-top: 8px;
  min-height: 44px;
  border: 1px solid #303544;
  border-radius: var(--radius);
  background: #1b1e28;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 0 10px;
}
input[type="range"] { accent-color: var(--purple); width: 100%; }
.pct-buttons { display: flex; align-items: center; gap: 5px; font-weight: 900; }
.pct-buttons strong { margin-right: 8px; }
.pct-buttons button {
  height: 34px;
  min-width: 42px;
  border-radius: 5px;
  background: #2a2e3e;
  color: #aeb5c7;
  font-weight: 900;
}
.pct-buttons .is-active { background: #535969; color: white; }
.trade-actions { margin-top: 13px; display: flex; justify-content: center; gap: 8px; }
.trade-actions button {
  width: min(150px, 32vw);
  height: 72px;
  border-radius: 16px;
  font-size: 22px;
  font-weight: 1000;
  color: rgba(255,255,255,.52);
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.22);
  transition: filter .16s ease, transform .16s ease, box-shadow .16s ease;
}
.trade-actions button:not(:disabled):hover { filter: brightness(1.12); transform: translateY(-1px); }
.buy { background: #0e6f40; }
.sell { background: #89313a; }

@keyframes chatIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .topbar { grid-template-columns: 1fr auto 42px; }
  .top-status { display: none; }
  .terminal { grid-template-columns: 1fr; }
  .chat-panel { display: none; }
  .game-panel { padding: 14px 10px 24px; }
  .market-tape { grid-template-columns: 1fr 1fr; height: auto; }
  .market-tape span { height: 32px; }
  .score-strip { grid-template-columns: 1fr; }
  .last-100 { flex-wrap: wrap; }
  .tile-track { grid-template-columns: repeat(3, 1fr); }
  .top-players { display: none; }
  .chart-grid { height: 280px; }
  .round-hud { display: none; }
  .chart-top { grid-template-columns: auto 1fr; }
  .chart-top .latency { display: none; }
  .chart-x-axis { left: 96px; right: 28px; }
  .bet-toolbar, .leverage-row { align-items: stretch; flex-direction: column; display: flex; }
  .wallet-gate { justify-content: center; }
  .quick-buttons { flex-wrap: wrap; justify-content: flex-end; }
  .round-tape { grid-template-columns: 1fr; height: auto; }
  .round-tape span { height: 34px; }
}
