* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  background: #4ec0ca;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
  color: #fff;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  position: relative;
}

canvas {
  display: block;
}

#modal {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(14,11,34,0.78);
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#modalBox {
  background: #17142e;
  border: 1px solid rgba(65,58,171,0.35);
  border-radius: 18px;
  padding: 28px 22px;
  width: 340px;
  max-width: 92%;
  max-height: 82vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(65,58,171,0.15);
}

#modalBox h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 18px;
  color: #fff8e8;
}

#modalBox h2 span {
  color: #fff;
  font-size: 28px;
}

#modalBox h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #5b53d4;
  margin-bottom: 10px;
}

.submit-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

#nameInp {
  flex: 1;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(65,58,171,0.35);
  background: #12102a;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#nameInp::placeholder { color: #4a4570; }
#nameInp:focus { border-color: #413aab; box-shadow: 0 0 0 2px rgba(65,58,171,0.2); }

#subBtn {
  padding: 11px 20px;
  border-radius: 10px;
  border: none;
  background: #413aab;
  color: #fff8e8;
  font-weight: 700;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

#subBtn:hover { background: #5b53d4; }
#subBtn:active { background: #352e8c; }
#subBtn:disabled { opacity: 0.45; cursor: default; }

#errMsg {
  color: #e66;
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 14px;
  line-height: 20px;
}

.restart-btn {
  margin-top: 18px;
  padding: 13px 28px;
  border-radius: 12px;
  border: 1px solid rgba(65,58,171,0.35);
  background: transparent;
  color: #fff8e8;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

.restart-btn:hover { background: rgba(65,58,171,0.15); }
.restart-btn:active { background: rgba(65,58,171,0.25); }

#lb { margin-top: 2px; margin-bottom: 4px; }

.lb-row {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 14px;
  transition: background 0.1s;
}

.lb-row:nth-child(odd) { background: rgba(65,58,171,0.08); }
.lb-top { color: #fff8e8; }

.lb-rank {
  width: 26px;
  font-weight: 700;
  text-align: center;
  color: #4a4570;
  font-size: 13px;
}

.lb-top .lb-rank { color: #5b53d4; }

.lb-name {
  flex: 1;
  text-align: left;
  margin-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-pts {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: 8px;
}

.lb-msg {
  padding: 18px;
  color: #4a4570;
  font-size: 14px;
  text-align: center;
}

.lb-err { color: #e66; }

@media (max-height: 500px) {
  #modalBox { padding: 18px 16px; }
  #modalBox h2 { font-size: 18px; margin-bottom: 12px; }
}
