:root {
  --bg: #070b10;
  --surface: #121a24;
  --surface2: #1a2533;
  --border: #2a3a4f;
  --accent: #49c5b6;
  --accent-dim: #2d8a7f;
  --text: #e8eef4;
  --muted: #8b9cb3;
  --warn: #e6b84a;
  --ok: #5dd39e;
  --err: #f07178;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(ellipse at top, #0f1a22 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.logo h1 {
  margin: 0;
  font-size: 1.75rem;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.logo p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-left: auto;
}

nav {
  display: flex;
  gap: 0.5rem;
}

.kasware-box {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.55rem 0.35rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 0.78rem;
}

.kasware-box.kasware-on {
  border-color: var(--accent-dim);
  background: rgba(73, 197, 182, 0.08);
}

.kasware-box.kasware-missing {
  border-color: #4a3030;
  background: rgba(240, 113, 120, 0.06);
}

.kasware-label {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.kasware-status {
  color: var(--muted);
  white-space: nowrap;
}

.kasware-box.kasware-on .kasware-status {
  color: var(--ok);
}

.kasware-addr {
  font-family: ui-monospace, monospace;
  color: var(--text);
  font-size: 0.72rem;
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}

.nav-btn.active, .nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: end;
}

.field {
  flex: 1;
  min-width: 140px;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input, select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--accent);
  color: #06221f;
}

.btn-primary:hover { background: #5ed4c6; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--accent); }

.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

.stake-chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.chip.active {
  border-color: var(--accent);
  background: rgba(73, 197, 182, 0.15);
  color: var(--accent);
}

.game-grid {
  display: grid;
  gap: 0.75rem;
}

.game-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.game-card-click {
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.game-card-click:hover {
  border-color: var(--accent-dim);
  background: #1e2a38;
}

.game-card-main {
  flex: 1;
  min-width: 0;
}

.game-card-chevron {
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}

.ok-text { color: var(--ok); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-wait1 { background: #3d3520; color: var(--warn); }
.badge-wait-opp { background: #1e3a32; color: var(--ok); }
.badge-wait2 { background: #1e2f3a; color: #7ec8e3; }
.badge-paid { background: #2a2040; color: #c9a0ff; }
.badge-done { background: #1a3328; color: var(--ok); }
.badge-expired { background: #3a2020; color: var(--err); }

.steps {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.step {
  flex: 1;
  min-width: 100px;
  text-align: center;
  padding: 0.5rem;
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid transparent;
}

.step.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(73, 197, 182, 0.08);
}

.step.done {
  color: var(--ok);
}

.addr-box {
  background: #0a1018;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  word-break: break-all;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  margin: 0.5rem 0;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0.5rem 0;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-info { background: #152535; border: 1px solid #2a5070; }
.alert-warn { background: #2a2418; border: 1px solid #6a5520; color: var(--warn); }
.alert-err { background: #2a1818; border: 1px solid #6a3030; color: var(--err); }

.hidden { display: none !important; }

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.meta dt { color: var(--muted); font-size: 0.75rem; }
.meta dd { margin: 0.15rem 0 0; font-weight: 600; }

#toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--surface2);
  border: 1px solid var(--accent);
  padding: 0.65rem 1rem;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 100;
}

#toast.show { opacity: 1; }

.settings-toggle {
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
}

.hint a {
  color: var(--accent);
}

code {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
  background: var(--surface2);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.side-chips {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}

.side-chip {
  flex: 1;
  padding: 0.65rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

.side-chip.active {
  border-color: var(--accent);
  background: rgba(73, 197, 182, 0.12);
  color: var(--accent);
}

.side-chip.side-chip-locked {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

.players-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.player-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
}

.player-card .player-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.player-card .player-side-badge {
  display: inline-block;
  font-weight: 700;
  text-transform: capitalize;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.player-card .player-addr {
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  word-break: break-all;
  color: var(--text);
  line-height: 1.35;
}

.flip-stage {
  text-align: center;
  padding: 1.25rem 0.5rem 1.5rem;
  margin: 0.5rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: radial-gradient(circle at 50% 30%, #1a2a35 0%, var(--surface2) 55%);
}

.flip-countdown {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.75rem;
  min-height: 3rem;
  line-height: 3rem;
}

.flip-label {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.coin {
  width: 7rem;
  height: 7rem;
  margin: 0 auto;
  perspective: 800px;
}

.coin-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s ease-out;
}

.coin-inner.spinning {
  animation: coin-spin 0.9s ease-in-out infinite;
}

.coin-inner.show-heads {
  transform: rotateY(0deg);
}

.coin-inner.show-tails {
  transform: rotateY(180deg);
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  backface-visibility: hidden;
  border: 3px solid var(--accent-dim);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.coin-face-heads {
  background: linear-gradient(145deg, #2a4a55, #1a3038);
  color: var(--accent);
}

.coin-face-tails {
  background: linear-gradient(145deg, #3a3050, #252038);
  color: #c9a0ff;
  transform: rotateY(180deg);
}

@keyframes coin-spin {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

.flip-result-text {
  margin-top: 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ok);
}

.nav-ops {
  font-size: 0.85rem;
  opacity: 0.85;
}

.admin-table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

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

.admin-table tr.row-attn td {
  background: rgba(240, 113, 120, 0.08);
}

.admin-table .mono {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  word-break: break-all;
}

.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.admin-filters label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.leaderboards-card h3.leaderboard-sub {
  margin: 1rem 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.leaderboard-table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.leaderboard-table th,
.leaderboard-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.55rem;
  text-align: left;
}

.leaderboard-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
}

.leaderboard-rank {
  display: inline-block;
  min-width: 1.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.leaderboard-name {
  font-weight: 600;
  letter-spacing: 0.04em;
}
