html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: #0e2a3b;
  overflow: hidden;
}

body {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* The canvas fills the whole browser window. Its pixel size is set by game.js to match the window exactly
   (see applyViewport), so the picture is never stretched: wider windows simply show more of the game world. */
canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* ---- nickname popup (opened from the lobby) ---- */
.nick-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 28, 42, 0.62);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  touch-action: auto;
}

.nick-card {
  box-sizing: border-box;
  width: min(88vw, 340px);
  padding: 22px 22px 16px;
  text-align: center;
  color: #ffffff;
  background: rgba(16, 44, 62, 0.97);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}

.nick-card h2 { margin: 0 0 4px; font-size: 20px; font-weight: 900; color: #b6f26b; }
.nick-card p { margin: 0 0 14px; font-size: 13px; color: #9fcde4; }

.nick-input {
  box-sizing: border-box;
  width: 100%;
  padding: 12px 14px;
  font: 800 18px "Segoe UI", "Helvetica Neue", Arial, sans-serif; /* 16px+ keeps phones from zooming in */
  text-align: center;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.nick-input:focus { border-color: #8be860; }

.nick-meta { display: flex; justify-content: space-between; min-height: 16px; margin: 6px 4px 14px; font-size: 12px; }
.nick-error { color: #ffb4a0; }
.nick-count { margin-left: auto; color: #8fc4de; }

.nick-save {
  width: 100%;
  padding: 13px;
  font: 900 17px "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: #0f3a1c;
  background: linear-gradient(#9cf06c, #52c744);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 4px 0 #3f9f35;
  cursor: pointer;
}
.nick-save:active { transform: translateY(2px); box-shadow: 0 2px 0 #3f9f35; }

.nick-cancel {
  margin-top: 10px;
  padding: 6px 12px;
  font: 700 13px "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: #9fcde4;
  background: none;
  border: 0;
  cursor: pointer;
}

/* ---- full leaderboard overlay (opened from the lobby) ---- */
.board-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 28, 42, 0.66);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  touch-action: auto;
}

.board-card {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(92vw, 380px);
  max-height: 94vh;
  padding: 20px 18px 16px;
  text-align: center;
  color: #ffffff;
  background: rgba(16, 44, 62, 0.97);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}

.board-x {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.board-x:hover { background: rgba(255, 255, 255, 0.2); }

.board-logo { font-size: 26px; font-weight: 900; color: #b6f26b; text-shadow: 0 2px 0 #1d6a31; }
.board-sub { margin-top: 2px; font-size: 15px; font-weight: 900; color: #ffd95a; }
.board-timer { margin: 8px 0 12px; font-size: 12px; font-weight: 700; color: #9fcde4; }
.board-timer b { margin-left: 4px; font-size: 15px; color: #ffffff; font-variant-numeric: tabular-nums; }

.board-head,
.board-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  text-align: left;
}
.board-head {
  padding-bottom: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #8fc4de;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.board-head span:last-child { text-align: right; }

.board-list {
  max-height: min(50vh, 320px);
  margin-bottom: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.board-row {
  min-height: 34px;
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.board-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 12px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
}
.board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-score { font-weight: 900; color: #ffe9a0; font-variant-numeric: tabular-nums; }

.board-row.r1 { background: rgba(255, 213, 74, 0.1); }
.board-row.r1 .board-rank { color: #3a2a05; background: #ffd54a; }
.board-row.r2 { background: rgba(211, 219, 230, 0.08); }
.board-row.r2 .board-rank { color: #1f2a36; background: #d3dbe6; }
.board-row.r3 { background: rgba(217, 149, 90, 0.1); }
.board-row.r3 .board-rank { color: #3a1f08; background: #d9955a; }
.board-row.me { background: rgba(182, 242, 107, 0.16); }

.board-msg { padding: 26px 10px; font-size: 13px; color: #9fcde4; }
.board-msg strong { display: block; margin-bottom: 6px; font-size: 15px; color: #ffe27a; }

.board-back {
  padding: 12px;
  font: 900 16px "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: #0f3a1c;
  background: linear-gradient(#9cf06c, #52c744);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 4px 0 #3f9f35;
  cursor: pointer;
}
.board-back:active { transform: translateY(2px); box-shadow: 0 2px 0 #3f9f35; }
