:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --ink: #172033;
  --muted: #667085;
  --line: #d9dfeb;
  --line-strong: #c7cfdd;
  --gold: #f5bd2f;
  --gold-2: #fff2bf;
  --mint: #39c68a;
  --blue: #3b82f6;
  --rose: #f35f7f;
  --shadow: 0 22px 58px rgba(23, 32, 51, 0.12);
  --shadow-soft: 0 8px 24px rgba(23, 32, 51, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.api-progress {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  z-index: 220;
  width: min(460px, calc(100% - 24px));
  padding: 10px 12px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 34px rgba(23, 32, 51, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -14px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.api-progress.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.api-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #475467;
  font-size: 13px;
  font-weight: 850;
}

.api-progress-head strong {
  min-width: 42px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.api-progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e9f1;
}

.api-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #2eae78;
  box-shadow: 0 0 12px rgba(46, 174, 120, 0.35);
  transition: width 150ms ease-out, background 160ms ease;
}

.api-progress[data-state="error"] {
  border-color: #f0a4b4;
}

.api-progress[data-state="error"] .api-progress-track span {
  background: var(--rose);
  box-shadow: 0 0 12px rgba(243, 95, 127, 0.3);
}

body.api-connecting {
  cursor: progress;
}

body.api-connecting .app {
  pointer-events: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.app {
  min-height: 100vh;
  padding-bottom: 88px;
}

.hidden {
  display: none !important;
}

.auth-gate,
.maintenance-screen {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(246, 247, 251, 0.97);
  backdrop-filter: blur(10px);
}

.auth-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.auth-card p {
  color: var(--muted);
  line-height: 1.65;
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 900;
}

.auth-card input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.password-field {
  position: relative;
  display: block;
  width: 100%;
}

.password-field > input {
  width: 100%;
  padding-right: 48px;
}

.password-visibility {
  position: absolute;
  top: 50%;
  right: 2px;
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #697383;
  transform: translateY(-50%);
  cursor: pointer;
}

.password-visibility:hover {
  background: #f1f3f2;
  color: var(--ink);
}

.password-visibility:focus-visible {
  outline: 3px solid rgba(242, 189, 53, 0.34);
}

.password-eye {
  position: relative;
  display: block;
  width: 19px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 60% 40% / 60% 40%;
  transform: rotate(45deg);
}

.password-eye::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  transform: translate(-50%, -50%);
}

.password-visibility[aria-pressed="true"] .password-eye::before {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: -4px;
  width: 25px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 0 0 2px #fff;
  content: "";
  transform: translateY(-50%);
}

.admin-auth-view {
  display: none;
  gap: 14px;
}

.admin-auth-view.active {
  display: grid;
}

.auth-inline-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-inline-head h1,
.auth-inline-head p {
  margin: 0;
}

.auth-inline-head p {
  font-size: 12px;
}

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

.auth-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-status.error {
  color: #a1263f;
}

.auth-status.success {
  color: #12633f;
}

.icon-button,
.text-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  padding: 0;
}

.text-button {
  min-height: 36px;
  justify-self: start;
  padding: 0 8px;
  border-color: transparent;
  color: var(--blue);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 38px);
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.menu-button {
  display: grid;
  gap: 5px;
  place-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 80;
  width: min(360px, calc(100vw - 36px));
  padding: 16px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 28px 0 70px rgba(23, 32, 51, 0.16);
  transform: translateX(-105%);
  transition: transform 180ms ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: none;
  background: rgba(23, 32, 51, 0.25);
  backdrop-filter: blur(2px);
}

.drawer-backdrop.show {
  display: block;
}

.drawer-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.drawer-head strong,
.drawer-head small,
.account-row strong,
.account-row small,
.account-panel strong,
.account-panel small {
  display: block;
}

.drawer-head small,
.account-row small,
.account-panel small {
  color: var(--muted);
}

.drawer-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 900;
}

.account-panel,
.account-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-panel {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff7d6, #fff);
}

.account-row {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #172033;
  color: #fff;
  font-weight: 950;
}

