:root {
  --felt: #1fa855;
  --felt-dark: #0f7a3d;
  --accent: #d4af37;
  --panel-bg: #14181c;
  --panel-bg-2: #1c2228;
  --border: #333c44;
  --text: #f2f2f0;
  --text-dim: #9aa4ac;
  --good: #4caf7d;
  --bad: #d05a5a;
  --red: #b0202a;
  --black-num: #161616;
  --green-num: #0f7a3d;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #05070a;
  color: var(--text);
  font-family: 'Segoe UI', Tahoma, sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#top-bar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 20px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}
#top-bar h1 {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
  margin: 0;
  white-space: nowrap;
}

#top-bar-left {
  grid-column: 1;
  justify-self: start;
  color: var(--accent);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

#top-bar-right { grid-column: 3; justify-self: end; position: relative; }
#btn-settings {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#btn-settings:hover { border-color: var(--accent); color: var(--text); }

#settings-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 200px;
  padding: 14px 16px;
  background: var(--panel-bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 50;
}
#settings-panel[hidden] { display: none; }
.settings-row { display: flex; flex-direction: column; gap: 6px; }
.settings-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
#volume-slider { width: 100%; accent-color: var(--accent); }

#main-area {
  flex: 1;
  display: flex;
  min-height: 0;
}

#table-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  min-width: 0;
  background:
    linear-gradient(rgba(8,10,14,0.35), rgba(8,10,14,0.35)),
    url('../assets/bg.png?v=1') center / cover no-repeat;
}

#table {
  position: relative;
  width: 100%;
  max-width: 1320px;
  max-height: 96%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px 30px 30px;
  background: radial-gradient(ellipse at 50% 20%, var(--felt) 0%, var(--felt-dark) 100%);
  border: 14px solid #3a2415;
  border-radius: 26px;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.25), 0 10px 30px rgba(0,0,0,0.6);
  overflow-y: auto;
}

#table-banner {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  color: #29c5ff;
  -webkit-text-stroke: 2px #ff36b3;
  paint-order: stroke fill;
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  max-width: 90%;
  pointer-events: none;
  animation: banner-pulse 1.3s ease-in-out infinite;
}
#table-banner[hidden] { display: none; }
@keyframes banner-pulse {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    text-shadow: 0 0 10px rgba(255,54,179,0.6), 0 0 3px rgba(255,54,179,0.9);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.07);
    text-shadow: 0 0 26px rgba(255,54,179,1), 0 0 10px rgba(255,54,179,1);
  }
}

#wheel-wrap {
  position: relative;
  width: 440px;
  height: 440px;
  flex-shrink: 0;
}
#wheel-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 6px solid #3a2415;
  box-shadow: 0 4px 14px rgba(0,0,0,0.6), inset 0 0 10px rgba(0,0,0,0.4);
  background: #0c0c10;
}
#wheel-disc svg { display: block; width: 100%; height: 100%; }
#wheel-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f0d78a, #8a6c1e);
  border: 3px solid #3a2415;
  z-index: 5;
}
.pocket-win text { fill: #fff !important; }
.pocket-win path { filter: drop-shadow(0 0 6px #fff); }

#wheel-ball {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.7));
}

#betting-grid {
  display: grid;
  grid-template-columns: 64px repeat(12, minmax(46px, 1fr)) 72px;
  grid-template-rows: repeat(3, 52px) 40px 40px;
  gap: 3px;
  width: 100%;
  max-width: 1080px;
}

.bet-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(255,255,255,0.15);
}
.bet-cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
#betting-grid.grid-locked .bet-cell { cursor: default; pointer-events: none; opacity: 0.8; }
.bet-cell.zero { background: var(--green-num); font-size: 1.1rem; }
.bet-cell.num-red { background: var(--red); }
.bet-cell.num-black { background: var(--black-num); }
.bet-cell.outside {
  background: var(--panel-bg-2);
  color: var(--text-dim);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.bet-cell.outside.red-label { color: #e07a7a; }
.bet-cell.outside.black-label { color: #ccc; }
.bet-cell.column-bet { background: var(--panel-bg-2); color: var(--text-dim); font-size: 0.8rem; }

.chip-badge {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: var(--accent);
  color: #1a1200;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 50%;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1px solid #1a1200;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

#bet-hotspots {
  position: relative;
  pointer-events: none;
  z-index: 3;
}
.hotspot {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  border: 1px solid transparent;
  pointer-events: auto;
  cursor: pointer;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  color: #1a1200;
  transition: transform 0.1s ease, background 0.1s ease;
}
.hotspot:hover { background: var(--accent); border-color: var(--accent); transform: translate(-50%, -50%) scale(1.35); }
#betting-grid.grid-locked .hotspot { pointer-events: none; opacity: 0.8; }
.hotspot.has-bet {
  width: 26px;
  height: 26px;
  background: var(--accent);
  border-color: #1a1200;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

#side-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.panel-view[hidden] { display: none; }
.panel-view h2 { margin: 0 0 4px; font-size: 1.1rem; color: var(--accent); }
.panel-view p, .panel-view div#idle-copy { color: var(--text-dim); font-size: 0.85rem; line-height: 1.4; }

.primary-btn, .secondary-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.primary-btn { background: var(--accent); color: #1a1200; }
.primary-btn:hover { filter: brightness(1.1); }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.secondary-btn { background: var(--panel-bg-2); color: var(--text); border: 1px solid var(--border); }
.secondary-btn:hover { border-color: var(--accent); }

#bet-stack-note { color: var(--text-dim); font-size: 0.85rem; }
#wager-note { color: var(--text); font-size: 0.9rem; font-weight: 700; }

#chip-tray { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px dashed rgba(255,255,255,0.5);
  background: var(--panel-bg-2);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}
.chip-btn.selected { border-style: solid; border-color: var(--accent); background: #2a2410; color: var(--accent); }

#bet-actions { display: flex; gap: 8px; }
#bet-actions .primary-btn, #bet-actions .secondary-btn { flex: 1; }

#result-body { display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; }
.win-line { padding: 2px 0; }
.win-line.win { color: var(--good); }
.win-line.lose { color: var(--bad); }

#log-panel {
  height: 130px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
}
#log-title { font-weight: 700; color: var(--accent); font-size: 0.85rem; margin-bottom: 4px; }
#log-entries {
  flex: 1;
  overflow-y: auto;
  font-size: 0.82rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

@media (max-width: 880px) {
  html, body { height: auto; min-height: 100%; }
  #app { height: auto; min-height: 100vh; }
  #main-area { flex-direction: column; }
  #table-wrap { flex: none; padding: 12px 8px 4px; }
  #table { max-width: 100%; max-height: none; }
  #settings-panel { min-width: 180px; }

  #table { overflow-x: auto; }
  #top-bar-left { font-size: 0.75rem; }
  #wheel-wrap { width: 190px; height: 190px; }
  #wheel-ball { width: 11px; height: 11px; }
  #betting-grid {
    grid-template-columns: 20px repeat(12, minmax(16px, 1fr)) 24px;
    grid-template-rows: repeat(3, 26px) 22px 22px;
    gap: 1px;
  }
  .bet-cell { font-size: 0.58rem; }
  .bet-cell.outside { font-size: 0.5rem; }
  .chip-badge { min-width: 14px; height: 14px; font-size: 0.5rem; }
  .hotspot { width: 10px; height: 10px; }
  .hotspot.has-bet { width: 15px; height: 15px; font-size: 0.42rem; }

  #table-banner { font-size: 1rem; }
  #side-panel { width: auto; }
}
