@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap');

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #212121;
  color: #fafafa;
  font-family: "JetBrains Mono", monospace;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #2e2e2e;
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.wake {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: #aaa;
  cursor: pointer;
  user-select: none;
}

.wake input { accent-color: #6aa84f; }

main {
  flex: 1;
  padding: 1rem 0;
}

h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 0.75rem;
}

.muted { color: #888; font-size: 0.85rem; }

/* Player list */
.player-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.player-row input {
  flex: 1;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #fafafa;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.7rem 0.8rem;
  border-radius: 6px;
  min-width: 0;
}

.player-row input:focus {
  outline: none;
  border-color: #6aa84f;
}

.icon-btn {
  background: #2a2a2a;
  color: #fafafa;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  width: 2.5rem;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.icon-btn:active { background: #333; }

/* Buttons */
.btn {
  width: 100%;
  background: #6aa84f;
  color: #0c1a06;
  border: none;
  border-radius: 6px;
  padding: 0.95rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.btn:disabled {
  background: #3a3a3a;
  color: #777;
  cursor: not-allowed;
}

.btn.secondary {
  background: #2a2a2a;
  color: #fafafa;
  border: 1px solid #3a3a3a;
}

.btn.danger {
  background: #2a2a2a;
  color: #e57373;
  border: 1px solid #3a3a3a;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.5rem;
}

/* Round / match */
.round-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}

.round-head .num { font-size: 1.2rem; font-weight: 700; }

.match {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 0.9rem;
  margin-bottom: 0.75rem;
}

.match .court {
  font-size: 0.7rem;
  color: #888;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.team {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
}

.team .names {
  font-size: 0.95rem;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.score-input {
  width: 3.2rem;
  text-align: center;
  background: #1c1c1c;
  border: 1px solid #3a3a3a;
  color: #fafafa;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.5rem;
  border-radius: 6px;
}

.score-input:focus {
  outline: none;
  border-color: #6aa84f;
}

.vs {
  text-align: center;
  font-size: 0.7rem;
  color: #666;
  letter-spacing: 0.2em;
  padding: 0.2rem 0;
}

.resting {
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.4rem;
  padding: 0.5rem 0.2rem 0;
  border-top: 1px dashed #3a3a3a;
}

/* Leaderboard */
.lb {
  width: 100%;
  border-collapse: collapse;
}

.lb th, .lb td {
  text-align: left;
  padding: 0.6rem 0.4rem;
  border-bottom: 1px solid #2e2e2e;
  font-size: 0.95rem;
}

.lb th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
  font-weight: 600;
}

.lb td.num, .lb th.num { text-align: right; font-variant-numeric: tabular-nums; }

.lb tr.me td { color: #fafafa; }

.lb .rank {
  width: 1.8rem;
  color: #888;
}

.back-link {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: #666;
  text-decoration: none;
  padding-top: 1rem;
}

.back-link:hover { color: #aaa; }

/* Podium */
.podium {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: end;
  gap: 0.4rem;
  margin: 1rem 0 1.5rem;
}

.podium-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
}

.podium-col.empty { visibility: hidden; }

/* A pedestal with no player on it (e.g. no 2nd place after a tie for 1st). */
.podium-col.vacant { justify-content: flex-end; }
.podium-col.vacant .p-block { opacity: 0.35; }

.podium-col .medal {
  font-size: 1.8rem;
  line-height: 1;
  margin-bottom: 0.3rem;
}

.podium-col .p-name {
  font-size: 0.9rem;
  font-weight: 700;
  word-break: break-word;
  margin-bottom: 0.1rem;
}

.podium-col .p-pts {
  font-size: 0.75rem;
  color: #aaa;
  margin-bottom: 0.4rem;
  font-variant-numeric: tabular-nums;
}

.podium-col .p-block {
  width: 100%;
  border-radius: 6px 6px 0 0;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.05em;
  color: #0c1a06;
  background: #6aa84f;
  display: flex;
  align-items: center;
  justify-content: center;
}

.podium-col.p1 .p-block { height: 5.5rem; background: #d4af37; color: #1a1100; }
.podium-col.p2 .p-block { height: 4rem;   background: #c0c0c0; color: #111; }
.podium-col.p3 .p-block { height: 3rem;   background: #cd7f32; color: #1a0e00; }
