:root {
  --bg: #0f1720;
  --bg-card: #182433;
  --bg-card-2: #202f42;
  --border: #2c3d52;
  --text: #eef3f8;
  --text-dim: #93a4b8;
  --accent: #3ddc97;
  --accent-2: #4d9fff;
  --red: #ff6767;
  --amber: #ffb347;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { padding-bottom: 80px; }

a { color: var(--accent-2); }

h1, h2, h3 { margin: 0 0 0.5em; line-height: 1.2; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

p { margin: 0.3em 0; }

.container { max-width: 720px; margin: 0 auto; padding: 12px 14px 40px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(15,23,32,0.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.topbar .title { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { color: var(--text-dim); font-size: 0.8rem; }

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

.card-2 { background: var(--bg-card-2); }

.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: 1fr 1fr; }

label { display: block; font-size: 0.82rem; color: var(--text-dim); margin: 10px 0 4px; }
label:first-child { margin-top: 0; }

input, select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0c141c;
  color: var(--text);
  font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--accent-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-card-2);
  color: var(--text);
  border: 1px solid var(--border);
  transition: transform 0.05s ease;
  width: 100%;
  gap: 6px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #06251a; border-color: var(--accent); }
.btn-accent { background: var(--accent-2); color: #04182e; border-color: var(--accent-2); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn-ghost { background: transparent; }
.btn-sm { width: auto; padding: 8px 12px; font-size: 0.85rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { width: auto; flex: 1; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; }
.tab {
  flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-dim); font-size: 0.85rem; cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--accent); color: #06251a; border-color: var(--accent); font-weight: 700; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  background: var(--bg-card-2); color: var(--text-dim); border: 1px solid var(--border);
}
.badge-live { background: var(--accent); color: #06251a; border-color: var(--accent); }
.badge-done { background: var(--bg-card-2); color: var(--accent); border-color: var(--accent); }
.badge-amber { background: var(--amber); color: #331e00; border-color: var(--amber); }

.court-card { border-left: 4px solid var(--accent-2); }
.court-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.team { padding: 8px 10px; border-radius: 10px; background: #0c141c; margin: 4px 0; font-size: 0.98rem; }
.team.winner { background: rgba(61,220,151,0.15); border: 1px solid var(--accent); }
.vs { text-align: center; color: var(--text-dim); font-size: 0.78rem; margin: 2px 0; }

.match-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.team-col { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.team-col.right { align-items: flex-end; text-align: right; }
.team-col .player-name {
  font-size: 1.08rem; font-weight: 700; padding: 8px 10px; border-radius: 10px;
  background: #0c141c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%;
}
.team-col.right .player-name { width: 100%; }
.team-col.winner .player-name { background: rgba(61,220,151,0.18); border: 1px solid var(--accent); color: var(--accent); }
.score-col { flex: none; min-width: 78px; text-align: center; }
.big-score { font-size: 2.1rem; font-weight: 800; letter-spacing: 0.02em; }
.vs-big { font-size: 1.25rem; font-weight: 800; color: var(--text-dim); }

.score-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.score-row input { text-align: center; font-size: 1.2rem; font-weight: 700; width: 64px; flex: none; }
.score-row .colon { color: var(--text-dim); font-weight: 700; }
.score-row .btn { flex: 1; }

.sub-toggle-row { margin-top: 8px; }
.sub-picker { margin-top: 8px; padding: 10px; border-radius: 10px; background: #0c141c; border: 1px solid var(--border); }
.sub-picker label { margin-top: 8px; }
.sub-picker label:first-child { margin-top: 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: center; }
tr.me-rank1 td:first-child { color: var(--accent); font-weight: 800; }

.list-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .name { font-weight: 600; }
.list-row .meta { color: var(--text-dim); font-size: 0.8rem; }

.muted { color: var(--text-dim); }
.center { text-align: center; }
.small { font-size: 0.82rem; }
.error { color: var(--red); font-size: 0.88rem; margin-top: 6px; }
.success { color: var(--accent); font-size: 0.88rem; margin-top: 6px; }

.metrics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.metric { background: #0c141c; border-radius: 10px; padding: 8px 10px; }
.metric .v { font-size: 1.3rem; font-weight: 800; }
.metric .l { font-size: 0.72rem; color: var(--text-dim); }

.link-box { display: flex; gap: 6px; align-items: center; background: #0c141c; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 0.85rem; overflow: hidden; }
.link-box input { border: none; background: transparent; padding: 0; flex: 1; font-size: 0.85rem; }

.empty { text-align: center; padding: 30px 10px; color: var(--text-dim); }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; box-shadow: 0 0 0 0 rgba(61,220,151,0.7); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61,220,151,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(61,220,151,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,220,151,0); }
}

.bracket { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 700px) {
  .metrics-grid { grid-template-columns: repeat(5, 1fr); }
}
