* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0f1724;
  color: #e8edf3;
  margin: 0;
  padding: 0;
}
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}
header.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: #16223a;
  border-bottom: 1px solid #233048;
  position: sticky;
  top: 0;
  z-index: 10;
}
header.top a { color: #e8edf3; text-decoration: none; }
header.top .brand { font-weight: 700; font-size: 18px; color: #ffd166; }
header.top .right a { margin-left: 14px; color: #9fb3c8; display: inline-block; padding: 4px 0; }
.card {
  background: #16223a;
  border: 1px solid #233048;
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 18px;
}
h1, h2, h3 { margin-top: 0; }
.balance {
  font-size: 26px;
  font-weight: 700;
  color: #4ade80;
}
form { display: flex; flex-direction: column; gap: 10px; }
label { font-size: 13px; color: #9fb3c8; }
input, select {
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #2d3c58;
  background: #0f1724;
  color: #e8edf3;
  font-size: 16px;
  width: 100%;
}
button {
  padding: 13px;
  border-radius: 6px;
  border: none;
  background: #ffd166;
  color: #16223a;
  font-weight: 700;
  cursor: pointer;
  font-size: 16px;
  min-height: 44px;
}
button:hover { background: #ffdb85; }
button:active { background: #f5c34d; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #233048; white-space: nowrap; }
.users-table th, .users-table td { white-space: normal; }
.users-table td:last-child { overflow: visible; }
.users-table td[data-label="Actions"] { vertical-align: top; }
.win { color: #4ade80; font-weight: 700; }
.lose { color: #f87171; }
.pending { color: #fbbf24; }
.msg { padding: 10px; border-radius: 6px; margin-bottom: 12px; }
.msg.ok { background: #16331f; color: #4ade80; }
.msg.err { background: #3a1620; color: #f87171; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row .card { flex: 1; min-width: 220px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stats-grid .card { margin-bottom: 0; }
.container.wide { max-width: 1100px; }
.auth-box { max-width: 380px; margin: 80px auto; }
a.link { color: #ffd166; }
.muted { color: #9fb3c8; font-size: 13px; }
.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #233048; }
.result-strip {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffd166;
  background: #0f1724;
  border: 1px solid #2d3c58;
  border-radius: 8px;
  padding: 10px 14px;
  display: inline-block;
  font-family: 'Courier New', monospace;
}
.result-strip-cell { font-family: 'Courier New', monospace; font-weight: 700; color: #ffd166; }

.actions-dropdown { position: relative; }
.actions-dropdown summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 12px;
  background: #233048;
  color: #e8edf3;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  display: inline-block;
  user-select: none;
}
.actions-dropdown summary::-webkit-details-marker { display: none; }
.actions-dropdown summary:hover { background: #2d3c58; }
.actions-dropdown[open] summary { background: #2d3c58; }
.actions-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  flex-direction: column;
  gap: 8px;
  background: #0f1724;
  border: 1px solid #2d3c58;
  border-radius: 8px;
  padding: 12px;
  min-width: 190px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.actions-dropdown[open] .actions-menu { display: flex; }
.actions-menu form { gap: 6px; }
.actions-menu button { padding: 8px; font-size: 13px; min-height: auto; }
.actions-menu button.danger, button.danger { background: #f87171; }
.actions-menu button.danger:hover { background: #fa9494; }
.actions-menu input { padding: 8px; font-size: 13px; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .container { padding: 16px 12px 50px; }
  .auth-box { max-width: 100%; margin: 24px auto; padding: 0 4px; }
  .row { flex-direction: column; gap: 12px; }
  .row .card { min-width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 14px; }
  h1 { font-size: 22px; }
  .balance { font-size: 22px; }
  table { font-size: 13px; }
  th, td { padding: 6px; }
  header.top .right a { margin-left: 10px; font-size: 14px; }
  form[style*="row"] { flex-direction: column !important; align-items: stretch !important; }
  form[style*="row"] button { width: 100% !important; }

  .users-table, .users-table thead, .users-table tbody { display: block; width: 100%; }
  .users-table tr:first-child { display: none; }
  .users-table tr {
    display: block;
    border: 1px solid #233048;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
  }
  .users-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-bottom: none;
    padding: 6px 2px;
  }
  .users-table td[data-label]::before {
    content: attr(data-label);
    color: #9fb3c8;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
  }
  .users-table td[data-label="Actions"] {
    flex-direction: column;
    align-items: stretch;
  }
  .users-table td[data-label="Actions"]::before { margin-bottom: 6px; }
  .users-table td[data-label="Actions"] > div { justify-content: space-between; }
  .actions-dropdown { position: static; }
  .actions-menu { position: static; width: 100%; box-shadow: none; margin-top: 8px; }
}