.drawer-nav {
  display: grid;
  gap: 8px;
}

.drawer-nav button,
.drawer-nav a {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
}

.drawer-nav a {
  background: var(--gold-2);
  border-color: #d9a20f;
}

.drawer-foot {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
}

.drawer-foot span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.drawer-foot strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 2px solid #e2a70f;
  border-radius: 8px;
  background: linear-gradient(145deg, #fff4c8, #f5bd2f);
  color: #352400;
  font-weight: 950;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), var(--shadow-soft);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.top-tabs,
.mobile-tabs,
.game-picker,
.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab,
.game-chip,
.admin-nav,
.ghost,
.primary,
.danger {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.tab:hover,
.game-chip:hover,
.admin-nav:hover,
.ghost:hover,
.primary:hover,
.danger:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.tab {
  padding: 0 16px;
}

.tab.active,
.game-chip.active,
.admin-nav.active {
  border-color: #d9a20f;
  background: var(--gold-2);
  color: #4a3500;
}

main {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
}

.view,
.game-view,
.admin-section {
  display: none;
}

.view.active,
.game-view.active,
.admin-section.active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: clamp(18px, 4vw, 42px);
  align-items: center;
  padding: clamp(36px, 7vw, 72px) 0 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #9b6c00;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 16px;
  font-size: clamp(40px, 6.5vw, 74px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.06;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
}

.lead {
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.75;
}

.balance-card,
.machine,
.side-panel,
.admin-panel,
.admin-menu {
  border: 1px solid rgba(199, 207, 221, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.balance-card {
  padding: 22px;
  background:
    linear-gradient(145deg, rgba(255, 242, 191, 0.86), rgba(255, 255, 255, 0.94) 54%),
    #fff;
}

.balance-card span,
.balance-card strong {
  display: block;
}

.balance-card > span {
  color: var(--muted);
  font-weight: 800;
}

.balance-card > strong {
  margin: 8px 0 16px;
  font-size: 42px;
}

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

.balance-meta span {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
}

.game-picker {
  position: sticky;
  top: 77px;
  z-index: 20;
  overflow-x: auto;
  padding: 12px 0;
  background: rgba(246, 247, 251, 0.9);
  backdrop-filter: blur(12px);
}

.game-chip {
  flex: 0 0 auto;
  padding: 0 16px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 340px);
  gap: 18px;
  padding: 18px 0 44px;
}

.machine,
.side-panel {
  padding: clamp(16px, 3vw, 24px);
}

.machine {
  position: relative;
  overflow: hidden;
}

.machine::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--gold), var(--mint), var(--blue), var(--rose));
}

.machine-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.select,
.inline-field input,
.form-grid input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.cost-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--gold-2);
  color: #5c4200;
  font-weight: 900;
}

.primary,
.ghost {
  padding: 0 16px;
}

.primary {
  border-color: #d9a20f;
  background: var(--gold);
  color: #352400;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
}

.ghost {
  background: var(--surface);
}

.danger {
  padding: 0 16px;
  border-color: #ff8a00;
  background: linear-gradient(135deg, #ff4d6d, #ffb703);
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 77, 109, 0.24);
}

.wide {
  width: 100%;
}

.hint {
  color: var(--muted);
  line-height: 1.7;
}

.scratch-board {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 420 / 260;
  margin: 0 auto 16px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255,255,255,0.86), transparent 8rem),
    linear-gradient(135deg, #fff7d6, #e7f8ef);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6), var(--shadow-soft);
}

.prize-layer,
#scratchCanvas {
  position: absolute;
  inset: 0;
}

.prize-layer {
  display: grid;
  place-items: center;
  text-align: center;
}

.prize-layer span {
  display: block;
  color: #1d2a3f;
  font-size: clamp(48px, 9vw, 86px);
  font-weight: 950;
}

.prize-layer small {
  display: block;
  color: var(--muted);
  font-weight: 900;
}

#scratchCanvas {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.mini-stats {
  display: grid;
  gap: 10px;
}

