:root {
  --bg: #090a0d;
  --bg-soft: #11141a;
  --panel: rgba(20, 23, 31, 0.9);
  --panel-strong: #171b24;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f6f2e9;
  --muted: #a9afba;
  --gold: #d8a746;
  --gold-strong: #ffc861;
  --green: #1dbf74;
  --red: #d54545;
  --black: #101116;
  --blue: #5f8cff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(216, 167, 70, 0.18), transparent 34rem),
    radial-gradient(circle at 84% 12%, rgba(29, 191, 116, 0.13), transparent 28rem),
    linear-gradient(145deg, #08090d 0%, #0e1118 45%, #10141a 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(216, 167, 70, 0.14);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.public-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(440px, 100%);
}

.auth-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(23, 27, 36, 0.94), rgba(13, 16, 22, 0.94));
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 34px;
}

.auth-card h1,
.topbar h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.auth-card h1 {
  font-size: clamp(2rem, 8vw, 3.4rem);
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(216, 167, 70, 0.48);
  border-radius: 8px;
  color: var(--gold-strong);
  background: linear-gradient(135deg, rgba(216, 167, 70, 0.16), rgba(29, 191, 116, 0.1));
  font-weight: 900;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stack-form {
  display: grid;
  gap: 16px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.inline-form label {
  min-width: 190px;
  flex: 1;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.button.primary {
  color: #151008;
  background: linear-gradient(135deg, var(--gold-strong), #d99830);
  font-weight: 800;
}

.button.secondary {
  border-color: rgba(216, 167, 70, 0.38);
  background: rgba(216, 167, 70, 0.12);
}

.button.ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.button.full {
  width: 100%;
}

.flash {
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.055);
}

.flash.success {
  border-color: rgba(29, 191, 116, 0.4);
}

.flash.error {
  border-color: rgba(213, 69, 69, 0.5);
}

.app-body {
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--line);
  padding: 22px;
  background: rgba(8, 9, 13, 0.82);
  backdrop-filter: blur(16px);
}

.logo {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo small {
  display: block;
  color: var(--muted);
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.sidebar nav a {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--muted);
}

.sidebar nav a.active,
.sidebar nav a:hover {
  border-color: rgba(216, 167, 70, 0.28);
  color: var(--text);
  background: rgba(216, 167, 70, 0.1);
}

.sidebar-foot {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.balance-chip {
  display: inline-flex;
  border: 1px solid rgba(216, 167, 70, 0.24);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--gold-strong);
  background: rgba(216, 167, 70, 0.1);
}

.main {
  width: min(1500px, 100%);
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.switch {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.switch input:checked + span::after {
  transform: translateX(20px);
  background: var(--gold-strong);
}

.grid {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  grid-template-columns: 2fr 1fr 1fr;
}

.two-col {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 18px;
}

.admin-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head a {
  color: var(--gold);
  font-size: 0.92rem;
}

.hero-panel {
  position: relative;
  min-height: 220px;
  overflow: hidden;
}

.hero-panel::after {
  content: "";
  position: absolute;
  right: -92px;
  bottom: -110px;
  width: 320px;
  height: 320px;
  border: 34px solid rgba(216, 167, 70, 0.16);
  border-radius: 50%;
}

.hero-panel h2 {
  position: relative;
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.4rem);
  z-index: 1;
}

.quick-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  z-index: 1;
}

.stat-card {
  display: grid;
  align-content: center;
  gap: 10px;
}

.stat-card span {
  color: var(--muted);
}

.stat-card strong {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
}

.stat-card small {
  color: var(--muted);
  line-height: 1.5;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.leaderboard,
.activity-list,
.challenge-list {
  display: grid;
  gap: 10px;
}

.leader-row,
.activity-item,
.challenge-card {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.challenge-card {
  grid-template-columns: 1fr auto;
}

.rank {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  color: #110e08;
  background: var(--gold);
  font-weight: 900;
}

.activity-item {
  grid-template-columns: auto 1fr auto;
}

.activity-item small,
.leader-row small {
  display: block;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
  background: var(--muted);
}

.dot.red {
  background: var(--red);
}

.dot.black {
  background: #040507;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.dot.green {
  background: var(--green);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.side-stack {
  display: grid;
  align-self: start;
  gap: 18px;
}

.roulette-stage {
  position: relative;
  display: grid;
  min-height: 640px;
  place-items: center;
  overflow: hidden;
}

.roulette-wheel {
  position: relative;
  width: min(62vw, 540px);
  aspect-ratio: 1;
  border: 12px solid #c99838;
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 28%, #15171e 28% 33%, transparent 33%),
    conic-gradient(
      from -4.865deg,
      var(--green) 0deg 9.73deg,
      var(--red) 9.73deg 19.46deg,
      #08090c 19.46deg 29.19deg,
      var(--red) 29.19deg 38.92deg,
      #08090c 38.92deg 48.65deg,
      var(--red) 48.65deg 58.38deg,
      #08090c 58.38deg 68.11deg,
      var(--red) 68.11deg 77.84deg,
      #08090c 77.84deg 87.57deg,
      var(--red) 87.57deg 97.30deg,
      #08090c 97.30deg 107.03deg,
      var(--red) 107.03deg 116.76deg,
      #08090c 116.76deg 126.49deg,
      var(--red) 126.49deg 136.22deg,
      #08090c 136.22deg 145.95deg,
      var(--red) 145.95deg 155.68deg,
      #08090c 155.68deg 165.41deg,
      var(--red) 165.41deg 175.14deg,
      #08090c 175.14deg 184.87deg,
      var(--red) 184.87deg 194.60deg,
      #08090c 194.60deg 204.33deg,
      var(--red) 204.33deg 214.06deg,
      #08090c 214.06deg 223.79deg,
      var(--red) 223.79deg 233.52deg,
      #08090c 233.52deg 243.25deg,
      var(--red) 243.25deg 252.98deg,
      #08090c 252.98deg 262.71deg,
      var(--red) 262.71deg 272.44deg,
      #08090c 272.44deg 282.17deg,
      var(--red) 282.17deg 291.90deg,
      #08090c 291.90deg 301.63deg,
      var(--red) 301.63deg 311.36deg,
      #08090c 311.36deg 321.09deg,
      var(--red) 321.09deg 330.82deg,
      #08090c 330.82deg 340.55deg,
      var(--red) 340.55deg 350.28deg,
      #08090c 350.28deg 360deg
    );
  box-shadow: inset 0 0 0 14px rgba(255, 255, 255, 0.08), 0 34px 90px rgba(0, 0, 0, 0.52);
  transition: transform 4.2s cubic-bezier(0.12, 0.72, 0.08, 1);
}

.roulette-wheel.spinning {
  filter: saturate(1.2) brightness(1.06);
}

.wheel-core {
  position: absolute;
  inset: 31%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216, 167, 70, 0.5);
  border-radius: 50%;
  background: radial-gradient(circle, #2b2315, #090a0d 68%);
  text-align: center;
}

.wheel-core span {
  color: var(--gold-strong);
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 950;
}

.wheel-core small {
  color: var(--muted);
}

.roulette-pointer {
  position: absolute;
  top: 44px;
  z-index: 4;
  width: 0;
  height: 0;
  border-right: 17px solid transparent;
  border-left: 17px solid transparent;
  border-top: 34px solid var(--gold-strong);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

.result-strip {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.result-strip.success {
  border-color: rgba(29, 191, 116, 0.42);
  color: var(--green);
}

.result-strip.danger {
  border-color: rgba(213, 69, 69, 0.46);
  color: var(--red);
}

.bet-panel {
  align-self: start;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.color-choice {
  cursor: pointer;
}

.color-choice input {
  position: absolute;
  opacity: 0;
}

.color-choice span {
  display: grid;
  min-height: 80px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: 900;
}

.red-choice span {
  background: rgba(213, 69, 69, 0.18);
}

.black-choice span {
  background: rgba(0, 0, 0, 0.3);
}

.color-choice input:checked + span {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(216, 167, 70, 0.14);
}

.rule-box {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
}

.rule-box strong {
  color: var(--text);
}

.dice-showcase {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  margin: 30px 0;
}

.die {
  position: relative;
  display: grid;
  width: min(30vw, 138px);
  aspect-ratio: 1;
  border: 1px solid rgba(216, 167, 70, 0.4);
  border-radius: 8px;
  padding: 16px;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  background: linear-gradient(145deg, #f7f2df, #cba24b);
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.36);
}

.die span {
  display: none;
  width: 18px;
  height: 18px;
  place-self: center;
  border-radius: 50%;
  background: #151008;
}

.die[data-face="1"] span:nth-child(5) {
  display: block;
}

.die[data-face="2"] span:nth-child(1),
.die[data-face="2"] span:nth-child(9),
.die[data-face="3"] span:nth-child(1),
.die[data-face="3"] span:nth-child(5),
.die[data-face="3"] span:nth-child(9),
.die[data-face="4"] span:nth-child(1),
.die[data-face="4"] span:nth-child(3),
.die[data-face="4"] span:nth-child(7),
.die[data-face="4"] span:nth-child(9),
.die[data-face="5"] span:nth-child(1),
.die[data-face="5"] span:nth-child(3),
.die[data-face="5"] span:nth-child(5),
.die[data-face="5"] span:nth-child(7),
.die[data-face="5"] span:nth-child(9),
.die[data-face="6"] span:nth-child(1),
.die[data-face="6"] span:nth-child(3),
.die[data-face="6"] span:nth-child(4),
.die[data-face="6"] span:nth-child(6),
.die[data-face="6"] span:nth-child(7),
.die[data-face="6"] span:nth-child(9) {
  display: block;
}

.versus {
  color: var(--gold-strong);
  font-size: 1.6rem;
  font-weight: 950;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(29, 191, 116, 0.35);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green);
  background: rgba(29, 191, 116, 0.1);
  font-size: 0.8rem;
  font-weight: 800;
}

.status-pill.disabled {
  border-color: rgba(213, 69, 69, 0.35);
  color: var(--red);
  background: rgba(213, 69, 69, 0.1);
}

.status-pill.pending {
  border-color: rgba(216, 167, 70, 0.4);
  color: var(--gold-strong);
  background: rgba(216, 167, 70, 0.1);
}

.status-pill.completed {
  border-color: rgba(29, 191, 116, 0.35);
  color: var(--green);
  background: rgba(29, 191, 116, 0.1);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(380px, 58vh) auto;
}

.side-stack .chat-panel {
  grid-template-rows: auto minmax(220px, 34vh) auto auto;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.16);
}

.chat-message {
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.055);
}

.chat-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-delete {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(213, 69, 69, 0.35);
  border-radius: 8px;
  color: var(--red);
  background: rgba(213, 69, 69, 0.1);
  cursor: pointer;
}

.chat-message p {
  margin: 4px 0;
}

.chat-message small {
  color: var(--muted);
}

.chat-form {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.emoji-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.emoji-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
}

.emoji-button:hover {
  border-color: rgba(216, 167, 70, 0.45);
  background: rgba(216, 167, 70, 0.1);
}

.chat-form input {
  flex: 1;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-grid .button,
.settings-grid .check-row {
  grid-column: 1 / -1;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.table-wrap {
  overflow-x: auto;
}

.mini-form {
  display: flex;
  min-width: 520px;
  gap: 8px;
}

.mini-form input {
  min-width: 120px;
}

@media (max-width: 1100px) {
  .app-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .sidebar-foot {
    grid-template-columns: 1fr 1fr auto;
    align-items: center;
  }

  .dashboard-grid,
  .admin-stats,
  .game-layout,
  .two-col {
    grid-template-columns: 1fr;
  }

  .roulette-stage {
    min-height: 560px;
  }
}

@media (max-width: 720px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .chat-form,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar nav {
    grid-template-columns: 1fr 1fr;
  }

  .sidebar-foot {
    grid-template-columns: 1fr;
  }

  .leader-row,
  .activity-item {
    grid-template-columns: auto 1fr;
  }

  .leader-row > span:nth-last-child(-n+2),
  .activity-item > span:last-child {
    grid-column: 2;
  }

  .roulette-stage {
    min-height: 440px;
  }

  .roulette-wheel {
    width: min(84vw, 430px);
  }

  .settings-grid,
  .choice-grid {
    grid-template-columns: 1fr;
  }

  .dice-showcase {
    gap: 12px;
  }
}
