html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #EAF1F9;
}

body {
  position: fixed;
  inset: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #003366;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  touch-action: none;
  outline: none;
}

#boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 24px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  pointer-events: none;
}

#boot small {
  max-width: 28em;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #4A6C93;
}

/* ---------------------------------------------------------------- legal links (title, game over) */
#legal {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  padding: 6px 16px max(8px, env(safe-area-inset-bottom));
  font-size: 13px;
  font-weight: 600;
  pointer-events: none; /* only the links themselves take taps; the rest goes to the game */
}

#legal[hidden] {
  display: none;
}

#legal a {
  padding: 4px 2px;
  color: #4A6C93;
  text-decoration: underline;
  text-underline-offset: 2px;
  pointer-events: auto;
}

#legal a:focus-visible {
  outline: 2px solid #0069D1;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- dialogs (nickname, leaderboard) */
dialog {
  box-sizing: border-box;
  width: min(92vw, 420px);
  max-height: 86vh;
  max-height: 86dvh;
  margin: max(16px, 8vh) auto auto; /* top-aligned, so an on-screen keyboard doesn't cover it */
  padding: 22px 22px 18px;
  border: none;
  border-radius: 20px;
  background: #FFFFFF;
  color: #003366;
  font: inherit;
  box-shadow: 0 6px 24px rgba(0, 41, 82, 0.18);
  -webkit-user-select: text;
  user-select: text;
}

dialog::backdrop {
  background: rgba(0, 41, 82, 0.35);
}

dialog h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
}

dialog .hint {
  margin: 0 0 12px;
  font-size: 14px;
  color: #4A6C93;
}

dialog .hint.small {
  margin: 10px 0 0;
  font-size: 13px;
}

dialog label {
  display: block;
  margin: 12px 0 6px;
  font-size: 15px;
  font-weight: 700;
}

dialog input[type="text"],
dialog input[type="email"] {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #B3CAEF;
  border-radius: 12px;
  background: #FFFFFF;
  color: #003366;
  font: inherit;
  font-size: 16px; /* 16px or more: iOS doesn't zoom in on focus */
  -webkit-user-select: text;
  user-select: text;
}

dialog input:focus-visible {
  outline: none;
  border-color: #0069D1;
}

dialog .check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 14px;
  font-weight: 500;
}

dialog .check input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  flex: none;
}

dialog a {
  color: #0069D1;
}

dialog .error {
  margin: 6px 0 0;
  font-size: 14px;
  color: #C8455A;
}

dialog .buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

dialog button {
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

dialog button.primary {
  background: #0069D1;
  color: #FFFFFF;
}

dialog button.secondary {
  background: #DEE8F8;
  color: #003366;
}

dialog button:focus-visible {
  outline: 3px solid #B3CAEF;
  outline-offset: 2px;
}

#board-list {
  max-height: 55vh;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  counter-reset: place;
}

#board-list li {
  display: flex;
  gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px solid #DEE8F8;
  font-size: 16px;
  counter-increment: place;
}

#board-list li::before {
  content: counter(place) ".";
  flex: none;
  width: 2.2em;
  text-align: right;
  font-weight: 700;
  color: #4A6C93;
}

#board-list .name {
  flex: 1;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#board-list .score {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