.mini-stats div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border-radius: 8px;
  background: var(--surface-2);
}

.mini-stats span {
  color: var(--muted);
}

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

.pointer {
  position: absolute;
  top: 16px;
  z-index: 2;
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 34px solid var(--rose);
  filter: drop-shadow(0 4px 4px rgba(23, 32, 51, 0.2));
}

.roulette-wheel {
  position: relative;
  width: min(330px, 78vw);
  height: min(330px, 78vw);
  border: 12px solid #ffffff;
  border-radius: 999px;
  background: conic-gradient(
    #f5bd2f 0deg 45deg,
    #eef2f7 45deg 90deg,
    #39c68a 90deg 135deg,
    #fff2bf 135deg 180deg,
    #3b82f6 180deg 225deg,
    #e7f8ef 225deg 270deg,
    #f35f7f 270deg 315deg,
    #172033 315deg 360deg
  );
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.7), 0 18px 46px rgba(23, 32, 51, 0.18);
  transition: transform 4s cubic-bezier(0.12, 0.76, 0.15, 1);
}

.roulette-wheel::after {
  content: "";
  position: absolute;
  inset: 42%;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--line);
}

.wheel-label {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 42px;
  height: 42px;
  margin: -21px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.84);
  font-weight: 950;
}

.label-0 { transform: rotate(22deg) translateY(-122px) rotate(-22deg); }
.label-1 { transform: rotate(67deg) translateY(-122px) rotate(-67deg); }
.label-2 { transform: rotate(112deg) translateY(-122px) rotate(-112deg); }
.label-3 { transform: rotate(157deg) translateY(-122px) rotate(-157deg); }
.label-4 { transform: rotate(202deg) translateY(-122px) rotate(-202deg); }
.label-5 { transform: rotate(247deg) translateY(-122px) rotate(-247deg); }
.label-6 { transform: rotate(292deg) translateY(-122px) rotate(-292deg); }
.label-7 { transform: rotate(337deg) translateY(-122px) rotate(-337deg); color: #fff; background: #172033; }

.result-box {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 800;
  line-height: 1.55;
}

.rules-title {
  margin-top: 18px;
}

.rules-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.rules-list li {
  margin: 7px 0;
}

.coin-stage {
  display: grid;
  place-items: center;
  gap: 16px;
  min-height: 330px;
}

.coin {
  display: grid;
  place-items: center;
  width: min(230px, 60vw);
  height: min(230px, 60vw);
  border-radius: 999px;
  border: 12px solid #fff;
  background: radial-gradient(circle at 34% 28%, #fff8d8, #f5bd2f 68%, #c88b07);
  color: #342400;
  font-size: 54px;
  font-weight: 950;
  box-shadow: var(--shadow);
  transform-style: preserve-3d;
}

.coin.flip {
  animation: coinFlip 900ms ease-out;
}

@keyframes coinFlip {
  50% { transform: rotateY(540deg) translateY(-12px); }
  100% { transform: rotateY(1080deg) translateY(0); }
}

.coin-status {
  text-align: center;
}

.coin-status span,
.coin-status strong,
.coin-status small {
  display: block;
}

.coin-status strong {
  font-size: 42px;
}

.coin-status small {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 950;
}

.machine.all-in {
  border-color: #ff8a00;
  box-shadow: 0 18px 48px rgba(255, 77, 109, 0.18), 0 0 0 4px rgba(255, 183, 3, 0.18);
}

.machine.all-in .coin-status small {
  color: #ff4d6d;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.inline-field input {
  width: 92px;
}

.card-table,
.blackjack-table {
  display: grid;
  gap: 18px;
  min-height: 320px;
  padding: 20px;
  border: 1px solid #b7e6cd;
  border-radius: 8px;
  background:
    radial-gradient(circle at top right, rgba(245, 189, 47, 0.15), transparent 16rem),
    linear-gradient(135deg, rgba(57, 198, 138, 0.14), rgba(59, 130, 246, 0.08)),
    #f8fffb;
}

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

.score-board div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.score-board span,
.score-board strong {
  display: block;
}

.score-board span {
  color: var(--muted);
  font-weight: 900;
}

.score-board strong {
  margin-top: 4px;
  font-size: 30px;
}

.card-table {
  grid-template-columns: 130px minmax(0, 1fr);
  align-items: center;
}

.deck,
.playing-card {
  display: grid;
  place-items: center;
  width: 108px;
  height: 150px;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.12);
  font-weight: 950;
}

.deck {
  background: linear-gradient(145deg, #172033, #3b4a68);
  color: #fff;
}

.deck.deal {
  animation: deckTap 500ms ease-out;
}

@keyframes deckTap {
  50% { transform: translateX(18px) rotate(4deg); }
}

.hand-zone,
.hand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 162px;
  flex-wrap: wrap;
}

.playing-card {
  background: #fff;
  color: #172033;
  font-size: 52px;
}

.playing-card.next {
  color: var(--muted);
  background: #f8fafc;
}

.playing-card.dealt,
.hand .playing-card {
  animation: dealCard 360ms ease-out;
}

@keyframes dealCard {
  from { transform: translate(-90px, -18px) rotate(-10deg); opacity: 0; }
  to { transform: translate(0, 0) rotate(0); opacity: 1; }
}

.table-label {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 900;
}

.lotto-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
  align-items: start;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.number-grid button {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 900;
}

.number-grid button.selected {
  border-color: #d9a20f;
  background: var(--gold);
  color: #352400;
}

.lotto-ticket {
  min-height: 180px;
  padding: 18px;
  border: 1px dashed #d9a20f;
  border-radius: 8px;
  background: var(--gold-2);
  color: #5a4000;
  font-weight: 950;
  line-height: 1.8;
}

.page-head {
  padding: clamp(34px, 6vw, 62px) 0 22px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.sync-status span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #94a3b8;
}

.sync-status[data-state="online"] {
  border-color: #8ddab8;
  color: #12633f;
}

.sync-status[data-state="online"] span {
  background: var(--mint);
}

.sync-status[data-state="offline"] {
  border-color: #f4a6b6;
  color: #9c2841;
}

.sync-status[data-state="offline"] span {
  background: var(--rose);
}

.sync-status[data-state="connecting"] span {
  animation: syncPulse 900ms ease-in-out infinite alternate;
}

@keyframes syncPulse {
  to { opacity: 0.32; }
}

.admin-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  padding-bottom: 46px;
}

