:root {
  --bg: #120a02;
  --surface: rgba(36, 22, 8, 0.88);
  --text: #f5e8cb;
  --muted: #d7b884;
  --primary: #d8891d;
  --danger: #d24b2f;
  --border: rgba(255, 197, 99, 0.28);
  --surface-strong: rgba(51, 30, 10, 0.94);
  --surface-soft: rgba(255, 208, 128, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 18% 6%, rgba(255, 177, 41, 0.22), rgba(255, 177, 41, 0) 40%),
    linear-gradient(180deg, rgba(10, 6, 2, 0.75) 0%, rgba(10, 6, 2, 0.88) 55%, rgba(10, 6, 2, 0.96) 100%),
    url('/assets/totem.png');
  background-size: cover, cover, cover;
  background-position: center top, center, center top;
  background-attachment: fixed, fixed, fixed;
}

.container {
  max-width: 1180px;
  margin: 32px auto;
  padding: 0 16px 40px;
}

.admin-page .container {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 16px 16px 28px;
}

.site-locked {
  visibility: hidden;
}

.header {
  margin-bottom: 20px;
}

.header h1 {
  margin: 0;
  font-size: 28px;
}

.header p {
  color: var(--muted);
  margin: 8px 0 0;
}

.player-welcome-banner {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(116, 246, 166, 0.45);
  background: linear-gradient(120deg, rgba(115, 246, 166, 0.24), rgba(115, 246, 166, 0.08));
  color: #d9ffe8;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
}

.player-welcome-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.player-welcome-row .player-welcome-banner {
  margin-top: 0;
  flex: 1 1 560px;
}

.player-logout-btn {
  width: auto;
  min-width: 88px;
  padding: 10px 14px;
  flex: 0 0 auto;
}

.player-change-password-btn {
  width: auto;
  min-width: 108px;
  padding: 10px 14px;
  flex: 0 0 auto;
}

.admin-auth-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-welcome-banner {
  flex: 1 1 560px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(116, 246, 166, 0.45);
  background: linear-gradient(120deg, rgba(115, 246, 166, 0.24), rgba(115, 246, 166, 0.08));
  color: #d9ffe8;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
}

.admin-logout-btn {
  width: auto;
  min-width: 88px;
  padding: 10px 14px;
  flex: 0 0 auto;
}

.entry-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 5, 2, 0.86);
  backdrop-filter: blur(2px);
}

.entry-gate-hidden {
  display: none;
}

.entry-gate-card {
  width: min(460px, 100%);
  padding: 20px;
  border-radius: 14px;
  border: 1px solid rgba(255, 196, 95, 0.44);
  background: linear-gradient(145deg, rgba(44, 26, 8, 0.97), rgba(26, 16, 6, 0.97));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.entry-gate-card h2 {
  margin: 0 0 8px;
  color: #ffd480;
}

.entry-gate-card p {
  margin: 0 0 14px;
  color: #e6c896;
}

.totem-hero {
  display: grid;
  grid-template-columns: minmax(240px, 360px) 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #2b1c07 0%, #4b3210 55%, #221605 100%);
  border-color: #7f591d;
  color: #f7dfaf;
}

.totem-media {
  width: 100%;
}

.totem-media img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  object-position: center top;
  border-radius: 10px;
  border: 1px solid rgba(255, 208, 124, 0.35);
}

.totem-copy h2 {
  margin: 4px 0 8px;
  color: #ffd57e;
  font-size: 30px;
}

.totem-copy p {
  margin: 0;
  color: #f3d59f;
}

.totem-tag {
  margin: 0;
  color: #ffcf73;
  letter-spacing: 2px;
  font-size: 12px;
  text-transform: uppercase;
}

.totem-hero-admin .totem-media img {
  max-height: 220px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: linear-gradient(145deg, var(--surface), var(--surface-strong));
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  padding: 16px;
  backdrop-filter: blur(2px);
}

.card h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 18px;
}

label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
select,
button {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  padding: 10px;
}

input,
select {
  background: rgba(22, 13, 5, 0.9);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(216, 137, 29, 0.35);
  border-color: var(--primary);
}

