:root {
  --bg: #edf5fb;
  --bg-soft: #f4f9fd;
  --surface: rgba(255, 255, 255, 0.74);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --text: #1f2736;
  --muted: #5f687a;
  --border: rgba(31, 39, 54, 0.14);
  --accent: #4fa7db;
  --accent-strong: #2f86bb;
  --bg-layer-1: radial-gradient(circle at 0 0, #f2f9ff 0%, rgba(242, 249, 255, 0) 35%);
  --bg-layer-2: radial-gradient(circle at 100% 0, rgba(193, 223, 247, 0.56) 0%, rgba(193, 223, 247, 0) 39%);
  --bg-layer-3: linear-gradient(180deg, #e5f1fb 0%, var(--bg) 42%, var(--bg-soft) 100%);
  --menu-bg: rgba(255, 255, 255, 0.95);
  --glass-bg: rgba(255, 255, 255, 0.68);
  --glass-border: rgba(255, 255, 255, 0.9);
  --glass-hover: rgba(255, 255, 255, 0.75);
  --topbar-shadow: 0 10px 24px rgba(20, 44, 77, 0.08);
  --shadow-soft: 0 24px 48px rgba(20, 44, 77, 0.08);
  --shadow-card: 0 16px 30px rgba(20, 44, 77, 0.09);
}

.dark {
  --bg: #1f2632;
  --bg-soft: #1a212d;
  --surface: rgba(36, 45, 60, 0.72);
  --surface-strong: rgba(40, 49, 65, 0.9);
  --text: #edf2fb;
  --muted: #a7b2c6;
  --border: rgba(159, 174, 199, 0.22);
  --accent: #69b7ff;
  --accent-strong: #3d8fd6;
  --bg-layer-1: radial-gradient(circle at 0 0, rgba(84, 105, 146, 0.26) 0%, rgba(84, 105, 146, 0) 38%);
  --bg-layer-2: radial-gradient(circle at 100% 0, rgba(91, 159, 223, 0.24) 0%, rgba(91, 159, 223, 0) 40%);
  --bg-layer-3: linear-gradient(180deg, #242d3c 0%, var(--bg) 42%, var(--bg-soft) 100%);
  --menu-bg: rgba(34, 44, 60, 0.96);
  --glass-bg: rgba(29, 38, 52, 0.72);
  --glass-border: rgba(156, 171, 197, 0.22);
  --glass-hover: rgba(57, 68, 86, 0.72);
  --topbar-shadow: 0 12px 24px rgba(4, 8, 14, 0.34);
  --shadow-soft: 0 22px 48px rgba(3, 6, 13, 0.44);
  --shadow-card: 0 16px 32px rgba(3, 6, 13, 0.36);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  overscroll-behavior-y: none;
  background-color: #1f2632;
}

body {
  min-height: 100dvh;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  line-height: 1.45;
  background-color: var(--bg);
  background:
    radial-gradient(circle at 0 0, #f2f9ff 0%, rgba(242, 249, 255, 0) 35%),
    radial-gradient(circle at 100% 0, rgba(193, 223, 247, 0.56) 0%, rgba(193, 223, 247, 0) 39%),
    linear-gradient(180deg, #e5f1fb 0%, var(--bg) 42%, var(--bg-soft) 100%);
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.light body {
  background-color: #edf5fb;
  background:
    radial-gradient(circle at 0 0, #f2f9ff 0%, rgba(242, 249, 255, 0) 35%),
    radial-gradient(circle at 100% 0, rgba(193, 223, 247, 0.56) 0%, rgba(193, 223, 247, 0) 39%),
    linear-gradient(180deg, #e5f1fb 0%, #edf5fb 42%, #f4f9fd 100%);
}

.dark body {
  background-color: #1f2632;
  background:
    radial-gradient(circle at 0 0, rgba(84, 105, 146, 0.26) 0%, rgba(84, 105, 146, 0) 38%),
    radial-gradient(circle at 100% 0, rgba(91, 159, 223, 0.24) 0%, rgba(91, 159, 223, 0) 40%),
    linear-gradient(180deg, #242d3c 0%, #1f2632 42%, #1a212d 100%);
}

.light {
  background-color: #edf5fb;
}

.dark {
  background-color: #1f2632;
}

@supports (-webkit-touch-callout: none) {
  @media (pointer: coarse) {
    .dark body {
      background-image: none;
    }
  }
}

button {
  cursor: pointer;
}

.site-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(1px);
}

.orb-one {
  width: 360px;
  height: 360px;
  top: -120px;
  right: -90px;
  background: radial-gradient(circle, rgba(90, 170, 230, 0.2), rgba(90, 170, 230, 0));
}

.orb-two {
  width: 280px;
  height: 280px;
  top: 45vh;
  left: -100px;
  background: radial-gradient(circle, rgba(102, 135, 174, 0.12), rgba(102, 135, 174, 0));
}

.orb-three {
  width: 280px;
  height: 280px;
  bottom: -100px;
  right: 18%;
  background: radial-gradient(circle, rgba(69, 140, 206, 0.16), rgba(69, 140, 206, 0));
}

.app-shell {
  width: min(1220px, 95vw);
  margin: 1.1rem auto 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1 0 auto;
}

.topbar {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 0.7rem);
  z-index: 20;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  box-shadow: var(--topbar-shadow);
  padding: 0.62rem 0.84rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.62rem;
  min-width: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 1.95rem;
  height: 1.95rem;
  border-radius: 0.6rem;
  border: 0;
  background: transparent;
  object-fit: cover;
  display: block;
}

.topnav {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.topnav a:hover {
  color: var(--text);
  background: var(--glass-hover);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  margin-left: 0.35rem;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--glass-bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  min-width: 4.1rem;
  font-size: 0.79rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--glass-hover);
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 167, 219, 0.18);
}

.menu-toggle {
  display: none;
  position: relative;
  border: 1px solid var(--border);
  background: var(--glass-bg);
  color: var(--muted);
  border-radius: 0.72rem;
  width: 2.15rem;
  height: 2.15rem;
  align-items: center;
  justify-content: center;
  overflow: visible;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.menu-toggle:hover {
  background: var(--glass-hover);
}

.menu-toggle span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.9rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
  transition: transform 0.24s ease, opacity 0.2s ease;
}

.menu-toggle span:nth-child(1) {
  transform: translate(-50%, -0.32rem);
}

.menu-toggle span:nth-child(2) {
  transform: translate(-50%, -50%);
}

.menu-toggle span:nth-child(3) {
  transform: translate(-50%, 0.2rem);
}

.menu-toggle.open span:nth-child(1) {
  transform: translate(-50%, -50%) rotate(45deg);
}

.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.open span:nth-child(3) {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.mobile-menu {
  display: none;
}

.layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr) minmax(250px, 320px);
  align-items: start;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 1.35rem;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  padding: 1rem;
}

.panel h2 {
  font-size: 1.03rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.85rem;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.controls-roulette {
  margin-top: 0.35rem;
}

.balance-card {
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  padding: 0.85rem;
}

.label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.balance-value {
  margin-top: 0.25rem;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-group label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
}

input[type="number"] {
  appearance: textfield;
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.58rem 0.62rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 167, 219, 0.16);
}

.btn {
  border: 1px solid transparent;
  border-radius: 0.82rem;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 0.62rem 0.84rem;
  transition: transform 0.18s ease, filter 0.18s ease, border-color 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.btn-primary {
  color: #ffffff;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 16px 30px rgba(53, 126, 176, 0.3);
}

.btn-secondary {
  color: var(--text);
  background: var(--surface-strong);
  border-color: var(--border);
}

.btn-ghost {
  color: var(--muted);
  background: transparent;
  border-color: var(--border);
}

.board {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.subtle {
  font-size: 0.82rem;
  color: var(--muted);
}

.total {
  margin-top: 0.38rem;
  font-size: 0.92rem;
  font-weight: 700;
}

.quick-bets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.bet-chip {
  border: 1px solid transparent;
  border-radius: 0.75rem;
  min-height: 2.45rem;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #f7f9ff;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

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

.bet-chip.red {
  background: linear-gradient(145deg, #d05b68 0%, #b7404e 100%);
}

.bet-chip.black {
  background: linear-gradient(145deg, #2f3949 0%, #202734 100%);
}

.bet-chip.green {
  background: linear-gradient(145deg, #3ea672 0%, #2e7e56 100%);
}

.bet-chip.neutral {
  color: var(--text);
  background: var(--surface-strong);
  border-color: var(--border);
}

.bet-chip.number {
  min-height: 2.2rem;
  font-size: 0.8rem;
}

.bet-chip.selected {
  border-color: rgba(250, 253, 255, 0.9);
  box-shadow: 0 0 0 2px var(--accent), 0 12px 22px rgba(53, 126, 176, 0.28);
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.42rem;
}

.board-actions {
  margin-top: 0.3rem;
}

.board-actions .btn-primary {
  width: 100%;
}

.board-actions .btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.roulette-wrap {
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface-strong);
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.72rem;
}

.roulette {
  width: clamp(170px, 28vw, 240px);
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  border: 6px solid rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(21, 31, 47, 0.1), 0 22px 30px rgba(20, 44, 77, 0.22);
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.95) 0 28%, rgba(255, 255, 255, 0) 29%),
    repeating-conic-gradient(#cc4f5e 0 9.73deg, #1f2a3a 9.73deg 19.46deg);
  transition: transform 2.2s cubic-bezier(0.17, 0.84, 0.44, 1);
  will-change: transform;
}

.dark .roulette {
  border-color: rgba(174, 191, 219, 0.32);
  box-shadow: inset 0 0 0 1px rgba(180, 198, 227, 0.18), 0 20px 30px rgba(2, 6, 12, 0.42);
}

#rouletteValue {
  width: 30%;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  font-weight: 800;
  color: #1f2736;
  border: 1px solid rgba(31, 39, 54, 0.12);
}

.result {
  width: 100%;
  text-align: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
}

.result[data-type="success"] {
  color: #11603a;
  background: rgba(59, 177, 118, 0.18);
  border-color: rgba(48, 132, 93, 0.32);
}

.dark .result[data-type="success"] {
  color: #8ee6b7;
  background: rgba(37, 112, 76, 0.3);
  border-color: rgba(108, 182, 145, 0.42);
}

.result[data-type="error"] {
  color: #902f45;
  background: rgba(222, 92, 122, 0.14);
  border-color: rgba(181, 64, 92, 0.32);
}

.dark .result[data-type="error"] {
  color: #ffb3c4;
  background: rgba(128, 49, 66, 0.35);
  border-color: rgba(216, 133, 153, 0.4);
}

.history {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.history-empty {
  color: var(--muted);
  font-size: 0.84rem;
  border: 1px dashed var(--border);
  border-radius: 0.85rem;
  padding: 0.6rem;
  text-align: center;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  border-radius: 0.76rem;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  padding: 0.52rem 0.58rem;
  font-size: 0.8rem;
}

.history-item span {
  color: var(--muted);
}

.history-item strong {
  font-size: 0.84rem;
}

.history-item.win strong {
  color: #197a4d;
}

.dark .history-item.win strong {
  color: #92efc3;
}

.history-item.loss strong {
  color: #a33b52;
}

.dark .history-item.loss strong {
  color: #ffb5c5;
}

.site-footer {
  width: min(1220px, 95vw);
  margin: 1.9rem auto calc(2rem + env(safe-area-inset-bottom, 0px));
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(146, 171, 207, 0.45);
  text-underline-offset: 0.15em;
}

.site-footer a:hover {
  color: var(--text);
}

@media (max-width: 1160px) {
  .layout {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  }

  .history {
    grid-column: 1 / -1;
  }

  .history-list {
    max-height: 250px;
  }
}

@media (max-width: 840px) {
  .app-shell {
    width: min(96vw, 760px);
    margin-top: 0.8rem;
    margin-bottom: 1rem;
  }

  .site-footer {
    width: min(96vw, 760px);
    margin: 1.3rem auto calc(0.8rem + env(safe-area-inset-bottom, 0px));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .controls,
  .board,
  .history {
    grid-column: auto;
  }

  .topbar {
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    border-radius: 999px;
    gap: 0.45rem;
    padding: 0.48rem 0.56rem;
    position: sticky;
    overflow: visible;
  }

  .brand {
    gap: 0.46rem;
    font-size: 0.9rem;
    flex-shrink: 0;
  }

  .brand-mark {
    width: 1.78rem;
    height: 1.78rem;
  }

  .topnav {
    display: none;
  }

  .topbar-actions {
    margin-left: auto;
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 0.34rem;
  }

  .theme-toggle {
    min-width: auto;
    padding: 0.36rem 0.58rem;
    font-size: 0.74rem;
    line-height: 1.1;
  }

  .menu-toggle {
    display: inline-flex;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
  }

  .mobile-menu {
    display: flex;
    position: absolute;
    top: calc(100% + 0.48rem);
    right: 0;
    width: min(16.8rem, calc(100vw - 1.2rem));
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.38rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    background: var(--menu-bg);
    backdrop-filter: blur(14px) saturate(120%);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    box-shadow: var(--topbar-shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 30;
  }

  .mobile-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .mobile-menu a {
    display: flex;
    align-items: center;
    padding: 0.55rem 0.68rem;
    border-radius: 0.76rem;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
    transition: color 0.2s ease, background-color 0.2s ease;
  }

  .mobile-menu a:hover,
  .mobile-menu a[aria-current="page"] {
    color: var(--text);
    background: var(--glass-hover);
  }

  body.menu-open {
    overflow: hidden;
  }

  .quick-bets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .roulette {
    width: min(72vw, 230px);
  }
}

@media (max-width: 460px) {
  .panel {
    padding: 0.85rem;
    border-radius: 1.1rem;
  }

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

  .theme-toggle {
    min-width: auto;
    padding-inline: 0.7rem;
  }
}