.admin-layout > * {
  min-width: 0;
}

.admin-menu {
  display: grid;
  align-content: start;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 12px;
}

.admin-nav {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  padding: 0 14px;
}

.nav-count {
  display: inline-grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--rose);
  color: #fff;
  font-size: 11px;
}

.admin-panel {
  width: 100%;
  min-width: 0;
  padding: 22px;
}

.admin-section h2,
.admin-section p {
  letter-spacing: 0;
}

.section-heading-row,
.box-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-heading-row {
  margin-bottom: 16px;
}

.section-heading-row h2,
.section-heading-row p,
.box-heading-row h3 {
  margin: 0;
}

.section-heading-row p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.5;
}

.settlement-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.settlement-overview > div {
  display: grid;
  gap: 5px;
  min-height: 76px;
  align-content: center;
  padding: 12px 14px;
  border-left: 1px solid var(--line);
}

.settlement-overview > div:first-child {
  border-left: 0;
}

.settlement-overview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.settlement-overview strong {
  font-size: 20px;
}

.positive {
  color: #12633f;
}

.negative {
  color: #a1263f;
}

.status-tabs {
  display: flex;
  gap: 6px;
  margin: 14px 0;
  overflow-x: auto;
}

.status-tabs button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.status-tabs button.active {
  border-color: #d9a20f;
  background: var(--gold-2);
  color: #4a3500;
}

.settlement-list,
.application-list,
.settings-stack {
  display: grid;
  gap: 10px;
}

