:root {
  --bg: #0d0f1a;
  --panel: #161a2b;
  --panel-2: #1d2238;
  --line: #2a3050;
  --text: #e8eaf6;
  --muted: #8a90b4;
  --red: #ff5d73;
  --blue: #4cc9f0;
  --gold: #ffd166;
  --green: #06d6a0;
  --orange: #f78c6b;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 30% -10%, #1f2547 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { font-size: 22px; margin: 0; letter-spacing: 0.02em; }
.brand .sub { color: var(--muted); font-size: 13px; letter-spacing: 0.15em; text-transform: uppercase; }
.logo { color: var(--gold); font-size: 22px; text-shadow: 0 0 12px var(--gold); align-self: center; }
.wallet { display: flex; align-items: center; gap: 14px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang button {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 0;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
}
.lang button.on { background: var(--panel-2); color: var(--text); }
.stat { display: flex; flex-direction: column; font-size: 12px; }
.stat b { font-size: 20px; font-variant-numeric: tabular-nums; transition: color 0.2s; }
.stat b.up { color: var(--green); }
.stat b.down { color: var(--red); }

button {
  background: var(--gold);
  color: #1a1400;
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
  transition: transform 0.08s, filter 0.15s;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px) scale(0.98); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.small { padding: 6px 12px; font-size: 13px; }
button.drop {
  flex: 1;
  min-width: 160px;
  padding: 14px 24px;
  font-size: 18px;
  box-shadow: 0 6px 24px rgba(255, 209, 102, 0.25);
}
.kbd {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 12px;
  font-weight: 600;
  vertical-align: 2px;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  padding: 24px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  header { padding: 12px 16px; }
  .kbd { display: none; }
}

.board-wrap { position: relative; }
canvas {
  width: 100%;
  height: auto;
  background: linear-gradient(180deg, #121633 0%, #0f1226 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: block;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 15, 26, 0.92);
  border: 1px solid var(--line);
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.25s;
}
.banner.win { border-color: var(--green); color: var(--green); }
.banner.big { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 24px rgba(255, 209, 102, 0.35); }
.banner.lose { border-color: var(--red); color: var(--red); }
.banner.info { color: var(--muted); }
.hidden { display: none; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.bets { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.chip.on { background: var(--gold); color: #1a1400; border-color: var(--gold); }
.hint { margin: 10px 0 0; }
.count { display: flex; align-items: center; gap: 6px; }
.count span { margin-right: 4px; }
.count input {
  width: 56px;
  text-align: center;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 4px;
  font-size: 14px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.count input::-webkit-outer-spin-button,
.count input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.count .step {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 18px;
  line-height: 1;
}
.row.end { justify-content: flex-end; margin-top: 10px; }

aside { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card h2 { margin: 0 0 12px; font-size: 15px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; margin: 6px 0; font-size: 13px; }
.row b { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.dist { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; align-items: end; height: 110px; }
.dist .bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: 10px; color: var(--muted); }
.dist .bar i { display: block; width: 100%; border-radius: 4px 4px 0 0; min-height: 2px; transition: height 0.3s; }
.dist .bar span { font-variant-numeric: tabular-nums; }

.list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.list li:last-child { border-bottom: 0; }
.list .empty { color: var(--muted); justify-content: center; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--panel-2); color: #1a1400; }