button {
  border: none;
  background: linear-gradient(135deg, #f0a52f, #be6f10);
  color: #281705;
  cursor: pointer;
  font-weight: 700;
}

button.secondary {
  background: rgba(255, 199, 102, 0.14);
  color: #ffd79a;
  border: 1px solid rgba(255, 199, 102, 0.36);
}

button.danger {
  background: linear-gradient(135deg, #ec6242, #af2f19);
  color: #fff2ea;
}

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

.form-row {
  margin-bottom: 12px;
}

.player-identity-row {
  display: none;
}

#todayMatchContent {
  font-size: 22px;
  line-height: 1.35;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #ffe2a9;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 196, 95, 0.42);
  background: linear-gradient(120deg, rgba(255, 196, 95, 0.2), rgba(255, 196, 95, 0.06));
}

.bet-status {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
}

.bet-status-open {
  color: #08371f;
  background: linear-gradient(120deg, #73f6a6, #33cd7f);
  border-color: #9fffc3;
  box-shadow: 0 0 0 2px rgba(115, 246, 166, 0.22);
}

.bet-status-closed {
  color: #ffe6e0;
  background: linear-gradient(120deg, #f0604a, #c72d18);
  border-color: #ff9f93;
  box-shadow: 0 0 0 2px rgba(240, 96, 74, 0.28);
}

.message {
  margin-top: 10px;
  font-size: 13px;
  min-height: 18px;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: #77d39e;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 8px 6px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.project-row-selected {
  background: rgba(240, 165, 47, 0.14);
}

#projectOptionsBody tr {
  cursor: pointer;
}

#projectOptionsBody td:first-child {
  width: 56px;
}

#projectOptionsBody input[type='radio'] {
  width: auto;
}

.result-win {
  color: #77d39e;
  font-weight: 600;
}

.result-lose {
  color: #ff8f75;
  font-weight: 600;
}

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

.settlement-positive {
  color: #77d39e;
  font-weight: 700;
}

.settlement-negative {
  color: #ff8f75;
  font-weight: 700;
}

.settlement-neutral {
  color: var(--muted);
  font-weight: 600;
}

.inline-actions {
  display: flex;
  gap: 8px;
}

.inline-actions button {
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
}

.history-card {
  overflow: hidden;
}

.current-bets-view-actions {
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.current-bets-view-actions button {
  min-width: 128px;
}

.current-bets-btn-active {
  box-shadow: 0 0 0 2px rgba(255, 204, 112, 0.28);
}

.history-filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.history-filter-actions {
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.history-filter-actions button {
  min-width: 120px;
}

.result-select {
  min-width: 110px;
  width: 110px;
  padding: 6px 8px;
  font-size: 13px;
}

#projectOptionsBody .project-name-cell,
#betsBody .project-name-cell,
#adminBetsBody .project-name-cell,
#playerHistoryBetsBody .project-name-cell,
#adminHistoryBetsBody .project-name-cell {
  white-space: normal;
  word-break: break-word;
}

#projectOptionsBody .project-name-cell {
  min-width: 220px;
}

#projectsBody td.project-name-admin {
  min-width: 260px;
  white-space: normal;
}

#projectsBody td.project-name-admin input[data-project-name] {
  min-width: 220px;
}

#projectsBody input[data-project-odds] {
  min-width: 150px;
  width: 150px;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
}

#projectOddsInput {
  min-width: 180px;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 16px;
}

.pnl-summary {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: #f5ddb0;
}

.pnl-summary.pnl-profit {
  color: #77d39e;
  background: rgba(119, 211, 158, 0.1);
  border-color: rgba(119, 211, 158, 0.35);
}

.pnl-summary.pnl-loss {
  color: #ff9c86;
  background: rgba(255, 120, 91, 0.09);
  border-color: rgba(255, 120, 91, 0.35);
}

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

.site-footer {
  margin-top: 16px;
  padding: 12px 10px;
  text-align: center;
  color: #e8c88f;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(22, 13, 5, 0.78);
  font-size: 13px;
}

.admin-hidden {
  display: none;
}

@media (max-width: 820px) {
  body {
    background-attachment: scroll, scroll, scroll;
  }

  .totem-hero {
    grid-template-columns: 1fr;
  }

  .totem-media img,
  .totem-hero-admin .totem-media img {
    max-height: 340px;
  }

  .totem-copy h2 {
    font-size: 24px;
  }

  .player-welcome-banner {
    font-size: 17px;
  }

  .player-welcome-row {
    align-items: stretch;
  }

  .player-logout-btn {
    width: 100%;
  }

  .player-change-password-btn {
    width: 100%;
  }

  .admin-auth-row {
    align-items: stretch;
  }

  .admin-logout-btn {
    width: 100%;
  }

  #todayMatchContent {
    font-size: 18px;
  }

  .bet-status {
    font-size: 16px;
  }

  .history-filter-actions button {
    width: 100%;
  }
}