.settlement-item,
.application-item,
.managed-user,
.managed-operator {
  display: grid;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.settlement-row,
.application-row,
.managed-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.settlement-person strong,
.settlement-person small,
.application-person strong,
.application-person small,
.managed-person strong,
.managed-person small {
  display: block;
}

.settlement-person small,
.application-person small,
.managed-person small {
  margin-top: 3px;
  color: var(--muted);
}

.settlement-amount {
  text-align: right;
}

.settlement-amount strong,
.settlement-amount small {
  display: block;
}

.settlement-amount strong {
  font-size: 21px;
}

.settlement-amount small {
  color: var(--muted);
}

.settlement-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.status-pill.active,
.status-pill.processing {
  border-color: #8ddab8;
  background: #e6f7ef;
  color: #12633f;
}

.status-pill.hold,
.status-pill.pending,
.status-pill.setup {
  border-color: #e6ca79;
  background: var(--gold-2);
  color: #6f5000;
}

.status-pill.suspended,
.status-pill.rejected {
  border-color: #efb4bf;
  background: #fff0f3;
  color: #a1263f;
}

.ledger-detail {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.ledger-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.ledger-row small {
  color: var(--muted);
}

.application-reason {
  margin: 0;
  padding: 11px;
  border-left: 3px solid var(--gold);
  background: var(--surface-2);
  color: var(--ink);
  line-height: 1.6;
}

.permission-fieldset,
.inline-permissions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.permission-fieldset legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.permission-fieldset label,
.inline-permissions label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 12px;
}

.permission-fieldset input,
.inline-permissions input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
}

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

.compact-search {
  width: min(190px, 50%);
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.managed-controls {
  display: grid;
  grid-template-columns: 100px minmax(150px, 1fr) auto;
  gap: 8px;
}

.managed-controls input,
.managed-controls select {
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  background: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 900;
}

.form-grid input:focus,
.select:focus,
.inline-field input:focus {
  outline: 3px solid rgba(245, 189, 47, 0.28);
  border-color: #d9a20f;
}

.account-admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1.25fr);
  gap: 14px;
}

.admin-box {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.admin-box h3 {
  margin: 0;
}

.admin-box label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 900;
}

.admin-box input,
.account-edit-row input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.account-table,
.operator-list {
  display: grid;
  gap: 10px;
}

.account-edit-row,
.operator-row,
.system-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.operator-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.account-edit-row strong,
.account-edit-row small,
.operator-row strong,
.operator-row small {
  display: block;
}

.account-edit-row small,
.operator-row small,
.system-row p {
  color: var(--muted);
}

.system-row {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 16px;
}

.system-row h3,
.system-row p {
  margin: 0;
}

.toggle-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 950;
}

.toggle-button span {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--line-strong);
}

.toggle-button.on {
  border-color: #d9a20f;
  background: var(--gold-2);
  color: #4a3500;
}

.toggle-button.on span {
  background: var(--gold);
}

.mobile-tabs {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 40;
  display: none;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.mobile-tabs .tab {
  flex: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  z-index: 150;
  max-width: min(440px, calc(100% - 28px));
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #172033;
  color: #fff;
  box-shadow: var(--shadow);
  transition: 180ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(245, 189, 47, 0.45), transparent 18rem),
    radial-gradient(circle at 80% 34%, rgba(57, 198, 138, 0.38), transparent 16rem),
    rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(2px);
  transition: opacity 180ms ease;
}

.celebration.show {
  opacity: 1;
  animation: flashWin 1200ms ease-out;
}

.celebration strong,
.celebration span {
  grid-area: 1 / 1;
  display: block;
  text-align: center;
  text-shadow: 0 12px 30px rgba(23, 32, 51, 0.22);
}

.celebration strong {
  transform: translateY(-42px);
  color: #172033;
  font-size: clamp(54px, 14vw, 160px);
  font-weight: 950;
  letter-spacing: 0;
}

.celebration span {
  transform: translateY(70px);
  padding: 10px 22px;
  border-radius: 999px;
  background: #172033;
  color: #fff;
  font-size: clamp(28px, 7vw, 76px);
  font-weight: 950;
}

