:root {
  --orange: #e74e19;
  --orange-dark: #c73f10;
  --yellow: #ffb802;
  --green: #105a1e;
  --green-light: #14712a;
  --ink: #0a0a0a;
  --charcoal: #202124;
  --gray: #656565;
  --gray-light: #efefef;
  --white: #ffffff;
  --danger: #c73f10;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(10, 10, 10, 0.08);
  --shadow-lg: 0 10px 30px rgba(10, 10, 10, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--gray-light);
  color: var(--ink);
  font-family: 'Montserrat', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { margin: 0 0 4px; letter-spacing: -0.01em; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ---------- Top bar ---------- */
.topbar {
  background: var(--ink);
  color: var(--white);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.02em;
}
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--yellow);
}
.brand small {
  display: block;
  font-weight: 500;
  font-size: 11px;
  color: #bdbdbd;
  letter-spacing: 0.03em;
}
.nav-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.nav-links a {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #d8d8d8;
}
.nav-links a:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-links a.active { background: var(--orange); color: var(--white); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.btn:hover { box-shadow: var(--shadow-lg); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-primary { background: var(--orange); color: var(--white); }
.btn-green { background: var(--green); color: var(--white); }
.btn-yellow { background: var(--yellow); color: var(--ink); }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-outline { background: transparent; border: 2px solid var(--ink); box-shadow: none; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 8px;
  margin: 22px 0 14px;
  flex-wrap: wrap;
}
.tab {
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: var(--white);
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab .count {
  background: var(--gray-light);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}
.tab.active { border-color: var(--ink); }
.tab.tab-live.active { border-color: var(--orange); color: var(--orange); }
.tab-live .live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--orange);
  box-shadow: 0 0 0 0 rgba(231,78,25,0.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(231,78,25,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(231,78,25,0); }
  100% { box-shadow: 0 0 0 0 rgba(231,78,25,0); }
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filters input[type="text"],
.filters select,
.field input,
.field select,
.field textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid #ddd;
  background: var(--white);
  color: var(--ink);
}
.filters input[type="text"] { flex: 1; min-width: 180px; }
.filters select { min-width: 150px; }

/* ---------- Category badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-ELITE { background: var(--ink); color: var(--yellow); }
.badge-NEXT_GEN { background: var(--orange); color: var(--white); }
.badge-NOVICE { background: var(--green); color: var(--white); }
.badge-FRIENDLY { background: var(--yellow); color: var(--ink); }

.badge-status { background: var(--gray-light); color: var(--gray); }
.badge-status.status-LIVE { background: var(--orange); color: var(--white); }
.badge-status.status-PLANNED { background: var(--gray-light); color: var(--charcoal); }
.badge-status.status-FINISHED { background: var(--green); color: var(--white); }

/* ---------- Match list ---------- */
.match-list { display: flex; flex-direction: column; gap: 12px; }
.match-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  border-left: 5px solid transparent;
}
.match-card:hover { box-shadow: var(--shadow-lg); }
.match-card.status-LIVE { border-left-color: var(--orange); }
.match-card.status-FINISHED { border-left-color: var(--green); }
.match-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.match-card-meta {
  font-size: 12px;
  color: var(--gray);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.match-players {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.match-players .name {
  font-weight: 700;
  font-size: 16px;
}
.match-players .winner { color: var(--green-light); }
.match-score {
  font-weight: 800;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray);
}

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 700; font-size: 13px; }
.field small { color: var(--gray); font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
datalist {}

.format-options { display: flex; flex-direction: column; gap: 8px; }
.format-option {
  border: 1.5px solid #ddd;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.format-option:has(input:checked) { border-color: var(--orange); background: #fff6f2; }
/* .field input {width:100%} above also matches these radios since .format-options
   sits inside a .field — override back to their natural size so the dot stays put
   at the start of the row instead of stretching and dragging the label rightward. */
.format-option input[type="radio"] {
  width: auto;
  flex-shrink: 0;
  margin: 0;
}
.format-option > span { flex: 1; }

/* ---------- Live scoring page ---------- */
.match-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 15px;
  background: var(--ink);
  color: var(--white);
  padding: 8px 14px;
  border-radius: 999px;
}
.scoreboard {
  background: var(--ink);
  color: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-lg);
}
.scoreboard table { width: 100%; border-collapse: collapse; }
.scoreboard td, .scoreboard th {
  padding: 10px 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.scoreboard th { color: #9a9a9a; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.scoreboard td.set-score { font-size: 22px; font-weight: 800; width: 54px; }
.scoreboard td.set-score.current { color: var(--yellow); }
.scoreboard td.name-cell { text-align: left; font-weight: 700; font-size: 17px; }
.scoreboard .sub-tb { font-size: 11px; color: #9a9a9a; margin-left: 2px; }
.scoreboard tr.winner-row td.name-cell::after { content: " \2713"; color: var(--yellow); }

.score-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0;
}
.score-controls .player-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 12px;
}
.score-controls .player-controls .pname { font-weight: 800; font-size: 15px; text-align: center; }
.btn-giant {
  width: 100%;
  padding: 26px 10px;
  font-size: 20px;
  border-radius: 16px;
  background: var(--orange);
  color: var(--white);
  box-shadow: var(--shadow-lg);
}
.btn-giant:active { transform: translateY(2px) scale(0.98); }
.btn-minus {
  background: var(--gray-light);
  color: var(--ink);
  width: 100%;
  padding: 10px;
  border-radius: 10px;
}

.match-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.info-item { background: var(--white); border-radius: 10px; padding: 12px; box-shadow: var(--shadow); }
.info-item .label { font-size: 11px; text-transform: uppercase; color: var(--gray); font-weight: 700; letter-spacing: 0.03em; }
.info-item .value { font-weight: 700; font-size: 14px; margin-top: 2px; }
.info-item .edit-link {
  font-size: 11px; color: var(--orange); font-weight: 700; cursor: pointer;
  background: none; border: none; padding: 0; font-family: inherit;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,10,10,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 12px; }
.modal .close {
  float: right; cursor: pointer; font-weight: 800; font-size: 18px;
  background: none; border: none; padding: 0; line-height: 1; color: var(--ink);
}
.share-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.code-box {
  background: var(--gray-light);
  border-radius: 8px;
  padding: 10px;
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
  user-select: all;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }

/* ---------- Embed views ---------- */
body.embed { background: var(--white); }
.embed .container { padding: 10px; max-width: none; }
.embed-live-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #eee;
  margin-bottom: 8px;
}
.embed-live-item a { flex: 1; }

footer.credit { text-align: center; font-size: 11px; color: var(--gray); margin-top: 24px; }

/* ---------- Player rows ---------- */
.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--gray-light);
}
.player-row:last-child { border-bottom: none; }
.player-name { font-weight: 700; font-size: 14px; }
.player-row-actions { display: flex; gap: 8px; flex-shrink: 0; }
.player-row .edit-name-input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--orange);
  font-family: inherit;
  font-size: 14px;
}