.spark {
  position: fixed;
  z-index: 75;
  width: 10px;
  height: 18px;
  border-radius: 3px;
  pointer-events: none;
  animation: sparkFall 900ms ease-out forwards;
}

@keyframes flashWin {
  0% { transform: scale(0.96); filter: saturate(1); }
  24% { transform: scale(1.02); filter: saturate(1.7); }
  100% { transform: scale(1); filter: saturate(1); }
}

@keyframes sparkFall {
  to {
    transform: translate(var(--dx), var(--dy)) rotate(620deg);
    opacity: 0;
  }
}

.lotto-admin-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lotto-admin-overview > div {
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 72px;
  padding: 11px 13px;
  border-right: 1px solid var(--line);
}

.lotto-admin-overview > div:last-child {
  border-right: 0;
}

.lotto-admin-overview span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.lotto-admin-overview strong {
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lotto-admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 14px;
  margin-bottom: 14px;
}

.lotto-round-control .form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 2px;
}

.lotto-admin-method {
  display: grid;
  gap: 7px;
}

.lotto-admin-method > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.lotto-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.lotto-mode-switch button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
}

.lotto-mode-switch button:last-child {
  border-right: 0;
}

.lotto-mode-switch button.active {
  background: #172033;
  color: #fff;
}

.lotto-admin-picker {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lotto-admin-picker.hidden {
  display: none;
}

.lotto-admin-picker .box-heading-row h3 {
  font-size: 14px;
}

.lotto-admin-picker .box-heading-row strong {
  color: #765300;
}

.lotto-admin-number-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.lotto-admin-number-grid button {
  min-width: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.lotto-admin-number-grid button.selected {
  border-color: #c58d00;
  background: var(--gold-2);
  color: #4a3500;
  box-shadow: inset 0 0 0 2px #fff2bd;
}

.lotto-admin-number-grid button:disabled:not(.selected) {
  opacity: 0.36;
}

.lotto-admin-picker .hint {
  margin: 0;
}

.lotto-admin-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.lotto-admin-ticket-list {
  display: grid;
  align-content: start;
  gap: 7px;
  max-height: 424px;
  overflow: auto;
}

.lotto-admin-ticket {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.lotto-admin-person {
  display: grid;
  min-width: 0;
}

.lotto-admin-person strong,
.lotto-admin-person small,
.lotto-admin-ticket-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lotto-admin-person strong {
  font-size: 13px;
}

.lotto-admin-person small,
.lotto-admin-ticket-meta {
  color: var(--muted);
  font-size: 10px;
}

.lotto-admin-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.lotto-admin-balls span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #d3a021;
  border-radius: 999px;
  background: var(--gold-2);
  color: #4a3500;
  font-size: 11px;
  font-weight: 950;
}

.lotto-admin-balls span.operator-fixed {
  border-color: #3f83d1;
  background: #dcecff;
  color: #194f89;
}

.lotto-admin-history-box {
  background: #fff;
}

.lotto-admin-history {
  display: grid;
  gap: 7px;
}

.lotto-admin-history-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.55fr) auto minmax(260px, 1.1fr);
  align-items: center;
  gap: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.lotto-admin-history-heading {
  display: grid;
}

.lotto-admin-history-heading small,
.lotto-admin-history-detail span {
  color: var(--muted);
  font-size: 10px;
}

.lotto-admin-history-detail {
  display: flex;
  justify-content: flex-end;
  gap: 6px 12px;
  flex-wrap: wrap;
}

@media (max-width: 940px) {
  .hero,
  .game-layout,
  .admin-layout,
  .account-admin-grid,
  .lotto-admin-grid,
  .lotto-panel {
    grid-template-columns: 1fr;
  }

  .admin-menu {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    overflow-x: auto;
  }

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

  .lotto-admin-history-row {
    grid-template-columns: minmax(120px, 0.5fr) auto minmax(220px, 1fr);
  }
}

@media (max-width: 720px) {
  .auth-gate {
    place-items: start center;
    overflow-y: auto;
    padding: 14px 12px;
  }

  .auth-card {
    padding: 18px;
  }

  .top-tabs {
    display: none;
  }

  main {
    width: min(100% - 22px, 1180px);
  }

  .admin-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }

  .mobile-tabs {
    display: flex;
    position: static;
    width: calc(100% - 24px);
    margin: 0 12px 12px;
  }

  h1 {
    font-size: 42px;
  }

  .balance-meta,
  .form-grid,
  .settlement-overview,
  .lotto-admin-overview,
  .name-field-grid,
  .permission-fieldset,
  .inline-permissions,
  .managed-controls {
    grid-template-columns: 1fr;
  }

  .settlement-overview > div {
    min-height: 60px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .settlement-overview > div:first-child {
    border-top: 0;
  }

  .lotto-admin-overview > div {
    min-height: 58px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .lotto-admin-overview > div:last-child {
    border-bottom: 0;
  }

  .section-heading-row,
  .box-heading-row {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-search {
    width: 100%;
  }

  .settlement-row,
  .application-row,
  .managed-row {
    grid-template-columns: 1fr;
  }

  .settlement-amount {
    text-align: left;
  }

  .machine-head,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .card-table {
    grid-template-columns: 1fr;
    justify-items: center;
  }

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

  .lotto-round-control .form-grid,
  .lotto-admin-history-row {
    grid-template-columns: 1fr;
  }

  .lotto-admin-actions {
    grid-template-columns: 1fr;
  }

  .lotto-admin-history-detail {
    justify-content: flex-start;
  }
}

@media (max-width: 420px) {
  .brand small {
    display: none;
  }

  h1 {
    font-size: 36px;
  }

  .balance-card > strong {
    font-size: 34px;
  }
}

/* Community operations */
.community-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.community-overview > div {
  display: grid;
  gap: 5px;
  min-height: 82px;
  align-content: center;
  padding: 14px;
  border: 1px solid var(--line);
  background: #f7f9fb;
}

.community-overview span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.community-overview strong {
  font-size: 22px;
}

.community-admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.community-admin-tabs button {
  min-height: 43px;
  padding: 0 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}

.community-admin-tabs button.active {
  border-bottom-color: #167a58;
  color: var(--ink);
}

.community-admin-view {
  display: none;
}

.community-admin-view.active {
  display: block;
}

.community-admin-list {
  display: grid;
  gap: 8px;
  max-height: 720px;
  overflow: auto;
}

.community-audit-row,
.community-report-row,
.community-room-row,
.publishing-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  background: #fff;
}

.community-audit-row.deleted {
  opacity: .55;
  background: #f2f4f6;
}

.community-row-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.community-row-copy > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-row-copy p {
  margin: 0;
  color: #344054;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.community-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.community-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

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

.publishing-lists {
  margin-top: 14px;
}

.publishing-grid textarea,
.community-config textarea {
  resize: vertical;
}

.publishing-row {
  margin-top: 7px;
}

.publishing-row .status-pill {
  justify-self: start;
}

.check-line {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 42px;
}

.check-line input {
  width: 18px;
  height: 18px;
}

.community-config {
  display: grid;
  gap: 12px;
}

.switch-check {
  position: relative;
  display: block;
  width: 48px;
  height: 28px;
  flex: 0 0 auto;
}

.switch-check input {
  position: absolute;
  opacity: 0;
}

.switch-check span {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: #cbd3dc;
  cursor: pointer;
  transition: background 160ms;
}

.switch-check span::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(18, 28, 40, .2);
  content: "";
  transition: transform 160ms;
}

.switch-check input:checked + span {
  background: #137b57;
}

.switch-check input:checked + span::after {
  transform: translateX(20px);
}

@media (max-width: 820px) {
  .community-overview,
  .publishing-grid {
    grid-template-columns: 1fr;
  }

  .community-audit-row,
  .community-report-row,
  .community-room-row,
  .publishing-row {
    grid-template-columns: 1fr;
  }

  .community-row-actions {
    justify-content: flex-start;
  }
}
